Browse Source

Neopixel-signaling for boot/sd-not-available added

master
Torsten Stauder 5 years ago
parent
commit
844538ee17
  1. 2
      README.md
  2. 55
      src/main.cpp

2
README.md

@ -139,6 +139,8 @@ There are special RFID-tags, that don't start music by themself but can modify t
### Neopixel-ring (optional)
Indicates different things. Don't forget setting number of LEDs via #define NUM_LEDS
* While booting: 1/2 LEDs rotating orange
* Unable to mount SD: LEDs flashing red (will remain forever unless SD-card is not available)
* IDLE: four LEDs slow rotating
* ERROR: all LEDs flashing red (1x)
* OK: all LEDs flashing green (1x)

55
src/main.cpp

@ -85,7 +85,7 @@ char logBuf[160]; // Buffer for all log-messag
// Neopixel-configuration
#ifdef NEOPIXEL_ENABLE
#define NUM_LEDS 24 // number of LEDs
#define NUM_LEDS 16 // number of LEDs
#define CHIPSET WS2812B // type of Neopixel
#define COLOR_ORDER GRB
#endif
@ -1523,6 +1523,7 @@ void showLed(void *parameter) {
static bool ledBusyShown = false;
static bool notificationShown = false;
static bool volumeChangeShown = false;
static bool showEvenError = false;
static uint8_t ledPosWebstream = 0;
static uint8_t ledSwitchInterval = 5; // time in secs (webstream-only)
static uint8_t webstreamColor = 0;
@ -1535,13 +1536,34 @@ void showLed(void *parameter) {
FastLED.setBrightness(ledBrightness);
for (;;) {
if (!bootComplete) {
if (!bootComplete) { // Rotates red unless boot isn't complete
FastLED.clear();
for (uint8_t led = 0; led < NUM_LEDS; led++) {
if (showEvenError) {
if (led % 2 == 0) {
if (millis() <= 10000) {
leds[led] = CRGB::Orange;
} else {
leds[led] = CRGB::Red;
}
}
} else {
if (millis() >= 10000) { // Flashes red after 10s (will remain forever if SD cannot be mounted)
leds[led] = CRGB::Red;
} else {
if (led % 2 == 1) {
leds[led] = CRGB::Orange;
}
}
}
}
FastLED.show();
vTaskDelay(portTICK_RATE_MS*100);
showEvenError = !showEvenError;
vTaskDelay(portTICK_RATE_MS*500);
esp_task_wdt_reset();
continue;
}
if (lastLedBrightness != ledBrightness) {
FastLED.setBrightness(ledBrightness);
lastLedBrightness = ledBrightness;
@ -2905,6 +2927,18 @@ void setup() {
prefsRfid.putString("228064156042", "#0#0#110#0"); // modification-card (repeat playlist)
prefsRfid.putString("212130160042", "#/mp3/Hoerspiele/Yakari/Sammlung2#0#3#0");*/
#ifdef NEOPIXEL_ENABLE
xTaskCreatePinnedToCore(
showLed, /* Function to implement the task */
"LED", /* Name of the task */
2000, /* Stack size in words */
NULL, /* Task input parameter */
1 | portPRIVILEGE_BIT, /* Priority of the task */
&LED, /* Task handle. */
0 /* Core where the task should run */
);
#endif
// Init uSD-SPI
pinMode(SPISD_CS, OUTPUT);
digitalWrite(SPISD_CS, HIGH);
@ -3074,17 +3108,7 @@ void setup() {
&mp3Play, /* Task handle. */
1 /* Core where the task should run */
);
#ifdef NEOPIXEL_ENABLE
xTaskCreatePinnedToCore(
showLed, /* Function to implement the task */
"LED", /* Name of the task */
2000, /* Stack size in words */
NULL, /* Task input parameter */
1 | portPRIVILEGE_BIT, /* Priority of the task */
&LED, /* Task handle. */
0 /* Core where the task should run */
);
#endif
esp_sleep_enable_ext0_wakeup((gpio_num_t) DREHENCODER_BUTTON, 0);
@ -3164,6 +3188,9 @@ void loop() {
postHeartbeatViaMqtt();
}
#endif
#ifdef OTA_ENABLE
ArduinoOTA.handle();
#endif
#ifdef FTP_ENABLE
ftpSrv.handleFTP();
#endif

Loading…
Cancel
Save