Created
January 28, 2020 19:34
-
-
Save remisarrailh/af1a762bade28aa82b93ab57ab5a1c97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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