Dealing with Memory and Selector Object #938
Replies: 1 comment
-
I found out what's happening here. When the compiler sees a static number index to the array it just gets that one string. When there is a variable as the index the compiler needs to put the whole array into memory, and that's too big! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I will try to be judicious about the question and code here...
I have an array of strings:
... 50 items...
}
I'm using the ProgramChanger and IncrementDecrementSelector to send program change commands to a synth pedal, which all works. I'm trying to display those preset names on a TFT display. The Control_Surface and Adafruit TFT libraries take up memory of course. Here's what I find odd. I can assign the current preset number from the Selector to a variable, no issues. I can use that variable as an index to assign the array value to a char pointer, no issues. If I try to print that to the display I get memory issues. If I use a number index in code the print works fine, no memory issues. If I assign a number to the char point variable it works fine. I don't under why using a 'dead' number in code would be any different than using an int for the index.
If I change the line to
presetName = presetListMan[6]; // it prints fine
If I directly assign a number to presetName, it prints fine
presetName = 8;
It makes a BIG difference, 55% of dynamic memory to 106% of dynamic memory. I thought that a variable
int
would not be much bigger than a static number. I'm sure I'm missing something about how the arrays or Selector class works.Thanks for any help!
Beta Was this translation helpful? Give feedback.
All reactions