@@ -261,7 +261,6 @@ void updateButton()
261261 static bool buttonWasPressed;
262262 uint32_t deltaTime;
263263 static Settings originalSettings;
264- static uint32_t pressedTime;
265264
266265 if (trainBtn != NULL )
267266 {
@@ -271,9 +270,7 @@ void updateButton()
271270 // Determine the current button state
272271 if (buttonWasPressed)
273272 {
274- // Update the LEDs
275- deltaTime = millis () - pressedTime;
276- buttonLeds (deltaTime);
273+ deltaTime = millis () - buttonPressedTime;
277274 if (!buttonPressed)
278275 {
279276 // Button just released
@@ -319,8 +316,6 @@ void updateButton()
319316 else
320317 {
321318 // The user has stopped training with the button
322- // Restore the previous settings
323- settings = originalSettings;
324319 if (inTraining)
325320 {
326321 inTraining = false ;
@@ -338,11 +333,14 @@ void updateButton()
338333 if (buttonPressed)
339334 {
340335 // Button just pressed
341- pressedTime = millis ();
336+ buttonPressedTime = millis ();
342337
343338 // Save the previous led state
344339 if (!inTraining)
340+ {
345341 originalSettings = settings;
342+ settings.selectLedUse = LEDS_BUTTON_PRESS;
343+ }
346344 }
347345 }
348346
@@ -1064,14 +1062,16 @@ void updateCylonLEDs()
10641062}
10651063
10661064// Acknowledge the button press
1067- void buttonLeds (uint32_t pressedMilliseconds )
1065+ void buttonLeds ()
10681066{
10691067 const uint32_t blinkTime = 1000 / 4 ; // Blink 4 times per second
10701068 uint8_t on;
10711069 const uint32_t onTime = blinkTime / 2 ;
1070+ uint32_t pressedMilliseconds;
10721071 uint8_t seconds;
10731072
10741073 // Display the number of seconds the button has been pushed
1074+ pressedMilliseconds = millis () - buttonPressedTime;
10751075 seconds = pressedMilliseconds / 1000 ;
10761076 setRSSI ((pressedMilliseconds >= trainButtonFactoryResetTime) ? 15 : seconds);
10771077
@@ -1146,6 +1146,10 @@ void updateLeds()
11461146 radioLeds ();
11471147 break ;
11481148
1149+ case LEDS_BUTTON_PRESS:
1150+ buttonLeds ();
1151+ break ;
1152+
11491153 // Turn off all the LEDs
11501154 case LEDS_ALL_OFF:
11511155 break ;
0 commit comments