| 958 | } |
| 959 | |
| 960 | void runClockLoop(bool showMenuHint) { |
| 961 | int tmp = 0; |
| 962 | unsigned long hintStartTime = millis(); |
| 963 | bool hintVisible = showMenuHint; |
| 964 | |
| 965 | #if defined(HAS_RTC) |
| 966 | #if defined(HAS_RTC_BM8563) |
| 967 | _rtc.GetBm8563Time(); |
| 968 | #endif |
| 969 | #if defined(HAS_RTC_PCF85063A) |
| 970 | _rtc.GetPcf85063Time(); |
| 971 | #endif |
| 972 | _rtc.GetTime(&_time); |
| 973 | #endif |
| 974 | |
| 975 | // Delay due to SelPress() detected on run |
| 976 | tft.fillScreen(bruceConfig.bgColor); |
| 977 | delay(300); |
| 978 | |
| 979 | for (;;) { |
| 980 | if (millis() - tmp > 1000) { |
| 981 | #if defined(HAS_RTC) |
| 982 | updateTimeStr(_rtc.getTimeStruct()); |
| 983 | #else |
| 984 | updateTimeStr(rtc.getTimeStruct()); |
| 985 | #endif |
| 986 | Serial.print("Current time: "); |
| 987 | Serial.println(timeStr); |
| 988 | tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); |
| 989 | tft.drawRect( |
| 990 | BORDER_PAD_X, |
| 991 | BORDER_PAD_X, |
| 992 | tftWidth - 2 * BORDER_PAD_X, |
| 993 | tftHeight - 2 * BORDER_PAD_X, |
| 994 | bruceConfig.priColor |
| 995 | ); |
| 996 | uint8_t f_size = 4; |
| 997 | for (uint8_t i = 4; i > 0; i--) { |
| 998 | if (i * LW * strlen(timeStr) < (tftWidth - BORDER_PAD_X * 2)) { |
| 999 | f_size = i; |
| 1000 | break; |
| 1001 | } |
| 1002 | } |
| 1003 | tft.setTextSize(f_size); |
| 1004 | tft.drawCentreString(timeStr, tftWidth / 2, tftHeight / 2 - 13, 1); |
| 1005 | |
| 1006 | // "OK to show menu" hint management |
| 1007 | if (hintVisible && (millis() - hintStartTime < 5000)) { |
| 1008 | tft.setTextSize(1); |
| 1009 | tft.drawCentreString("OK to show menu", tftWidth / 2, tftHeight / 2 + 25, 1); |
| 1010 | } else if (hintVisible && (millis() - hintStartTime >= 5000)) { |
| 1011 | // Clear hint after 5 seconds |
| 1012 | tft.fillRect( |
| 1013 | BORDER_PAD_X + 1, |
| 1014 | tftHeight / 2 + 20, |
| 1015 | tftWidth - 2 * BORDER_PAD_X - 2, |
| 1016 | 20, |
| 1017 | bruceConfig.bgColor |
no test coverage detected