Page 1 of 1

GLCD Bitmap Drawer for more than 1 Object

Posted: Sat Oct 31, 2020 7:14 pm
by ronaldlijs
Hi guys,

Just wondering if it is possible to reuse bitmaps for more than one GLCD Object. Our setup has got 4x OLEDs in total driven by PIC32MZ (1x Parallel 8088 SSD1322 and 3x Buffered SSD1306 and we were looking for a way of being more efficient when storing bitmaps in ROM by sharing the same bitmaps amongst the different GLCD objects?

I know this looks more like a request rather than a question, but was wondering if this was easily doable or due to some constrains was really not possible to implement at the moment...

Thanks for your help!!
R

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Sat Oct 31, 2020 7:51 pm
by mnf
It's a bit of a kludge - but it would certainly be possible to 'copy' Display_BMP and add a 'display' variable that specifies the display to draw to (this would be relatively easy with the source - pretty please...)

So:
If (display == 1)
display1_plot(x,y,pixel)
if(display == 2)
display2_plot(x,y,pixel)

etc...

I'd almost be tempted to use this as a template for your own 'custom' draw routine - the one here is generalised to work with a range of displays and bitmap formats - so if, for example, you only work with 24bit images - then work only with these rather than allowing different colour depths etc.. (Use Display_BMP_Fast as template)

Martin

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Mon Nov 02, 2020 11:21 am
by Benj
Hello,

Yes I agree with Martin, adapting the component to be able to do it would be very tricky but copying the existing routine and replicating it using C icons to point to the various display components should be possible.

Have a go and if your struggling then send us your project so far and we can have a quick go for you.

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Mon Nov 02, 2020 8:08 pm
by ronaldlijs
Thanks Martin and Ben.

Ben sorry for my ignorance, I didn't quite get the bit about copying the existing routine... What routine exactly? Obviously I am unable to open BitmapDrawer.fcpx to have a look at the routine, otherwise fine... Is there any way to dynamically change the gLCD Object Property of a Component when the program is running? C Icons sounds great to me, but would you have some kind of example file I can have a look?

I reckon maybe some C code one can modify the Properties of that component before drawing the Bitmap? Just an already working demo of something similar will do for me ;-)

Thanks again!

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Mon Nov 02, 2020 9:02 pm
by mnf
Basically - copy the C code (use view C) - and amend this..

I did a version for 2 displays (0 and 1) (there is a display parameter (set to 0 or 1) - if it works the same principle can be used to extend to 4 displays..)-
Display.fcm
(17.82 KiB) Downloaded 206 times
There is a problem with this approach - the name of the 'plot' routine may vary depending on the displays you have used ( so you might need to edit it - I've added a comment where the display is selected). You can check the name FC uses for the display using the view C option again...

After doing this - it struck me there might be a neater way to do it using function pointers (so - plot_fn = glcdN_plot) which could be set once at the start of the c code (this would be quicker than choosing each time...)

But - can you try this first...

Martin

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Tue Nov 03, 2020 3:44 pm
by mnf
Another idea - I did a bitmap reader a while ago (reading .BMP files in any format) in FC
It would be relatively easy to modify this to write to one of a choice of displays (or more than one at once by using a bit to indicate whether to write to a given display)
I used a memory chip (i2c after originally using a SD card) but it could be modified to use SPI or ROM - the issue (particularly with ROM) is writing the file to it..

Depends on the requirements of your project - but I can look it out of it sounds useful...

Martin

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Mon Nov 30, 2020 9:42 pm
by ronaldlijs
Hi Martin,

Sorry for the late reply and many thanks for your suggestions. Will check this when I have a chance.

Regards!
R

Re: GLCD Bitmap Drawer for more than 1 Object

Posted: Mon Nov 30, 2020 11:01 pm
by mnf
Hi,

In the meantime - I did this ST7789 code - here -https://www.matrixtsl.com/mmforums/view ... 68#p104068 - which has a 'bitmap' copy. For monochrome displays you'd just need the 1 bit version. This is (hopefully) a bit easier to follow than reverse engineering the FC component. The code here also just uses 'stored' bitmap data - though I think I'll do a version that works with 'complete' bitmap files too (this is fairly straightforward - the Python script in the posts effectively does this - reading the dimensions and colour table from a bitmap file)
The ST7789 is slightly unusual in that the code defines a 'window' to draw to. However, it should be fairly easy to modify to use a x,y address system. The code in the post draws the bitmap from RAM - though I use it to draw from i2c EEPROM (and it would be possible to draw from MCU ROM too. (SD card or SPI EEPROM would be difficult with the display shown and only one SPI port...)

Martin