Olimex Support Forum

Microcontrollers => ESP8266 => Topic started by: KNK on October 12, 2015, 04:40:10 pm

Title: OLED fonts in flash
Post by: KNK on October 12, 2015, 04:40:10 pm
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)
Title: Re: OLED fonts in flash
Post by: KNK on October 14, 2015, 01:12:19 pm
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 (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 :(