#include #include #include #include #include "FastLED.h" #include #include #include "config.h" CRGB leds[LED_COUNT]; WiFiClient wifi; WiFiUDP ntpUDP; NTPClient ntpClient(ntpUDP, NTP_SERVER, NTP_OFFSET, NTP_INTERVAL); #ifdef DEBUG #define LOG(x) Serial.print(x); #define LOGln(x) Serial.println(x); #else #define LOG(x) "" #define LOGln(x) "" #endif typedef struct { uint8_t x; uint8_t y; uint8_t w; uint8_t h; } Window; #include "functions.h" #include "text.h" #include "sprites.h" #include "animations.h" #include "tools.h" #include "effects.h" #define NUM_EFFECTS 10 //EffectEntry effects[NUM_EFFECTS]; Sinematrix3 sinematrix3; BigClock big_clock; Clock clock; Bell bell; Static off(CRGB(0x000000)); Animation anim_koopa(&animation_koopa, CRGB(0x000000), 0, 0); Animation anim_couple_rain(&animation_couple_rain, CRGB(0x000000), -8, -16); SingleDynamic single_dynamic; MultiDynamic multi_dynamic; MatrixEffect matrix; EffectEntry effects[NUM_EFFECTS] = { {"sinematrix3", (Effect *)&sinematrix3}, {"big_clock", (Effect *)&big_clock}, {"clock", (Effect *)&clock}, {"bell", (Effect *)&bell}, {"off", (Effect *)&off}, {"koopa", (Effect *)&anim_koopa}, {"couple_rain", (Effect *)&anim_couple_rain}, {"single_dynamic", (Effect *)&single_dynamic}, {"multi_dynamic", (Effect *)&multi_dynamic}, {"matrix", (Effect *)&matrix}, }; void setup() { // put your setup code here, to run once: Serial.begin(74880); Serial.println("Core * Starting"); wifi_setup(); ota_setup(); fastled_setup(); ntp_setup(); mqtt_setup(); Serial.println("Core * Setup complete"); } Effect* current_effect = &clock; #include "mqtt.h" uint8_t starting_up = OTA_STARTUP_DELAY; int loop_timeouts = 0; long loop_started_at = 0; void loop() { loop_started_at = millis(); ota_loop(); if (starting_up > 0) { EVERY_N_SECONDS(1) { Serial.print("Core * Waiting for OTA... "); Serial.println(starting_up); starting_up--; clear(); for (int i=0; iloop(); if (current_effect->can_be_shown_with_clock()) { clock.loop(current_effect->clock_as_mask(), CRGB(0xFFFFFF), CRGB(0x000000)); } FastLED.show(); } if (MONITOR_LOOP_TIMES && millis()-loop_started_at>=MONITOR_LOOP_TIME_THRESHOLD) { LOG("Core * Loop took "); LOG(millis()-loop_started_at); LOGln("ms."); loop_timeouts++; LOG("Core * Timeout counter is now "); LOGln(loop_timeouts); if (loop_timeouts >= MONITOR_LOOP_TIME_COUNT_MAX) { ESP.restart(); } } else if (loop_timeouts > 0) { loop_timeouts--; } }