Skip to content

Instantly share code, notes, and snippets.

@remisarrailh
Created January 28, 2020 19:34
Show Gist options
  • Save remisarrailh/af1a762bade28aa82b93ab57ab5a1c97 to your computer and use it in GitHub Desktop.
Save remisarrailh/af1a762bade28aa82b93ab57ab5a1c97 to your computer and use it in GitHub Desktop.
#include <Adafruit_GFX.h>
#include <FastLED.h>
#include <FastLED_NeoMatrix.h>
#include <Fonts/TomThumb.h>
#include <ezTime.h>
#include <WiFi.h>
#define PIN 27
#define mw 5
#define mh 5
#define NUMMATRIX (mw*mh)
Timezone myTZ;
String timeString = "";
CRGB matrixleds[NUMMATRIX];
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(matrixleds, mw, mh,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE );
const uint16_t colors[] = {
matrix->Color(255, 0, 0), matrix->Color(0, 255, 0), matrix->Color(0, 0, 255)
};
void setup() {
Serial.begin(115200);
FastLED.addLeds<NEOPIXEL, PIN>(matrixleds, NUMMATRIX);
WiFi.begin("", "");
setDebug(INFO);
waitForSync();
myTZ.setLocation(F("fr"));
matrix->begin();
matrix->setTextWrap(false);
matrix->setFont(&TomThumb);
matrix->setBrightness(40);
matrix->setTextColor(colors[0]);
}
int x = mh;
int pass = 0;
void loop() {
timeString = myTZ.dateTime("H:i:s");
matrix->fillScreen(0);
matrix->setCursor(x, mh);
matrix->print(timeString);
if (--x < -25) {
x = matrix->width();
if (++pass >= 3) pass = 0;
matrix->setTextColor(colors[pass]);
}
matrix->show();
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment