@@ -1767,36 +1767,46 @@ void paintConnectingToNtripCaster()
1767
1767
printTextwithKerning (" Connecting" , textX, textY, textKerning);
1768
1768
}
1769
1769
1770
- // Scroll through IP address. Wipe with spaces both ends.
1770
+ // Shuttle through IP address
1771
1771
void paintIPAddress ()
1772
1772
{
1773
- char ipAddress[32 ];
1774
- snprintf (ipAddress, sizeof (ipAddress), " %d.%d.%d.%d " ,
1773
+ char ipAddress[16 ];
1774
+ snprintf (ipAddress, sizeof (ipAddress), " %d.%d.%d.%d" ,
1775
1775
#ifdef COMPILE_ETHERNET
1776
1776
ETH.localIP ()[0 ], ETH.localIP ()[1 ], ETH.localIP ()[2 ], ETH.localIP ()[3 ]);
1777
1777
#else // COMPILE_ETHERNET
1778
1778
0 , 0 , 0 , 0 );
1779
1779
#endif // COMPILE_ETHERNET
1780
1780
1781
- static uint8_t ipAddressPosition = 0 ;
1782
-
1783
- // Check if IP address is all single digits and can be printed without scrolling
1784
- if (strlen (ipAddress) <= 21 )
1785
- ipAddressPosition = 7 ;
1786
-
1787
- // Print seven characters of IP address
1788
- char printThis[9 ];
1789
- snprintf (printThis, sizeof (printThis), " %c%c%c%c%c%c%c" , ipAddress[ipAddressPosition + 0 ],
1790
- ipAddress[ipAddressPosition + 1 ], ipAddress[ipAddressPosition + 2 ], ipAddress[ipAddressPosition + 3 ],
1791
- ipAddress[ipAddressPosition + 4 ], ipAddress[ipAddressPosition + 5 ], ipAddress[ipAddressPosition + 6 ]);
1792
-
1793
1781
oled->setFont (QW_FONT_5X7); // Set font to smallest
1794
1782
oled->setCursor (0 , 3 );
1795
- oled->print (printThis);
1796
1783
1797
- ipAddressPosition++; // Increment the print position
1798
- if (ipAddress[ipAddressPosition + 7 ] == 0 ) // Wrap
1799
- ipAddressPosition = 0 ;
1784
+ // If we can print the full IP address without shuttling
1785
+ if (strlen (ipAddress) <= 7 )
1786
+ {
1787
+ oled->print (ipAddress);
1788
+ }
1789
+ else
1790
+ {
1791
+ // Print as many characters as we can. Shuttle back and forth to display all.
1792
+ static int startPos = 0 ;
1793
+ char printThis[7 + 1 ];
1794
+ int extras = strlen (ipAddress) - 7 ;
1795
+ int shuttle[(2 * extras) + 2 ]; // Wait for a double state at each end
1796
+ shuttle[0 ] = 0 ;
1797
+ int x;
1798
+ for (x = 0 ; x <= extras; x++)
1799
+ shuttle[x + 1 ] = x;
1800
+ shuttle[extras + 2 ] = extras;
1801
+ x += 2 ;
1802
+ for (int y = extras - 1 ; y > 0 ; y--)
1803
+ shuttle[x++] = y;
1804
+ if (startPos >= (2 * extras) + 2 )
1805
+ startPos = 0 ;
1806
+ snprintf (printThis, sizeof (printThis), &ipAddress[shuttle[startPos]]);
1807
+ startPos++;
1808
+ oled->print (printThis);
1809
+ }
1800
1810
}
1801
1811
1802
1812
void paintMACAddress4digit (uint8_t xPos, uint8_t yPos)
0 commit comments