80 lines
1.6 KiB
C++
80 lines
1.6 KiB
C++
#include <ESP8266WiFi.h>
|
|
#include <ESP8266mDNS.h>
|
|
#include <WiFiUdp.h>
|
|
#include <ArduinoOTA.h>
|
|
#include "FastLED.h"
|
|
#include <NTPClient.h>
|
|
#include <PubSubClient.h>
|
|
|
|
#include "config.h"
|
|
CRGB leds[LED_COUNT];
|
|
WiFiClient wifi;
|
|
WiFiUDP ntpUDP;
|
|
NTPClient ntpClient(ntpUDP, NTP_SERVER, NTP_OFFSET, NTP_INTERVAL);
|
|
|
|
#include "functions.h"
|
|
#include "text.h"
|
|
#include "sprites.h"
|
|
#include "animations.h"
|
|
#include "tools.h"
|
|
#include "effects.h"
|
|
|
|
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");
|
|
}
|
|
|
|
Sinematrix3 effect_sinematrix3;
|
|
Clock effect_clock;
|
|
SmallClock effect_small_clock;
|
|
Bell effect_bell;
|
|
Static effect_off(CRGB(0x000000));
|
|
Animation effect_koopa(&koopa);
|
|
Effect* current_effect = &effect_small_clock;
|
|
|
|
#define NUM_EFFECTS 6
|
|
EffectEntry effects[NUM_EFFECTS] = {
|
|
{"bell", &effect_bell},
|
|
{"sinematrix3", &effect_sinematrix3},
|
|
{"clock", &effect_clock},
|
|
{"small_clock", &effect_small_clock},
|
|
{"koopa", &effect_koopa},
|
|
{"off", &effect_off}
|
|
};
|
|
|
|
#include "mqtt.h"
|
|
|
|
uint8_t starting_up = OTA_STARTUP_DELAY;
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
ota_loop();
|
|
|
|
if (starting_up > 0) {
|
|
EVERY_N_SECONDS(1) {
|
|
starting_up--;
|
|
clear();
|
|
for (int i=0; i<starting_up; i++) {
|
|
leds[XYsafe(i, 0)] = CRGB(0xff0000);
|
|
}
|
|
FastLED.show();
|
|
}
|
|
return;
|
|
}
|
|
|
|
ntp_loop();
|
|
mqtt_loop();
|
|
|
|
EVERY_N_MILLISECONDS(1000 / FPS) {
|
|
current_effect->loop();
|
|
FastLED.show();
|
|
}
|
|
}
|