File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1424,6 +1424,20 @@ int8_t getProfileNumberFromUnit(uint8_t profileUnit)
1424
1424
return (-1 );
1425
1425
}
1426
1426
1427
+ // Returns the number of available profiles
1428
+ // https://stackoverflow.com/questions/8871204/count-number-of-1s-in-binary-representation
1429
+ uint8_t getProfileCount ()
1430
+ {
1431
+ int count = 0 ;
1432
+ uint8_t n = activeProfiles;
1433
+ while (n != 0 )
1434
+ {
1435
+ n = n & (n - 1 );
1436
+ count++;
1437
+ }
1438
+ return (count);
1439
+ }
1440
+
1427
1441
// Record large character blob to file
1428
1442
void recordFile (const char *fileID, char *fileContents, uint32_t fileSize)
1429
1443
{
Original file line number Diff line number Diff line change @@ -1230,9 +1230,9 @@ void constructSetupDisplay(std::vector<setupButton> *buttons)
1230
1230
}
1231
1231
addSetupButton (buttons, " E-Pair" , STATE_ESPNOW_PAIRING_NOT_STARTED);
1232
1232
// If only one active profile do not show any profiles
1233
- if (getProfileNumberFromUnit ( 1 ) >= 0 )
1233
+ if (getProfileCount ( ) > 1 )
1234
1234
{
1235
- for (int x = 0 ; x < MAX_PROFILE_COUNT ; x++)
1235
+ for (int x = 0 ; x < getProfileCount () ; x++)
1236
1236
{
1237
1237
int profile = getProfileNumberFromUnit (x);
1238
1238
if (profile >= 0 )
You can’t perform that action at this time.
0 commit comments