Ok - this is the 'how it works'. Just in time for Christmas! Sadly work gets in the way of fun too often
So - for speed - I output the complete screen data in a single 'lump' (see BlitBuffer) This means that the whole display can be drawn at the maximum speed (I got SPI working at 30MHz - and faster may be possible with newer esp32 variants or by 'tweaking' some of the SPI settings - see the error messages sent to UART when attempting faster speeds)
To do this - the whole display must be buffered in RAM - and I went with a 4 colour display (2 bits per pixel, with 0 as black and 3 as white) Note that it would be possible to do a black and white display (one bit per pixel - my first attempt did this) or up to 256 colour (8 bits per pixel) - the trade off is RAM usage - 2 bits per pixel uses 19.2KB RAM and 8 bits would be 4 times this. The only macros that need changing are Plot, Clear and BlitBuffer.
I added a Plot, DrawLine and CopyBM (Copy bitmap - currently just monochrome 1 bit per pixel)as well as a simple text.
The only macros I use from the component are Initialise and Window. The wiring to the display uses A15 for Chip Select - and if you change this then you MUST change the pin used in BlitBuffer (where this is hard-coded - I couldn't find an easy way to 'pull' the value from FC) It's fairly easy to modify to use the component (for example the cube rotation) - if you want to see the speed improvement.
Bitmaps - these are added using #include statements in supplementary code. There is a simple Python program to convert a bitmap to a C file in the attachment (tohex.py usage tohex.py fname.abc -> creates fname.dat) I used ImageMagick to convert pngs to mono bitmaps. There is a 'draw background' option - if there are large areas of background it is quicker to use clear and set this to false. This is also used to give the 'transparent' images.
Unfortunately FC doesn't support pointers - so I use 32 bit integers and a little bit of C to get the address of the bitmaps and to read data from the memory referenced.
Compilation - save then attempt to compile the program (demo.fcfx) this will fail - but it will create the directory structure - and then copy the attached files (extract the zip) to demo\main. Then recompile and enjoy(?) There are '4' distinct demos - one with a suitably seasonal message!
I toyed with different fonts for the final 'scrollie' - The 'F' is still different...
I used (pseudo) random colours - output may not always be harmonious!
- main.zip
- (59.75 KiB) Downloaded 90 times
Good luck to anyone brave enough to try - and to everyone at Matrix and Flowocode users everywhere my best wishes for a happy Christmas and a prosperous and peaceful New Year.
Martin