From aabb888069a54fe299f068e4171917bd3f6d1c9c Mon Sep 17 00:00:00 2001 From: SQFMI Date: Sun, 13 Jun 2021 21:21:37 -0400 Subject: [PATCH] Add support for ESP RTC --- library.json | 2 +- library.properties | 2 +- src/Watchy.cpp | 28 ++++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/library.json b/library.json index 45c257b..a1ff938 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Watchy", - "version": "1.2.5", + "version": "1.2.6", "description": "Watchy - An Open Source E-Paper Watch by SQFMI", "authors": [ { diff --git a/library.properties b/library.properties index 35dacef..0fa17f6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Watchy -version=1.2.5 +version=1.2.6 author=SQFMI maintainer=SQFMI sentence=Watchy - An Open Source E-Paper Watch by SQFMI diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 779baf6..032df37 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -37,20 +37,39 @@ void Watchy::init(String datetime){ switch (wakeup_reason) { + #ifdef ESP_RTC + case ESP_SLEEP_WAKEUP_TIMER: //ESP Internal RTC + if(guiState == WATCHFACE_STATE){ + RTC.read(currentTime); + currentTime.Minute++; + tmElements_t tm; + tm.Month = currentTime.Month; + tm.Day = currentTime.Day; + tm.Year = currentTime.Year; + tm.Hour = currentTime.Hour; + tm.Minute = currentTime.Minute; + tm.Second = 0; + time_t t = makeTime(tm); + RTC.set(t); + RTC.read(currentTime); + showWatchFace(true); //partial updates on tick + } + break; + #endif case ESP_SLEEP_WAKEUP_EXT0: //RTC Alarm RTC.alarm(ALARM_2); //resets the alarm flag in the RTC if(guiState == WATCHFACE_STATE){ RTC.read(currentTime); showWatchFace(true); //partial updates on tick - }else{ - // } break; case ESP_SLEEP_WAKEUP_EXT1: //button Press handleButtonPress(); break; default: //reset + #ifndef ESP_RTC _rtcConfig(datetime); + #endif _bmaConfig(); showWatchFace(false); //full update on reset break; @@ -59,7 +78,12 @@ void Watchy::init(String datetime){ } void Watchy::deepSleep(){ + #ifndef ESP_RTC esp_sleep_enable_ext0_wakeup(RTC_PIN, 0); //enable deep sleep wake on RTC interrupt + #endif + #ifdef ESP_RTC + esp_sleep_enable_timer_wakeup(60000000); + #endif esp_sleep_enable_ext1_wakeup(BTN_PIN_MASK, ESP_EXT1_WAKEUP_ANY_HIGH); //enable deep sleep wake on button press esp_deep_sleep_start(); }