Browse Source

showRewind added

master
Torsten Stauder 5 years ago
parent
commit
91ff44b7f6
  1. 8
      README.md
  2. 2
      src/logmessages.h
  3. 31
      src/main.cpp

8
README.md

@ -123,10 +123,10 @@ Indicates different things. Don't forget setting number of LEDs via #define NUM_
### Buttons ### Buttons
Some buttons have different actions if pressed long or short. Minimum duration for long press in ms is defined by intervalToLongPress. Some buttons have different actions if pressed long or short. Minimum duration for long press in ms is defined by intervalToLongPress.
* previous (short): previous track
* previous (long): first track in playlist
* next (short): next track in playlist
* next (long): last track in playlist
* previous (short): previous track / beginning of the first track if pressed while first track is playing
* previous (long): first track of playlist
* next (short): next track of playlist
* next (long): last track of playlist
* pause/play (short/long): pause/play * pause/play (short/long): pause/play
* rotary encoder (turning): vol +/- * rotary encoder (turning): vol +/-
* rotary encoder (press long): switch off (only when on) * rotary encoder (press long): switch off (only when on)

2
src/logmessages.h

@ -45,7 +45,7 @@ static const char endOfPlaylistReached[] PROGMEM = "Ende der Playlist erreicht."
static const char trackStartatPos[] PROGMEM = "Titel wird abgespielt ab Position"; static const char trackStartatPos[] PROGMEM = "Titel wird abgespielt ab Position";
static const char rfidScannerReady[] PROGMEM = "RFID-Tags koennen jetzt gescannt werden..."; static const char rfidScannerReady[] PROGMEM = "RFID-Tags koennen jetzt gescannt werden...";
static const char rfidTagDetected[] PROGMEM = "RFID-Karte erkannt: "; static const char rfidTagDetected[] PROGMEM = "RFID-Karte erkannt: ";
static const char rfidTagReceived[] PROGMEM = "RFID-Karte empfangen: ";
static const char rfidTagReceived[] PROGMEM = "RFID-Karte empfangen";
static const char rfidTagUnknownInNvs[] PROGMEM = "RFID-Karte ist im NVS nicht hinterlegt."; static const char rfidTagUnknownInNvs[] PROGMEM = "RFID-Karte ist im NVS nicht hinterlegt.";
static const char goToSleepDueToIdle[] PROGMEM = "Gehe in Deep Sleep wegen Inaktivität..."; static const char goToSleepDueToIdle[] PROGMEM = "Gehe in Deep Sleep wegen Inaktivität...";
static const char goToSleepDueToTimer[] PROGMEM = "Gehe in Deep Sleep wegen Sleep Timer..."; static const char goToSleepDueToTimer[] PROGMEM = "Gehe in Deep Sleep wegen Sleep Timer...";

31
src/main.cpp

