INFOBoard/lib/image/image.cpp
2022-01-08 18:32:31 +08:00

76 lines
1.8 KiB
C++

#ifndef __IMAGE__
#include <image.h>
#endif
#include <font.h>
#include <utils.h>
extern String ver;
extern String localIP;
// Overlays are statically drawn on top of a frame
int overlaysCount = 1;
OverlayCallback overlays[] = { msOverlay };
void msOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
String time("");
if( localIP == "Unconnected" ) {
unsigned long mscount = millis();
unsigned long sec = mscount / 1000;
unsigned long mse = mscount / 100 - sec * 10;
time = (String)sec + "." + (String)mse;
}
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64, 50, time);
}
// frames
// int frameCount = 4;
// FrameCallback frames[] = { oled_web_page, oled_mqtt_page, oled_bilibili_page, oled_os_page };
int frameCount = 1;
FrameCallback frames[] = { oled_os_page };
static void oled_title(OLEDDisplay *display) {
// Title
display->setFont(Roboto_Mono_13);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 0, "INFO BOARD");
display->setFont(Roboto_Mono_10);
}
void oled_web_page(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
}
void oled_mqtt_page(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
}
void oled_bilibili_page(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
}
void oled_os_page(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
// Title
oled_title(display);
// Version
display->drawFastImage(0, 16, 16, 16, board_icon);
display->drawString(24, 18, ver);
// WiFi
if( localIP == "Unconnected")
display->drawFastImage(0, 34, 16, 16, wifi_unconnected_icon);
else
display->drawFastImage(0, 34, 16, 16, wifi_connected_icon);
display->drawString(24, 36, localIP);
//
display->display();
}