Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Simulating ili9341_t3: request help with drawChar()

  1. #1
    Member
    Join Date
    Nov 2015
    Location
    New York
    Posts
    64

    Simulating ili9341_t3: request help with drawChar()

    Hey All,

    I am working on a ili9341_t3 port into Excel in VBA. I was tired of dreaming up the layout and uploading each time, so I wanted to preview the displays I built with the library before I uplodaed. Picture below:
    https://flic.kr/p/V7zfJy

    I am having a bit of trouble understanding the drawChar method in ili9341_t3.cpp.

    Can anyone offer an interpretation for a non-coding expert? I would like to include atleast one font implementation to simulate the prospective display.

    I can share the excel spreadsheets I have, but I just don't know how to upload here.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,043
    First the easy part. Uploading to here.

    When editing a post (or entering new thread, you are already there), click on the advanced button and it will take you to a more complete edigint setup... Including # button for code tags and the like. But below the editing area on the page, will be a section for Attachments and a button <Manage Attachments> , Click on it. Bring up dialog, In there click on <Add Files> button, which will take to a dialog to pick which file(s) to upload... Most files need to be put in a zip file or the like before it can be uploaded.

    the drawChar function if I remember correctly, draws from the built in font. For each character in this font there are 5 bytes of data The where each byte gives you 8 columns of data for one row, So the font is 5x8 where we then skip a sixth pixel.

    In simplest from, the code simply walks through those 5 bytes, and if a bit is set, in those bytes it sets the corresponding pixel (if font size == 1) to the current font color, if the bit is zero, the drawchar will in transparent mode setFontColor(fgcolor), will not touch that pixel on the display. On the other hand if in opaque mode (setFontColor(fgColor, bgColor), it will set those pixels to the background color.

    Note: if text font size is not set to 1, then instead of setting one pixel in each of these cases it fills a rectangle (size, size) to the appropriate color..

    This code in the Adafruit_ILI9341 library is much more simplistic and does more or less exactly what I said... However the code in this library tries to be smarter and instead of simply dealing with each pixel (or rectangle), there are at least three sections in this function.

    It first branches on if we are Transparent or Opaque.
    If Transparent
    it special cases when drawing with text size 1... (pixels)
    retangles or like instead of pixels.

    what it is trying to do is if there are multiple 1's in a row in a column, it tries to output all of those in one drawRect, drawFastVLine or the like as to speed things up as to not have to tell the system to reset the position to output the next pixel to...

    If Opaque: It tries to work to draw it like it is simply one bitmap. That is it tells the system it is going to output all of the bytes for the rectangle associated with drawing that charcter and then figures out if each pixel is FG or BG color... This mode is a lot faster than the transparent mode.

    Again sorry if I did not explain it overly clearly. But hope it helps

  3. #3
    Member
    Join Date
    Nov 2015
    Location
    New York
    Posts
    64
    Quote Originally Posted by KurtE View Post
    First the easy part. Uploading to here.

    When editing a post (or entering new thread, you are already there), click on the advanced button and it will take you to a more complete edigint setup... Including # button for code tags and the like. But below the editing area on the page, will be a section for Attachments and a button <Manage Attachments> , Click on it. Bring up dialog, In there click on <Add Files> button, which will take to a dialog to pick which file(s) to upload... Most files need to be put in a zip file or the like before it can be uploaded.
    Yeah, I had a problem with browser history when you told me the steps I was used to. I thought the layout changed on the forum when in actuality it was Chrome just being stupid and not loading the forum correctly. Fixed now


    Quote Originally Posted by KurtE View Post
    Again sorry if I did not explain it overly clearly. But hope it helps
    No worries, that is super helpful! I just wasn't sure how to port the font.c files into VBA without knowing how the arrays were structured. I'll take a crack at it over the next couple days and post results. Hopefully someone will find it useful.

    What I have so far implements most of the basic shapes and standard colors. Open up both excel documents and edit the one with yellow background text fields. If you are handy with excel you will kind of understand where I am going with the layout. I should probably make a tutorial sheet if people are interested in this thing.
    ili9341_simulator_v0.1.zip

  4. #4
    Member
    Join Date
    Nov 2015
    Location
    New York
    Posts
    64
    Successfully employed one of the fonts using the Adafruit font library
    Click image for larger version. 

Name:	disp.jpg 
Views:	61 
Size:	128.2 KB 
ID:	10808

    A bunch of missing functions and descriptions, but it is working. Uploaded here just in case I lose a copy.
    ili9341_simulator_v0.2.zip

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •