Simulating ili9341_t3: request help with drawChar()

Status
Not open for further replies.

josechow

Well-known member
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.
 
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
 
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


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.
View attachment ili9341_simulator_v0.1.zip
 
Successfully employed one of the fonts using the Adafruit font library
disp.jpg

A bunch of missing functions and descriptions, but it is working. Uploaded here just in case I lose a copy.
View attachment ili9341_simulator_v0.2.zip
 
Status
Not open for further replies.
Back
Top