Fix formatting / temporarily disable busy callback
This commit is contained in:
parent
99878ffe60
commit
e4a7be7bfb
3 changed files with 45 additions and 28 deletions
|
@ -30,33 +30,37 @@ void WatchFace::HandleButtonPress(uint64_t buttonMask)
|
||||||
m_inMenu = true;
|
m_inMenu = true;
|
||||||
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};
|
||||||
while (m_inMenu) {
|
ClearBusyCallback();
|
||||||
for (int button : buttons) {
|
|
||||||
if (digitalRead(button) == HIGH) {
|
while (m_inMenu) {
|
||||||
switch (button) {
|
for (int button : buttons) {
|
||||||
case MENU_BTN_PIN:
|
if (digitalRead(button) == HIGH) {
|
||||||
m_menu.HandleButtonPress(MENU_BTN_MASK);
|
switch (button) {
|
||||||
break;
|
case MENU_BTN_PIN:
|
||||||
case UP_BTN_PIN:
|
m_menu.HandleButtonPress(MENU_BTN_MASK);
|
||||||
m_menu.HandleButtonPress(UP_BTN_MASK);
|
break;
|
||||||
break;
|
case UP_BTN_PIN:
|
||||||
case DOWN_BTN_PIN:
|
m_menu.HandleButtonPress(UP_BTN_MASK);
|
||||||
m_menu.HandleButtonPress(DOWN_BTN_MASK);
|
break;
|
||||||
break;
|
case DOWN_BTN_PIN:
|
||||||
case BACK_BTN_PIN:
|
m_menu.HandleButtonPress(DOWN_BTN_MASK);
|
||||||
m_menu.HandleButtonPress(BACK_BTN_MASK);
|
break;
|
||||||
break;
|
case BACK_BTN_PIN:
|
||||||
}
|
m_menu.HandleButtonPress(BACK_BTN_MASK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (digitalRead(button) == LOW) {
|
if (digitalRead(button) == LOW) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetBusyCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
@ -140,4 +140,14 @@ void Watchy::DisconnectWiFi()
|
||||||
void Watchy::ShowWatchFace(bool partialRefresh)
|
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);
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue