#include <Arduino.h>
#include <FastLED.h>
#include <ESPDateTime.h>
#include <WiFi.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
#define DATA_PIN 14
const int width = 32; // links nach rechts = 0 : 31
const int height = 8; // oben nach unten = 0 : 7
const int NUM_LEDS = (width*height);
const uint8_t INT6x4[10][6] = {
{6,9,9,9,9,6}, // 0
{6,7,6,6,6,6}, // 1
{}, // 2
{}, // 3
{}, // 4
{}, // 5
{}, // 6
{}, // 7
{}, // 8
{}, // 9
};
enum Strings{ COLON = 10};
int rundum = 0;
long interval = 400;
long old1 = 0;
long old2 = 300;
long fOld = 0;
long finterval = interval/2-1;
struct cursor {
int x = 0;
int y = 0;
}cursor;
struct Matrix {
// bool is_lines = false; // Matrix is separated into columns if false
int width = width;
int height = height;
} Matrix;
// const int NUM_LEDS = (width*height);
CRGB leds[NUM_LEDS];
bool set_cursor(int x,int y){
if (x > 0 && y > 0){
cursor.x = x;
cursor.y = y;
return true;
}
else return false;
};
int Value (int h=0, int w=0, int x=0, int y=0, int r = 1){
return (w+x<width?(w+x+1)*height:(w+x+1-width)*height) -y-h-1;
// return (w+x<width?w+x:w+x-width)+y*width+h*width;
}
void print_num(int c, int x=0, int y=0){
for (int h = 0;h<6;h++){
for (int w=0;w<4;w++){
// Serial.println(w+x<width?w+x:w+x-width);
leds[Value(h,w,x,y)] = (INT6x4[c][h]>>w&1)?CRGB::Red:CRGB::Black;
}
}
}
void setup() {
Serial.begin(9600);
Serial.println("Test:");
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
WiFi.begin(ssid, password, 6);
DateTime.setServer("de.pool.ntp.org");
DateTime.setTimeZone("GMT+1");
DateTime.begin();
DateTimeParts p = DateTime.getParts();
Serial.println(p.getHours()/10);
}
void loop() {
// if (millis()-old1 > interval) {FastLED.clear();print_num(1,rundum,1); old1 = millis();FastLED.show();};
// FastLED.show();
// delay(500);
if (millis()-old2 > interval) {FastLED.clear();print_num(0,rundum,1);print_num(0,rundum+4,1); old2 = millis();if (++rundum >= width) rundum = 0;FastLED.show();};
// if (millis()-fOld > finterval) {FastLED.show(); fOld = millis();};
// delay(500);
// print_num(1,6,1);
// FastLED.show();
// delay(500);
// print_num(0,6,1);
// FastLED.show();
// delay(500);
}