commit
d14fb2cfc7
@ -3,51 +3,104 @@
|
||||
|
||||
#include "cyclic.h"
|
||||
#include "qrcode.h"
|
||||
|
||||
#if (HAS_DISPLAY) == 1
|
||||
#include <ss_oled.h>
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
#include <bb_spi_lcd.h>
|
||||
#else
|
||||
#error Unknown display type
|
||||
#endif
|
||||
|
||||
#define DISPLAY_PAGES (7) // number of paxcounter display pages
|
||||
|
||||
// settings for oled display library
|
||||
// settings for display library
|
||||
#define USE_BACKBUFFER 1
|
||||
#define MY_OLED OLED_128x64
|
||||
#ifdef MY_OLED_ADDR
|
||||
#define OLED_ADDR MY_OLED_ADDR
|
||||
#else
|
||||
#define OLED_ADDR -1
|
||||
#endif
|
||||
#define OLED_INVERT 0
|
||||
#define USE_HW_I2C 1
|
||||
|
||||
#ifndef DISPLAY_FLIP
|
||||
#define DISPLAY_FLIP 0
|
||||
// setup display hardware type, default is OLED 128x64
|
||||
#ifndef MY_DISPLAY_TYPE
|
||||
#define MY_DISPLAY_TYPE OLED_128x64
|
||||
#endif
|
||||
|
||||
#ifdef MY_DISPLAY_ADDR
|
||||
#define OLED_ADDR MY_DISPLAY_ADDR
|
||||
#else
|
||||
#define OLED_ADDR -1
|
||||
#endif
|
||||
#ifndef MY_DISPLAY_INVERT
|
||||
#define MY_DISPLAY_INVERT 0
|
||||
#endif
|
||||
|
||||
#ifndef USW_HW_I2C
|
||||
#define USE_HW_I2C 1
|
||||
#endif
|
||||
|
||||
#ifndef MY_DISPLAY_FLIP
|
||||
#define MY_DISPLAY_FLIP 0
|
||||
#endif
|
||||
|
||||
#ifndef MY_DISPLAY_WIDTH
|
||||
#define MY_DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
|
||||
#endif
|
||||
#ifndef MY_DISPLAY_HEIGHT
|
||||
#define MY_DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 64X
|
||||
#endif
|
||||
|
||||
// some RGB color definitions
|
||||
#define Black 0x0000 /* 0, 0, 0 */
|
||||
#define Navy 0x000F /* 0, 0, 128 */
|
||||
#define DarkGreen 0x03E0 /* 0, 128, 0 */
|
||||
#define DarkCyan 0x03EF /* 0, 128, 128 */
|
||||
#define Maroon 0x7800 /* 128, 0, 0 */
|
||||
#define Purple 0x780F /* 128, 0, 128 */
|
||||
#define Olive 0x7BE0 /* 128, 128, 0 */
|
||||
#define LightGrey 0xC618 /* 192, 192, 192 */
|
||||
#define DarkGrey 0x7BEF /* 128, 128, 128 */
|
||||
#define Blue 0x001F /* 0, 0, 255 */
|
||||
#define Green 0x07E0 /* 0, 255, 0 */
|
||||
#define Cyan 0x07FF /* 0, 255, 255 */
|
||||
#define Red 0xF800 /* 255, 0, 0 */
|
||||
#define Magenta 0xF81F /* 255, 0, 255 */
|
||||
#define Yellow 0xFFE0 /* 255, 255, 0 */
|
||||
#define White 0xFFFF /* 255, 255, 255 */
|
||||
#define Orange 0xFD20 /* 255, 165, 0 */
|
||||
#define GreenYellow 0xAFE5 /* 173, 255, 47 */
|
||||
#define Pink 0xF81F
|
||||
|
||||
#ifndef MY_DISPLAY_FGCOLOR
|
||||
#define MY_DISPLAY_FGCOLOR White
|
||||
#endif
|
||||
#ifndef MY_DISPLAY_BGCOLOR
|
||||
#define MY_DISPLAY_BGCOLOR Black
|
||||
#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[];
|
||||
|
||||
void setup_display(int contrast = 0);
|
||||
void refreshTheDisplay(bool nextPage = false);
|
||||
void init_display(bool verbose = false);
|
||||
void shutdown_display(void);
|
||||
void draw_page(time_t t, bool nextpage);
|
||||
void dp_setup(int contrast = 0);
|
||||
void dp_refresh(bool nextPage = false);
|
||||
void dp_init(bool verbose = false);
|
||||
void dp_shutdown(void);
|
||||
void dp_drawPage(time_t t, bool nextpage);
|
||||
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
||||
const char *format, ...);
|
||||
void dp_dump(uint8_t *pBuffer);
|
||||
void dp_contrast(uint8_t contrast);
|
||||
void dp_clear(void);
|
||||
void dp_power(uint8_t screenon);
|
||||
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,
|
||||
uint8_t bRender);
|
||||
void oledScrollBufferHorizontal(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, bool left = true);
|
||||
void oledScrollBufferVertical(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, int offset = 0);
|
||||
int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||
const uint8_t dot);
|
||||
void oledPlotCurve(uint16_t count, bool reset);
|
||||
void oledRescaleBuffer(uint8_t *buf, const int factor);
|
||||
void dp_fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||
uint8_t bRender);
|
||||
void dp_scrollHorizontal(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, bool left = true);
|
||||
void dp_scrollVertical(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, int offset = 0);
|
||||
int dp_drawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||
const uint8_t dot);
|
||||
void dp_plotCurve(uint16_t count, bool reset);
|
||||
void dp_rescaleBuffer(uint8_t *buf, const int factor);
|
||||
|
||||
#endif
|
@ -11,6 +11,14 @@
|
||||
#define MCP_24AA02E64_PRIMARY_ADDRESS (0x50)
|
||||
#define QUECTEL_GPS_PRIMARY_ADDRESS (0x10)
|
||||
|
||||
#ifndef MY_DISPLAY_SDA
|
||||
#define MY_DISPLAY_SDA SDA
|
||||
#endif
|
||||
|
||||
#ifndef MY_DISPLAY_SCL
|
||||
#define MY_DISPLAY_SCL SCL
|
||||
#endif
|
||||
|
||||
void i2c_init(void);
|
||||
void i2c_deinit(void);
|
||||
int i2c_scan(void);
|
||||
|
@ -45,7 +45,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 1.9.98
|
||||
release_version = 1.9.982
|
||||
; 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
|
||||
debug_level = 3
|
||||
@ -53,15 +53,18 @@ extra_scripts = pre:build.py
|
||||
otakeyfile = ota.conf
|
||||
lorakeyfile = loraconf.h
|
||||
lmicconfigfile = lmic_config.h
|
||||
platform_espressif32 = espressif32@1.11.2
|
||||
platform_espressif32 = espressif32@1.12.0
|
||||
monitor_speed = 115200
|
||||
upload_speed = 115200
|
||||
;upload_port = COM9
|
||||
lib_deps_lora =
|
||||
MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore
|
||||
lib_deps_display =
|
||||
ss_oled@4.1.0 ; simple and small OLED lib by Larry Bank
|
||||
;ss_oled@4.1.1 ; simple and small OLED lib by Larry Bank
|
||||
https://github.com/bitbank2/ss_oled.git
|
||||
BitBang_I2C@2.0.1
|
||||
QRCode@>=0.0.1
|
||||
bb_spi_lcd@1.1.0 ; LCD TFT driver lib by Larry Bank
|
||||
lib_deps_matrix_display =
|
||||
Ultrathin_LED_Matrix@>=1.0.0
|
||||
lib_deps_rgbled =
|
||||
@ -109,6 +112,7 @@ framework = arduino
|
||||
board = esp32dev
|
||||
board_build.partitions = min_spiffs.csv
|
||||
upload_speed = ${common.upload_speed}
|
||||
;upload_port = ${common.upload_port}
|
||||
platform = ${common.platform_espressif32}
|
||||
lib_deps = ${common.lib_deps_all}
|
||||
build_flags = ${common.build_flags_all}
|
||||
|
@ -23,7 +23,7 @@ void button_init(int pin) {
|
||||
|
||||
b->setOnClicked([]() {
|
||||
#ifdef HAS_DISPLAY
|
||||
refreshTheDisplay(true); // switch to next display page
|
||||
dp_refresh(true); // switch to next display page
|
||||
#endif
|
||||
#ifdef HAS_MATRIX_DISPLAY
|
||||
refreshTheMatrixDisplay(true); // switch to next display page
|
||||
|
@ -153,7 +153,7 @@ void reset_counters() {
|
||||
macs_wifi = 0;
|
||||
macs_ble = 0;
|
||||
#ifdef HAS_DISPLAY
|
||||
oledPlotCurve(0, true);
|
||||
dp_plotCurve(0, true);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
215
src/display.cpp
215
src/display.cpp
@ -33,7 +33,6 @@ FONT_STRETCHED: 16x32px = 8 chars / line
|
||||
|
||||
// Basic Config
|
||||
#include "globals.h"
|
||||
#include <ss_oled.h>
|
||||
#include <esp_spi_flash.h> // needed for reading ESP32 chip attributes
|
||||
|
||||
// local Tag for logging
|
||||
@ -43,36 +42,55 @@ static const char TAG[] = __FILE__;
|
||||
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
uint8_t DisplayIsOn = 0;
|
||||
uint8_t displaybuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
||||
static uint8_t plotbuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
||||
uint8_t displaybuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
|
||||
static uint8_t plotbuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
|
||||
|
||||
QRCode qrcode;
|
||||
|
||||
#if (HAS_DISPLAY) == 1
|
||||
SSOLED ssoled;
|
||||
#endif
|
||||
|
||||
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,
|
||||
void dp_setup(int contrast) {
|
||||
|
||||
#if (HAS_DISPLAY) == 1
|
||||
int rc = oledInit(&ssoled, MY_DISPLAY_TYPE, OLED_ADDR, MY_DISPLAY_FLIP,
|
||||
MY_DISPLAY_INVERT, USE_HW_I2C, MY_DISPLAY_SDA, MY_DISPLAY_SCL,
|
||||
MY_DISPLAY_RST,
|
||||
400000L); // use standard I2C bus at 400Khz
|
||||
|
||||
assert(rc != OLED_NOT_FOUND);
|
||||
|
||||
// set display buffer
|
||||
oledSetBackBuffer(&ssoled, displaybuf);
|
||||
if (contrast)
|
||||
oledSetContrast(&ssoled, contrast);
|
||||
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
|
||||
int rc =
|
||||
spilcdInit(MY_DISPLAY_TYPE, 0, MY_DISPLAY_INVERT, MY_DISPLAY_FLIP, 32000000,
|
||||
MY_DISPLAY_CS, MY_DISPLAY_DC, MY_DISPLAY_RST, MY_DISPLAY_BL,
|
||||
MY_DISPLAY_MISO, MY_DISPLAY_MOSI, MY_DISPLAY_CLK);
|
||||
|
||||
assert(rc == 0);
|
||||
|
||||
// set display buffer
|
||||
spilcdAllocBackbuffer();
|
||||
|
||||
#endif
|
||||
|
||||
// clear display
|
||||
oledFill(&ssoled, 0, 1);
|
||||
dp_clear();
|
||||
if (contrast)
|
||||
dp_contrast(contrast);
|
||||
}
|
||||
|
||||
void init_display(bool verbose) {
|
||||
void dp_init(bool verbose) {
|
||||
|
||||
// block i2c bus access
|
||||
if (!I2C_MUTEX_LOCK())
|
||||
ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
||||
else {
|
||||
|
||||
setup_display(DISPLAYCONTRAST);
|
||||
dp_setup(DISPLAYCONTRAST);
|
||||
|
||||
if (verbose) {
|
||||
|
||||
@ -98,7 +116,7 @@ void init_display(bool verbose) {
|
||||
// give user some time to read or take picture
|
||||
dp_dump(displaybuf);
|
||||
delay(2000);
|
||||
oledFill(&ssoled, 0x00, 1);
|
||||
dp_clear();
|
||||
#endif // VERBOSE
|
||||
|
||||
#if (HAS_LORA)
|
||||
@ -109,7 +127,7 @@ void init_display(bool verbose) {
|
||||
snprintf(deveui, 17, "%016llX", (*(uint64_t *)(p)));
|
||||
|
||||
// display DEVEUI as QR code on the left
|
||||
oledSetContrast(&ssoled, 30);
|
||||
dp_contrast(30);
|
||||
dp_printqr(3, 3, deveui);
|
||||
|
||||
// display DEVEUI as plain text on the right
|
||||
@ -121,26 +139,26 @@ void init_display(bool verbose) {
|
||||
// give user some time to read or take picture
|
||||
dp_dump(displaybuf);
|
||||
delay(8000);
|
||||
oledSetContrast(&ssoled, DISPLAYCONTRAST);
|
||||
oledFill(&ssoled, 0x00, 1);
|
||||
dp_contrast(DISPLAYCONTRAST);
|
||||
dp_clear();
|
||||
#endif // HAS_LORA
|
||||
|
||||
} // verbose
|
||||
|
||||
oledPower(&ssoled, cfg.screenon); // set display off if disabled
|
||||
dp_power(cfg.screenon); // set display off if disabled
|
||||
|
||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||
} // mutex
|
||||
} // init_display
|
||||
} // dp_init
|
||||
|
||||
void refreshTheDisplay(bool nextPage) {
|
||||
void dp_refresh(bool nextPage) {
|
||||
|
||||
#ifndef HAS_BUTTON
|
||||
static uint32_t framecounter = 0;
|
||||
#endif
|
||||
|
||||
// update histogram
|
||||
oledPlotCurve(macs.size(), false);
|
||||
dp_plotCurve(macs.size(), false);
|
||||
|
||||
// if display is switched off we don't refresh it to relax cpu
|
||||
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
|
||||
@ -156,7 +174,7 @@ void refreshTheDisplay(bool nextPage) {
|
||||
// set display on/off according to current device configuration
|
||||
if (DisplayIsOn != cfg.screenon) {
|
||||
DisplayIsOn = cfg.screenon;
|
||||
oledPower(&ssoled, cfg.screenon);
|
||||
dp_power(cfg.screenon);
|
||||
}
|
||||
|
||||
#ifndef HAS_BUTTON
|
||||
@ -167,7 +185,7 @@ void refreshTheDisplay(bool nextPage) {
|
||||
}
|
||||
#endif
|
||||
|
||||
draw_page(t, nextPage);
|
||||
dp_drawPage(t, nextPage);
|
||||
dp_dump(displaybuf);
|
||||
|
||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||
@ -175,19 +193,7 @@ void refreshTheDisplay(bool nextPage) {
|
||||
} // mutex
|
||||
} // refreshDisplay()
|
||||
|
||||
void shutdown_display(void) {
|
||||
// block i2c bus access
|
||||
if (!I2C_MUTEX_LOCK())
|
||||
ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
||||
else {
|
||||
cfg.screenon = 0;
|
||||
oledShutdown();
|
||||
delay(DISPLAYREFRESH_MS / 1000 * 1.1);
|
||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||
}
|
||||
}
|
||||
|
||||
void draw_page(time_t t, bool nextpage) {
|
||||
void dp_drawPage(time_t t, bool nextpage) {
|
||||
|
||||
// write display content to display buffer
|
||||
// nextpage = true -> flip 1 page
|
||||
@ -206,7 +212,7 @@ start:
|
||||
|
||||
if (nextpage) {
|
||||
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
|
||||
oledFill(&ssoled, 0, 1);
|
||||
dp_clear();
|
||||
}
|
||||
|
||||
switch (DisplayPage) {
|
||||
@ -383,7 +389,7 @@ start:
|
||||
// page 6: blank screen
|
||||
case 6:
|
||||
#ifdef HAS_BUTTON
|
||||
oledFill(&ssoled, 0, 1);
|
||||
dp_clear();
|
||||
break;
|
||||
#else // don't show blank page if we are unattended
|
||||
DisplayPage++; // next page
|
||||
@ -394,7 +400,7 @@ start:
|
||||
|
||||
} // switch
|
||||
|
||||
} // draw_page
|
||||
} // dp_drawPage
|
||||
|
||||
// display helper functions
|
||||
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
||||
@ -420,13 +426,72 @@ void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
|
||||
len = vsnprintf(temp, len + 1, format, arg);
|
||||
}
|
||||
va_end(arg);
|
||||
#if (HAS_DISPLAY) == 1
|
||||
oledWriteString(&ssoled, 0, x, y, temp, font, inv, false);
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
/*
|
||||
if (font = 0 || font == 1)
|
||||
spilcdWriteStringFast(x, y, temp, MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR,
|
||||
font);
|
||||
else
|
||||
*/
|
||||
spilcdWriteString(x, y, temp, MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR, font,
|
||||
1);
|
||||
#endif
|
||||
if (temp != loc_buf) {
|
||||
free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void dp_dump(uint8_t *pBuffer) { oledDumpBuffer(&ssoled, pBuffer); }
|
||||
void dp_dump(uint8_t *pBuffer) {
|
||||
#if (HAS_DISPLAY) == 1
|
||||
oledDumpBuffer(&ssoled, pBuffer);
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
spilcdShowBuffer(0, 0, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void dp_clear() {
|
||||
#if (HAS_DISPLAY) == 1
|
||||
oledFill(&ssoled, 0, 1);
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
spilcdFill(0, 1);
|
||||
spilcdScrollReset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void dp_contrast(uint8_t contrast) {
|
||||
#if (HAS_DISPLAY) == 1
|
||||
oledSetContrast(&ssoled, contrast);
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
// to come
|
||||
#endif
|
||||
}
|
||||
|
||||
void dp_power(uint8_t screenon) {
|
||||
#if (HAS_DISPLAY) == 1
|
||||
oledPower(&ssoled, screenon);
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
// to come
|
||||
#endif
|
||||
}
|
||||
|
||||
void dp_shutdown(void) {
|
||||
#if (HAS_DISPLAY) == 1
|
||||
// block i2c bus access
|
||||
if (!I2C_MUTEX_LOCK())
|
||||
ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
||||
else {
|
||||
cfg.screenon = 0;
|
||||
oledShutdown(&ssoled);
|
||||
delay(DISPLAYREFRESH_MS / 1000 * 1.1);
|
||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||
}
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
spilcdShutdown();
|
||||
spilcdFreeBackbuffer();
|
||||
#endif
|
||||
}
|
||||
|
||||
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
||||
uint8_t qrcodeData[qrcode_getBufferSize(QR_VERSION)];
|
||||
@ -436,35 +501,39 @@ void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message) {
|
||||
for (uint16_t y = 0; y < qrcode.size; y++)
|
||||
for (uint16_t x = 0; x < qrcode.size; x++)
|
||||
if (!qrcode_getModule(&qrcode, x, y)) // "black"
|
||||
oledfillRect(x * QR_SCALEFACTOR + offset_x,
|
||||
y * QR_SCALEFACTOR + offset_y, QR_SCALEFACTOR,
|
||||
QR_SCALEFACTOR, false);
|
||||
dp_fillRect(x * QR_SCALEFACTOR + offset_x,
|
||||
y * QR_SCALEFACTOR + offset_y, QR_SCALEFACTOR,
|
||||
QR_SCALEFACTOR, false);
|
||||
// draw horizontal frame lines
|
||||
oledfillRect(0, 0, qrcode.size * QR_SCALEFACTOR + 2 * offset_x, offset_y,
|
||||
false);
|
||||
oledfillRect(0, qrcode.size * QR_SCALEFACTOR + offset_y,
|
||||
qrcode.size * QR_SCALEFACTOR + 2 * offset_x, offset_y, false);
|
||||
dp_fillRect(0, 0, qrcode.size * QR_SCALEFACTOR + 2 * offset_x, offset_y,
|
||||
false);
|
||||
dp_fillRect(0, qrcode.size * QR_SCALEFACTOR + offset_y,
|
||||
qrcode.size * QR_SCALEFACTOR + 2 * offset_x, offset_y, false);
|
||||
// draw vertical frame lines
|
||||
oledfillRect(0, 0, offset_x, qrcode.size * QR_SCALEFACTOR + 2 * offset_y,
|
||||
false);
|
||||
oledfillRect(qrcode.size * QR_SCALEFACTOR + offset_x, 0, offset_x,
|
||||
qrcode.size * QR_SCALEFACTOR + 2 * offset_y, false);
|
||||
dp_fillRect(0, 0, offset_x, qrcode.size * QR_SCALEFACTOR + 2 * offset_y,
|
||||
false);
|
||||
dp_fillRect(qrcode.size * QR_SCALEFACTOR + offset_x, 0, offset_x,
|
||||
qrcode.size * QR_SCALEFACTOR + 2 * offset_y, false);
|
||||
}
|
||||
|
||||
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||
uint8_t bRender) {
|
||||
void dp_fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||
uint8_t bRender) {
|
||||
#if (HAS_DISPLAY) == 1
|
||||
for (uint16_t xi = x; xi < x + width; xi++)
|
||||
oledDrawLine(&ssoled, xi, y, xi, y + height - 1, bRender);
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
spilcdRectangle(x, y, width, height, MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR, 1, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||
const uint8_t dot) {
|
||||
int dp_drawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||
const uint8_t dot) {
|
||||
|
||||
if (x > DISPLAY_WIDTH || y > DISPLAY_HEIGHT)
|
||||
if (x > MY_DISPLAY_WIDTH || y > MY_DISPLAY_HEIGHT)
|
||||
return -1;
|
||||
|
||||
uint8_t bit = y & 7;
|
||||
uint16_t idx = y / 8 * DISPLAY_WIDTH + x;
|
||||
uint16_t idx = y / 8 * MY_DISPLAY_WIDTH + x;
|
||||
|
||||
buf[idx] &= ~(1 << bit); // clear pixel
|
||||
if (dot)
|
||||
@ -473,8 +542,8 @@ int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void oledScrollBufferHorizontal(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, bool left) {
|
||||
void dp_scrollHorizontal(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, bool left) {
|
||||
|
||||
uint16_t col, page, idx = 0;
|
||||
|
||||
@ -496,17 +565,17 @@ void oledScrollBufferHorizontal(uint8_t *buf, const uint16_t width,
|
||||
}
|
||||
}
|
||||
|
||||
void oledScrollBufferVertical(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, int offset) {
|
||||
void dp_scrollVertical(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height, int offset) {
|
||||
|
||||
uint64_t buf_col;
|
||||
|
||||
if (!offset)
|
||||
return; // nothing to do
|
||||
|
||||
for (uint16_t col = 0; col < DISPLAY_WIDTH; col++) {
|
||||
for (uint16_t col = 0; col < MY_DISPLAY_WIDTH; col++) {
|
||||
// convert column bytes from display buffer to uint64_t
|
||||
buf_col = *(uint64_t *)&buf[col * DISPLAY_HEIGHT / 8];
|
||||
buf_col = *(uint64_t *)&buf[col * MY_DISPLAY_HEIGHT / 8];
|
||||
|
||||
if (offset > 0) // scroll down
|
||||
buf_col <<= offset;
|
||||
@ -514,11 +583,11 @@ void oledScrollBufferVertical(uint8_t *buf, const uint16_t width,
|
||||
buf_col >>= abs(offset);
|
||||
|
||||
// write back uint64_t to uint8_t display buffer
|
||||
*(uint64_t *)&buf[col * DISPLAY_HEIGHT / 8] = buf_col;
|
||||
*(uint64_t *)&buf[col * MY_DISPLAY_HEIGHT / 8] = buf_col;
|
||||
}
|
||||
}
|
||||
|
||||
void oledPlotCurve(uint16_t count, bool reset) {
|
||||
void dp_plotCurve(uint16_t count, bool reset) {
|
||||
|
||||
static uint16_t last_count = 0, col = 0, row = 0;
|
||||
uint16_t v_scroll = 0;
|
||||
@ -526,26 +595,26 @@ void oledPlotCurve(uint16_t count, bool reset) {
|
||||
if ((last_count == count) && !reset)
|
||||
return;
|
||||
|
||||
if (reset) { // next count cycle?
|
||||
if (col < DISPLAY_WIDTH - 1) // matrix not full -> increment column
|
||||
if (reset) { // next count cycle?
|
||||
if (col < MY_DISPLAY_WIDTH - 1) // matrix not full -> increment column
|
||||
col++;
|
||||
else // matrix full -> scroll left 1 dot
|
||||
oledScrollBufferHorizontal(plotbuf, DISPLAY_WIDTH, DISPLAY_HEIGHT, true);
|
||||
dp_scrollHorizontal(plotbuf, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT, true);
|
||||
|
||||
} else // clear current dot
|
||||
oledDrawPixel(plotbuf, col, row, 0);
|
||||
dp_drawPixel(plotbuf, col, row, 0);
|
||||
|
||||
// scroll down, if necessary
|
||||
while ((count - v_scroll) > DISPLAY_HEIGHT - 1)
|
||||
while ((count - v_scroll) > MY_DISPLAY_HEIGHT - 1)
|
||||
v_scroll++;
|
||||
if (v_scroll)
|
||||
oledScrollBufferVertical(plotbuf, DISPLAY_WIDTH, DISPLAY_HEIGHT, v_scroll);
|
||||
dp_scrollVertical(plotbuf, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT, v_scroll);
|
||||
|
||||
// set new dot
|
||||
// row = DISPLAY_HEIGHT - 1 - (count - v_scroll) % DISPLAY_HEIGHT;
|
||||
row = DISPLAY_HEIGHT - 1 - count - v_scroll;
|
||||
// row = MY_DISPLAY_HEIGHT - 1 - (count - v_scroll) % MY_DISPLAY_HEIGHT;
|
||||
row = MY_DISPLAY_HEIGHT - 1 - count - v_scroll;
|
||||
last_count = count;
|
||||
oledDrawPixel(plotbuf, col, row, 1);
|
||||
dp_drawPixel(plotbuf, col, row, 1);
|
||||
}
|
||||
|
||||
#endif // HAS_DISPLAY
|
@ -13,7 +13,7 @@
|
||||
//#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
#define HAS_DISPLAY 1
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
||||
#define BAT_VOLTAGE_DIVIDER ((82.0+220.0)/82.0) // 82k + 220k 1%
|
||||
//#define BAT_MEASURE_EN EXT_POWER_SW // Turn power on for measurement
|
||||
@ -27,14 +27,14 @@
|
||||
//#define HAS_BUTTON (0) // on board button -> don't use, is same as RTC_INT!
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA SDA
|
||||
#define MY_OLED_SCL SCL
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_SDA SDA
|
||||
#define MY_DISPLAY_SCL SCL
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
// Settings for on board DS3231 RTC chip
|
||||
// note: to use RTC_INT, capacitor 100nF next to red LED must be removed to sharpen interrupt signal slope
|
||||
// and setting EXT_POWER_ON is needed (this is done in main.cpp)
|
||||
#define HAS_RTC MY_OLED_SDA, MY_OLED_SCL // SDA, SCL
|
||||
#define HAS_RTC MY_DISPLAY_SDA, MY_DISPLAY_SCL // SDA, SCL
|
||||
#define RTC_INT GPIO_NUM_0 //
|
||||
|
||||
// Settings for IF482 interface
|
||||
|
@ -63,7 +63,7 @@
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
#define HAS_DISPLAY 1
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
||||
#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board
|
||||
|
||||
@ -77,12 +77,12 @@
|
||||
#define GPS_INT GPIO_NUM_13 // 30ns accurary timepulse, to be external wired on pcb: NEO 6M Pin#3 -> GPIO13
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (4)
|
||||
#define MY_OLED_SCL (15)
|
||||
#define MY_OLED_RST (16)
|
||||
#define MY_DISPLAY_SDA (4)
|
||||
#define MY_DISPLAY_SCL (15)
|
||||
#define MY_DISPLAY_RST (16)
|
||||
|
||||
// Settings for on board DS3231 RTC chip
|
||||
#define HAS_RTC MY_OLED_SDA, MY_OLED_SCL // SDA, SCL
|
||||
#define HAS_RTC MY_DISPLAY_SDA, MY_DISPLAY_SCL // SDA, SCL
|
||||
#define RTC_INT GPIO_NUM_34 // timepulse with accuracy +/- 2*e-6 [microseconds] = 0,1728sec / day
|
||||
|
||||
// Settings for IF482 interface
|
||||
|
@ -21,9 +21,9 @@
|
||||
#define HAS_BUTTON KEY_BUILTIN // button "PROG" on board
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA SDA_OLED
|
||||
#define MY_OLED_SCL SCL_OLED
|
||||
#define MY_OLED_RST RST_OLED
|
||||
#define MY_DISPLAY_SDA SDA_OLED
|
||||
#define MY_DISPLAY_SCL SCL_OLED
|
||||
#define MY_DISPLAY_RST RST_OLED
|
||||
|
||||
// Pins for LORA chip SPI interface come from board file, we need some
|
||||
// additional definitions for LMIC
|
||||
|
@ -34,9 +34,9 @@
|
||||
//#define EXT_POWER_OFF 1
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA SDA_OLED
|
||||
#define MY_OLED_SCL SCL_OLED
|
||||
#define MY_OLED_RST RST_OLED
|
||||
#define MY_DISPLAY_SDA SDA_OLED
|
||||
#define MY_DISPLAY_SCL SCL_OLED
|
||||
#define MY_DISPLAY_RST RST_OLED
|
||||
|
||||
// Pins for LORA chip SPI interface come from board file, we need some
|
||||
// additional definitions for LMIC
|
||||
|
@ -12,6 +12,9 @@
|
||||
#define HAS_LED LED_BUILTIN // on board LED on GPIO5
|
||||
#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW
|
||||
|
||||
#define MY_SDA SDA
|
||||
#define MY_SCL SCL
|
||||
|
||||
// disable brownout detection (avoid unexpected reset on some boards)
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
#define HAS_DISPLAY 1 // OLED-Display on board
|
||||
//#define DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
//#define MY_DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
#define HAS_LED 22 // ESP32 GPIO12 (pin22) On Board LED
|
||||
#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW
|
||||
#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_13) // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED
|
||||
@ -35,9 +35,9 @@
|
||||
#define LORA_IO2 (4)
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (12)
|
||||
#define MY_OLED_SCL (14)
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_SDA (12)
|
||||
#define MY_DISPLAY_SCL (14)
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
// I2C config for Microchip 24AA02E64 DEVEUI unique address
|
||||
#define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
#define HAS_DISPLAY 1 // OLED-Display on board
|
||||
//#define DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
//#define MY_DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
#define HAS_LED NOT_A_PIN // Led os on same pin as Lora SS pin, to avoid problems, we don't use it
|
||||
#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW
|
||||
// Anyway shield is on over the LoLin32 board, so we won't be able to see this LED
|
||||
@ -36,9 +36,9 @@
|
||||
#define LORA_IO2 (4)
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA SDA
|
||||
#define MY_OLED_SCL SCL
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_SDA SDA
|
||||
#define MY_DISPLAY_SCL SCL
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
// I2C config for Microchip 24AA02E64 DEVEUI unique address
|
||||
#define MCP_24AA02E64_I2C_ADDRESS 0x50 // I2C address for the 24AA02E64
|
||||
|
@ -32,8 +32,8 @@
|
||||
#define BOARD_HAS_PSRAM // use if board has external PSRAM
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
//#define HAS_DISPLAY 1
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
//#define HAS_DISPLAY 2 // TFT-LCD, support work in progess, not ready yet
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
//#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
||||
//#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board
|
||||
|
||||
@ -46,12 +46,12 @@
|
||||
#define GPS_INT GPIO_NUM_35 // 30ns accurary timepulse, to be external wired on pcb: shorten R12!
|
||||
|
||||
// Pins for interface of LC Display
|
||||
#define MY_OLED_CS GPIO_NUM_14
|
||||
#define MY_OLED_DC GPIO_NUM_27
|
||||
#define MY_OLED_CLK GPIO_NUM_18
|
||||
#define MY_OLED_RST GPIO_NUM_33
|
||||
#define MY_OLED_BL GPIO_NUM_32
|
||||
#define MY_OLED_MOSI GPIO_NUM_23
|
||||
#define MY_OLED_MISO GPIO_NUM_19
|
||||
#define MY_DISPLAY_CS GPIO_NUM_14
|
||||
#define MY_DISPLAY_DC GPIO_NUM_27
|
||||
#define MY_DISPLAY_CLK GPIO_NUM_18
|
||||
#define MY_DISPLAY_RST GPIO_NUM_33
|
||||
#define MY_DISPLAY_BL GPIO_NUM_32
|
||||
#define MY_DISPLAY_MOSI GPIO_NUM_23
|
||||
#define MY_DISPLAY_MISO GPIO_NUM_19
|
||||
|
||||
#endif
|
@ -32,9 +32,8 @@
|
||||
#define BOARD_HAS_PSRAM // use if board has external PSRAM
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
//#define HAS_DISPLAY 1
|
||||
#define HAS_TFT 1
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
//#define HAS_DISPLAY 2 // TFT-LCD, support work in progess, not ready yet
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
//#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
||||
//#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board
|
||||
|
||||
@ -48,13 +47,16 @@
|
||||
#define GPS_SERIAL 9600, SERIAL_8N1, RXD2, TXD2 // UBlox NEO 6M RX, TX
|
||||
// #define GPS_INT GPIO_NUM_35 // 30ns accurary timepulse, to be external wired on pcb: shorten R12!
|
||||
|
||||
// Pins for interface of LC Display
|
||||
#define MY_OLED_CS GPIO_NUM_14
|
||||
#define MY_OLED_DC GPIO_NUM_27
|
||||
#define MY_OLED_CLK GPIO_NUM_18
|
||||
#define MY_OLED_RST GPIO_NUM_33
|
||||
#define MY_OLED_BL GPIO_NUM_32
|
||||
#define MY_OLED_MOSI GPIO_NUM_23
|
||||
#define MY_OLED_MISO GPIO_NUM_19
|
||||
// Display Settings
|
||||
#define MY_DISPLAY_WIDTH 320
|
||||
#define MY_DISPLAY_HEIGHT 240
|
||||
#define MY_DISPLAY_TYPE LCD_ILI9341
|
||||
#define MY_DISPLAY_CS GPIO_NUM_14 // Display CS pin
|
||||
#define MY_DISPLAY_CLK GPIO_NUM_18 // SPI CLOCK pin
|
||||
#define MY_DISPLAY_DC GPIO_NUM_27 // Display command/data pin
|
||||
#define MY_DISPLAY_MOSI GPIO_NUM_23 // SPI MOSI
|
||||
#define MY_DISPLAY_MISO GPIO_NUM_19 // SPI MISO
|
||||
#define MY_DISPLAY_BL GPIO_NUM_32 // backlight control
|
||||
#define MY_DISPLAY_RST GPIO_NUM_33 // RESET control
|
||||
|
||||
#endif
|
@ -44,9 +44,9 @@
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define HAS_DISPLAY 1
|
||||
//#define DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
#define MY_OLED_SDA (23)
|
||||
#define MY_OLED_SCL (22)
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
//#define MY_DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
#define MY_DISPLAY_SDA (23)
|
||||
#define MY_DISPLAY_SCL (22)
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
#endif
|
||||
|
@ -34,10 +34,10 @@
|
||||
|
||||
// display (if connected)
|
||||
#define HAS_DISPLAY 1
|
||||
#define MY_OLED_SDA SDA
|
||||
#define MY_OLED_SCL SCL
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_SDA SDA
|
||||
#define MY_DISPLAY_SCL SCL
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
|
||||
// user defined sensors (if connected)
|
||||
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||
|
@ -21,10 +21,10 @@ Reset -> reset device
|
||||
*/
|
||||
|
||||
#define HAS_DISPLAY 1
|
||||
#define MY_OLED_SDA SDA
|
||||
#define MY_OLED_SCL SCL
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_SDA SDA
|
||||
#define MY_DISPLAY_SCL SCL
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||
|
@ -21,12 +21,12 @@
|
||||
#define HAS_BUTTON GPIO_NUM_36 // on board button (next to reset)
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (21)
|
||||
#define MY_OLED_SCL (22)
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_SDA (21)
|
||||
#define MY_DISPLAY_SCL (22)
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
// Settings for on board DS3231 RTC chip
|
||||
#define HAS_RTC MY_OLED_SDA, MY_OLED_SCL // SDA, SCL
|
||||
#define HAS_RTC MY_DISPLAY_SDA, MY_DISPLAY_SCL // SDA, SCL
|
||||
#define RTC_INT GPIO_NUM_34 // timepulse with accuracy +/- 2*e-6 [microseconds] = 0,1728sec / day
|
||||
|
||||
// Settings for IF482 interface
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define CFG_sx1276_radio 1
|
||||
|
||||
#define HAS_DISPLAY 1 // OLED-Display on board
|
||||
//#define DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
//#define MY_DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
#define HAS_LED LED_BUILTIN
|
||||
#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW
|
||||
#define HAS_BUTTON KEY_BUILTIN
|
||||
@ -27,12 +27,12 @@
|
||||
#define SDCARD_SCLK (14)
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (4)
|
||||
#define MY_OLED_SCL (15)
|
||||
#define MY_OLED_RST (16)
|
||||
#define MY_DISPLAY_SDA (4)
|
||||
#define MY_DISPLAY_SCL (15)
|
||||
#define MY_DISPLAY_RST (16)
|
||||
|
||||
// This board reports back the wrong I2C address, so we overwrite it here
|
||||
#define MY_OLED_ADDR 0x3C
|
||||
#define MY_DISPLAY_ADDR 0x3C
|
||||
|
||||
// Pins for LORA chip SPI interface come from board file, we need some
|
||||
// additional definitions for LMIC
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||
|
||||
#define HAS_DISPLAY 1
|
||||
//#define DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
//#define MY_DISPLAY_FLIP 1 // uncomment this for rotated display
|
||||
#define HAS_LED NOT_A_PIN // on-board LED is wired to SCL (used by display) therefore totally useless
|
||||
|
||||
// disable brownout detection (needed on TTGOv2 for battery powered operation)
|
||||
@ -28,9 +28,9 @@
|
||||
#define SDCARD_SCLK (14)
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (21)
|
||||
#define MY_OLED_SCL (22)
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_SDA (21)
|
||||
#define MY_DISPLAY_SCL (22)
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
// Pins for LORA chip SPI interface come from board file, we need some
|
||||
// additional definitions for LMIC
|
||||
|
@ -28,14 +28,14 @@
|
||||
#define SDCARD_SCLK (14)
|
||||
|
||||
#define HAS_DISPLAY 1
|
||||
#define DISPLAY_FLIP 1 // rotated display
|
||||
#define MY_DISPLAY_FLIP 1 // rotated display
|
||||
//#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
|
||||
//#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (21)
|
||||
#define MY_OLED_SCL (22)
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_SDA (21)
|
||||
#define MY_DISPLAY_SCL (22)
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
|
||||
// Pins for LORA chip SPI interface, reset line and interrupt lines
|
||||
#define LORA_SCK (5)
|
||||
|
@ -10,10 +10,10 @@
|
||||
#define HAS_LED NOT_A_PIN // no LED
|
||||
|
||||
#define HAS_DISPLAY 1
|
||||
#define MY_OLED_SDA (5)
|
||||
#define MY_OLED_SCL (4)
|
||||
#define MY_OLED_RST NOT_A_PIN
|
||||
#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_SDA (5)
|
||||
#define MY_DISPLAY_SCL (4)
|
||||
#define MY_DISPLAY_RST NOT_A_PIN
|
||||
#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
|
20
src/i2c.cpp
20
src/i2c.cpp
@ -5,24 +5,14 @@
|
||||
// Local logging tag
|
||||
static const char TAG[] = __FILE__;
|
||||
|
||||
void i2c_init(void) {
|
||||
#ifdef HAS_DISPLAY
|
||||
Wire.begin(MY_OLED_SDA, MY_OLED_SCL, 400000);
|
||||
#else
|
||||
Wire.begin(SDA, SCL, 400000);
|
||||
#endif
|
||||
}
|
||||
void i2c_init(void) {
|
||||
Wire.begin(MY_DISPLAY_SDA, MY_DISPLAY_SCL, 400000); }
|
||||
|
||||
void i2c_deinit(void) {
|
||||
Wire.~TwoWire(); // shutdown/power off I2C hardware
|
||||
#ifdef HAS_DISPLAY
|
||||
// to save power, because Wire.end() enables pullups
|
||||
pinMode(MY_OLED_SDA, INPUT);
|
||||
pinMode(MY_OLED_SCL, INPUT);
|
||||
#else
|
||||
pinMode(SDA, INPUT);
|
||||
pinMode(SCL, INPUT);
|
||||
#endif
|
||||
// configure pins as input to save power, because Wire.end() enables pullups
|
||||
pinMode(MY_DISPLAY_SDA, INPUT);
|
||||
pinMode(MY_DISPLAY_SCL, INPUT);
|
||||
}
|
||||
|
||||
int i2c_scan(void) {
|
||||
|
@ -39,7 +39,7 @@ void irqHandler(void *pvParameters) {
|
||||
// display needs refresh?
|
||||
#ifdef HAS_DISPLAY
|
||||
if (InterruptStatus & DISPLAY_IRQ) {
|
||||
refreshTheDisplay();
|
||||
dp_refresh();
|
||||
InterruptStatus &= ~DISPLAY_IRQ;
|
||||
}
|
||||
#endif
|
||||
|
@ -39,7 +39,7 @@ void init_matrix_display(bool reverse) {
|
||||
matrix.reverse();
|
||||
matrix.clear();
|
||||
matrix.drawPoint(0, LED_MATRIX_HEIGHT - 1, 1);
|
||||
} // init_display
|
||||
} // dp_init
|
||||
|
||||
void refreshTheMatrixDisplay(bool nextPage) {
|
||||
static uint8_t DisplayPage = 0, col = 0, row = 0;
|
||||
|
@ -197,7 +197,7 @@ void setup() {
|
||||
strcat_P(features, " OLED");
|
||||
DisplayIsOn = cfg.screenon;
|
||||
// display verbose info only after a coldstart (note: blocking call!)
|
||||
init_display(RTC_runmode == RUNMODE_POWERCYCLE ? true : false);
|
||||
dp_init(RTC_runmode == RUNMODE_POWERCYCLE ? true : false);
|
||||
#endif
|
||||
|
||||
// scan i2c bus for devices
|
||||
|
@ -45,7 +45,7 @@ void start_ota_update() {
|
||||
// init display
|
||||
#ifdef HAS_DISPLAY
|
||||
|
||||
setup_display();
|
||||
dp_setup();
|
||||
|
||||
dp_printf(0, 0, 0, 1, "SOFTWARE UPDATE");
|
||||
dp_printf(0, 1, 0, 0, "WiFi connect ..");
|
||||
|
@ -98,7 +98,6 @@
|
||||
#define BMEPORT 7 // BME680 sensor
|
||||
#define BATTPORT 8 // battery voltage
|
||||
#define TIMEPORT 9 // time query and response
|
||||
#define TIMEDIFFPORT 13 // time adjust diff
|
||||
#define SENSOR1PORT 10 // user sensor #1
|
||||
#define SENSOR2PORT 11 // user sensor #2
|
||||
#define SENSOR3PORT 12 // user sensor #3
|
||||
|
@ -96,7 +96,7 @@ void enter_deepsleep(const int wakeup_sec, const gpio_num_t wakeup_gpio) {
|
||||
|
||||
// switch off display
|
||||
#ifdef HAS_DISPLAY
|
||||
shutdown_display();
|
||||
dp_shutdown();
|
||||
#endif
|
||||
|
||||
// switch off wifi & ble
|
||||
|
@ -111,7 +111,7 @@ void sendData() {
|
||||
}
|
||||
#ifdef HAS_DISPLAY
|
||||
else
|
||||
oledPlotCurve(macs.size(), true);
|
||||
dp_plotCurve(macs.size(), true);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user