#include <FastLED.h>
#include <ezTime.h>
#include <WiFi.h>
#include "LEDMatrix.h"
#include "LEDText.h"
#include "FontMatrise.h"
// Change the next 6 defines to match your matrix type and size
#define LED_PIN 33
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define MATRIX_WIDTH 75
#define MATRIX_HEIGHT -8
#define MATRIX_TYPE HORIZONTAL_MATRIX
//declare an instance of the cLEDMatrix class, used to declare and modify the LED data according to the matrix dimensions/layout/origin
cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;
//declare the cLEDText class variable
cLEDText ScrollingMsg;
unsigned char TxtDemo[] = {
EFFECT_HSV_AV "\x00\xff\xff\x40\xff\xff"
EFFECT_SCROLL_LEFT
" LEFT SCROLL > @@@@@@@@@@@@"
EFFECT_DELAY_FRAMES "\x00\xff < that's the time"
/*
EFFECT_SCROLL_RIGHT " LLORCS THGIR "
EFFECT_SCROLL_DOWN " SCROLL DOWN SCROLL DOWN " EFFECT_FRAME_RATE "\x04" " SCROLL DOWN " EFFECT_FRAME_RATE "\x00" " "
EFFECT_SCROLL_UP " SCROLL UP SCROLL UP " EFFECT_FRAME_RATE "\x04" " SCROLL UP " EFFECT_FRAME_RATE "\x00" " "
EFFECT_CHAR_UP EFFECT_SCROLL_LEFT " UP"
EFFECT_CHAR_RIGHT " RIGHT"
EFFECT_CHAR_DOWN " DOWN"
EFFECT_CHAR_LEFT " LEFT"
EFFECT_HSV_CV "\x00\xff\xff\x40\xff\xff" EFFECT_CHAR_UP " HSV_CV 00-40"
EFFECT_HSV_CH "\x00\xff\xff\x40\xff\xff" " HSV_CH 00-40"
EFFECT_HSV_AV "\x00\xff\xff\x40\xff\xff" " HSV_AV 00-40"
EFFECT_HSV_AH "\x00\xff\xff\xff\xff\xff" " HSV_AH 00-FF"
" " EFFECT_HSV "\x00\xff\xff" "R" EFFECT_HSV "\x20\xff\xff" "A" EFFECT_HSV "\x40\xff\xff" "I" EFFECT_HSV "\x60\xff\xff" "N" EFFECT_HSV "\xe0\xff\xff" "B" EFFECT_HSV "\xc0\xff\xff" "O"
EFFECT_HSV "\xa0\xff\xff" "W" EFFECT_HSV "\x80\xff\xff" "S " EFFECT_DELAY_FRAMES "\x00\x96" EFFECT_RGB "\xff\xff\xff"
*/
};
const char* val_ptr = memmem(TxtDemo, sizeof(TxtDemo), "@@@@@", 5);
Timezone myTZ;
void setup() {
Serial.begin(115200);
//wait for Serial port to connect, needed for native USB port only
while (!Serial) { ; }
//connect to WiFi and wait for ezTime to sync
// WiFi.begin("Wokwi-GUEST", "");
// waitForSync();
//create timezone variable and set location
//offical timezone names can be found at: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
//note - "US/Eastern", "US/Central", etc. don't work, the "notes" column of the table links to a working equivelent
myTZ.setLocation(F("America/Chicago"));
//print an example to serial monitor just to confirm it's working
Serial.println();
Serial.println("The current time is " + myTZ.dateTime("g:i A T"));
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());
// FastLED.setBrightness(32);
FastLED.clear(true);
delay(500);
//show RGBW (just to test all leds and indicate that the LED text is about to be shown on the matrix)
FastLED.showColor(CRGB::Red);
delay(500);
FastLED.showColor(CRGB::Lime);
delay(500);
FastLED.showColor(CRGB::Blue);
delay(500);
FastLED.showColor(CRGB::White);
delay(500);
FastLED.show();
ScrollingMsg.SetFont(MatriseFontData);
//initialize matrix with dimensions and X/Y origin
ScrollingMsg.Init(&leds, leds.Width(), ScrollingMsg.FontHeight() + 1, 0, 0);
ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1);
//if you don't want to use the special character codes in your text array, you could call the following:
ScrollingMsg.SetTextColrOptions(COLR_RGB | COLR_SINGLE, 0xff, 0x00, 0xff);
//SetBackgroundMode(Options, Dimming);
//SetScrollDirection(Options);
//SetTextDirection(Options);
//SetFrameRate(Rate);
//SetOptionsChangeMode(Options);
}
void loop() {
// get the time of day
String currentTimeString = myTZ.dateTime("H:i:s.v");
// copy the characters of the time String into the scrolltext
memcpy8(val_ptr, currentTimeString.c_str(), currentTimeString.length());
if (ScrollingMsg.UpdateText() == -1) {
ScrollingMsg.SetText((unsigned char *)TxtDemo, sizeof(TxtDemo) - 1);
}
else {
FastLED.show();
delay(25);
}
}
mega:SCL
mega:SDA
mega:AREF
mega:GND.1
mega:13
mega:12
mega:11
mega:10
mega:9
mega:8
mega:7
mega:6
mega:5
mega:4
mega:3
mega:2
mega:1
mega:0
mega:14
mega:15
mega:16
mega:17
mega:18
mega:19
mega:20
mega:21
mega:5V.1
mega:5V.2
mega:22
mega:23
mega:24
mega:25
mega:26
mega:27
mega:28
mega:29
mega:30
mega:31
mega:32
mega:33
mega:34
mega:35
mega:36
mega:37
mega:38
mega:39
mega:40
mega:41
mega:42
mega:43
mega:44
mega:45
mega:46
mega:47
mega:48
mega:49
mega:50
mega:51
mega:52
mega:53
mega:GND.4
mega:GND.5
mega:IOREF
mega:RESET
mega:3.3V
mega:5V
mega:GND.2
mega:GND.3
mega:VIN
mega:A0
mega:A1
mega:A2
mega:A3
mega:A4
mega:A5
mega:A6
mega:A7
mega:A8
mega:A9
mega:A10
mega:A11
mega:A12
mega:A13
mega:A14
mega:A15
neopixels1:DOUT
neopixels1:VDD
neopixels1:VSS
neopixels1:DIN