-
Notifications
You must be signed in to change notification settings - Fork 213
Arduino and Memory Consumption
It is important to note that Arduino devices based on the ATmega328P microcontroller (such as Arduino UNO, Arduino Pro Mini, etc.) are extremely limited in the amount of memory (RAM) that they provide, 2KB! There is very little memory available for a GUI after including the Adafruit-GFX and Adafruit display/touch libraries. As a result, GUIslice offers an optimized "minimum memory" API that pushes as much of the GUI code into FLASH memory as possible, greatly reducing the demands on the limited RAM available.
The minimum memory examples are provided in the /arduino_min
folder and in the Arduino IDE under Examples -> GUIslice -> arduino_min.
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.
For more information on how to use these reduced-memory APIs:
- Please see Creating 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]