@@ -76,28 +76,26 @@ void Cmd_Action(const uint16_t mod) {
7676 System_IndicateError ();
7777 return ;
7878 }
79+
80+ gPlayProperties .sleepAfterPlaylist = false ;
81+ gPlayProperties .playUntilTrackNumber = 0 ;
82+
7983 if (gPlayProperties .sleepAfterCurrentTrack ) {
84+ gPlayProperties .sleepAfterCurrentTrack = false ;
8085 Log_Println ((char *) FPSTR (modificatorSleepAtEOTd), LOGLEVEL_NOTICE);
8186 #ifdef MQTT_ENABLE
8287 publishMqtt ((char *) FPSTR (topicSleepTimerState), " 0" , false );
8388 #endif
84- #ifdef NEOPIXEL_ENABLE
85- Led_ResetToInitialBrightness ();
86- #endif
89+ Led_ResetToInitialBrightness ();
8790 } else {
91+ System_DisableSleepTimer ();
92+ gPlayProperties .sleepAfterCurrentTrack = true ;
8893 Log_Println ((char *) FPSTR (modificatorSleepAtEOT), LOGLEVEL_NOTICE);
8994 #ifdef MQTT_ENABLE
9095 publishMqtt ((char *) FPSTR (topicSleepTimerState), " EOT" , false );
9196 #endif
92- #ifdef NEOPIXEL_ENABLE
93- Led_ResetToNightBrightness ();
94- Log_Println ((char *) FPSTR (ledsDimmedToNightmode), LOGLEVEL_INFO);
95- #endif
97+ Led_ResetToNightBrightness ();
9698 }
97- gPlayProperties .sleepAfterCurrentTrack = !gPlayProperties .sleepAfterCurrentTrack ;
98- gPlayProperties .sleepAfterPlaylist = false ;
99- System_DisableSleepTimer ();
100- gPlayProperties .playUntilTrackNumber = 0 ;
10199
102100 #ifdef MQTT_ENABLE
103101 publishMqtt ((char *) FPSTR (topicLedBrightnessState), Led_GetBrightness (), false );
@@ -112,28 +110,24 @@ void Cmd_Action(const uint16_t mod) {
112110 System_IndicateError ();
113111 return ;
114112 }
115- if (gPlayProperties .sleepAfterCurrentTrack ) {
113+ if (gPlayProperties .sleepAfterPlaylist ) {
114+ System_DisableSleepTimer ();
115+ gPlayProperties .sleepAfterPlaylist = false ;
116116 #ifdef MQTT_ENABLE
117117 publishMqtt ((char *) FPSTR (topicSleepTimerState), " 0" , false );
118118 #endif
119- #ifdef NEOPIXEL_ENABLE
120- Led_ResetToInitialBrightness ();
121- #endif
119+ Led_ResetToInitialBrightness ();
122120 Log_Println ((char *) FPSTR (modificatorSleepAtEOPd), LOGLEVEL_NOTICE);
123121 } else {
124- #ifdef NEOPIXEL_ENABLE
125- Led_ResetToNightBrightness ();
126- Log_Println ((char *) FPSTR (ledsDimmedToNightmode), LOGLEVEL_INFO);
127- #endif
128- Log_Println ((char *) FPSTR (modificatorSleepAtEOP), LOGLEVEL_NOTICE);
122+ gPlayProperties .sleepAfterPlaylist = true ;
123+ Led_ResetToNightBrightness ();
124+ Log_Println ((char *) FPSTR (modificatorSleepAtEOP), LOGLEVEL_NOTICE);
129125 #ifdef MQTT_ENABLE
130126 publishMqtt ((char *) FPSTR (topicSleepTimerState), " EOP" , false );
131127 #endif
132128 }
133129
134130 gPlayProperties .sleepAfterCurrentTrack = false ;
135- gPlayProperties .sleepAfterPlaylist = !gPlayProperties .sleepAfterPlaylist ;
136- System_DisableSleepTimer ();
137131 gPlayProperties .playUntilTrackNumber = 0 ;
138132 #ifdef MQTT_ENABLE
139133 publishMqtt ((char *) FPSTR (topicLedBrightnessState), Led_GetBrightness (), false );
@@ -153,16 +147,16 @@ void Cmd_Action(const uint16_t mod) {
153147 gPlayProperties .sleepAfterPlaylist = false ;
154148 System_DisableSleepTimer ();
155149
156- if (gPlayProperties .playUntilTrackNumber > 0 ) {
150+ if (gPlayProperties .sleepAfter5Tracks ) {
151+ gPlayProperties .sleepAfter5Tracks = false ;
157152 gPlayProperties .playUntilTrackNumber = 0 ;
158153 #ifdef MQTT_ENABLE
159154 publishMqtt ((char *) FPSTR (topicSleepTimerState), " 0" , false );
160155 #endif
161- #ifdef NEOPIXEL_ENABLE
162- Led_ResetToInitialBrightness ();
163- #endif
156+ Led_ResetToInitialBrightness ();
164157 Log_Println ((char *) FPSTR (modificatorSleepd), LOGLEVEL_NOTICE);
165158 } else {
159+ gPlayProperties .sleepAfter5Tracks = true ;
166160 if (gPlayProperties .currentTrackNumber + 5 > gPlayProperties .numberOfTracks ) { // If currentTrack + 5 exceeds number of tracks in playlist, sleep after end of playlist
167161 gPlayProperties .sleepAfterPlaylist = true ;
168162 #ifdef MQTT_ENABLE
@@ -174,9 +168,7 @@ void Cmd_Action(const uint16_t mod) {
174168 publishMqtt ((char *) FPSTR (topicSleepTimerState), " EO5T" , false );
175169 #endif
176170 }
177- #ifdef NEOPIXEL_ENABLE
178- Led_ResetToNightBrightness ();
179- #endif
171+ Led_ResetToNightBrightness ();
180172 Log_Println ((char *) FPSTR (sleepTimerEO5), LOGLEVEL_NOTICE);
181173 }
182174
@@ -230,9 +222,7 @@ void Cmd_Action(const uint16_t mod) {
230222 publishMqtt ((char *) FPSTR (topicLedBrightnessState), Led_GetBrightness (), false );
231223 #endif
232224 Log_Println ((char *) FPSTR (ledsDimmedToNightmode), LOGLEVEL_INFO);
233- #ifdef NEOPIXEL_ENABLE
234- Led_ResetToNightBrightness ();
235- #endif
225+ Led_ResetToNightBrightness ();
236226 System_IndicateOk ();
237227 break ;
238228 }
0 commit comments