Skip to main content
added 686 characters in body
Source Link
Michel Keijzers
  • 13k
  • 7
  • 43
  • 59

Did you try using the (PROGMEM) F macro. It is described in the official Arduino documentation at the end of https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

This forces all strings to be stored in Flash memory instead of the scarce SRAM memory.

You can try with a few strings to see if the memory lowers and calculate if it would be enough (to fit in Flash). If even Flash is not enough, than SD card would be an alternative.

Also some refactorings that might clean up the code (not necessarily reduce the memory used):

  • instead of the many if (integerValue == xxx) constructs, use switch/case statements.
  • A possible bug are the identical values within (like 245 and 766 used many times, but for different products)
  • Move the function lcd.print("...") inside function ComScrn and pass the string (using F(..))
  • Similar as above but for IDScrn, using two strings and set the cursor inside IDScrn as well.
  • (key != NO_KEY && key == 'X') ... if key is 'X' it can never be NO_KEY so the first check can be removed.
  • if (result == true) can be written as if (result).

Did you try using the (PROGMEM) F macro. It is described in the official Arduino documentation at the end of https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

This forces all strings to be stored in Flash memory instead of the scarce SRAM memory.

You can try with a few strings to see if the memory lowers and calculate if it would be enough (to fit in Flash). If even Flash is not enough, than SD card would be an alternative.

Did you try using the (PROGMEM) F macro. It is described in the official Arduino documentation at the end of https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

This forces all strings to be stored in Flash memory instead of the scarce SRAM memory.

You can try with a few strings to see if the memory lowers and calculate if it would be enough (to fit in Flash). If even Flash is not enough, than SD card would be an alternative.

Also some refactorings that might clean up the code (not necessarily reduce the memory used):

  • instead of the many if (integerValue == xxx) constructs, use switch/case statements.
  • A possible bug are the identical values within (like 245 and 766 used many times, but for different products)
  • Move the function lcd.print("...") inside function ComScrn and pass the string (using F(..))
  • Similar as above but for IDScrn, using two strings and set the cursor inside IDScrn as well.
  • (key != NO_KEY && key == 'X') ... if key is 'X' it can never be NO_KEY so the first check can be removed.
  • if (result == true) can be written as if (result).
Source Link
Michel Keijzers
  • 13k
  • 7
  • 43
  • 59

Did you try using the (PROGMEM) F macro. It is described in the official Arduino documentation at the end of https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

This forces all strings to be stored in Flash memory instead of the scarce SRAM memory.

You can try with a few strings to see if the memory lowers and calculate if it would be enough (to fit in Flash). If even Flash is not enough, than SD card would be an alternative.