renderbug/src/SafeMode.cpp

59 lines
1.4 KiB
C++
Raw Normal View History

#include "./SafeMode.h"
#include "./LogService.h"
#include "./Platform.h"
#include "./Static.h"
#include "./Config.h"
#include "./inputs/Serial.h"
TaskFunc safeModeNag([]{
static uint8_t frame = 0;
static CRGB* leds = FastLED.leds();
EVERY_N_SECONDS(30) {
Log.fatal("I am running in safe mode!");
}
EVERY_N_MILLISECONDS(16) {
frame++;
for(int i = 0; i < HardwareConfig::MAX_LED_NUM; i++) {
leds[i] = CRGB(0, 0, 0);
}
for(int idx = 0; idx < 3; idx++) {
uint8_t length = beatsin8(5, 3, HardwareConfig::MAX_LED_NUM, 0, idx * 5);
for(int i = 0; i < length; i++) {
leds[i] += CRGB(scale8(5, beatsin8(5 + i * 7, 0, 255, 0, i*3)), 0, 0);
}
}
FastLED.show();
}
});
#ifdef CONFIG_WIFI
#include "platform/arduino/WiFiTask.h"
#endif // CONFIG_WIFI
#ifdef CONFIG_OTA
#include "platform/arduino/OTA.h"
#endif // CONFIG_OTA
#ifdef CONFIG_MQTT
#include "platform/arduino/MQTTTelemetry.h"
#endif // CONFIG_MQTT
MainLoop
SafeMode::safeModeApp{{
Static<Platform>::instance(),
// System logging
Static<LogService>::instance(),
&safeModeNag,
Static<SerialInput>::instance(),
#ifdef CONFIG_WIFI
// ESP Wifi
Static<WiFiTask>::instance(),
#endif // CONFIG_WIFI
#ifdef CONFIG_MQTT
// MQTT
Static<MQTTTelemetry>::instance(),
#endif // CONFIG_MQTT
#ifdef CONFIG_OTA
// OTA Updates
Static<ArduinoOTAUpdater>::instance(),
#endif // CONFIG_OTA
}};