display code sanitization
This commit is contained in:
parent
0af786224f
commit
6bfcf4d367
@ -108,7 +108,6 @@ void dp_message(const char *msg, int line, bool invers);
|
|||||||
void dp_drawPage(bool nextpage);
|
void dp_drawPage(bool nextpage);
|
||||||
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, 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);
|
||||||
|
@ -128,10 +128,10 @@ void dp_init(bool verbose) {
|
|||||||
// display DEVEUI as plain text on the right
|
// display DEVEUI as plain text on the right
|
||||||
const int x_offset = QR_SCALEFACTOR * 29 + 14;
|
const int x_offset = QR_SCALEFACTOR * 29 + 14;
|
||||||
dp_setFont(MY_FONT_NORMAL);
|
dp_setFont(MY_FONT_NORMAL);
|
||||||
dp_setTextCursor(x_offset, 0);
|
dp->setCursor(x_offset, 0);
|
||||||
dp->printf("DEVEUI:\r\n");
|
dp->printf("DEVEUI:\r\n");
|
||||||
for (uint8_t i = 0; i <= 3; i++) {
|
for (uint8_t i = 0; i <= 3; i++) {
|
||||||
dp_setTextCursor(x_offset, i * 8 + 20);
|
dp->setCursor(x_offset, i * 8 + 20);
|
||||||
dp->printf("%4.4s", deveui + i * 4);
|
dp->printf("%4.4s", deveui + i * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,14 +189,11 @@ void dp_drawPage(bool nextpage) {
|
|||||||
time_t now;
|
time_t now;
|
||||||
struct tm timeinfo = {0};
|
struct tm timeinfo = {0};
|
||||||
|
|
||||||
// update counter values from libpax
|
|
||||||
libpax_counter_count(&count);
|
|
||||||
|
|
||||||
if (nextpage) {
|
if (nextpage) {
|
||||||
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
||||||
dp_clear();
|
dp_clear();
|
||||||
} else
|
} else
|
||||||
dp_setTextCursor(0, 0);
|
dp->setCursor(0, 0);
|
||||||
|
|
||||||
switch (DisplayPage) {
|
switch (DisplayPage) {
|
||||||
|
|
||||||
@ -212,11 +209,12 @@ void dp_drawPage(bool nextpage) {
|
|||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
// show pax
|
// show pax
|
||||||
|
libpax_counter_count(&count);
|
||||||
dp_setFont(MY_FONT_LARGE);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
dp->printf("%-8d", count.pax);
|
dp->printf("%-8d", count.pax);
|
||||||
|
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_setTextCursor(0, MY_DISPLAY_FIRSTLINE);
|
dp->setCursor(0, MY_DISPLAY_FIRSTLINE);
|
||||||
|
|
||||||
// line 3: wifi + bluetooth counters
|
// line 3: wifi + bluetooth counters
|
||||||
// WIFI:abcde BLTH:abcde
|
// WIFI:abcde BLTH:abcde
|
||||||
@ -308,11 +306,12 @@ void dp_drawPage(bool nextpage) {
|
|||||||
// 7|SNR:-0000 RSSI:-0000
|
// 7|SNR:-0000 RSSI:-0000
|
||||||
|
|
||||||
// show pax
|
// show pax
|
||||||
|
libpax_counter_count(&count);
|
||||||
dp_setFont(MY_FONT_LARGE);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
dp->printf("%-8d", count.pax);
|
dp->printf("%-8d", count.pax);
|
||||||
|
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_setTextCursor(0, MY_DISPLAY_FIRSTLINE);
|
dp->setCursor(0, MY_DISPLAY_FIRSTLINE);
|
||||||
dp->printf("Net:%06X Pwr:%-2d\r\n", LMIC.netid & 0x001FFFFF,
|
dp->printf("Net:%06X Pwr:%-2d\r\n", LMIC.netid & 0x001FFFFF,
|
||||||
LMIC.radio_txpow);
|
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);
|
||||||
@ -334,18 +333,19 @@ void dp_drawPage(bool nextpage) {
|
|||||||
#if (HAS_GPS)
|
#if (HAS_GPS)
|
||||||
|
|
||||||
// show pax
|
// show pax
|
||||||
|
libpax_counter_count(&count);
|
||||||
dp_setFont(MY_FONT_LARGE);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
dp->printf("%-8d", count.pax);
|
dp->printf("%-8d", count.pax);
|
||||||
|
|
||||||
// show satellite status at bottom line
|
// show satellite status at bottom line
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_setTextCursor(0, 56);
|
dp->setCursor(0, 56);
|
||||||
dp->printf("%u Sats", gps.satellites.value());
|
dp->printf("%u Sats", gps.satellites.value());
|
||||||
dp->printf(gps_hasfix() ? " " : " - No fix");
|
dp->printf(gps_hasfix() ? " " : " - No fix");
|
||||||
|
|
||||||
// show latitude and longitude
|
// show latitude and longitude
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor(0, MY_DISPLAY_FIRSTLINE);
|
dp->setCursor(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',
|
||||||
@ -362,7 +362,7 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
#if (HAS_BME)
|
#if (HAS_BME)
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor(0, 0);
|
dp->setCursor(0, 0);
|
||||||
dp->printf("TMP: %-6.1f\r\n", bme_status.temperature);
|
dp->printf("TMP: %-6.1f\r\n", bme_status.temperature);
|
||||||
dp->printf("HUM: %-6.1f\r\n", bme_status.humidity);
|
dp->printf("HUM: %-6.1f\r\n", bme_status.humidity);
|
||||||
dp->printf("PRE: %-6.1f\r\n", bme_status.pressure);
|
dp->printf("PRE: %-6.1f\r\n", bme_status.pressure);
|
||||||
@ -383,9 +383,9 @@ void dp_drawPage(bool nextpage) {
|
|||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
|
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor(0, 0);
|
dp->setCursor(0, 0);
|
||||||
dp->printf("Timeofday:");
|
dp->printf("Timeofday:");
|
||||||
dp_setTextCursor(0, 26);
|
dp->setCursor(0, 26);
|
||||||
dp_setFont(MY_FONT_LARGE);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
|
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
|
||||||
dp->printf("%.8s\r\n", strftime_buf);
|
dp->printf("%.8s\r\n", strftime_buf);
|
||||||
@ -418,14 +418,6 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
// ------------- display helper functions -----------------
|
// ------------- display helper functions -----------------
|
||||||
|
|
||||||
void dp_setTextCursor(int x, int y) {
|
|
||||||
#if (HAS_DISPLAY) == 1
|
|
||||||
dp->setCursor(x, y);
|
|
||||||
#elif (HAS_DISPLAY) == 2
|
|
||||||
dp->setCursor(x, y);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void dp_setFont(int font, int inv) {
|
void dp_setFont(int font, int inv) {
|
||||||
|
|
||||||
// handle invers printing
|
// handle invers printing
|
||||||
@ -473,7 +465,7 @@ void dp_clear(void) {
|
|||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
dp->fillScreen(MY_DISPLAY_BGCOLOR);
|
dp->fillScreen(MY_DISPLAY_BGCOLOR);
|
||||||
#endif
|
#endif
|
||||||
dp_setTextCursor(0, 0);
|
dp->setCursor(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dp_contrast(uint8_t contrast) {
|
void dp_contrast(uint8_t contrast) {
|
||||||
@ -504,7 +496,7 @@ void dp_shutdown(void) {
|
|||||||
// print static message on display
|
// print static message on display
|
||||||
void dp_message(const char *msg, int line, bool invers) {
|
void dp_message(const char *msg, int line, bool invers) {
|
||||||
dp_setFont(MY_FONT_SMALL, invers ? 1 : 0);
|
dp_setFont(MY_FONT_SMALL, invers ? 1 : 0);
|
||||||
dp_setTextCursor(0, line * 8);
|
dp->setCursor(0, line * 8);
|
||||||
dp->printf("%-16s", msg);
|
dp->printf("%-16s", msg);
|
||||||
dp_dump();
|
dp_dump();
|
||||||
} // dp_message
|
} // dp_message
|
||||||
|
@ -185,7 +185,7 @@ void setup() {
|
|||||||
|
|
||||||
// initialize display
|
// initialize display
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
strcat_P(features, " OLED");
|
strcat_P(features, " DISP");
|
||||||
DisplayIsOn = cfg.screenon;
|
DisplayIsOn = cfg.screenon;
|
||||||
// display verbose info only after a coldstart (note: blocking call!)
|
// display verbose info only after a coldstart (note: blocking call!)
|
||||||
dp_init(RTC_runmode == RUNMODE_POWERCYCLE ? true : false);
|
dp_init(RTC_runmode == RUNMODE_POWERCYCLE ? true : false);
|
||||||
@ -213,7 +213,7 @@ void setup() {
|
|||||||
|
|
||||||
#ifdef HAS_TWO_LED
|
#ifdef HAS_TWO_LED
|
||||||
pinMode(HAS_TWO_LED, OUTPUT);
|
pinMode(HAS_TWO_LED, OUTPUT);
|
||||||
strcat_P(features, " LED1");
|
strcat_P(features, " LED2");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// use LED for power display if we have additional RGB LED, else for status
|
// use LED for power display if we have additional RGB LED, else for status
|
||||||
|
@ -325,7 +325,7 @@ retry:
|
|||||||
void ota_display(const uint8_t row, const std::string status,
|
void ota_display(const uint8_t row, const std::string status,
|
||||||
const std::string msg) {
|
const std::string msg) {
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
dp_setTextCursor(14 * 8, row * 8);
|
dp->setCursor(14 * 8, row * 8);
|
||||||
dp->printf(status.substr(0, 2).c_str());
|
dp->printf(status.substr(0, 2).c_str());
|
||||||
if (!msg.empty()) {
|
if (!msg.empty()) {
|
||||||
dp->printf(" ");
|
dp->printf(" ");
|
||||||
|
Loading…
Reference in New Issue
Block a user