November 24, 2024, 02:48:37 AM

OLED fonts in flash

Started by KNK, October 12, 2015, 04:40:10 PM

Previous topic - Next topic

KNK

I am experimenting with MOD-OLED, but the fonts take most of the available RAM :(
Is it possible to store the font in flash?
Any hints for similar (Arduino) libs, so i can try to write something on my own (if there is no such lib available)

KNK

#1
EDIT:
Found the reason for the fonts taking RAM and how to force them to stay in flash.
Using the code from https://github.com/OLIMEX/MOD-OLED-128x64/blob/master/SOFTWARE/Adruino/OLED.h  - one of the fonts (font_16x16) was properly defined with PROGMEM (to remain in flash only), but the small font (font_6x8) was not.

@ Olimex you should change the small font definition in order to save the precious SRAM

Well it is actually the opposite ...
ESP does not need PROGMEM to store them in Flash, so small font printing is OK and the 16x16 should be fixed not to use PROGMEM definition and the pgm_read_* macros, because they are causing the code to crash

EDIT END

The sad thing is that more than half of the RAM is still unavailable even with a blank project :(
Sketch uses 201,038 bytes (19%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 44,604 bytes (54%) of dynamic memory, leaving 37,316 bytes for local variables. Maximum is 81,920 bytes.

... will need to redesign my code to use spiffs instead of RAM for the data structures :(