-
Notifications
You must be signed in to change notification settings - Fork 220
Arduino and Memory Consumption
The traditional Arduino (ATmega328P) has very limited (read-write) SRAM available to programs: generally only 2KB. By default, GUIslice stores the majority of its objects in SRAM as the GUI needs to update data associated with elements, pages, etc. Thankfully, GUIslice offers several ways to reduce RAM consumption, through the storing of both string constants as well as GUI elements in Flash memory (PROGMEM
). Without taking advantage of these memory optimizations, sketches with a large number of GUI elements may exceed the available RAM resources on limited SRAM devices such as the basic ATmega328P.
A separate set of examples have been created to demonstrate the use of RAM optimizations (moving strings and GUI elements into FLASH memory). These have been optimized to work on low-memory Arduino devices, though note that the code is more complex due to the need to use FLASH (PROGMEM
).
To see these examples, please refer to the /arduino_min folder.
Please see Elements-in-Flash-Memory
In order to support GUI projects with a larger number of elements (or inclusion of the SD library), it is recommended that one select a microcontroller that offers more than 2KB of SRAM. The following Arduino-compatible processors offer considerably more SRAM:
- Arduino MEGA / ATmega2560 [8KB]
- ESP8266 / NodeMCU [80KB]
- ESP-32
- Cortex M0 (eg. Adafruit Feather M0 [32KB]
- Cortex M3 (eg. STM32duino / STM32F103C8T6) [20KB]