First the good news, I got past the memory issues I was having and started working on the displays. I also replaced all the LEDs in the buttons I'll be using with nice diffused ones. I also was able to get past some issues with the Adafruit library for the 24 LED bargraph. When all was said and done, I was able to compile my 42KB sketch and load it onto the Arduino.
That's when things started heading South.
It was then that I realized the severe memory limitations of the Arduino. Even the Mega, with 8KB of SRAM is seriously cramped. It never finished the setup() routine, it ran out of RAM before creating all the variables. So I started to work on cutting down. First, I found that using reserve() on the vectors was chewing through RAM and not doing what I expected. By removing that, I was able to immediately save a ton of SRAM, at least enough to have some breathing room.
From there, I learned about enclosing String literals with F() to reduce SRAM utilization. After implementing this across the board, I was able to save 1374 bytes. After that, I was able to compile the whole thing, with all buttons and displays and have 1638 bytes left. Which isn't enough to actually parse anything.
I do have some options:
- Try to reduce SRAM utilization
- Cut down on objects
- Optimize main sketch
- Purchase an SRAM extender
- Split the project across two Megas
- Relocate the logic to the other side of the serial cable
I'm still investigating, but I'm kind of disheartened.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.