Skip to content

Commit

Permalink
Exit menu after some inactive time
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Mehani <[email protected]>
  • Loading branch information
shtrom committed Oct 24, 2022
1 parent ac94b73 commit 39070ab
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/Watchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RTC_DATA_ATTR int weatherIntervalCounter = -1;
RTC_DATA_ATTR bool displayFullInit = true;
RTC_DATA_ATTR long gmtOffset = 0;
RTC_DATA_ATTR bool alreadyVibrated = false;
RTC_DATA_ATTR bool alreadyInMenu = true;

void Watchy::init(String datetime) {
esp_sleep_wakeup_cause_t wakeup_reason;
Expand All @@ -29,17 +30,28 @@ void Watchy::init(String datetime) {

switch (wakeup_reason) {
case ESP_SLEEP_WAKEUP_EXT0: // RTC Alarm
if (guiState == WATCHFACE_STATE) {
RTC.read(currentTime);
RTC.read(currentTime);
switch (guiState) {
case WATCHFACE_STATE:
showWatchFace(true); // partial updates on tick
if (settings.vibrateOClock) {
if (currentTime.Minute == 0
&& !alreadyVibrated) {
vibMotor(75, 4);
alreadyVibrated = true;
} else {
alreadyVibrated = false;
}
break;
case MAIN_MENU_STATE:
// Return to watchface if in menu for more than one tick
if (alreadyInMenu) {
guiState = WATCHFACE_STATE;
showWatchFace(false);
} else {
alreadyInMenu = true;
}
break;
}
if (settings.vibrateOClock) {
if (currentTime.Minute == 0
&& !alreadyVibrated) {
vibMotor(75, 4);
alreadyVibrated = true;
} else {
alreadyVibrated = false;
}
}
break;
Expand Down Expand Up @@ -270,6 +282,7 @@ void Watchy::showMenu(byte menuIndex, bool partialRefresh) {
display.display(partialRefresh);

guiState = MAIN_MENU_STATE;
alreadyInMenu = false;
}

void Watchy::showFastMenu(byte menuIndex) {
Expand Down

0 comments on commit 39070ab

Please sign in to comment.