fix: frame switch

This commit is contained in:
liuyihui 2022-01-09 15:47:13 +08:00
parent 5e4ee26588
commit d11420a398

View File

@ -23,43 +23,35 @@ void timeOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
display->setTextAlignment(TEXT_ALIGN_CENTER); display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64, 54, time); display->drawString(64, 54, time);
display->setTextAlignment(TEXT_ALIGN_LEFT);
} }
// frames // frames
int frameCount = 3; int frameCount = 3;
FrameCallback frames[] = { oledWebFrame, oledBilibiliFrame, oledOsFrame }; FrameCallback frames[] = { oledWebFrame, oledBilibiliFrame, oledOsFrame };
static void oledTitle(OLEDDisplay *display, String s) { static void oledTitle(OLEDDisplay *display, String s, int16_t x, int16_t y) {
// Title // Title
display->setFont(Roboto_Mono_13); display->setFont(Roboto_Mono_13);
display->setTextAlignment(TEXT_ALIGN_CENTER); display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64, 0, s); display->drawString(64+x, 0+y, s);
display->setFont(Roboto_Mono_10); display->setFont(Roboto_Mono_10);
display->setTextAlignment(TEXT_ALIGN_LEFT);
} }
void oledWebFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { void oledWebFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title // Title
oledTitle(display, "Fox Home"); oledTitle(display, "Fox Home", x, y);
// Day View // Items
display->drawString(0, 16, "Today");
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120, 16, (String)dayView);
display->setTextAlignment(TEXT_ALIGN_LEFT); display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0+x, 16+y, "Today");
display->drawString(0+x, 30+y, "Last Week");
display->drawString(0+x, 44+y, "Last Month");
// Week View // Values
display->drawString(0, 30, "Last Week");
display->setTextAlignment(TEXT_ALIGN_RIGHT); display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120, 30, (String)weekView); display->drawString(120+x, 16+y, (String)dayView);
display->setTextAlignment(TEXT_ALIGN_LEFT); display->drawString(120+x, 30+y, (String)weekView);
display->drawString(120+x, 44+y, (String)monthView);
// Month View
display->drawString(0, 44, "Last Month");
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120, 44, (String)monthView);
display->setTextAlignment(TEXT_ALIGN_LEFT);
} }
void oledMQTTFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { void oledMQTTFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
@ -68,39 +60,34 @@ void oledMQTTFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, i
void oledBilibiliFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { void oledBilibiliFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title // Title
oledTitle(display, "BiliBili"); oledTitle(display, "BiliBili", x, y);
// Follower // Items
display->drawString(0, 16, "Follower");
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120, 16, (String)follower);
display->setTextAlignment(TEXT_ALIGN_LEFT); display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0+x, 16+y, "Follower");
display->drawString(0+x, 30+y, "View");
display->drawString(0+x, 44+y, "Likes");
// View // Values
display->drawString(0, 30, "View");
display->setTextAlignment(TEXT_ALIGN_RIGHT); display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120, 30, (String)view); display->drawString(120+x, 16+y, (String)follower);
display->setTextAlignment(TEXT_ALIGN_LEFT); display->drawString(120+x, 30+y, (String)view);
display->drawString(120+x, 44+y, (String)likes);
// Likes
display->drawString(0, 44, "Likes");
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(120, 44, (String)likes);
display->setTextAlignment(TEXT_ALIGN_LEFT);
} }
void oledOsFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { void oledOsFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title // Title
oledTitle(display, "INFO BOARD"); oledTitle(display, "INFO BOARD", x, y);
display->setTextAlignment(TEXT_ALIGN_LEFT);
// Version // Version
display->drawFastImage(0, 16, 16, 16, Board_Icon); display->drawFastImage(0+x, 16+y, 16, 16, Board_Icon);
display->drawString(24, 18, ver); display->drawString(24+x, 18+y, ver);
// WiFi // WiFi
if( localIP == "Unconnected") if( localIP == "Unconnected")
display->drawFastImage(0, 34, 16, 16, Wifi_Unconnected_Icon); display->drawFastImage(0+x, 34+y, 16, 16, Wifi_Unconnected_Icon);
else else
display->drawFastImage(0, 34, 16, 16, Wifi_Connected_Icon); display->drawFastImage(0+x, 34+y, 16, 16, Wifi_Connected_Icon);
display->drawString(24, 36, localIP); display->drawString(24+x, 36+y, localIP);
} }