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

@ -30,33 +30,37 @@ void WatchFace::HandleButtonPress(uint64_t buttonMask)
m_inMenu = true;
m_menu.Redraw(false);
const std::vector<int> buttons = {MENU_BTN_PIN, UP_BTN_PIN, DOWN_BTN_PIN, BACK_BTN_PIN};
while (m_inMenu) {
for (int button : buttons) {
if (digitalRead(button) == HIGH) {
switch (button) {
case MENU_BTN_PIN:
m_menu.HandleButtonPress(MENU_BTN_MASK);
break;
case UP_BTN_PIN:
m_menu.HandleButtonPress(UP_BTN_MASK);
break;
case DOWN_BTN_PIN:
m_menu.HandleButtonPress(DOWN_BTN_MASK);
break;
case BACK_BTN_PIN:
m_menu.HandleButtonPress(BACK_BTN_MASK);
break;
}
const std::vector<int> buttons = {MENU_BTN_PIN, UP_BTN_PIN, DOWN_BTN_PIN, BACK_BTN_PIN};
ClearBusyCallback();
while (true) {
if (digitalRead(button) == LOW) {
break;
}
}
}
}
}
while (m_inMenu) {
for (int button : buttons) {
if (digitalRead(button) == HIGH) {
switch (button) {
case MENU_BTN_PIN:
m_menu.HandleButtonPress(MENU_BTN_MASK);
break;
case UP_BTN_PIN:
m_menu.HandleButtonPress(UP_BTN_MASK);
break;
case DOWN_BTN_PIN:
m_menu.HandleButtonPress(DOWN_BTN_MASK);
break;
case BACK_BTN_PIN:
m_menu.HandleButtonPress(BACK_BTN_MASK);
break;
}
while (true) {
if (digitalRead(button) == LOW) {
break;
}
}
}
}
}
SetBusyCallback();
}
}
}

View file

@ -20,7 +20,7 @@ void Watchy::Init()
m_display.epd2.selectSPI(SPI, SPISettings(20000000, MSBFIRST, SPI_MODE0));
m_display.init(0, g_displayFullInit, 10, true);
m_display.epd2.setBusyCallback(DisplayBusyCallback);
SetBusyCallback();
Setup();
@ -141,3 +141,13 @@ void Watchy::ShowWatchFace(bool 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 ShowWatchFace(bool partialRefresh = false);
void ClearBusyCallback();
void SetBusyCallback();
// Called after hardware is setup
virtual void Setup() = 0;
virtual void HandleButtonPress(uint64_t buttonMask) = 0;
virtual void DrawWatchFace(bool partialRefresh = false) = 0;
static void DisplayBusyCallback(const void *);
protected:
static void DisplayBusyCallback(const void *);
static WatchyDisplayBase m_displayBase;
static WatchyDisplay m_display;