@@ -1308,14 +1308,17 @@ void paintHorizontalAccuracy(displayCoords textCoords)
1308
1308
// Display clock with moving hands
1309
1309
void paintClock (std::vector<iconPropertyBlinking> *iconList, bool blinking)
1310
1310
{
1311
- // Animate icon to show system running
1312
- static uint8_t clockIconDisplayed = CLOCK_ICON_STATES - 1 ;
1313
- clockIconDisplayed++; // Goto next icon
1314
- clockIconDisplayed %= CLOCK_ICON_STATES; // Wrap
1311
+ // Animate icon to show system running. The 2* makes the blink correct
1312
+ static uint8_t clockIconDisplayed = ( 2 * CLOCK_ICON_STATES) - 1 ;
1313
+ clockIconDisplayed++; // Goto next icon
1314
+ clockIconDisplayed %= ( 2 * CLOCK_ICON_STATES) ; // Wrap
1315
1315
1316
1316
iconPropertyBlinking prop;
1317
- prop.icon = ClockIconProperties.iconDisplay [clockIconDisplayed][present.display_type ];
1318
- prop.duty = 0b01010101 ;
1317
+ prop.icon = ClockIconProperties.iconDisplay [clockIconDisplayed / 2 ][present.display_type ];
1318
+ if (blinking)
1319
+ prop.duty = 0b01010101 ;
1320
+ else
1321
+ prop.duty = 0b11111111 ;
1319
1322
iconList->push_back (prop);
1320
1323
1321
1324
displayCoords textCoords;
@@ -2257,19 +2260,29 @@ void paintProfile(uint8_t profileUnit)
2257
2260
if (getProfileNameFromUnit (profileUnit, profileName, sizeof (profileName)) ==
2258
2261
true ) // Load the profile name, limited to 8 chars
2259
2262
{
2260
- settings.updateGNSSSettings = true ; // When this profile is loaded next, force system to update GNSS settings.
2261
- recordSystemSettings (); // Before switching, we need to record the current settings to LittleFS and SD
2263
+ // Lookup profileNumber based on unit.
2264
+ // getProfileNumberFromUnit should not fail (return -1), because we have already called getProfileNameFromUnit.
2265
+ int8_t profileNumber = getProfileNumberFromUnit (profileUnit);
2262
2266
2263
- // Lookup profileNumber based on unit
2264
- uint8_t profileNumber = getProfileNumberFromUnit (profileUnit);
2265
- recordProfileNumber (profileNumber); // Update internal settings with user's choice, mark unit for config update
2267
+ if (profileNumber >= 0 )
2268
+ {
2269
+ settings.updateGNSSSettings = true ; // When this profile is loaded next, force system to update GNSS settings.
2270
+ recordSystemSettings (); // Before switching, we need to record the current settings to LittleFS and SD
2266
2271
2267
- log_d ( " Going to profile number %d from unit %d, name '%s' " , profileNumber, profileUnit, profileName);
2272
+ recordProfileNumber (( uint8_t )profileNumber); // Update internal settings with user's choice, mark unit for config update
2268
2273
2269
- snprintf (profileMessage, sizeof (profileMessage), " Loading %s" , profileName);
2270
- displayMessage (profileMessage, 2000 );
2271
- ESP.restart (); // Profiles require full restart to take effect
2274
+ log_d (" Going to profile number %d from unit %d, name '%s'" , profileNumber, profileUnit, profileName);
2275
+
2276
+ snprintf (profileMessage, sizeof (profileMessage), " Loading %s" , profileName);
2277
+ displayMessage (profileMessage, 2000 );
2278
+ ESP.restart (); // Profiles require full restart to take effect
2279
+ }
2272
2280
}
2281
+
2282
+ log_d (" Cannot go to profileUnit %d. No profile name / number. Restarting..." , profileUnit);
2283
+ snprintf (profileMessage, sizeof (profileMessage), " Invalid profile%d" , profileUnit);
2284
+ displayMessage (profileMessage, 2000 );
2285
+ ESP.restart (); // Something bad happened. Restart...
2273
2286
}
2274
2287
2275
2288
// Display unit self-tests until user presses a button to exit
0 commit comments