@@ -243,17 +243,8 @@ void updateDisplay()
243243 case (STATE_BUBBLE_LEVEL):
244244 paintBubbleLevel ();
245245 break ;
246- case (STATE_PROFILE_1):
247- paintProfile (0 );
248- break ;
249- case (STATE_PROFILE_2):
250- paintProfile (1 );
251- break ;
252- case (STATE_PROFILE_3):
253- paintProfile (2 );
254- break ;
255- case (STATE_PROFILE_4):
256- paintProfile (3 );
246+ case (STATE_PROFILE):
247+ paintProfile (displayProfile);
257248 break ;
258249 case (STATE_MARK_EVENT):
259250 // Do nothing. Static display shown during state change.
@@ -1271,7 +1262,7 @@ void paintProfile(uint8_t profileUnit)
12711262 char profileMessage[20 ]; // 'Loading HomeStar' max of ~18 chars
12721263
12731264 char profileName[8 + 1 ];
1274- if (getProfileNameFromUnit (profileUnit, profileName, 8 ) == true ) // Load the profile name, limited to 8 chars
1265+ if (getProfileNameFromUnit (profileUnit, profileName, sizeof (profileName) ) == true ) // Load the profile name, limited to 8 chars
12751266 {
12761267 settings.updateZEDSettings = true ; // When this profile is loaded next, force system to update ZED settings.
12771268 recordSystemSettings (); // Before switching, we need to record the current settings to LittleFS and SD
@@ -1544,6 +1535,54 @@ void getAngles()
15441535 }
15451536}
15461537
1538+ // Display the setup profiles
1539+ void paintDisplaySetupProfile (const char * firstState)
1540+ {
1541+ int index;
1542+ int itemsDisplayed;
1543+ char profileName[8 + 1 ];
1544+
1545+ // Display the first state if this is the first profile
1546+ itemsDisplayed = 0 ;
1547+ if (displayProfile == 0 )
1548+ {
1549+ printTextCenter (firstState, 12 * itemsDisplayed, QW_FONT_8X16, 1 , false );
1550+ itemsDisplayed++;
1551+ }
1552+
1553+ // Display Bubble if this is the second profile
1554+ if (displayProfile <= 1 )
1555+ {
1556+ printTextCenter (" Bubble" , 12 * itemsDisplayed, QW_FONT_8X16, 1 , false );
1557+ itemsDisplayed++;
1558+ }
1559+
1560+ // Display Config if this is the third profile
1561+ if (displayProfile <= 2 )
1562+ {
1563+ printTextCenter (" Config" , 12 * itemsDisplayed, QW_FONT_8X16, 1 , false );
1564+ itemsDisplayed++;
1565+ }
1566+
1567+ // displayProfile itemsDisplayed index
1568+ // 0 3 0
1569+ // 1 2 0
1570+ // 2 1 0
1571+ // 3 0 0
1572+ // 4 0 1
1573+ // 5 0 2
1574+ // n >= 3 0 n - 3
1575+
1576+ // Display the profile names
1577+ for (index = (displayProfile >= 3 ) ? displayProfile - 3 : 0 ; itemsDisplayed < 4 ; itemsDisplayed++)
1578+ {
1579+ // Lookup next available profile, limit to 8 characters
1580+ getProfileNameFromUnit (index, profileName, sizeof (profileName));
1581+ printTextCenter (profileName, 12 * itemsDisplayed, QW_FONT_8X16, 1 , itemsDisplayed == 3 );
1582+ index++;
1583+ }
1584+ }
1585+
15471586// Show different menu 'buttons' to allow user to pause on one to select it
15481587void paintDisplaySetup ()
15491588{
@@ -1584,61 +1623,8 @@ void paintDisplaySetup()
15841623 printTextCenter (" Bubble" , 12 * 2 , QW_FONT_8X16, 1 , false );
15851624 printTextCenter (" Config" , 12 * 3 , QW_FONT_8X16, 1 , true );
15861625 }
1587- else if (setupState == STATE_PROFILE_1)
1588- {
1589- char profileName[8 + 1 ];
1590-
1591- printTextCenter (" Base" , 12 * 0 , QW_FONT_8X16, 1 , false );
1592- printTextCenter (" Bubble" , 12 * 1 , QW_FONT_8X16, 1 , false );
1593- printTextCenter (" Config" , 12 * 2 , QW_FONT_8X16, 1 , false );
1594-
1595- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1596- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1597- }
1598- else if (setupState == STATE_PROFILE_2)
1599- {
1600- char profileName[8 + 1 ];
1601-
1602- printTextCenter (" Bubble" , 12 * 0 , QW_FONT_8X16, 1 , false );
1603- printTextCenter (" Config" , 12 * 1 , QW_FONT_8X16, 1 , false );
1604-
1605- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1606- printTextCenter (profileName, 12 * 2 , QW_FONT_8X16, 1 , false );
1607-
1608- getProfileNameFromUnit (1 , profileName, 8 ); // Lookup second available profile, limit to 8 characters
1609- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1610- }
1611- else if (setupState == STATE_PROFILE_3)
1612- {
1613- char profileName[8 + 1 ];
1614-
1615- printTextCenter (" Config" , 12 * 0 , QW_FONT_8X16, 1 , false );
1616-
1617- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1618- printTextCenter (profileName, 12 * 1 , QW_FONT_8X16, 1 , false );
1619-
1620- getProfileNameFromUnit (1 , profileName, 8 ); // Lookup second available profile, limit to 8 characters
1621- printTextCenter (profileName, 12 * 2 , QW_FONT_8X16, 1 , false );
1622-
1623- getProfileNameFromUnit (2 , profileName, 8 ); // Lookup third available profile, limit to 8 characters
1624- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1625- }
1626- else if (setupState == STATE_PROFILE_4)
1627- {
1628- char profileName[8 + 1 ];
1629-
1630- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1631- printTextCenter (profileName, 12 * 0 , QW_FONT_8X16, 1 , false );
1632-
1633- getProfileNameFromUnit (1 , profileName, 8 ); // Lookup second available profile, limit to 8 characters
1634- printTextCenter (profileName, 12 * 1 , QW_FONT_8X16, 1 , false );
1635-
1636- getProfileNameFromUnit (2 , profileName, 8 ); // Lookup third available profile, limit to 8 characters
1637- printTextCenter (profileName, 12 * 2 , QW_FONT_8X16, 1 , false );
1638-
1639- getProfileNameFromUnit (3 , profileName, 8 ); // Lookup forth available profile, limit to 8 characters
1640- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1641- }
1626+ else if (setupState == STATE_PROFILE)
1627+ paintDisplaySetupProfile (" Base" );
16421628 } // end type F9P
16431629 else if (zedModuleType == PLATFORM_F9R)
16441630 {
@@ -1670,61 +1656,8 @@ void paintDisplaySetup()
16701656 printTextCenter (" Bubble" , 12 * 2 , QW_FONT_8X16, 1 , false );
16711657 printTextCenter (" Config" , 12 * 3 , QW_FONT_8X16, 1 , true );
16721658 }
1673- else if (setupState == STATE_PROFILE_1)
1674- {
1675- char profileName[8 + 1 ];
1676-
1677- printTextCenter (" Rover" , 12 * 0 , QW_FONT_8X16, 1 , false );
1678- printTextCenter (" Bubble" , 12 * 1 , QW_FONT_8X16, 1 , false );
1679- printTextCenter (" Config" , 12 * 2 , QW_FONT_8X16, 1 , false );
1680-
1681- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1682- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1683- }
1684- else if (setupState == STATE_PROFILE_2)
1685- {
1686- char profileName[8 + 1 ];
1687-
1688- printTextCenter (" Bubble" , 12 * 0 , QW_FONT_8X16, 1 , false );
1689- printTextCenter (" Config" , 12 * 1 , QW_FONT_8X16, 1 , false );
1690-
1691- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1692- printTextCenter (profileName, 12 * 2 , QW_FONT_8X16, 1 , false );
1693-
1694- getProfileNameFromUnit (1 , profileName, 8 ); // Lookup second available profile, limit to 8 characters
1695- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1696- }
1697- else if (setupState == STATE_PROFILE_3)
1698- {
1699- char profileName[8 + 1 ];
1700-
1701- printTextCenter (" Config" , 12 * 0 , QW_FONT_8X16, 1 , false );
1702-
1703- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1704- printTextCenter (profileName, 12 * 1 , QW_FONT_8X16, 1 , false );
1705-
1706- getProfileNameFromUnit (1 , profileName, 8 ); // Lookup second available profile, limit to 8 characters
1707- printTextCenter (profileName, 12 * 2 , QW_FONT_8X16, 1 , false );
1708-
1709- getProfileNameFromUnit (2 , profileName, 8 ); // Lookup third available profile, limit to 8 characters
1710- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1711- }
1712- else if (setupState == STATE_PROFILE_4)
1713- {
1714- char profileName[8 + 1 ];
1715-
1716- getProfileNameFromUnit (0 , profileName, 8 ); // Lookup first available profile, limit to 8 characters
1717- printTextCenter (profileName, 12 * 0 , QW_FONT_8X16, 1 , false );
1718-
1719- getProfileNameFromUnit (1 , profileName, 8 ); // Lookup second available profile, limit to 8 characters
1720- printTextCenter (profileName, 12 * 1 , QW_FONT_8X16, 1 , false );
1721-
1722- getProfileNameFromUnit (2 , profileName, 8 ); // Lookup third available profile, limit to 8 characters
1723- printTextCenter (profileName, 12 * 2 , QW_FONT_8X16, 1 , false );
1724-
1725- getProfileNameFromUnit (3 , profileName, 8 ); // Lookup forth available profile, limit to 8 characters
1726- printTextCenter (profileName, 12 * 3 , QW_FONT_8X16, 1 , true );
1727- }
1659+ else if (setupState == STATE_PROFILE)
1660+ paintDisplaySetupProfile (" Rover" );
17281661 } // end type F9R
17291662}
17301663
0 commit comments