LEDDisplay/display/display.ino

56 lines
1.6 KiB
Arduino
Raw Normal View History

2019-12-28 02:06:36 +01:00
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
2019-12-27 19:32:03 +01:00
2019-12-28 02:58:14 +01:00
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16, 16, 2, 1, 16,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG +
NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS +
NEO_TILE_PROGRESSIVE, NEO_GRB + NEO_KHZ800);
2019-12-28 02:06:36 +01:00
int i=0;
2019-12-27 19:32:03 +01:00
2019-12-28 12:30:56 +01:00
#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];
2019-12-28 02:58:14 +01:00
void setup()
{
matrix.begin();
matrix.setTextSize(1);
Serial.begin(9600);
matrix.setTextWrap(false);
Serial.println("Setup Done");
2019-12-28 12:30:56 +01:00
currColor[0] = colors[random(NUM_COLORS)];
currColor[1] = colors[random(NUM_COLORS)];
2019-12-27 19:32:03 +01:00
}
2019-12-28 02:58:14 +01:00
void loop()
{
2019-12-28 12:30:56 +01:00
2019-12-28 02:58:14 +01:00
matrix.fillScreen(matrix.Color(0, 0, 0));
matrix.setCursor(i, 0);
2019-12-28 12:30:56 +01:00
matrix.setTextColor(currColor[0]);
2019-12-28 02:58:14 +01:00
matrix.print("/usr/space @36C3");
2019-12-28 12:30:56 +01:00
matrix.setTextColor(currColor[1]);
2019-12-28 02:58:14 +01:00
matrix.setCursor(i*3, 8);
matrix.print("Sticker Exchange Sticker Exchange");
portDISABLE_INTERRUPTS();
delay(1);
matrix.show();
portENABLE_INTERRUPTS();
2019-12-28 12:30:56 +01:00
if(--i < -16*6) {
2019-12-28 02:58:14 +01:00
i = matrix.width();
2019-12-28 12:30:56 +01:00
currColor[0] = colors[random(NUM_COLORS)];
currColor[1] = colors[random(NUM_COLORS)];
}
2019-12-28 02:58:14 +01:00
delay(249);
2019-12-27 19:32:03 +01:00
}