You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1006 B
47 lines
1006 B
#define LGFX_AUTODETECT; |
|
#define LGFX_USE_V1 |
|
#include <LovyanGFX.hpp> |
|
|
|
#define UI_WIDTH (320) |
|
#define UI_HEIGHT (240) |
|
|
|
#define STATUS_BAR_HEIGHT (20) |
|
|
|
static LGFX lcd; |
|
static AppState lastAppState; |
|
|
|
void uiDebug(AppState *state) { |
|
|
|
} |
|
|
|
void uiLoop(AppState *state) { |
|
lcd.startWrite(); |
|
|
|
lcd.setTextColor(0x000000U, 0x00FF00); |
|
|
|
bool statusBarDirty = false; |
|
statusBarDirty = state->wifiOnline != lastAppState.wifiOnline; |
|
statusBarDirty = statusBarDirty || (state->volume != lastAppState.volume); |
|
if (statusBarDirty) { |
|
lcd.fillRect(0, 0, UI_WIDTH, STATUS_BAR_HEIGHT, 0x00FF00); |
|
if (state->wifiOnline) { |
|
lcd.drawString(state->wifiIP.toString(), 10, 10); |
|
lcd.drawString(String(state->volume), UI_WIDTH - 20, 10); |
|
} |
|
else { |
|
lcd.drawString("connecting...", 10, 10); |
|
} |
|
} |
|
|
|
lastAppState = *state; |
|
|
|
lcd.endWrite(); |
|
} |
|
|
|
void uiSetup(AppState *state) { |
|
lcd.init(); |
|
lcd.fillScreen(0xFF0000); |
|
lcd.setBrightness(128); |
|
|
|
lastAppState = AppStateMake(); |
|
}
|
|
|