Hi,
I'm using a 2d bool array as a mask for turning an addressable LED strip into a seven segment display. It's currently only storing masks for 0-9 (I'd like to have masks for other letters and symbols tbd in the future) but it is already using up ~33% of my available dynamic memory on a Nano 328P with ~35% used elsewhere.
I've noticed it's using a byte for every bool, is there an alternate data type that is similarly easy to iterate over and perform operations on?
Alternately, what other low-cost micro-controllers would have better dynamic memory? I am considering integrating a web-server into the project in the future, (not sure if wired or wireless but wireless seems more accessible these days) and I imagine that would require a different board anyway.
Thanks!
#include <FastLED.h>
#define NUM_LEDS 194
#define DATA_PIN 2
CRGB leds[NUM_LEDS];
bool mask[10][64] = { {0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} };
unsigned long startTime;
byte currentTime;
byte currHue = 0;
byte currSat = 255;
byte currBri = 150;
void setup() {
delay(2000);
//Serial.begin(9600);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
startTime = millis();
}
void loop() {
currentTime = 180 - ( ( (millis()-startTime) / 1000 ) % 180 );
if ( (millis()/500) % 2) {
leds[0] = CHSV(currHue, currSat, currBri);
leds[1] = CHSV(currHue, currSat, currBri);
} else {
leds[0] = CHSV(currHue, currSat, 0);
leds[1] = CHSV(currHue, currSat, 0);
}
int curDigit = currentTime % 10;
for (int i = 0; i<64; i++) {
leds[i+2] = CHSV(currHue, currSat, mask[curDigit][i]*currBri);
}
curDigit = (currentTime/10) % 6;
for (int i = 0; i<64; i++) {
leds[i+66] = CHSV(currHue, currSat, mask[curDigit][i]*currBri);
}
curDigit = (currentTime/60) % 10;
for (int i = 0; i<64; i++) {
leds[i+130] = CHSV(currHue, currSat, mask[curDigit][i]*currBri);
}
FastLED.show();
delay(10);
}



