olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
5.18k stars 1.05k forks source link

Reducing RAM on AVR using PROGMEM #882

Closed espHorst closed 5 years ago

espHorst commented 5 years ago

Dear olikraus, thanks at first for this wonderful library! I would like to ask if it is possible to further reduce the RAM usage on AVR processors. On AVR

static const uint8_t u8x8_d_max7219_init_seq[] = {

goes to ram. If you agree I can try doing a PR including

#ifdef __AVR__
    #include <avr/pgmspace.h>
#endif

#ifdef __AVR__
static const uint8_t PROGMEM u8x8_d_max7219_init_seq[] = { 
#else
static const uint8_t sbox[256] = {
#endif

to put static const to PROGMEM. Do you think that there are any issues? Best regards, espHorst

olikraus commented 5 years ago

Well, yes, I know, this is a missing thing... However, there are several things to consider.

All in all a lot of analysis and tests need to be done. This is why I hesitated to do this.

espHorst commented 5 years ago

Hm. What about adding an additional dedicated u8x8_cad_SendSequenceP() with P for progmem. Then piece by piece memory critical sequences can be changed. I would try to start with u8x8_d_max7219_init_seq ;-)

olikraus commented 5 years ago

The goal is to keep the code portable for all platforms. This means, u8x8_d_max7219_init_seq should be usable on AVR but also on ARM and ESP. This means, adding a function for u8x8_d_max7219_init_seq only will not help. We need to do this for all 451 arrays. I mean, I need a solution, which will work for all 451 arrays on all plattforms.

You can definitly do a local solution for your own project for one specific array. But then this is not something what I will takeover here.

espHorst commented 5 years ago

Hi olikraus, thanks for the feedback - I will do a local solution for just this project and use a bigger uC (STM32F1) for the next project! Thanks a lot!

olikraus commented 5 years ago

Sure, I am sorry for this, but this task indeed is a bigger topic.