update display lib
This commit is contained in:
parent
1da355b7b0
commit
aa042f6968
@ -3,15 +3,37 @@
|
|||||||
|
|
||||||
#include "cyclic.h"
|
#include "cyclic.h"
|
||||||
#include "qrcode.h"
|
#include "qrcode.h"
|
||||||
|
#define DISPLAY_PAGES (7) // number of paxcounter display pages
|
||||||
|
|
||||||
|
// settings for oled display library
|
||||||
|
#define USE_BACKBUFFER 1
|
||||||
|
#define MY_OLED OLED_128x64
|
||||||
|
#define OLED_ADDR -1
|
||||||
|
#define OLED_INVERT 0
|
||||||
|
#define USE_HW_I2C 1
|
||||||
|
|
||||||
|
#ifndef DISPLAY_FLIP
|
||||||
|
#define DISPLAY_FLIP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// settings for qr code generator
|
||||||
|
#define QR_VERSION 3 // 29 x 29px
|
||||||
|
#define QR_SCALEFACTOR 2 // 29 -> 58x < 64px
|
||||||
|
|
||||||
|
// settings for curve plotter
|
||||||
|
#define DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
|
||||||
|
#define DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 64X
|
||||||
|
|
||||||
extern uint8_t DisplayIsOn, displaybuf[];
|
extern uint8_t DisplayIsOn, displaybuf[];
|
||||||
|
|
||||||
|
void setup_display(int contrast = 0);
|
||||||
void refreshTheDisplay(bool nextPage = false);
|
void refreshTheDisplay(bool nextPage = false);
|
||||||
void init_display(bool verbose = false);
|
void init_display(bool verbose = false);
|
||||||
void shutdown_display(void);
|
void shutdown_display(void);
|
||||||
void draw_page(time_t t, bool nextpage);
|
void draw_page(time_t t, bool nextpage);
|
||||||
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
||||||
const char *format, ...);
|
const char *format, ...);
|
||||||
|
void dp_dump(uint8_t *pBuffer);
|
||||||
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message);
|
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message);
|
||||||
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||||
uint8_t bRender);
|
uint8_t bRender);
|
||||||
|
@ -45,7 +45,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
|
|||||||
|
|
||||||
[common]
|
[common]
|
||||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||||
release_version = 1.9.95
|
release_version = 1.9.96
|
||||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||||
debug_level = 3
|
debug_level = 3
|
||||||
@ -59,8 +59,8 @@ upload_speed = 115200
|
|||||||
lib_deps_lora =
|
lib_deps_lora =
|
||||||
MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore
|
MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore
|
||||||
lib_deps_display =
|
lib_deps_display =
|
||||||
ss_oled@>=3.3.1 ; simple and small OLED lib by Larry Bank
|
ss_oled@4.0.1 ; simple and small OLED lib by Larry Bank
|
||||||
BitBang_I2C@>=1.3.0
|
BitBang_I2C@2.0.0
|
||||||
QRCode@>=0.0.1
|
QRCode@>=0.0.1
|
||||||
lib_deps_matrix_display =
|
lib_deps_matrix_display =
|
||||||
Ultrathin_LED_Matrix@>=1.0.0
|
Ultrathin_LED_Matrix@>=1.0.0
|
||||||
|
@ -39,19 +39,6 @@ FONT_STRETCHED: 16x32px = 8 chars / line
|
|||||||
// local Tag for logging
|
// local Tag for logging
|
||||||
static const char TAG[] = __FILE__;
|
static const char TAG[] = __FILE__;
|
||||||
|
|
||||||
#define DISPLAY_PAGES (7) // number of paxcounter display pages
|
|
||||||
|
|
||||||
// settings for oled display library
|
|
||||||
#define USE_BACKBUFFER
|
|
||||||
|
|
||||||
// settings for qr code generator
|
|
||||||
#define QR_VERSION 3 // 29 x 29px
|
|
||||||
#define QR_SCALEFACTOR 2 // 29 -> 58x < 64px
|
|
||||||
|
|
||||||
// settings for curve plotter
|
|
||||||
#define DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
|
|
||||||
#define DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 64X
|
|
||||||
|
|
||||||
// helper array for converting month values to text
|
// helper array for converting month values to text
|
||||||
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
@ -60,6 +47,23 @@ uint8_t displaybuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
|||||||
static uint8_t plotbuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
static uint8_t plotbuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
||||||
|
|
||||||
QRCode qrcode;
|
QRCode qrcode;
|
||||||
|
SSOLED ssoled;
|
||||||
|
|
||||||
|
void setup_display(int contrast) {
|
||||||
|
int rc = oledInit(&ssoled, MY_OLED, OLED_ADDR, DISPLAY_FLIP, OLED_INVERT,
|
||||||
|
USE_HW_I2C, MY_OLED_SDA, MY_OLED_SCL, MY_OLED_RST,
|
||||||
|
400000L); // use standard I2C bus at 400Khz
|
||||||
|
|
||||||
|
assert(rc != OLED_NOT_FOUND);
|
||||||
|
|
||||||
|
// set display buffer
|
||||||
|
oledSetBackBuffer(&ssoled, displaybuf);
|
||||||
|
if (contrast)
|
||||||
|
oledSetContrast(&ssoled, contrast);
|
||||||
|
|
||||||
|
// clear display
|
||||||
|
oledFill(&ssoled, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void init_display(bool verbose) {
|
void init_display(bool verbose) {
|
||||||
|
|
||||||
@ -68,19 +72,7 @@ void init_display(bool verbose) {
|
|||||||
ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// init display
|
setup_display(DISPLAYCONTRAST);
|
||||||
#ifndef DISPLAY_FLIP
|
|
||||||
oledInit(OLED_128x64, false, false, -1, -1, MY_OLED_RST, 400000L);
|
|
||||||
#else
|
|
||||||
oledInit(OLED_128x64, true, false, -1, -1, MY_OLED_RST, 400000L);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set display buffer
|
|
||||||
oledSetBackBuffer(displaybuf);
|
|
||||||
|
|
||||||
// clear display
|
|
||||||
oledSetContrast(DISPLAYCONTRAST);
|
|
||||||
oledFill(0, 1);
|
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
|
|
||||||
@ -104,9 +96,9 @@ void init_display(bool verbose) {
|
|||||||
: "ext.");
|
: "ext.");
|
||||||
|
|
||||||
// give user some time to read or take picture
|
// give user some time to read or take picture
|
||||||
oledDumpBuffer(displaybuf);
|
dp_dump(displaybuf);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
oledFill(0x00, 1);
|
oledFill(&ssoled, 0x00, 1);
|
||||||
#endif // VERBOSE
|
#endif // VERBOSE
|
||||||
|
|
||||||
#if (HAS_LORA)
|
#if (HAS_LORA)
|
||||||
@ -117,7 +109,7 @@ void init_display(bool verbose) {
|
|||||||
snprintf(deveui, 17, "%016llX", *((uint64_t *)&buf));
|
snprintf(deveui, 17, "%016llX", *((uint64_t *)&buf));
|
||||||
|
|
||||||
// display DEVEUI as QR code on the left
|
// display DEVEUI as QR code on the left
|
||||||
oledSetContrast(30);
|
oledSetContrast(&ssoled, 30);
|
||||||
dp_printqr(3, 3, deveui);
|
dp_printqr(3, 3, deveui);
|
||||||
|
|
||||||
// display DEVEUI as plain text on the right
|
// display DEVEUI as plain text on the right
|
||||||
@ -127,15 +119,15 @@ void init_display(bool verbose) {
|
|||||||
dp_printf(80, i + 3, FONT_NORMAL, 0, "%4.4s", deveui + i * 4);
|
dp_printf(80, i + 3, FONT_NORMAL, 0, "%4.4s", deveui + i * 4);
|
||||||
|
|
||||||
// give user some time to read or take picture
|
// give user some time to read or take picture
|
||||||
oledDumpBuffer(displaybuf);
|
dp_dump(displaybuf);
|
||||||
delay(8000);
|
delay(8000);
|
||||||
oledSetContrast(DISPLAYCONTRAST);
|
oledSetContrast(&ssoled, DISPLAYCONTRAST);
|
||||||
oledFill(0x00, 1);
|
oledFill(&ssoled, 0x00, 1);
|
||||||
#endif // HAS_LORA
|
#endif // HAS_LORA
|
||||||
|
|
||||||
} // verbose
|
} // verbose
|
||||||
|
|
||||||
oledPower(cfg.screenon); // set display off if disabled
|
oledPower(&ssoled, cfg.screenon); // set display off if disabled
|
||||||
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
} // mutex
|
} // mutex
|
||||||
@ -164,7 +156,7 @@ void refreshTheDisplay(bool nextPage) {
|
|||||||
// set display on/off according to current device configuration
|
// set display on/off according to current device configuration
|
||||||
if (DisplayIsOn != cfg.screenon) {
|
if (DisplayIsOn != cfg.screenon) {
|
||||||
DisplayIsOn = cfg.screenon;
|
DisplayIsOn = cfg.screenon;
|
||||||
oledPower(cfg.screenon);
|
oledPower(&ssoled, cfg.screenon);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAS_BUTTON
|
#ifndef HAS_BUTTON
|
||||||
@ -176,7 +168,7 @@ void refreshTheDisplay(bool nextPage) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
draw_page(t, nextPage);
|
draw_page(t, nextPage);
|
||||||
oledDumpBuffer(displaybuf);
|
dp_dump(displaybuf);
|
||||||
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
|
|
||||||
@ -214,7 +206,7 @@ start:
|
|||||||
|
|
||||||
if (nextpage) {
|
if (nextpage) {
|
||||||
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
||||||
oledFill(0, 1);
|
oledFill(&ssoled, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (DisplayPage) {
|
switch (DisplayPage) {
|
||||||
@ -307,7 +299,7 @@ start:
|
|||||||
|
|
||||||
// page 1: pax graph
|
// page 1: pax graph
|
||||||
case 1:
|
case 1:
|
||||||
oledDumpBuffer(plotbuf);
|
dp_dump(plotbuf);
|
||||||
break; // page1
|
break; // page1
|
||||||
|
|
||||||
// page 2: GPS
|
// page 2: GPS
|
||||||
@ -391,7 +383,7 @@ start:
|
|||||||
// page 6: blank screen
|
// page 6: blank screen
|
||||||
case 6:
|
case 6:
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
oledFill(0, 1);
|
oledFill(&ssoled, 0, 1);
|
||||||
break;
|
break;
|
||||||
#else // don't show blank page if we are unattended
|
#else // don't show blank page if we are unattended
|
||||||
DisplayPage++; // next page
|
DisplayPage++; // next page
|
||||||
@ -428,12 +420,14 @@ void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
|||||||
len = vsnprintf(temp, len + 1, format, arg);
|
len = vsnprintf(temp, len + 1, format, arg);
|
||||||
}
|
}
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
oledWriteString(0, x, y, temp, font, inv, false);
|
oledWriteString(&ssoled, 0, x, y, temp, font, inv, false);
|
||||||
if (temp != loc_buf) {
|
if (temp != loc_buf) {
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dp_dump(uint8_t *pBuffer) { oledDumpBuffer(&ssoled, pBuffer); }
|
||||||
|
|
||||||
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
||||||
uint8_t qrcodeData[qrcode_getBufferSize(QR_VERSION)];
|
uint8_t qrcodeData[qrcode_getBufferSize(QR_VERSION)];
|
||||||
qrcode_initText(&qrcode, qrcodeData, QR_VERSION, ECC_HIGH, Message);
|
qrcode_initText(&qrcode, qrcodeData, QR_VERSION, ECC_HIGH, Message);
|
||||||
@ -460,7 +454,7 @@ void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
|||||||
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||||
uint8_t bRender) {
|
uint8_t bRender) {
|
||||||
for (uint16_t xi = x; xi < x + width; xi++)
|
for (uint16_t xi = x; xi < x + width; xi++)
|
||||||
oledDrawLine(xi, y, xi, y + height - 1, bRender);
|
oledDrawLine(&ssoled, xi, y, xi, y + height - 1, bRender);
|
||||||
}
|
}
|
||||||
|
|
||||||
int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||||
|
Loading…
Reference in New Issue
Block a user