Just one update on render for everything.

pull/264/head
Elías A. Angulo Klein 2024-07-05 19:21:51 +02:00
parent 9c0b7e6b45
commit 2b1679446c
1 changed files with 27 additions and 23 deletions

View File

@ -57,7 +57,7 @@ void Watchy::init(String datetime) {
// Return to watchface if in menu for more than one tick // Return to watchface if in menu for more than one tick
if (alreadyInMenu) { if (alreadyInMenu) {
guiState = WATCHFACE_STATE; guiState = WATCHFACE_STATE;
showWatchFace(false); showWatchFace(true);
} else { } else {
alreadyInMenu = true; alreadyInMenu = true;
} }
@ -118,7 +118,7 @@ void Watchy::handleButtonPress() {
if (wakeupBit & MENU_BTN_MASK) { if (wakeupBit & MENU_BTN_MASK) {
if (guiState == if (guiState ==
WATCHFACE_STATE) { // enter menu state if coming from watch face WATCHFACE_STATE) { // enter menu state if coming from watch face
showMenu(menuIndex, false); showMenu(menuIndex, true);
} else if (guiState == } else if (guiState ==
MAIN_MENU_STATE) { // if already in menu, then select menu item MAIN_MENU_STATE) { // if already in menu, then select menu item
switch (menuIndex) { switch (menuIndex) {
@ -154,11 +154,11 @@ void Watchy::handleButtonPress() {
else if (wakeupBit & BACK_BTN_MASK) { else if (wakeupBit & BACK_BTN_MASK) {
if (guiState == MAIN_MENU_STATE) { // exit to watch face if already in menu if (guiState == MAIN_MENU_STATE) { // exit to watch face if already in menu
RTC.read(currentTime); RTC.read(currentTime);
showWatchFace(false); showWatchFace(true);
} else if (guiState == APP_STATE) { } else if (guiState == APP_STATE) {
showMenu(menuIndex, false); // exit to menu if already in app showMenu(menuIndex, true); // exit to menu if already in app
} else if (guiState == FW_UPDATE_STATE) { } else if (guiState == FW_UPDATE_STATE) {
showMenu(menuIndex, false); // exit to menu if already in app showMenu(menuIndex, true); // exit to menu if already in app
} else if (guiState == WATCHFACE_STATE) { } else if (guiState == WATCHFACE_STATE) {
return; return;
} }
@ -236,12 +236,12 @@ void Watchy::handleButtonPress() {
if (guiState == if (guiState ==
MAIN_MENU_STATE) { // exit to watch face if already in menu MAIN_MENU_STATE) { // exit to watch face if already in menu
RTC.read(currentTime); RTC.read(currentTime);
showWatchFace(false); showWatchFace(true);
break; // leave loop break; // leave loop
} else if (guiState == APP_STATE) { } else if (guiState == APP_STATE) {
showMenu(menuIndex, false); // exit to menu if already in app showMenu(menuIndex, true); // exit to menu if already in app
} else if (guiState == FW_UPDATE_STATE) { } else if (guiState == FW_UPDATE_STATE) {
showMenu(menuIndex, false); // exit to menu if already in app showMenu(menuIndex, true); // exit to menu if already in app
} }
} else if (digitalRead(UP_BTN_PIN) == ACTIVE_LOW) { } else if (digitalRead(UP_BTN_PIN) == ACTIVE_LOW) {
lastTimeout = millis(); lastTimeout = millis();
@ -375,7 +375,7 @@ void Watchy::showAbout() {
}else{ }else{
display.println("WiFi Not Connected"); display.println("WiFi Not Connected");
} }
display.display(false); // full refresh display.display(true); // full refresh
guiState = APP_STATE; guiState = APP_STATE;
} }
@ -387,9 +387,9 @@ void Watchy::showBuzz() {
display.setTextColor(GxEPD_WHITE); display.setTextColor(GxEPD_WHITE);
display.setCursor(70, 80); display.setCursor(70, 80);
display.println("Buzz!"); display.println("Buzz!");
display.display(false); // full refresh display.display(true); // full refresh
vibMotor(); vibMotor();
showMenu(menuIndex, false); showMenu(menuIndex, true);
} }
void Watchy::vibMotor(uint8_t intervalMs, uint8_t length) { void Watchy::vibMotor(uint8_t intervalMs, uint8_t length) {
@ -567,7 +567,7 @@ void Watchy::setTime() {
RTC.set(tm); RTC.set(tm);
showMenu(menuIndex, false); showMenu(menuIndex, true);
} }
void Watchy::showAccelerometer() { void Watchy::showAccelerometer() {
@ -639,7 +639,7 @@ void Watchy::showAccelerometer() {
} }
} }
showMenu(menuIndex, false); showMenu(menuIndex, true);
} }
void Watchy::showWatchFace(bool partialRefresh) { void Watchy::showWatchFace(bool partialRefresh) {
@ -910,7 +910,7 @@ void Watchy::setupWifi() {
lastIPAddress = WiFi.localIP(); lastIPAddress = WiFi.localIP();
WiFi.SSID().toCharArray(lastSSID, 30); WiFi.SSID().toCharArray(lastSSID, 30);
} }
display.display(false); // full refresh display.display(true); // full refresh
// turn off radios // turn off radios
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
btStop(); btStop();
@ -932,7 +932,7 @@ void Watchy::_configModeCallback(WiFiManager *myWiFiManager) {
display.println(WiFi.softAPIP()); display.println(WiFi.softAPIP());
display.println("MAC address:"); display.println("MAC address:");
display.println(WiFi.softAPmacAddress().c_str()); display.println(WiFi.softAPmacAddress().c_str());
display.display(false); // full refresh display.display(true); // full refresh
} }
bool Watchy::connectWiFi() { bool Watchy::connectWiFi() {
@ -971,7 +971,7 @@ void Watchy::showUpdateFW() {
display.println("again when ready"); display.println("again when ready");
display.println(" "); display.println(" ");
display.println("Keep USB powered"); display.println("Keep USB powered");
display.display(false); // full refresh display.display(true); // full refresh
guiState = FW_UPDATE_STATE; guiState = FW_UPDATE_STATE;
} }
@ -988,7 +988,7 @@ void Watchy::updateFWBegin() {
display.println(" "); display.println(" ");
display.println("Waiting for"); display.println("Waiting for");
display.println("connection..."); display.println("connection...");
display.display(false); // full refresh display.display(true); // full refresh
BLE BT; BLE BT;
BT.begin("Watchy BLE OTA"); BT.begin("Watchy BLE OTA");
@ -1008,7 +1008,7 @@ void Watchy::updateFWBegin() {
display.println(" "); display.println(" ");
display.println("Waiting for"); display.println("Waiting for");
display.println("upload..."); display.println("upload...");
display.display(false); // full refresh display.display(true); // full refresh
} }
if (currentStatus == 1) { if (currentStatus == 1) {
display.setFullWindow(); display.setFullWindow();
@ -1033,7 +1033,7 @@ void Watchy::updateFWBegin() {
display.println("completed!"); display.println("completed!");
display.println(" "); display.println(" ");
display.println("Rebooting..."); display.println("Rebooting...");
display.display(false); // full refresh display.display(true); // full refresh
delay(2000); delay(2000);
esp_restart(); esp_restart();
@ -1047,19 +1047,23 @@ void Watchy::updateFWBegin() {
display.println("BLE Disconnected!"); display.println("BLE Disconnected!");
display.println(" "); display.println(" ");
display.println("exiting..."); display.println("exiting...");
display.display(false); // full refresh display.display(true); // full refresh
delay(1000); delay(1000);
break; break;
} }
prevStatus = currentStatus; prevStatus = currentStatus;
} }
if(digitalRead(BACK_BTN_PIN) == ACTIVE_LOW) break;
delay(100); delay(100);
} }
// turn off radios // turn off radios
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
btStop(); btStop();
showMenu(menuIndex, false); showMenu(menuIndex, true);
} }
void Watchy::showSyncNTP() { void Watchy::showSyncNTP() {
@ -1071,7 +1075,7 @@ void Watchy::showSyncNTP() {
display.println("Syncing NTP... "); display.println("Syncing NTP... ");
display.print("GMT offset: "); display.print("GMT offset: ");
display.println(gmtOffset); display.println(gmtOffset);
display.display(false); // full refresh display.display(true); // full refresh
if (connectWiFi()) { if (connectWiFi()) {
if (syncNTP()) { if (syncNTP()) {
display.println("NTP Sync Success\n"); display.println("NTP Sync Success\n");
@ -1103,7 +1107,7 @@ void Watchy::showSyncNTP() {
} }
display.display(true); // full refresh display.display(true); // full refresh
delay(3000); delay(3000);
showMenu(menuIndex, false); showMenu(menuIndex, true);
} }
bool Watchy::syncNTP() { // NTP sync - call after connecting to WiFi and bool Watchy::syncNTP() { // NTP sync - call after connecting to WiFi and