Randomized colors

This commit is contained in:
Peter 2019-12-28 12:30:56 +01:00
parent 715b39e9f1
commit 40a20fc3be
1 changed files with 21 additions and 5 deletions

View File

@ -9,31 +9,47 @@ Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16, 16, 2, 1, 16,
NEO_TILE_PROGRESSIVE, NEO_GRB + NEO_KHZ800); NEO_TILE_PROGRESSIVE, NEO_GRB + NEO_KHZ800);
int i=0; int i=0;
#define NUM_COLORS 7
const PROGMEM uint16_t colors[NUM_COLORS] = {
Adafruit_NeoMatrix::Color(127, 0, 0),
Adafruit_NeoMatrix::Color(0, 127, 0),
Adafruit_NeoMatrix::Color(0, 0, 127),
Adafruit_NeoMatrix::Color(127, 0, 127),
Adafruit_NeoMatrix::Color(127, 127, 0),
Adafruit_NeoMatrix::Color(0, 127, 127),
Adafruit_NeoMatrix::Color(127, 127, 127)
};
uint16_t currColor[2];
void setup() void setup()
{ {
matrix.begin(); matrix.begin();
matrix.setTextSize(1); matrix.setTextSize(1);
matrix.setTextColor(matrix.Color(0, 0, 100));
Serial.begin(9600); Serial.begin(9600);
matrix.setTextWrap(false); matrix.setTextWrap(false);
Serial.println("Setup Done"); Serial.println("Setup Done");
currColor[0] = colors[random(NUM_COLORS)];
currColor[1] = colors[random(NUM_COLORS)];
} }
void loop() void loop()
{ {
matrix.fillScreen(matrix.Color(0, 0, 0)); matrix.fillScreen(matrix.Color(0, 0, 0));
matrix.setCursor(i, 0); matrix.setCursor(i, 0);
matrix.setTextColor(matrix.Color(0, 0, 128)); matrix.setTextColor(currColor[0]);
matrix.print("/usr/space @36C3"); matrix.print("/usr/space @36C3");
matrix.setTextColor(matrix.Color(64, 0, 0)); matrix.setTextColor(currColor[1]);
matrix.setCursor(i*3, 8); matrix.setCursor(i*3, 8);
matrix.print("Sticker Exchange Sticker Exchange"); matrix.print("Sticker Exchange Sticker Exchange");
portDISABLE_INTERRUPTS(); portDISABLE_INTERRUPTS();
delay(1); delay(1);
matrix.show(); matrix.show();
portENABLE_INTERRUPTS(); portENABLE_INTERRUPTS();
if(--i < -16*6) if(--i < -16*6) {
i = matrix.width(); i = matrix.width();
currColor[0] = colors[random(NUM_COLORS)];
currColor[1] = colors[random(NUM_COLORS)];
}
delay(249); delay(249);
} }