oled lib release migration
This commit is contained in:
parent
739fecfc98
commit
e097589267
@ -14,14 +14,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DISPLAY_PAGES (7) // number of paxcounter display pages
|
#define DISPLAY_PAGES (7) // number of paxcounter display pages
|
||||||
|
#define PLOTBUFFERSIZE (MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8)
|
||||||
|
|
||||||
// settings for OLED display library
|
// settings for OLED display library
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
#define MY_FONT_SMALL FONT_SMALL
|
#define MY_FONT_SMALL FONT_6x8
|
||||||
#define MY_FONT_NORMAL FONT_NORMAL
|
#define MY_FONT_NORMAL FONT_8x8
|
||||||
#define MY_FONT_LARGE FONT_LARGE
|
#define MY_FONT_LARGE FONT_16x32
|
||||||
#define MY_FONT_STRETCHED FONT_STRETCHED
|
#define MY_FONT_STRETCHED FONT_12x16
|
||||||
#define USE_BACKBUFFER 1
|
|
||||||
|
#define MY_DISPLAY_FIRSTLINE 30
|
||||||
|
|
||||||
#ifdef MY_DISPLAY_ADDR
|
#ifdef MY_DISPLAY_ADDR
|
||||||
#define OLED_ADDR MY_DISPLAY_ADDR
|
#define OLED_ADDR MY_DISPLAY_ADDR
|
||||||
#else
|
#else
|
||||||
@ -33,6 +36,12 @@
|
|||||||
#ifndef OLED_FREQUENCY
|
#ifndef OLED_FREQUENCY
|
||||||
#define OLED_FREQUENCY 400000L
|
#define OLED_FREQUENCY 400000L
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef MY_DISPLAY_FGCOLOR
|
||||||
|
#define MY_DISPLAY_FGCOLOR OLED_WHITE
|
||||||
|
#endif
|
||||||
|
#ifndef MY_DISPLAY_BGCOLOR
|
||||||
|
#define MY_DISPLAY_BGCOLOR OLED_BLACK
|
||||||
|
#endif
|
||||||
|
|
||||||
// settings for TFT display library
|
// settings for TFT display library
|
||||||
#elif (HAS_DISPLAY == 2)
|
#elif (HAS_DISPLAY == 2)
|
||||||
@ -42,6 +51,8 @@
|
|||||||
#define MY_FONT_LARGE 4
|
#define MY_FONT_LARGE 4
|
||||||
#define MY_FONT_STRETCHED 6
|
#define MY_FONT_STRETCHED 6
|
||||||
|
|
||||||
|
#define MY_DISPLAY_FIRSTLINE 30
|
||||||
|
|
||||||
#ifndef MY_DISPLAY_FGCOLOR
|
#ifndef MY_DISPLAY_FGCOLOR
|
||||||
#define MY_DISPLAY_FGCOLOR TFT_WHITE
|
#define MY_DISPLAY_FGCOLOR TFT_WHITE
|
||||||
#endif
|
#endif
|
||||||
@ -76,7 +87,7 @@
|
|||||||
|
|
||||||
const uint8_t QR_SCALEFACTOR = (MY_DISPLAY_HEIGHT - 4) / 29; // 4px borderlines
|
const uint8_t QR_SCALEFACTOR = (MY_DISPLAY_HEIGHT - 4) / 29; // 4px borderlines
|
||||||
|
|
||||||
extern uint8_t DisplayIsOn, displaybuf[];
|
extern uint8_t DisplayIsOn;
|
||||||
extern hw_timer_t *displayIRQ;
|
extern hw_timer_t *displayIRQ;
|
||||||
extern uint8_t volatile channel; // wifi channel rotation counter
|
extern uint8_t volatile channel; // wifi channel rotation counter
|
||||||
|
|
||||||
@ -86,11 +97,11 @@ void dp_init(bool verbose = false);
|
|||||||
void dp_shutdown(void);
|
void dp_shutdown(void);
|
||||||
void dp_message(const char *msg, int line, bool invers);
|
void dp_message(const char *msg, int line, bool invers);
|
||||||
void dp_drawPage(bool nextpage);
|
void dp_drawPage(bool nextpage);
|
||||||
void dp_println(int lines = 1);
|
void dp_println(void);
|
||||||
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);
|
void dp_dump(uint8_t *pBuffer = NULL);
|
||||||
void dp_setTextCursor(int col, int row);
|
void dp_setTextCursor(int col = 0, int row = MY_DISPLAY_FIRSTLINE);
|
||||||
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);
|
||||||
|
239
src/display.cpp
239
src/display.cpp
@ -8,11 +8,11 @@ Display-Mask (128 x 64 pixel):
|
|||||||
| 11111111112
|
| 11111111112
|
||||||
|012345678901234567890 Font
|
|012345678901234567890 Font
|
||||||
----------------------- ---------
|
----------------------- ---------
|
||||||
0|PAX:aabbccdd STRETCHED
|
0|PAX:aabbccdd LARGE
|
||||||
1|PAX:aabbccdd STRETCHED
|
1|PAX:aabbccdd LARGE
|
||||||
2|
|
2|
|
||||||
3|WIFI:abcde BLTH:abcde SMALL
|
3|WIFI:abcde BLTH:abcde SMALL
|
||||||
4|B:a.bcV Sats:ab ch:ab SMALL
|
4|Batt:abc% chan:ab SMALL
|
||||||
5|RLIM:abcd Mem:abcdKB SMALL
|
5|RLIM:abcd Mem:abcdKB SMALL
|
||||||
6|27.Feb 2019 20:27:00* SMALL
|
6|27.Feb 2019 20:27:00* SMALL
|
||||||
7|yyyyyyyyyyyyy xx SFab SMALL
|
7|yyyyyyyyyyyyy xx SFab SMALL
|
||||||
@ -25,9 +25,10 @@ y = LMIC event message
|
|||||||
xx = payload sendqueue length
|
xx = payload sendqueue length
|
||||||
ab = LMIC spread factor
|
ab = LMIC spread factor
|
||||||
|
|
||||||
MY_FONT_SMALL: 6x8px = 21 chars / line
|
MY_FONT_SMALL: 6x8px = 21 chars / line @ 8 lines
|
||||||
MY_FONT_NORMAL: 8x8px = 16 chars / line
|
MY_FONT_NORMAL: 8x8px = 16 chars / line @ 8 lines
|
||||||
MY_FONT_STRETCHED: 16x32px = 8 chars / line
|
MY_FONT_STRETCHED: 12x16px = 10 chars / line @ 4 lines
|
||||||
|
MY_FONT_LARGE: 16x32px = 8 chars / line @ 2 lines
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -39,18 +40,14 @@ MY_FONT_STRETCHED: 16x32px = 8 chars / line
|
|||||||
// local Tag for logging
|
// local Tag for logging
|
||||||
static const char TAG[] = __FILE__;
|
static const char TAG[] = __FILE__;
|
||||||
|
|
||||||
|
static uint8_t plotbuf[PLOTBUFFERSIZE] = {0};
|
||||||
uint8_t DisplayIsOn = 0;
|
uint8_t DisplayIsOn = 0;
|
||||||
uint8_t displaybuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
|
|
||||||
static uint8_t plotbuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
|
|
||||||
static int dp_row = 0, dp_col = 0, dp_font = 0;
|
|
||||||
|
|
||||||
hw_timer_t *displayIRQ = NULL;
|
hw_timer_t *displayIRQ = NULL;
|
||||||
|
|
||||||
QRCode qrcode;
|
QRCode qrcode;
|
||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
OBDISP ssoled;
|
ONE_BIT_DISPLAY oled;
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT);
|
TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT);
|
||||||
#else
|
#else
|
||||||
@ -62,16 +59,11 @@ void dp_setup(int contrast) {
|
|||||||
|
|
||||||
#if (HAS_DISPLAY) == 1 // I2C OLED
|
#if (HAS_DISPLAY) == 1 // I2C OLED
|
||||||
|
|
||||||
int rc = obdI2CInit(&ssoled, OLED_TYPE, OLED_ADDR, MY_DISPLAY_FLIP,
|
oled.I2Cbegin(OLED_TYPE, OLED_ADDR, OLED_FREQUENCY);
|
||||||
MY_DISPLAY_INVERT, USE_HW_I2C, MY_DISPLAY_SDA,
|
assert(oled.allocBuffer()); // render all outputs to lib internal backbuffer
|
||||||
MY_DISPLAY_SCL, MY_DISPLAY_RST,
|
oled.setTextWrap(false);
|
||||||
OLED_FREQUENCY); // use standard I2C bus at 400Khz
|
oled.setRotation(
|
||||||
//_ASSERT(rc != OLED_NOT_FOUND);
|
MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°
|
||||||
|
|
||||||
// set display buffer
|
|
||||||
obdSetBackBuffer(&ssoled, displaybuf);
|
|
||||||
obdSetTextWrap(&ssoled, true);
|
|
||||||
dp_font = MY_FONT_NORMAL;
|
|
||||||
|
|
||||||
#elif (HAS_DISPLAY) == 2 // SPI TFT
|
#elif (HAS_DISPLAY) == 2 // SPI TFT
|
||||||
|
|
||||||
@ -118,7 +110,7 @@ void dp_init(bool verbose) {
|
|||||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "int." : "ext.");
|
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "int." : "ext.");
|
||||||
|
|
||||||
// give user some time to read or take picture
|
// give user some time to read or take picture
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
dp_clear();
|
dp_clear();
|
||||||
#endif // VERBOSE
|
#endif // VERBOSE
|
||||||
@ -136,17 +128,17 @@ 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_setTextCursor(x_offset, 0);
|
|
||||||
dp_setFont(MY_FONT_NORMAL);
|
dp_setFont(MY_FONT_NORMAL);
|
||||||
dp_printf("DEVEUI");
|
dp_setTextCursor(x_offset, 0);
|
||||||
|
dp_printf("DEVEUI:");
|
||||||
dp_println();
|
dp_println();
|
||||||
for (uint8_t i = 0; i <= 3; i++) {
|
for (uint8_t i = 0; i <= 3; i++) {
|
||||||
dp_setTextCursor(x_offset, i + 3);
|
dp_setTextCursor(x_offset, i * 8 + 20);
|
||||||
dp_printf("%4.4s", deveui + i * 4);
|
dp_printf("%4.4s", deveui + i * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// give user some time to read or take picture
|
// give user some time to read or take picture
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
#if !(BOOTMENU)
|
#if !(BOOTMENU)
|
||||||
delay(8000);
|
delay(8000);
|
||||||
#endif
|
#endif
|
||||||
@ -198,10 +190,6 @@ void dp_drawPage(bool nextpage) {
|
|||||||
time_t now;
|
time_t now;
|
||||||
struct tm timeinfo = {0};
|
struct tm timeinfo = {0};
|
||||||
|
|
||||||
#if (HAS_GPS)
|
|
||||||
static bool wasnofix = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (nextpage) {
|
if (nextpage) {
|
||||||
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
||||||
dp_clear();
|
dp_clear();
|
||||||
@ -215,9 +203,9 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
// 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 < 5) {
|
if (DisplayPage < 3) {
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_LARGE);
|
||||||
dp_printf("%-5d", count.pax);
|
dp_printf("%-8d", count.pax);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (DisplayPage) {
|
switch (DisplayPage) {
|
||||||
@ -233,8 +221,8 @@ void dp_drawPage(bool nextpage) {
|
|||||||
// ---------- page 0: parameters overview ----------
|
// ---------- page 0: parameters overview ----------
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
dp_setTextCursor(0, 3);
|
|
||||||
dp_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
|
dp_setTextCursor();
|
||||||
|
|
||||||
// line 3: wifi + bluetooth counters
|
// line 3: wifi + bluetooth counters
|
||||||
// WIFI:abcde BLTH:abcde
|
// WIFI:abcde BLTH:abcde
|
||||||
@ -268,19 +256,11 @@ void dp_drawPage(bool nextpage) {
|
|||||||
if (batt_level == 0)
|
if (batt_level == 0)
|
||||||
dp_printf("No batt ");
|
dp_printf("No batt ");
|
||||||
else
|
else
|
||||||
dp_printf("B:%3d%% ", batt_level);
|
dp_printf("Batt:%3u%% ", batt_level);
|
||||||
#else
|
#else
|
||||||
dp_printf(" ");
|
dp_printf(" ");
|
||||||
#endif
|
#endif
|
||||||
|
dp_printf("chan:%02u", channel);
|
||||||
#if (HAS_GPS)
|
|
||||||
dp_setFont(MY_FONT_SMALL, !gps_hasfix());
|
|
||||||
dp_printf("Sats:%.2d", gps.satellites.value());
|
|
||||||
dp_setFont(MY_FONT_SMALL);
|
|
||||||
#else
|
|
||||||
dp_printf(" ");
|
|
||||||
#endif
|
|
||||||
dp_printf(" ch:%02d", channel);
|
|
||||||
dp_println();
|
dp_println();
|
||||||
|
|
||||||
// line 5: RSSI limiter + free memory
|
// line 5: RSSI limiter + free memory
|
||||||
@ -322,7 +302,7 @@ void dp_drawPage(bool nextpage) {
|
|||||||
dp_setFont(MY_FONT_SMALL, 0);
|
dp_setFont(MY_FONT_SMALL, 0);
|
||||||
#endif // HAS_LORA
|
#endif // HAS_LORA
|
||||||
|
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ---------- page 1: lorawan parameters ----------
|
// ---------- page 1: lorawan parameters ----------
|
||||||
@ -337,7 +317,7 @@ 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(0, 3);
|
dp_setTextCursor();
|
||||||
dp_printf("Net:%06X Pwr:%-2d", LMIC.netid & 0x001FFFFF, LMIC.radio_txpow);
|
dp_printf("Net:%06X Pwr:%-2d", LMIC.netid & 0x001FFFFF, LMIC.radio_txpow);
|
||||||
dp_println();
|
dp_println();
|
||||||
dp_printf("Dev:%08X DR:%1d", LMIC.devaddr, LMIC.datarate);
|
dp_printf("Dev:%08X DR:%1d", LMIC.devaddr, LMIC.datarate);
|
||||||
@ -349,7 +329,7 @@ void dp_drawPage(bool nextpage) {
|
|||||||
dp_println();
|
dp_println();
|
||||||
dp_printf("SNR:%-5d RSSI:%-5d", (LMIC.snr + 2) / 4, LMIC.rssi);
|
dp_printf("SNR:%-5d RSSI:%-5d", (LMIC.snr + 2) / 4, LMIC.rssi);
|
||||||
|
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
break;
|
break;
|
||||||
#else // flip page if we are unattended
|
#else // flip page if we are unattended
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
@ -359,31 +339,22 @@ void dp_drawPage(bool nextpage) {
|
|||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
#if (HAS_GPS)
|
#if (HAS_GPS)
|
||||||
|
|
||||||
|
// show satellite status at bottom line
|
||||||
|
dp_setFont(MY_FONT_SMALL);
|
||||||
|
dp_setTextCursor(0, 56);
|
||||||
|
dp_printf("%u Sats", gps.satellites.value());
|
||||||
|
dp_printf(gps_hasfix() ? " " : " - No fix");
|
||||||
|
|
||||||
|
// show latitude and longitude
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor(0, 3);
|
dp_setTextCursor();
|
||||||
if (gps_hasfix()) {
|
dp_printf("%c%09.6f", gps.location.rawLat().negative ? 'S' : 'N',
|
||||||
// line 5: clear "No fix"
|
|
||||||
if (wasnofix) {
|
|
||||||
dp_setTextCursor(2, 4);
|
|
||||||
dp_printf(" ");
|
|
||||||
wasnofix = false;
|
|
||||||
}
|
|
||||||
// line 3-4: GPS latitude
|
|
||||||
dp_printf("%c%07.4f", gps.location.rawLat().negative ? 'S' : 'N',
|
|
||||||
gps.location.lat());
|
gps.location.lat());
|
||||||
|
dp_println();
|
||||||
// line 6-7: GPS longitude
|
dp_printf("%c%09.6f", gps.location.rawLng().negative ? 'W' : 'E',
|
||||||
dp_printf("%c%07.4f", gps.location.rawLng().negative ? 'W' : 'E',
|
|
||||||
gps.location.lng());
|
gps.location.lng());
|
||||||
|
dp_dump();
|
||||||
} else {
|
|
||||||
dp_setTextCursor(2, 4);
|
|
||||||
dp_setFont(MY_FONT_STRETCHED, 1);
|
|
||||||
dp_printf("No fix");
|
|
||||||
wasnofix = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dp_dump(displaybuf);
|
|
||||||
break;
|
break;
|
||||||
#else // flip page if we are unattended
|
#else // flip page if we are unattended
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
@ -394,25 +365,17 @@ void dp_drawPage(bool nextpage) {
|
|||||||
|
|
||||||
#if (HAS_BME)
|
#if (HAS_BME)
|
||||||
dp_setFont(MY_FONT_STRETCHED);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
dp_setTextCursor(0, 2);
|
dp_setTextCursor(0, 0);
|
||||||
|
dp_printf("TMP: %-6.1f", bme_status.temperature);
|
||||||
// line 2-3: Temp
|
dp_println();
|
||||||
dp_printf("TMP:%-2.1f", bme_status.temperature);
|
dp_printf("HUM: %-6.1f", bme_status.humidity);
|
||||||
dp_println(2);
|
dp_println();
|
||||||
|
dp_printf("PRE: %-6.1f", bme_status.pressure);
|
||||||
// line 4-5: Hum
|
|
||||||
dp_printf("HUM:%-2.1f", bme_status.humidity);
|
|
||||||
dp_println(2);
|
|
||||||
|
|
||||||
#ifdef HAS_BME680
|
#ifdef HAS_BME680
|
||||||
// line 6-7: IAQ
|
dp_println();
|
||||||
dp_printf("IAQ:%-3.0f", bme_status.iaq);
|
dp_printf("IAQ: %-6.0f", bme_status.iaq);
|
||||||
#else // is BME280 or BMP180
|
#endif
|
||||||
// line 6-7: Pre
|
dp_dump();
|
||||||
dp_printf("PRE:%-2.1f", bme_status.pressure);
|
|
||||||
#endif // HAS_BME680
|
|
||||||
|
|
||||||
dp_dump(displaybuf);
|
|
||||||
break; // page 3
|
break; // page 3
|
||||||
#else // flip page if we are unattended
|
#else // flip page if we are unattended
|
||||||
DisplayPage++;
|
DisplayPage++;
|
||||||
@ -421,20 +384,26 @@ void dp_drawPage(bool nextpage) {
|
|||||||
// ---------- page 4: time ----------
|
// ---------- page 4: time ----------
|
||||||
case 4:
|
case 4:
|
||||||
|
|
||||||
dp_setFont(MY_FONT_LARGE);
|
|
||||||
dp_setTextCursor(0, 4);
|
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
|
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
|
||||||
dp_printf("%.8s", strftime_buf);
|
|
||||||
|
|
||||||
dp_dump(displaybuf);
|
dp_setFont(MY_FONT_STRETCHED);
|
||||||
|
dp_setTextCursor(0, 0);
|
||||||
|
dp_printf("Timeofday:");
|
||||||
|
dp_setTextCursor(0, 26);
|
||||||
|
dp_setFont(MY_FONT_LARGE);
|
||||||
|
dp_printf("%.8s", strftime_buf);
|
||||||
|
dp_println();
|
||||||
|
dp_setFont(MY_FONT_SMALL);
|
||||||
|
dp_printf("%21.1f", uptime() / 1000.0);
|
||||||
|
dp_dump();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ---------- page 5: pax graph ----------
|
// ---------- page 5: pax graph ----------
|
||||||
case 5:
|
case 5:
|
||||||
|
|
||||||
// update histogram
|
// update and show histogram
|
||||||
dp_plotCurve(count.pax, false);
|
dp_plotCurve(count.pax, false);
|
||||||
dp_dump(plotbuf);
|
dp_dump(plotbuf);
|
||||||
break;
|
break;
|
||||||
@ -455,35 +424,33 @@ void dp_drawPage(bool nextpage) {
|
|||||||
// ------------- display helper functions -----------------
|
// ------------- display helper functions -----------------
|
||||||
|
|
||||||
void dp_setTextCursor(int x, int y) {
|
void dp_setTextCursor(int x, int y) {
|
||||||
// x represents the pixel column
|
|
||||||
// y represents the text row
|
|
||||||
dp_col = x;
|
|
||||||
|
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
dp_row = y;
|
oled.setCursor(x, y);
|
||||||
obdSetCursor(&ssoled, dp_col, dp_row);
|
|
||||||
|
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
switch (dp_font >> 1) {
|
tft.setCursor(x, y);
|
||||||
case MY_FONT_STRETCHED:
|
|
||||||
case MY_FONT_LARGE:
|
|
||||||
dp_row = y * 26;
|
|
||||||
break;
|
|
||||||
case MY_FONT_SMALL:
|
|
||||||
case MY_FONT_NORMAL:
|
|
||||||
default:
|
|
||||||
dp_row = y * 16;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tft.setCursor(dp_col, dp_row);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dp_setFont(int font, int inv) {
|
void dp_setFont(int font, int inv) {
|
||||||
|
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
dp_font = (font << 1) | (inv & 0x01);
|
// handle invers printing
|
||||||
|
if (inv)
|
||||||
|
oled.setTextColor(MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR);
|
||||||
|
else
|
||||||
|
oled.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
|
||||||
|
|
||||||
|
// set desired font
|
||||||
|
oled.setFont(font);
|
||||||
|
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
// map font oled -> tft
|
// handle invers printing
|
||||||
|
if (inv)
|
||||||
|
tft.setTextColor(MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR);
|
||||||
|
else
|
||||||
|
tft.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
|
||||||
|
|
||||||
|
// map desired oled font to tft font
|
||||||
switch (font) {
|
switch (font) {
|
||||||
case MY_FONT_STRETCHED: // 16x16 on OLED
|
case MY_FONT_STRETCHED: // 16x16 on OLED
|
||||||
case MY_FONT_LARGE: // 16x32 on OLED
|
case MY_FONT_LARGE: // 16x32 on OLED
|
||||||
@ -495,17 +462,14 @@ void dp_setFont(int font, int inv) {
|
|||||||
tft.setTextFont(2); // 16px
|
tft.setTextFont(2); // 16px
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// to do: invers printing
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dp_println(int lines) {
|
void dp_println(void) {
|
||||||
dp_col = 0;
|
|
||||||
dp_row += lines;
|
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
dp_setTextCursor(dp_col, dp_row);
|
oled.println();
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
for (int i = 1; i <= lines; i++)
|
|
||||||
tft.println();
|
tft.println();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -533,8 +497,7 @@ void dp_printf(const char *format, ...) {
|
|||||||
}
|
}
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
obdWriteString(&ssoled, 0, -1, dp_row, temp, dp_font >> 1, dp_font & 0x01,
|
oled.write(temp);
|
||||||
false);
|
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
tft.printf(temp);
|
tft.printf(temp);
|
||||||
#endif
|
#endif
|
||||||
@ -545,26 +508,29 @@ void dp_printf(const char *format, ...) {
|
|||||||
|
|
||||||
void dp_dump(uint8_t *pBuffer) {
|
void dp_dump(uint8_t *pBuffer) {
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
obdDumpBuffer(&ssoled, pBuffer);
|
if (pBuffer)
|
||||||
|
memcpy(oled.getBuffer(), pBuffer, PLOTBUFFERSIZE);
|
||||||
|
oled.display();
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
// probably oled buffer stucture is not suitable for tft -> to be checked
|
if (pBuffer)
|
||||||
tft.drawBitmap(0, 0, pBuffer, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT,
|
tft.drawBitmap(0, 0, pBuffer, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT,
|
||||||
MY_DISPLAY_FGCOLOR);
|
MY_DISPLAY_FGCOLOR);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dp_clear(void) {
|
void dp_clear(void) {
|
||||||
dp_setTextCursor(0, 0);
|
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
obdFill(&ssoled, 0, 1);
|
oled.fillScreen(MY_DISPLAY_BGCOLOR);
|
||||||
|
oled.display();
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
tft.fillScreen(MY_DISPLAY_BGCOLOR);
|
tft.fillScreen(MY_DISPLAY_BGCOLOR);
|
||||||
#endif
|
#endif
|
||||||
|
dp_setTextCursor(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dp_contrast(uint8_t contrast) {
|
void dp_contrast(uint8_t contrast) {
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
obdSetContrast(&ssoled, contrast);
|
oled.setContrast(contrast);
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
// to do: gamma correction for TFT
|
// to do: gamma correction for TFT
|
||||||
#endif
|
#endif
|
||||||
@ -572,7 +538,10 @@ void dp_contrast(uint8_t contrast) {
|
|||||||
|
|
||||||
void dp_power(uint8_t screenon) {
|
void dp_power(uint8_t screenon) {
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
obdPower(&ssoled, screenon);
|
//not yet in library, awaiting PR https://github.com/bitbank2/OneBitDisplay/pull/34
|
||||||
|
//oled.setPower(screenon);
|
||||||
|
//as workaround be blank the sreen
|
||||||
|
dp_clear();
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
// to come
|
// to come
|
||||||
#endif
|
#endif
|
||||||
@ -580,7 +549,10 @@ void dp_power(uint8_t screenon) {
|
|||||||
|
|
||||||
void dp_shutdown(void) {
|
void dp_shutdown(void) {
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
obdPower(&ssoled, false);
|
//not yet in library, awaiting PR https://github.com/bitbank2/OneBitDisplay/pull/34
|
||||||
|
//oled.setPower(false);
|
||||||
|
//as workaround be blank the sreen
|
||||||
|
dp_clear();
|
||||||
delay(DISPLAYREFRESH_MS / 1000 * 1.1);
|
delay(DISPLAYREFRESH_MS / 1000 * 1.1);
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
// to come
|
// to come
|
||||||
@ -589,10 +561,10 @@ 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_setTextCursor(0, line);
|
dp_setFont(MY_FONT_SMALL, invers ? 1 : 0);
|
||||||
dp_setFont(MY_FONT_NORMAL, invers ? 1 : 0);
|
dp_setTextCursor(0, line * 8);
|
||||||
dp_printf("%-16s", msg);
|
dp_printf("%-16s", msg);
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
} // dp_message
|
} // dp_message
|
||||||
|
|
||||||
// ------------- QR code plotter -----------------
|
// ------------- QR code plotter -----------------
|
||||||
@ -625,8 +597,7 @@ void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
|||||||
void dp_fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
void dp_fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||||
uint8_t bRender) {
|
uint8_t bRender) {
|
||||||
#if (HAS_DISPLAY) == 1
|
#if (HAS_DISPLAY) == 1
|
||||||
for (uint16_t xi = x; xi < x + width; xi++)
|
oled.fillRect(x, y, width, height, MY_DISPLAY_FGCOLOR);
|
||||||
obdDrawLine(&ssoled, xi, y, xi, y + height - 1, 1, bRender);
|
|
||||||
#elif (HAS_DISPLAY) == 2
|
#elif (HAS_DISPLAY) == 2
|
||||||
tft.fillRect(x, y, width, height, MY_DISPLAY_FGCOLOR);
|
tft.fillRect(x, y, width, height, MY_DISPLAY_FGCOLOR);
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,7 +62,7 @@ void start_ota_update() {
|
|||||||
dp_printf("Downloading ..");
|
dp_printf("Downloading ..");
|
||||||
dp_println();
|
dp_println();
|
||||||
dp_printf("Rebooting ..");
|
dp_printf("Rebooting ..");
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Starting Wifi OTA update");
|
ESP_LOGI(TAG, "Starting Wifi OTA update");
|
||||||
@ -331,14 +331,14 @@ 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_setFont(MY_FONT_SMALL);
|
dp_setFont(MY_FONT_SMALL);
|
||||||
dp_setTextCursor(14, row);
|
dp_setTextCursor(14, 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(" ");
|
||||||
dp_printf(msg.substr(0, 16).c_str());
|
dp_printf(msg.substr(0, 16).c_str());
|
||||||
dp_println();
|
dp_println();
|
||||||
}
|
}
|
||||||
dp_dump(displaybuf);
|
dp_dump();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user