From eb43be0634b912991bce3ec81f05036741c78dfa Mon Sep 17 00:00:00 2001 From: SQFMI Date: Fri, 14 Oct 2022 22:37:50 -0400 Subject: [PATCH 1/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ccaa9da..b93a192 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ Visit [**https://watchy.sqfmi.com**](https://watchy.sqfmi.com) for documentation 2. Install this library (search for **Watchy** in the library manager), and any other dependencies when prompted 3. Check out the examples under ```Examples``` -> ```Watchy``` 4. Compile & Upload with these board settings: - * Board: "ESP32 Dev Module" + * Board: "Watchy" * Partition Scheme: "Huge App" + * Board Revision: Choose your Watchy version * All Other Settings: leave to default You may also have to install the [CP2104 USB to Serial drivers](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers) if the port is not automatically detected. From b0e405e187bf59fbb5ccc9504ad871fb49e713c5 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sun, 16 Oct 2022 00:20:05 +1100 Subject: [PATCH 2/5] Use designated initialisers for watchySettings This [0] allows to skip obsolete fields, and generally not have to rely on field ordering. [0] https://www.cppstories.com/2021/designated-init-cpp20/ Signed-off-by: Olivier Mehani --- examples/WatchFaces/7_SEG/settings.h | 16 ++++++++-------- examples/WatchFaces/Basic/settings.h | 16 ++++++++-------- examples/WatchFaces/DOS/settings.h | 16 ++++++++-------- examples/WatchFaces/MacPaint/settings.h | 16 ++++++++-------- examples/WatchFaces/Pokemon/settings.h | 16 ++++++++-------- examples/WatchFaces/StarryHorizon/settings.h | 16 ++++++++-------- examples/WatchFaces/Tetris/settings.h | 16 ++++++++-------- 7 files changed, 56 insertions(+), 56 deletions(-) diff --git a/examples/WatchFaces/7_SEG/settings.h b/examples/WatchFaces/7_SEG/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/7_SEG/settings.h +++ b/examples/WatchFaces/7_SEG/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/Basic/settings.h b/examples/WatchFaces/Basic/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/Basic/settings.h +++ b/examples/WatchFaces/Basic/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/DOS/settings.h b/examples/WatchFaces/DOS/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/DOS/settings.h +++ b/examples/WatchFaces/DOS/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/MacPaint/settings.h b/examples/WatchFaces/MacPaint/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/MacPaint/settings.h +++ b/examples/WatchFaces/MacPaint/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/Pokemon/settings.h b/examples/WatchFaces/Pokemon/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/Pokemon/settings.h +++ b/examples/WatchFaces/Pokemon/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/StarryHorizon/settings.h b/examples/WatchFaces/StarryHorizon/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/StarryHorizon/settings.h +++ b/examples/WatchFaces/StarryHorizon/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file diff --git a/examples/WatchFaces/Tetris/settings.h b/examples/WatchFaces/Tetris/settings.h index 654a219..53d47e3 100644 --- a/examples/WatchFaces/Tetris/settings.h +++ b/examples/WatchFaces/Tetris/settings.h @@ -13,14 +13,14 @@ #define GMT_OFFSET_SEC 3600 * -5 //New York is UTC -5 EST, -4 EDT watchySettings settings{ - CITY_ID, - OPENWEATHERMAP_APIKEY, - OPENWEATHERMAP_URL, - TEMP_UNIT, - TEMP_LANG, - WEATHER_UPDATE_INTERVAL, - NTP_SERVER, - GMT_OFFSET_SEC + .cityID = CITY_ID, + .weatherAPIKey = OPENWEATHERMAP_APIKEY, + .weatherURL = OPENWEATHERMAP_URL, + .weatherUnit = TEMP_UNIT, + .weatherLang = TEMP_LANG, + .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, + .ntpServer = NTP_SERVER, + .gmtOffset = GMT_OFFSET_SEC, }; #endif \ No newline at end of file From 5f07f2ec63d5b21fb1877f1c069b55509083c1f1 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sun, 16 Oct 2022 00:34:52 +1100 Subject: [PATCH 3/5] Add opion to vibrate every hour (and on reset) Set watchySettings.vibrateOClock to true Signed-off-by: Olivier Mehani --- examples/WatchFaces/7_SEG/settings.h | 1 + src/Watchy.cpp | 11 +++++++++++ src/Watchy.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/examples/WatchFaces/7_SEG/settings.h b/examples/WatchFaces/7_SEG/settings.h index 53d47e3..e4f2669 100644 --- a/examples/WatchFaces/7_SEG/settings.h +++ b/examples/WatchFaces/7_SEG/settings.h @@ -21,6 +21,7 @@ watchySettings settings{ .weatherUpdateInterval = WEATHER_UPDATE_INTERVAL, .ntpServer = NTP_SERVER, .gmtOffset = GMT_OFFSET_SEC, + .vibrateOClock = true, }; #endif \ No newline at end of file diff --git a/src/Watchy.cpp b/src/Watchy.cpp index b95a036..e26479a 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -12,6 +12,7 @@ RTC_DATA_ATTR bool BLE_CONFIGURED; RTC_DATA_ATTR weatherData currentWeather; RTC_DATA_ATTR int weatherIntervalCounter = -1; RTC_DATA_ATTR bool displayFullInit = true; +RTC_DATA_ATTR bool alreadyVibrated = false; void Watchy::init(String datetime) { esp_sleep_wakeup_cause_t wakeup_reason; @@ -30,6 +31,15 @@ void Watchy::init(String datetime) { if (guiState == WATCHFACE_STATE) { RTC.read(currentTime); showWatchFace(true); // partial updates on tick + if (settings.vibrateOClock) { + if (currentTime.Minute == 0 + && !alreadyVibrated) { + vibMotor(75, 4); + alreadyVibrated = true; + } else { + alreadyVibrated = false; + } + } } break; case ESP_SLEEP_WAKEUP_EXT1: // button Press @@ -40,6 +50,7 @@ void Watchy::init(String datetime) { _bmaConfig(); RTC.read(currentTime); showWatchFace(false); // full update on reset + vibMotor(75, 4); break; } deepSleep(); diff --git a/src/Watchy.h b/src/Watchy.h index af6ae29..74140c9 100644 --- a/src/Watchy.h +++ b/src/Watchy.h @@ -35,6 +35,8 @@ typedef struct watchySettings { String ntpServer; int gmtOffset; int dstOffset; + // + bool vibrateOClock; } watchySettings; class Watchy { From cbb4820d85ecab0cbf1f2e7b70ad68feeaea5e4e Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Wed, 26 Oct 2022 23:31:36 +1100 Subject: [PATCH 4/5] fixup! Add opion to vibrate every hour (and on reset) --- src/Watchy.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Watchy.cpp b/src/Watchy.cpp index e26479a..a005180 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -12,7 +12,6 @@ RTC_DATA_ATTR bool BLE_CONFIGURED; RTC_DATA_ATTR weatherData currentWeather; RTC_DATA_ATTR int weatherIntervalCounter = -1; RTC_DATA_ATTR bool displayFullInit = true; -RTC_DATA_ATTR bool alreadyVibrated = false; void Watchy::init(String datetime) { esp_sleep_wakeup_cause_t wakeup_reason; @@ -32,12 +31,9 @@ void Watchy::init(String datetime) { RTC.read(currentTime); showWatchFace(true); // partial updates on tick if (settings.vibrateOClock) { - if (currentTime.Minute == 0 - && !alreadyVibrated) { + if (currentTime.Minute == 0) { + // The RTC wakes us up once per minute vibMotor(75, 4); - alreadyVibrated = true; - } else { - alreadyVibrated = false; } } } From dd3797f2d5d30a72a806e5f39f5e57e81678e9d9 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sun, 16 Oct 2022 22:56:42 +1100 Subject: [PATCH 5/5] Exit menu after some inactive time Signed-off-by: Olivier Mehani --- src/Watchy.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Watchy.cpp b/src/Watchy.cpp index a005180..26f022e 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -12,6 +12,7 @@ RTC_DATA_ATTR bool BLE_CONFIGURED; RTC_DATA_ATTR weatherData currentWeather; RTC_DATA_ATTR int weatherIntervalCounter = -1; RTC_DATA_ATTR bool displayFullInit = true; +RTC_DATA_ATTR bool alreadyInMenu = true; void Watchy::init(String datetime) { esp_sleep_wakeup_cause_t wakeup_reason; @@ -27,8 +28,9 @@ 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) { @@ -36,6 +38,16 @@ void Watchy::init(String datetime) { vibMotor(75, 4); } } + 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; } break; case ESP_SLEEP_WAKEUP_EXT1: // button Press @@ -264,6 +276,7 @@ void Watchy::showMenu(byte menuIndex, bool partialRefresh) { display.display(partialRefresh); guiState = MAIN_MENU_STATE; + alreadyInMenu = false; } void Watchy::showFastMenu(byte menuIndex) {