sanitize display logic code
This commit is contained in:
parent
c78250b8d3
commit
09cc2f57b1
@ -107,7 +107,7 @@ void dp_drawPage(bool nextpage);
|
|||||||
void dp_printf(const char *format, ...);
|
void dp_printf(const char *format, ...);
|
||||||
void dp_setFont(int font, int inv = 0);
|
void dp_setFont(int font, int inv = 0);
|
||||||
void dp_dump(uint8_t *pBuffer = NULL);
|
void dp_dump(uint8_t *pBuffer = NULL);
|
||||||
void dp_setTextCursor(int col = 0, int row = MY_DISPLAY_FIRSTLINE);
|
void dp_setTextCursor(int col, int row);
|
||||||
void dp_contrast(uint8_t contrast);
|
void dp_contrast(uint8_t contrast);
|
||||||
void dp_clear(void);
|
void dp_clear(void);
|
||||||
void dp_power(uint8_t screenon);
|
void dp_power(uint8_t screenon);
|
||||||
|
@ -100,7 +100,8 @@ void dp_init(bool verbose) {
|
|||||||
dp_printf("Software v%s\r\n", PROGVERSION);
|
dp_printf("Software v%s\r\n", PROGVERSION);
|
||||||
dp_printf("ESP32 %d cores\r\n", chip_info.cores);
|
dp_printf("ESP32 %d cores\r\n", chip_info.cores);
|
||||||
dp_printf("Chip Rev.%d\r\n", chip_info.revision);
|
dp_printf("Chip Rev.%d\r\n", chip_info.revision);
|
||||||
dp_printf("WiFi%s%s\r\n", (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
dp_printf("WiFi%s%s\r\n",
|
||||||
|
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
|
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
|
||||||
dp_printf("%dMB %s Flash", spi_flash_get_chip_size() / (1024 * 1024),
|
dp_printf("%dMB %s Flash", spi_flash_get_chip_size() / (1024 * 1024),
|
||||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "int." : "ext.");
|
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "int." : "ext.");
|
||||||
@ -185,31 +186,29 @@ void dp_drawPage(bool nextpage) {
|
|||||||
time_t now;
|
time_t now;
|
||||||
struct tm timeinfo = {0};
|
struct tm timeinfo = {0};
|
||||||
|
|
||||||
if (nextpage) {
|
|
||||||
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
|
||||||
dp_clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// update counter values from libpax
|
// update counter values from libpax
|
||||||
libpax_counter_count(&count);
|
libpax_counter_count(&count);
|
||||||
|
|
||||||
// cursor home
|
if (nextpage) {
|
||||||
|
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
||||||
|
dp_clear();
|
||||||
|
} else
|
||||||
dp_setTextCursor(0, 0);
|
dp_setTextCursor(0, 0);
|
||||||
|
|
||||||
// line 1/2: pax counter
|
// line 1/2: pax counter
|
||||||
// display number of unique macs total Wifi + BLE
|
// display number of unique macs total Wifi + BLE
|
||||||
if (DisplayPage < 3) {
|
if (DisplayPage <= 2) {
|
||||||
dp_setFont(MY_FONT_LARGE);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
dp_printf("%-8d", count.pax);
|
dp_printf("%-8d", count.pax);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (DisplayPage) {
|
switch (DisplayPage) {
|
||||||
|
|
||||||
// page 0: parameters overview
|
// page 0: pax + parameters overview
|
||||||
// page 1: lorawan parameters
|
// page 1: pax + lorawan parameters
|
||||||
// page 2: GPS
|
// page 2: pax + GPS lat/lon
|
||||||
// page 3: BME280/680
|
// page 3: BME280/680 values
|
||||||
// page 4: time
|
// page 4: timeofday
|
||||||
// page 5: pax graph
|
// page 5: pax graph
|
||||||
// page 6: blank screen
|
// page 6: blank screen
|
||||||
|
|
||||||
@ -217,7 +216,7 @@ void dp_drawPage(bool nextpage) {
|
|||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_setTextCursor();
|
dp_setTextCursor(0, MY_DISPLAY_FIRSTLINE);
|
||||||
|
|
||||||
// line 3: wifi + bluetooth counters
|
// line 3: wifi + bluetooth counters
|
||||||
// WIFI:abcde BLTH:abcde
|
// WIFI:abcde BLTH:abcde
|
||||||
@ -309,8 +308,9 @@ void dp_drawPage(bool nextpage) {
|
|||||||
// 7|SNR:-0000 RSSI:-0000
|
// 7|SNR:-0000 RSSI:-0000
|
||||||
|
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_setTextCursor();
|
dp_setTextCursor(0, MY_DISPLAY_FIRSTLINE);
|
||||||
dp_printf("Net:%06X Pwr:%-2d\r\n", LMIC.netid & 0x001FFFFF, LMIC.radio_txpow);
|
dp_printf("Net:%06X Pwr:%-2d\r\n", LMIC.netid & 0x001FFFFF,
|
||||||
|
LMIC.radio_txpow);
|
||||||
dp_printf("Dev:%08X DR:%1d\r\n", LMIC.devaddr, LMIC.datarate);
|
dp_printf("Dev:%08X DR:%1d\r\n", LMIC.devaddr, LMIC.datarate);
|
||||||
dp_printf("ChMsk:%04X Nonce:%04X\r\n", LMIC.channelMap, LMIC.devNonce);
|
dp_printf("ChMsk:%04X Nonce:%04X\r\n", LMIC.channelMap, LMIC.devNonce);
|
||||||
dp_printf("fUp:%-6d fDn:%-6d\r\n", LMIC.seqnoUp ? LMIC.seqnoUp - 1 : 0,
|
dp_printf("fUp:%-6d fDn:%-6d\r\n", LMIC.seqnoUp ? LMIC.seqnoUp - 1 : 0,
|
||||||
@ -319,8 +319,9 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
dp_dump();
|
dp_dump();
|
||||||
break;
|
break;
|
||||||
#else // flip page if we are unattended
|
#else // skip this page
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
|
break;
|
||||||
#endif // HAS_LORA
|
#endif // HAS_LORA
|
||||||
|
|
||||||
// ---------- page 2: GPS ----------
|
// ---------- page 2: GPS ----------
|
||||||
@ -336,15 +337,16 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
// show latitude and longitude
|
// show latitude and longitude
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor();
|
dp_setTextCursor(0, MY_DISPLAY_FIRSTLINE);
|
||||||
dp_printf("%c%09.6f\r\n", gps.location.rawLat().negative ? 'S' : 'N',
|
dp_printf("%c%09.6f\r\n", gps.location.rawLat().negative ? 'S' : 'N',
|
||||||
gps.location.lat());
|
gps.location.lat());
|
||||||
dp_printf("%c%09.6f", gps.location.rawLng().negative ? 'W' : 'E',
|
dp_printf("%c%09.6f", gps.location.rawLng().negative ? 'W' : 'E',
|
||||||
gps.location.lng());
|
gps.location.lng());
|
||||||
dp_dump();
|
dp_dump();
|
||||||
break;
|
break;
|
||||||
#else // flip page if we are unattended
|
#else // skip this page
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ---------- page 3: BME280/680 ----------
|
// ---------- page 3: BME280/680 ----------
|
||||||
@ -360,9 +362,10 @@ void dp_drawPage(bool nextpage) {
|
|||||||
dp_printf("IAQ: %-6.0f", bme_status.iaq);
|
dp_printf("IAQ: %-6.0f", bme_status.iaq);
|
||||||
#endif
|
#endif
|
||||||
dp_dump();
|
dp_dump();
|
||||||
break; // page 3
|
break;
|
||||||
#else // flip page if we are unattended
|
#else // skip this page
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
|
break;
|
||||||
#endif // HAS_BME
|
#endif // HAS_BME
|
||||||
|
|
||||||
// ---------- page 4: time ----------
|
// ---------- page 4: time ----------
|
||||||
@ -370,13 +373,13 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
|
|
||||||
|
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor(0, 0);
|
dp_setTextCursor(0, 0);
|
||||||
dp_printf("Timeofday:");
|
dp_printf("Timeofday:");
|
||||||
dp_setTextCursor(0, 26);
|
dp_setTextCursor(0, 26);
|
||||||
dp_setFont(MY_FONT_LARGE);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
|
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
|
||||||
dp_printf("%.8s\r\n", strftime_buf);
|
dp_printf("%.8s\r\n", strftime_buf);
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_printf("%21.1f", uptime() / 1000.0);
|
dp_printf("%21.1f", uptime() / 1000.0);
|
||||||
@ -397,8 +400,9 @@ void dp_drawPage(bool nextpage) {
|
|||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
dp_clear();
|
dp_clear();
|
||||||
break;
|
break;
|
||||||
#else // flip page if we are unattended
|
#else // skip this page
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // switch (page)
|
} // switch (page)
|
||||||
|
Loading…
Reference in New Issue
Block a user