@ -202,6 +202,7 @@ unsigned long const stillOnlineInterval = 60; // Interval 'I'm still alive
bool showLedError = false; bool showLedError = false;
bool showLedOk = false; bool showLedOk = false;
bool showPlaylistProgress = false; bool showPlaylistProgress = false;
bool showRewind = false;
// MQTT-helper // MQTT-helper
PubSubClient MQTTclient(wifiClient); PubSubClient MQTTclient(wifiClient);
@ -1019,6 +1020,7 @@ void playAudio(void *parameter) {
playProperties.currentTrackNumber++; playProperties.currentTrackNumber++;
} else { } else {
loggerNl((char *) FPSTR(repeatTrackDueToPlaymode), LOGLEVEL_INFO); loggerNl((char *) FPSTR(repeatTrackDueToPlaymode), LOGLEVEL_INFO);
showRewind = true;
} }
} }
@ -1113,6 +1115,7 @@ void playAudio(void *parameter) {
nvsRfidWriteWrapper(playProperties.playRfidTag, *(playProperties.playlist + playProperties.currentTrackNumber), 0, playProperties.playMode, playProperties.currentTrackNumber, playProperties.numberOfTracks); nvsRfidWriteWrapper(playProperties.playRfidTag, *(playProperties.playlist + playProperties.currentTrackNumber), 0, playProperties.playMode, playProperties.currentTrackNumber, playProperties.numberOfTracks);
} }
audio.stopSong(); audio.stopSong();
showRewind = true;
audio.connecttoSD(*(playProperties.playlist + playProperties.currentTrackNumber)); audio.connecttoSD(*(playProperties.playlist + playProperties.currentTrackNumber));
loggerNl((char *) FPSTR(trackStart), LOGLEVEL_INFO); loggerNl((char *) FPSTR(trackStart), LOGLEVEL_INFO);
trackCommand = 0; trackCommand = 0;
@ -1417,10 +1420,23 @@ void showLed(void *parameter) {
} }
} }
if (showRewind) {
showRewind = false;
for (uint8_t i=NUM_LEDS-1; i>0; i--) {
leds[i] = CRGB::Black;
FastLED.show();
if (hlastVolume != currentVolume || lastLedBrightness != ledBrightness || showLedError || showLedOk || !buttons[3].currentState) {
break;
} else {
vTaskDelay(portTICK_RATE_MS*30);
}
}
}
if (showPlaylistProgress) { if (showPlaylistProgress) {
showPlaylistProgress = false; showPlaylistProgress = false;
if (playProperties.numberOfTracks > 1 && playProperties.currentTrackNumber < playProperties.numberOfTracks) { if (playProperties.numberOfTracks > 1 && playProperties.currentTrackNumber < playProperties.numberOfTracks) {
uint8_t numLedsToLight = map(playProperties.currentTrackNumber, 0, playProperties.numberOfTracks, 0, NUM_LEDS);
uint8_t numLedsToLight = map(playProperties.currentTrackNumber, 0, playProperties.numberOfTracks-1, 0, NUM_LEDS);
FastLED.clear(); FastLED.clear();
for (uint8_t i=0; i < numLedsToLight; i++) { for (uint8_t i=0; i < numLedsToLight; i++) {
leds[i] = CRGB::Blue; leds[i] = CRGB::Blue;
@ -1436,7 +1452,7 @@ void showLed(void *parameter) {
if (hlastVolume != currentVolume || lastLedBrightness != ledBrightness || showLedError || showLedOk || !buttons[3].currentState) { if (hlastVolume != currentVolume || lastLedBrightness != ledBrightness || showLedError || showLedOk || !buttons[3].currentState) {
break; break;
} else { } else {
vTaskDelay(portTICK_RATE_MS*20);
vTaskDelay(portTICK_RATE_MS*15);
} }
} }
@ -1455,19 +1471,18 @@ void showLed(void *parameter) {
switch (playProperties.playMode) { switch (playProperties.playMode) {
case NO_PLAYLIST: // If no playlist is active (idle) case NO_PLAYLIST: // If no playlist is active (idle)
if (hlastVolume == currentVolume && lastLedBrightness == ledBrightness) { if (hlastVolume == currentVolume && lastLedBrightness == ledBrightness) {
double c = NUM_LEDS * 0.75;
for (uint8_t i=0; i < NUM_LEDS; i++) { for (uint8_t i=0; i < NUM_LEDS; i++) {
FastLED.clear(); FastLED.clear();
if (i == 0) { if (i == 0) {
leds[0] = CRGB::White; leds[0] = CRGB::White;
leds[NUM_LEDS/4] = CRGB::White; leds[NUM_LEDS/4] = CRGB::White;
leds[NUM_LEDS/2] = CRGB::White; leds[NUM_LEDS/2] = CRGB::White;
leds[(int) c] = CRGB::White;
leds[NUM_LEDS/4*3] = CRGB::White;
} else { } else {
leds[i % NUM_LEDS] = CRGB::White; leds[i % NUM_LEDS] = CRGB::White;
leds[(i+NUM_LEDS/4) % NUM_LEDS] = CRGB::White; leds[(i+NUM_LEDS/4) % NUM_LEDS] = CRGB::White;
leds[(i+NUM_LEDS/2) % NUM_LEDS] = CRGB::White; leds[(i+NUM_LEDS/2) % NUM_LEDS] = CRGB::White;
leds[(i+(int) c) % NUM_LEDS] = CRGB::White;
leds[(i+NUM_LEDS/4*3) % NUM_LEDS] = CRGB::White;
} }
FastLED.show(); FastLED.show();
for (uint8_t i=0; i<=50; i++) { for (uint8_t i=0; i<=50; i++) {
@ -1489,12 +1504,12 @@ void showLed(void *parameter) {
leds[0] = CRGB::BlueViolet; leds[0] = CRGB::BlueViolet;
leds[NUM_LEDS/4] = CRGB::BlueViolet; leds[NUM_LEDS/4] = CRGB::BlueViolet;
leds[NUM_LEDS/2] = CRGB::BlueViolet; leds[NUM_LEDS/2] = CRGB::BlueViolet;
leds[NUM_LEDS*3 / NUM_LEDS*4] = CRGB::BlueViolet;
leds[NUM_LEDS/4*3] = CRGB::BlueViolet;
} else { } else {
leds[i % NUM_LEDS] = CRGB::BlueViolet; leds[i % NUM_LEDS] = CRGB::BlueViolet;
leds[(i+NUM_LEDS/4) % NUM_LEDS] = CRGB::BlueViolet; leds[(i+NUM_LEDS/4) % NUM_LEDS] = CRGB::BlueViolet;
leds[(i+NUM_LEDS/2) % NUM_LEDS] = CRGB::BlueViolet; leds[(i+NUM_LEDS/2) % NUM_LEDS] = CRGB::BlueViolet;
leds[(i+NUM_LEDS*3 / NUM_LEDS*4) % NUM_LEDS] = CRGB::BlueViolet;
leds[(i+NUM_LEDS/4*3) % NUM_LEDS] = CRGB::BlueViolet;
} }
FastLED.show(); FastLED.show();
if (playProperties.playMode != BUSY) { if (playProperties.playMode != BUSY) {
@ -1523,7 +1538,7 @@ void showLed(void *parameter) {
if (playProperties.currentRelPos != lastPos || redrawProgress) { if (playProperties.currentRelPos != lastPos || redrawProgress) {
redrawProgress = false; redrawProgress = false;
lastPos = playProperties.currentRelPos; lastPos = playProperties.currentRelPos;
uint8_t numLedsToLight = map(playProperties.currentRelPos, 0, 94, 0, NUM_LEDS);
uint8_t numLedsToLight = map(playProperties.currentRelPos, 0, 98, 0, NUM_LEDS);
FastLED.clear(); FastLED.clear();
for(uint8_t led = 0; led < numLedsToLight; led++) { for(uint8_t led = 0; led < numLedsToLight; led++) {
if (lockControls) { if (lockControls) {

Loading…
Cancel
Save