pitrix/pitrix.ino

80 lines
1.6 KiB
Arduino
Raw Normal View History

2019-05-21 03:52:57 +00:00
#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"
2019-05-21 03:52:57 +00:00
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;
2019-05-21 03:52:57 +00:00
Bell effect_bell;
Static effect_off(CRGB(0x000000));
Animation effect_koopa(&koopa);
Effect* current_effect = &effect_small_clock;
2019-05-21 03:52:57 +00:00
#define NUM_EFFECTS 6
2019-05-21 03:52:57 +00:00
EffectEntry effects[NUM_EFFECTS] = {
{"bell", &effect_bell},
{"sinematrix3", &effect_sinematrix3},
{"clock", &effect_clock},
{"small_clock", &effect_small_clock},
{"koopa", &effect_koopa},
2019-05-21 03:52:57 +00:00
{"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();
}
}