Created
December 12, 2022 23:26
-
-
Save reefwing/433575f178a032480e5d7e7dc30cc999 to your computer and use it in GitHub Desktop.
Example modifications to the SimpleFramework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t wday = 0; // Sunday | |
uint8_t hh, mm, ss, mmonth, dday; // H, M, S, month & day variables | |
uint16_t yyear; // Year is 16 bit int | |
char const* WEEKDAYS[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; | |
void displayTime(boolean fullUpdate) { | |
int batSOC = ttgo->power->getBattPercentage(); | |
int temp = ttgo->power->getTemp(); | |
ttgo->tft->setTextSize(2); | |
ttgo->tft->setCursor(10, 0); | |
ttgo->tft->setTextColor(TFT_YELLOW, TFT_BLACK); | |
ttgo->tft->print("Reefwing "); | |
ttgo->tft->print(batSOC); ttgo->tft->println(" % "); | |
ttgo->tft->setTextColor(TFT_ORANGE, TFT_BLACK); | |
// Draw Battery Charged Icon | |
ttgo->tft->fillRect(150, 0, 20, 10, TFT_GREEN); | |
ttgo->tft->fillRect(146, 3, 4, 4, TFT_GREEN); | |
int chargeOffset = map(batSOC, 0, 100, 0, 17); | |
ttgo->tft->fillRect(152, 2, 16 - chargeOffset, 6, TFT_BLACK); | |
byte xpos = 40; // Stating position for the display | |
byte ypos = 90; | |
// Get the current data | |
RTC_Date tnow = ttgo->rtc->getDateTime(); | |
hh = tnow.hour; | |
mm = tnow.minute; | |
ss = tnow.second; | |
dday = tnow.day; | |
mmonth = tnow.month; | |
yyear = tnow.year % 100; // % 100 gets last two digits - i.e., converts 2022 to 22 | |
wday = ttgo->rtc->getDayOfWeek(tnow.day, tnow.month, tnow.year); | |
ttgo->tft->setTextSize(1); | |
if (fullUpdate) { | |
// Font 7 is a 7-seg display but only contains | |
// characters [space] 0 1 2 3 4 5 6 7 8 9 0 : . | |
ttgo->tft->setTextColor(0x39C4, TFT_BLACK); // U16 Colour - Grey | |
ttgo->tft->drawString("88:88", xpos, ypos, 7); | |
ttgo->tft->setTextColor(0xFBE0, TFT_BLACK); // Orange | |
if (hh < 10) xpos += ttgo->tft->drawChar('0', xpos, ypos, 7); | |
xpos += ttgo->tft->drawNumber(hh, xpos, ypos, 7); | |
xcolon = xpos + 3; | |
xpos += ttgo->tft->drawChar(':', xcolon, ypos, 7); | |
if (mm < 10) xpos += ttgo->tft->drawChar('0', xpos, ypos, 7); | |
ttgo->tft->drawNumber(mm, xpos, ypos, 7); | |
} | |
if (ss % 2) { // Toggle the colon every second | |
ttgo->tft->setTextColor(0x39C4, TFT_BLACK); | |
xpos += ttgo->tft->drawChar(':', xcolon, ypos, 7); | |
ttgo->tft->setTextColor(0xFBE0, TFT_BLACK); | |
} else { | |
ttgo->tft->drawChar(':', xcolon, ypos, 7); | |
} | |
ttgo->tft->setTextSize(2); | |
ttgo->tft->setTextColor(TFT_YELLOW, TFT_BLACK); | |
ttgo->tft->setCursor(5, 220); | |
ttgo->tft->print(dday); | |
ttgo->tft->print("/"); | |
ttgo->tft->print(mmonth); | |
ttgo->tft->print("/"); | |
ttgo->tft->print(yyear); | |
ttgo->tft->print(" "); | |
ttgo->tft->print(temp); | |
ttgo->tft->print((char)247); | |
ttgo->tft->print("C "); | |
ttgo->tft->print(WEEKDAYS[wday]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment