fix screen switching

This commit is contained in:
2020-11-20 17:22:49 +01:00
parent aff85b6d3e
commit f1c3cb33e3
4 changed files with 11 additions and 4 deletions

View File

@ -23,7 +23,8 @@ typedef enum {
} oledScreen_t;
void oledInit(void);
void oledClear();
void oledClearActiveScreen();
void oledClearAllScreens();
void oledPrint(oledScreen_t screen, char msg[]);
void oledPrintf(oledScreen_t screen, const char *format, ...);
void oledSetActiveScreen(oledScreen_t screen);

View File

@ -39,7 +39,7 @@ void my_setup_2() {
logMsg("Application starting");
oledInit();
oledClear();
oledClearAllScreens();
oledSetActiveScreen(OLED_SCREEN0);
oledPrint(OLED_SCREEN0, "App starting");

View File

@ -63,8 +63,8 @@ static void mqttStatusPublisher(void *handle) {
bool res = publish(&mqttClient, StatusTopic, (const uint8_t*)buf, strlen(buf), false);
coloredMsg(LOG_GREEN, false, "mqch, publish returned %d", res);
oledClear();
oledSetActiveScreen(OLED_SCREEN1);
oledClearActiveScreen();
uint8_t *addr = wizGetIPAddress();
oledPrintf(OLED_SCREEN1, "Addr:%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
oledPrintf(OLED_SCREEN1, "Network available:%d", isNetworkAvailable());

View File

@ -406,7 +406,13 @@ static uint8_t currentLine = 0;
static char lines[NUM_OF_SCREENS][MAX_LINES+1][MAX_CHARS+1];
static oledScreen_t activeScreen = OLED_SCREEN0;
void oledClear() {
void oledClearActiveScreen() {
oled_CLS();
memset(lines[activeScreen], 0, sizeof(lines[activeScreen]));
currentLine = 0;
}
void oledClearAllScreens() {
oled_CLS();
memset(lines, 0, sizeof(lines));
currentLine = 0;