mirror of https://github.com/sqfmi/Watchy.git
parent
342eb48a49
commit
2b21e50c2f
|
@ -16,10 +16,19 @@
|
|||
|
||||
#include "Display.h"
|
||||
|
||||
WatchyDisplay::WatchyDisplay(int16_t cs, int16_t dc, int16_t rst, int16_t busy) :
|
||||
GxEPD2_EPD(cs, dc, rst, busy, HIGH, 10000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
|
||||
#include "config.h"
|
||||
void WatchyDisplay::busyCallback(const void *) {
|
||||
gpio_wakeup_enable((gpio_num_t)DISPLAY_BUSY, GPIO_INTR_LOW_LEVEL);
|
||||
esp_sleep_enable_gpio_wakeup();
|
||||
esp_light_sleep_start();
|
||||
}
|
||||
|
||||
WatchyDisplay::WatchyDisplay() :
|
||||
GxEPD2_EPD(DISPLAY_CS, DISPLAY_DC, DISPLAY_RES, DISPLAY_BUSY, HIGH, 10000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
|
||||
{
|
||||
// Watchy default initialization
|
||||
selectSPI(SPI, SPISettings(20000000, MSBFIRST, SPI_MODE0)); // Set SPI to 20Mhz (default is 4Mhz)
|
||||
setBusyCallback(busyCallback);
|
||||
}
|
||||
|
||||
void WatchyDisplay::clearScreen(uint8_t value)
|
||||
|
|
|
@ -34,7 +34,8 @@ class WatchyDisplay : public GxEPD2_EPD
|
|||
static const uint16_t full_refresh_time = 2600; // ms, e.g. 2509602us
|
||||
static const uint16_t partial_refresh_time = 500; // ms, e.g. 457282us
|
||||
// constructor
|
||||
WatchyDisplay(int16_t cs, int16_t dc, int16_t rst, int16_t busy);
|
||||
WatchyDisplay();
|
||||
static void busyCallback(const void *);
|
||||
// methods (virtual)
|
||||
// Support for Bitmaps (Sprites) to Controller Buffer and to Screen
|
||||
void clearScreen(uint8_t value = 0xFF); // init controller memory and screen (default white)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
WatchyRTC Watchy::RTC;
|
||||
GxEPD2_BW<WatchyDisplay, WatchyDisplay::HEIGHT> Watchy::display(
|
||||
WatchyDisplay(DISPLAY_CS, DISPLAY_DC, DISPLAY_RES, DISPLAY_BUSY));
|
||||
WatchyDisplay{});
|
||||
|
||||
RTC_DATA_ATTR int guiState;
|
||||
RTC_DATA_ATTR int menuIndex;
|
||||
|
@ -23,10 +23,8 @@ void Watchy::init(String datetime) {
|
|||
RTC.init();
|
||||
|
||||
// Init the display here for all cases, if unused, it will do nothing
|
||||
display.epd2.selectSPI(SPI, SPISettings(20000000, MSBFIRST, SPI_MODE0)); // Set SPI to 20Mhz (default is 4Mhz)
|
||||
display.init(0, displayFullInit, 10,
|
||||
true); // 10ms by spec, and fast pulldown reset
|
||||
display.epd2.setBusyCallback(displayBusyCallback);
|
||||
|
||||
switch (wakeup_reason) {
|
||||
case ESP_SLEEP_WAKEUP_EXT0: // RTC Alarm
|
||||
|
@ -67,13 +65,6 @@ void Watchy::init(String datetime) {
|
|||
}
|
||||
deepSleep();
|
||||
}
|
||||
|
||||
void Watchy::displayBusyCallback(const void *) {
|
||||
gpio_wakeup_enable((gpio_num_t)DISPLAY_BUSY, GPIO_INTR_LOW_LEVEL);
|
||||
esp_sleep_enable_gpio_wakeup();
|
||||
esp_light_sleep_start();
|
||||
}
|
||||
|
||||
void Watchy::deepSleep() {
|
||||
display.hibernate();
|
||||
if (displayFullInit) // For some reason, seems to be enabled on first boot
|
||||
|
@ -834,8 +825,8 @@ void Watchy::setupWifi() {
|
|||
// turn off radios
|
||||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
display.epd2.setBusyCallback(displayBusyCallback); // enable lightsleep on
|
||||
// busy
|
||||
// enable lightsleep on busy
|
||||
display.epd2.setBusyCallback(WatchyDisplay::busyCallback);
|
||||
guiState = APP_STATE;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
explicit Watchy(const watchySettings &s) : settings(s) {} // constructor
|
||||
void init(String datetime = "");
|
||||
void deepSleep();
|
||||
static void displayBusyCallback(const void *);
|
||||
float getBatteryVoltage();
|
||||
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
|
||||
|
||||
|
|
Loading…
Reference in New Issue