Fix formatting / temporarily disable busy callback

This commit is contained in:
Lewis Jackson 2023-05-29 23:03:21 +03:00
parent 99878ffe60
commit e4a7be7bfb
3 changed files with 45 additions and 28 deletions

View file

@ -31,6 +31,8 @@ void WatchFace::HandleButtonPress(uint64_t buttonMask)
m_menu.Redraw(false); m_menu.Redraw(false);
const std::vector<int> buttons = {MENU_BTN_PIN, UP_BTN_PIN, DOWN_BTN_PIN, BACK_BTN_PIN}; const std::vector<int> buttons = {MENU_BTN_PIN, UP_BTN_PIN, DOWN_BTN_PIN, BACK_BTN_PIN};
ClearBusyCallback();
while (m_inMenu) { while (m_inMenu) {
for (int button : buttons) { for (int button : buttons) {
if (digitalRead(button) == HIGH) { if (digitalRead(button) == HIGH) {
@ -57,6 +59,8 @@ void WatchFace::HandleButtonPress(uint64_t buttonMask)
} }
} }
} }
SetBusyCallback();
} }
} }
} }

View file

@ -20,7 +20,7 @@ void Watchy::Init()
m_display.epd2.selectSPI(SPI, SPISettings(20000000, MSBFIRST, SPI_MODE0)); m_display.epd2.selectSPI(SPI, SPISettings(20000000, MSBFIRST, SPI_MODE0));
m_display.init(0, g_displayFullInit, 10, true); m_display.init(0, g_displayFullInit, 10, true);
m_display.epd2.setBusyCallback(DisplayBusyCallback); SetBusyCallback();
Setup(); Setup();
@ -141,3 +141,13 @@ void Watchy::ShowWatchFace(bool partialRefresh)
{ {
DrawWatchFace(partialRefresh); DrawWatchFace(partialRefresh);
} }
void Watchy::ClearBusyCallback()
{
m_display.epd2.setBusyCallback(nullptr);
}
void Watchy::SetBusyCallback()
{
m_display.epd2.setBusyCallback(DisplayBusyCallback);
}

View file

@ -20,13 +20,16 @@ public:
void DisconnectWiFi(); void DisconnectWiFi();
void ShowWatchFace(bool partialRefresh = false); void ShowWatchFace(bool partialRefresh = false);
void ClearBusyCallback();
void SetBusyCallback();
// Called after hardware is setup // Called after hardware is setup
virtual void Setup() = 0; virtual void Setup() = 0;
virtual void HandleButtonPress(uint64_t buttonMask) = 0; virtual void HandleButtonPress(uint64_t buttonMask) = 0;
virtual void DrawWatchFace(bool partialRefresh = false) = 0; virtual void DrawWatchFace(bool partialRefresh = false) = 0;
static void DisplayBusyCallback(const void *);
protected: protected:
static void DisplayBusyCallback(const void *);
static WatchyDisplayBase m_displayBase; static WatchyDisplayBase m_displayBase;
static WatchyDisplay m_display; static WatchyDisplay m_display;