diff --git a/library.json b/library.json index 1684c8b..7623719 100644 --- a/library.json +++ b/library.json @@ -23,7 +23,11 @@ { "name": "Wire" }, { "name": "WiFi" }, { "name": "ESP32 BLE Arduino" }, - { "name": "espressif32" }, + { "name": "Update" }, + { + "name": "WiFiSelector", + "version": "oatssss/WiFiSelector" + }, { "name": "Rtc_Pcf8563", "version": "https://github.com/orbitalair/Rtc_Pcf8563.git#master" diff --git a/src/BLE.cpp b/src/BLE.cpp index 52c5dec..17f2433 100644 --- a/src/BLE.cpp +++ b/src/BLE.cpp @@ -148,6 +148,7 @@ int BLE::updateStatus(){ return status; } -int BLE::howManyBytes(){ +int BLE::howManyBytes() +{ return bytesReceived; } diff --git a/src/BLE.h b/src/BLE.h index e346711..8275680 100644 --- a/src/BLE.h +++ b/src/BLE.h @@ -1,5 +1,4 @@ -#ifndef _BLE_H_ -#define _BLE_H_ +#pragma once #include "Arduino.h" @@ -12,8 +11,6 @@ #include "config.h" -class BLE; - class BLE { public: @@ -38,5 +35,3 @@ class BLE BLECharacteristic * pOtaCharacteristic = NULL; BLECharacteristic * pWatchFaceNameCharacteristic = NULL; }; - -#endif diff --git a/src/DSEG7_Classic_Bold_53.h b/src/DSEG7_Classic_Bold_53.h index 107aef2..1d3688e 100644 --- a/src/DSEG7_Classic_Bold_53.h +++ b/src/DSEG7_Classic_Bold_53.h @@ -1,3 +1,4 @@ + // Created by http://oleddisplay.squix.ch/ Consider a donation // In case of problems make sure that you are using the font file with the correct version! const uint8_t DSEG7_Classic_Bold_53Bitmaps[] PROGMEM = { @@ -196,4 +197,4 @@ const GFXglyph DSEG7_Classic_Bold_53Glyphs[] PROGMEM = { { 13675, 15, 36, 20, 2, -36 } // '}' }; const GFXfont DSEG7_Classic_Bold_53 PROGMEM = { -(uint8_t *)DSEG7_Classic_Bold_53Bitmaps,(GFXglyph *)DSEG7_Classic_Bold_53Glyphs,0x20, 0x7E, 58}; \ No newline at end of file +(uint8_t *)DSEG7_Classic_Bold_53Bitmaps,(GFXglyph *)DSEG7_Classic_Bold_53Glyphs,0x20, 0x7E, 58}; diff --git a/src/WatchFace.h b/src/WatchFace.h index c61f134..326999f 100644 --- a/src/WatchFace.h +++ b/src/WatchFace.h @@ -2,5 +2,6 @@ class CWatchFace { - + public: + CWatchFace() = default; }; diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 3d4994f..4477ad4 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -48,7 +48,7 @@ void Watchy::init(String datetime) void Watchy::displayBusyCallback(const void*) { - gpio_wakeup_enable((gpio_num_t)DISPLAY_BUSY, GPIO_INTR_LOW_LEVEL); + gpio_wakeup_enable((gpio_num_t)BUSY, GPIO_INTR_LOW_LEVEL); esp_sleep_enable_gpio_wakeup(); esp_light_sleep_start(); } diff --git a/src/WatchyExpanded.cpp b/src/WatchyExpanded.cpp index 20f00bb..73b55f3 100644 --- a/src/WatchyExpanded.cpp +++ b/src/WatchyExpanded.cpp @@ -6,11 +6,17 @@ // Wire #include +// Fonts +#include + +// Watchy +#include "WatchyRTC.h" + CWatchyExpanded::CWatchyExpanded() : m_display(GxEPD2_154_D67(DISPLAY_CS, DISPLAY_DC, DISPLAY_RES, DISPLAY_BUSY)) { } -void CWatchyExpanded::AddWatchFace(Watchy* pFace) +void CWatchyExpanded::AddWatchFace(CWatchFace* pFace) { m_faces.push_back(pFace); } @@ -23,44 +29,45 @@ void CWatchyExpanded::Init() // Init the display here for all cases, if unused, it will do nothing m_display.init(0, true, 10, true); // 10ms by spec, and fast pulldown reset - display.epd2.setBusyCallback(displayBusyCallback); + m_display.epd2.setBusyCallback(DisplayBusyCallback); switch (wakeup_reason) { case ESP_SLEEP_WAKEUP_EXT0: //RTC Alarm - if(guiState == kWatchFace_State){ + if(m_guiState == kWatchFace_State) + { RTC.read(m_currentTime); - showWatchFace(true); //partial updates on tick + UpdateScreen(); //partial updates on tick } break; // case ESP_SLEEP_WAKEUP_EXT1: //button Press // handleButtonPress(); // break; - // default: //reset - // RTC.config(datetime); - // _bmaConfig(); - // RTC.read(currentTime); - // //showWatchFace(false); //full update on reset + default: //reset + //RTC.config(datetime); + //_bmaConfig(); + //RTC.read(currentTime); + //showWatchFace(false); //full update on reset break; } - //deepSleep(); + DeepSleep(); } -void Watchy::DisplayBusyCallback(const void*) +void CWatchyExpanded::DisplayBusyCallback(const void*) { - gpio_wakeup_enable((gpio_num_t)DISPLAY_BUSY, GPIO_INTR_LOW_LEVEL); + gpio_wakeup_enable((gpio_num_t)BUSY, GPIO_INTR_LOW_LEVEL); esp_sleep_enable_gpio_wakeup(); esp_light_sleep_start(); } -void UpdateScreen() +void CWatchyExpanded::UpdateScreen() { m_display.setFullWindow(); //drawWatchFace(); DrawBasicClock(); // Temp m_display.display(true); //partial refresh - guiState = kWatchFace_State; + m_guiState = kWatchFace_State; } void CWatchyExpanded::DrawBasicClock() @@ -90,7 +97,7 @@ void CWatchyExpanded::DrawBasicClock() void CWatchyExpanded::DeepSleep() { - display.hibernate(); + m_display.hibernate(); RTC.clearAlarm(); //resets the alarm flag in the RTC for(int i=0; i<40; i++) // Set pins 0-39 to input to avoid power leaking out diff --git a/src/WatchyExpanded.h b/src/WatchyExpanded.h index d62bb72..a263b73 100644 --- a/src/WatchyExpanded.h +++ b/src/WatchyExpanded.h @@ -9,6 +9,12 @@ // Time #include +// Watchy +#include "config.h" + +// Expanded +#include "WatchFace.h" + // Defs class CWatchFace; @@ -22,7 +28,8 @@ class CWatchyExpanded void Init(); private: - void DisplayBusyCallback(const void*); + static void DisplayBusyCallback(const void*); + void UpdateScreen(); void DeepSleep(); @@ -33,4 +40,5 @@ class CWatchyExpanded GxEPD2_BW m_display; tmElements_t m_currentTime; + std::int8_t m_guiState = kWatchFace_State; }; diff --git a/src/config.h b/src/config.h index 7f3d4f6..06846bf 100644 --- a/src/config.h +++ b/src/config.h @@ -1,14 +1,14 @@ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once //display #define DISPLAY_WIDTH 200 #define DISPLAY_HEIGHT 200 +#define BTN_PIN_MASK MENU_BTN_MASK|BACK_BTN_MASK|UP_BTN_MASK|DOWN_BTN_MASK //wifi #define WIFI_AP_TIMEOUT 60 #define WIFI_AP_SSID "Watchy AP" //menu -constexpr std::int8_t kWatchFace_State -1 +constexpr std::int8_t kWatchFace_State{-1} #define MAIN_MENU_STATE 0 #define APP_STATE 1 #define FW_UPDATE_STATE 2 @@ -31,4 +31,3 @@ constexpr std::int8_t kWatchFace_State -1 #define HARDWARE_VERSION_MINOR 0 //Versioning #define WATCHY_LIB_VER "1.4.0" -#endif