Moved clear alarm function

pull/116/head^2
SQFMI 2021-12-12 16:43:38 -05:00 committed by GitHub
parent c6483eebe0
commit b794d8ee79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 11 deletions

View File

@ -21,7 +21,6 @@ void Watchy::init(String datetime){
switch (wakeup_reason) switch (wakeup_reason)
{ {
case ESP_SLEEP_WAKEUP_EXT0: //RTC Alarm case ESP_SLEEP_WAKEUP_EXT0: //RTC Alarm
RTC.clearAlarm(); //resets the alarm flag in the RTC
if(guiState == WATCHFACE_STATE){ if(guiState == WATCHFACE_STATE){
RTC.read(currentTime); RTC.read(currentTime);
showWatchFace(true); //partial updates on tick showWatchFace(true); //partial updates on tick
@ -41,13 +40,14 @@ void Watchy::init(String datetime){
} }
void Watchy::deepSleep(){ void Watchy::deepSleep(){
// Set all pins to input to avoid power leaking out RTC.clearAlarm(); //resets the alarm flag in the RTC
for(int i=0; i<48; i++) { // Set pins 0-39 to input to avoid power leaking out
pinMode(i, INPUT); for(int i=0; i<40; i++) {
} pinMode(i, INPUT);
esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt }
esp_sleep_enable_ext1_wakeup(BTN_PIN_MASK, ESP_EXT1_WAKEUP_ANY_HIGH); //enable deep sleep wake on button press esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt
esp_deep_sleep_start(); esp_sleep_enable_ext1_wakeup(BTN_PIN_MASK, ESP_EXT1_WAKEUP_ANY_HIGH); //enable deep sleep wake on button press
esp_deep_sleep_start();
} }
void Watchy::handleButtonPress(){ void Watchy::handleButtonPress(){
@ -87,7 +87,6 @@ void Watchy::handleButtonPress(){
//Back Button //Back Button
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.clearAlarm(); //resets the alarm flag in the RTC
RTC.read(currentTime); RTC.read(currentTime);
showWatchFace(false); showWatchFace(false);
}else if(guiState == APP_STATE){ }else if(guiState == APP_STATE){
@ -166,7 +165,6 @@ void Watchy::handleButtonPress(){
}else if(digitalRead(BACK_BTN_PIN) == 1){ }else if(digitalRead(BACK_BTN_PIN) == 1){
lastTimeout = millis(); lastTimeout = millis();
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.clearAlarm(); //resets the alarm flag in the RTC
RTC.read(currentTime); RTC.read(currentTime);
showWatchFace(false); showWatchFace(false);
break; //leave loop break; //leave loop
@ -910,4 +908,4 @@ void Watchy::updateFWBegin(){
// time_t t = makeTime(tm); // time_t t = makeTime(tm);
// return t + FUDGE; //add fudge factor to allow for compile time // return t + FUDGE; //add fudge factor to allow for compile time
// } // }