This link https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2/drawing-bitmaps shows how to draw a bitmap on adafruit tft screen.
I would like to use this capability but I don't know how to write the inline C for this function reader.drawBMP.
Also, are these definitions included in the b4r libraries (adafruit_GFX and mcufriends_kbv which are used in the existing drawing programs that I use) or needed in the code ? will they work together or contradict ?
Sorry, wrong link. This link https://electropeak.com/learn/absol...o-tft-lcd-displays-by-arduino/#Basic_Commands shows demos with a function "drawRGBBitmap" in mcufriends_kbv library but I can't find it in the library's code (???) and it is also not exposed to B4R code. In the example the used bitmaps are stored as arrays so there should also be a method to create them from files. Complicated... also adding all the files will end by a too big application
Both alternatives work when run from Arduino IDE. The bitmaps in the above picture need conversion from file to an array.
In the mcufriends example the function showBMP is doing the conversion in real time, the files are in the SD card.
For me, the arrays solution is not good, if I need 7 bitmaps and they all are coded in the memory - the application will be giant.
With the mcufriends example - each bitmap is created when used but the size of the function seems too big.
It is exactly what I refer to as the first option but I made some calculation and it is too big for the application. I'll play with it when I'll get another screen.
I have to draw 11 bitmaps, all with the same height.
I made this sub in B4R:
B4X:
Private Sub DrawBitmap(img As Int,x As Int, y As Int, Width As Int) ' the height is already set
bmpx = x
bmpy = y
imageWidth = Width
Select img
Case 0
RunNative("drawBitmap0", mcu.GFX)
Case 1
RunNative("drawBitmap1", mcu.GFX)
Case 2
RunNative("drawBitmap2", mcu.GFX)
Case 3
RunNative("drawBitmap3", mcu.GFX)
Case 4
RunNative("drawBitmap4", mcu.GFX)
Case 5
RunNative("drawBitmap5", mcu.GFX)
Case 6
RunNative("drawBitmap6", mcu.GFX)
Case 7
RunNative("drawBitmap7", mcu.GFX)
Case 8
RunNative("drawBitmap8", mcu.GFX)
Case 9
RunNative("drawBitmap9", mcu.GFX)
Case 10
RunNative("drawBitmap10", mcu.GFX)
End Select
End Sub
I call for drawing an image with this:
B4X:
DrawBitmap(1, 180 ,355 , 32)
In C I made this code * 11, for each bitmap the array and the function :
I've tried several things but they didn't work. If the arrays weren't a PROGMEM arrays then it would have been simple to create an array of pointers to these arrays. However dealing with PROGMEM arrays is more difficult. Better to keep your current solution.
Thank you, Erel.
I completed the change to have DayofWeek in Hebrew on the clock using 11 bitmaps the size of 45x60, the size of the complete code is 99% !
Strange thing - although the bitmaps are monochrome , made of black text on white background, I have the letters in red !
The bitmaps were coded to invert the colors in order to have black background. I realized that the white color of the letters is actually transparent like a mask so I draw a color rectangle to be used as background and on it the bitmap !
A simple way to do it is to put it in the folder of one of the referenced libraries as all the files from these folders are copied during compilation.
Another option is to copy it with a custom build action that is executed in the "folders ready" step.