From 7534c5143fe89c21331b0e9c92b953ba62c7c67a Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Thu, 10 Apr 2025 16:24:17 +0200 Subject: [PATCH 1/5] display and btn handling starts working ... --- examples/companion_radio/UITask.cpp | 10 +++- examples/companion_radio/UITask.h | 1 + examples/companion_radio/main.cpp | 9 ++- src/helpers/ui/ST7789Display.cpp | 88 +++++++++++++++++++++++++++++ src/helpers/ui/ST7789Display.h | 33 +++++++++++ variants/t114/platformio.ini | 6 ++ variants/t114/variant.h | 19 ++++++- 7 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 src/helpers/ui/ST7789Display.cpp create mode 100644 src/helpers/ui/ST7789Display.h diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index 2d2e95a6..401284fb 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -43,6 +43,10 @@ void UITask::begin(DisplayDriver* display, const char* node_name, const char* bu *dash = 0; } + #ifdef PIN_USER_BTN + pinMode(PIN_USER_BTN, INPUT); + #endif + // v1.2.3 (1 Jan 2025) sprintf(_version_info, "%s (%s)", version, build_date); } @@ -57,6 +61,7 @@ void UITask::msgRead(int msgcount) { void UITask::clearMsgPreview() { _origin[0] = 0; _msg[0] = 0; + _need_refresh = true; } void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) { @@ -72,6 +77,7 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i if (_display != NULL) { if (!_display->isOn()) _display->turnOn(); _auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer + _need_refresh = true; } } @@ -114,6 +120,7 @@ void UITask::renderCurrScreen() { _display->print(tmp); } } + _need_refresh = false; } void UITask::userLedHandler() { @@ -157,6 +164,7 @@ void UITask::buttonHandler() { clearMsgPreview(); } else { _display->turnOn(); + _need_refresh = true; } _auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer } @@ -182,7 +190,7 @@ void UITask::loop() { userLedHandler(); if (_display != NULL && _display->isOn()) { - if (millis() >= _next_refresh) { + if (millis() >= _next_refresh && _need_refresh) { _display->startFrame(); renderCurrScreen(); _display->endFrame(); diff --git a/examples/companion_radio/UITask.h b/examples/companion_radio/UITask.h index 4cba1fca..9050bc42 100644 --- a/examples/companion_radio/UITask.h +++ b/examples/companion_radio/UITask.h @@ -15,6 +15,7 @@ class UITask { char _origin[62]; char _msg[80]; int _msgcount; + bool _need_refresh = true; void renderCurrScreen(); void buttonHandler(); diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 30e492ce..c68f827e 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -59,9 +59,12 @@ #ifdef DISPLAY_CLASS #include "UITask.h" - #include - - static DISPLAY_CLASS display; + #ifdef ST7789 + #include + #else + #include + #endif + static DISPLAY_CLASS display; #define HAS_UI #endif diff --git a/src/helpers/ui/ST7789Display.cpp b/src/helpers/ui/ST7789Display.cpp new file mode 100644 index 00000000..6f877230 --- /dev/null +++ b/src/helpers/ui/ST7789Display.cpp @@ -0,0 +1,88 @@ +#include "ST7789Display.h" + +bool ST7789Display::i2c_probe(TwoWire& wire, uint8_t addr) { + return true; +/* + wire.beginTransmission(addr); + uint8_t error = wire.endTransmission(); + return (error == 0); +*/ +} + +bool ST7789Display::begin() { + if(!_isOn) { + pinMode(PIN_TFT_VDD_CTL, OUTPUT); + pinMode(PIN_TFT_LEDA_CTL, OUTPUT); + digitalWrite(PIN_TFT_VDD_CTL, LOW); + digitalWrite(PIN_TFT_LEDA_CTL, LOW); + digitalWrite(PIN_TFT_RST, HIGH); + + display.init(135, 240); + display.setRotation(2); + display.setSPISpeed(40000000); + display.fillScreen(ST77XX_BLACK); + display.setTextColor(ST77XX_WHITE); + display.setTextSize(2); + display.cp437(true); // Use full 256 char 'Code Page 437' font + + _isOn = true; + } + return true; +} + +void ST7789Display::turnOn() { + ST7789Display::begin(); +} + +void ST7789Display::turnOff() { + digitalWrite(PIN_TFT_VDD_CTL, HIGH); + digitalWrite(PIN_TFT_LEDA_CTL, HIGH); + digitalWrite(PIN_TFT_RST, LOW); + // digitalWrite(PIN_TFT_VDD_CTL, LOW); + // digitalWrite(PIN_TFT_LEDA_CTL, LOW); + _isOn = false; +} + +void ST7789Display::clear() { + display.fillScreen(ST77XX_BLACK); +} + +void ST7789Display::startFrame(Color bkg) { + display.fillScreen(0x00); + display.setTextColor(ST77XX_WHITE); + display.setTextSize(2); + display.cp437(true); // Use full 256 char 'Code Page 437' font +} + +void ST7789Display::setTextSize(int sz) { + display.setTextSize(sz); +} + +void ST7789Display::setColor(Color c) { + _color = (c == LIGHT) ? ST77XX_WHITE : ST77XX_BLACK; + display.setTextColor(_color); +} + +void ST7789Display::setCursor(int x, int y) { + display.setCursor(x, y); +} + +void ST7789Display::print(const char* str) { + display.print(str); +} + +void ST7789Display::fillRect(int x, int y, int w, int h) { + display.fillRect(x, y, w, h, _color); +} + +void ST7789Display::drawRect(int x, int y, int w, int h) { + display.drawRect(x, y, w, h, _color); +} + +void ST7789Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { + display.drawBitmap(x, y, bits, w, h, ST77XX_BLUE); +} + +void ST7789Display::endFrame() { + // display.display(); +} diff --git a/src/helpers/ui/ST7789Display.h b/src/helpers/ui/ST7789Display.h new file mode 100644 index 00000000..0ddc7ae2 --- /dev/null +++ b/src/helpers/ui/ST7789Display.h @@ -0,0 +1,33 @@ +#pragma once + +#include "DisplayDriver.h" +#include +#include +#include +#include + +class ST7789Display : public DisplayDriver { + Adafruit_ST7789 display; + bool _isOn; + uint8_t _color; + + bool i2c_probe(TwoWire& wire, uint8_t addr); +public: + ST7789Display() : DisplayDriver(135, 240), display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST) { _isOn = false; } +// ST7789Display() : DisplayDriver(135, 240), display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST) { _isOn = false; } + bool begin(); + + bool isOn() override { return _isOn; } + void turnOn() override; + void turnOff() override; + void clear() override; + void startFrame(Color bkg = DARK) override; + void setTextSize(int sz) override; + void setColor(Color c) override; + void setCursor(int x, int y) override; + void print(const char* str) override; + void fillRect(int x, int y, int w, int h) override; + void drawRect(int x, int y, int w, int h) override; + void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override; + void endFrame() override; +}; diff --git a/variants/t114/platformio.ini b/variants/t114/platformio.ini index 61a722d0..d1be32e5 100644 --- a/variants/t114/platformio.ini +++ b/variants/t114/platformio.ini @@ -60,6 +60,9 @@ build_flags = extends = Heltec_t114 build_flags = ${Heltec_t114.build_flags} + -I src/helpers/ui + -D ST7789 + -D DISPLAY_CLASS=ST7789Display -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 @@ -71,9 +74,12 @@ build_flags = build_src_filter = ${Heltec_t114.build_src_filter} + +<../examples/companion_radio/main.cpp> + +<../examples/companion_radio/UITask.cpp> + + lib_deps = ${Heltec_t114.lib_deps} densaugeo/base64 @ ~1.4.0 + adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0 [env:Heltec_t114_companion_radio_usb] extends = Heltec_t114 diff --git a/variants/t114/variant.h b/variants/t114/variant.h index ee04861e..56fc536d 100644 --- a/variants/t114/variant.h +++ b/variants/t114/variant.h @@ -80,11 +80,13 @@ //////////////////////////////////////////////////////////////////////////////// // Builtin buttons -#define PIN_BUTTON1 (5) +#define PIN_BUTTON1 (42) #define BUTTON_PIN PIN_BUTTON1 -#define PIN_BUTTON2 (11) -#define BUTTON_PIN2 PIN_BUTTON2 +// #define PIN_BUTTON2 (11) +// #define BUTTON_PIN2 PIN_BUTTON2 + +#define PIN_USER_BTN BUTTON_PIN #define EXTERNAL_FLASH_DEVICES MX25R1635F #define EXTERNAL_FLASH_USE_QSPI @@ -108,3 +110,14 @@ // Buzzer #define PIN_BUZZER (46) + + +//////////////////////////////////////////////////////////////////////////////// +// TFT +#define PIN_TFT_SCL (40) +#define PIN_TFT_SDA (41) +#define PIN_TFT_RST (2) +#define PIN_TFT_VDD_CTL (3) +#define PIN_TFT_LEDA_CTL (15) +#define PIN_TFT_CS (11) +#define PIN_TFT_DC (12) From cf3d55201fdbe3864e870090f77536ceefa1e976 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 11 Apr 2025 22:23:47 +0200 Subject: [PATCH 2/5] ui : manage colors and ensure fw using ssd1306 still compile --- examples/companion_radio/UITask.cpp | 8 ++++++ src/helpers/ui/DisplayDriver.h | 2 +- src/helpers/ui/SSD1306Display.cpp | 2 +- src/helpers/ui/ST7789Display.cpp | 33 +++++++++++++++++++++-- src/helpers/ui/ST7789Display.h | 2 +- variants/heltec_v2/platformio.ini | 8 +++--- variants/heltec_v3/platformio.ini | 10 +++---- variants/lilygo_t3s3/platformio.ini | 8 +++--- variants/lilygo_tbeam/platformio.ini | 4 +-- variants/lilygo_tlora_v2_1/platformio.ini | 10 +++---- variants/rak4631/platformio.ini | 8 +++--- variants/t114/platformio.ini | 16 +++++++---- 12 files changed, 77 insertions(+), 34 deletions(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index 401284fb..01770363 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -89,22 +89,29 @@ void UITask::renderCurrScreen() { // render message preview _display->setCursor(0, 0); _display->setTextSize(1); + _display->setColor(DisplayDriver::GREEN); _display->print(_node_name); _display->setCursor(0, 12); + _display->setColor(DisplayDriver::YELLOW); _display->print(_origin); _display->setCursor(0, 24); + _display->setColor(DisplayDriver::LIGHT); _display->print(_msg); _display->setCursor(100, 9); _display->setTextSize(2); + _display->setColor(DisplayDriver::ORANGE); sprintf(tmp, "%d", _msgcount); _display->print(tmp); } else { // render 'home' screen + _display->setColor(DisplayDriver::BLUE); _display->drawXbm(0, 0, meshcore_logo, 128, 13); _display->setCursor(0, 20); _display->setTextSize(1); + + _display->setColor(DisplayDriver::LIGHT); _display->print(_node_name); _display->setCursor(0, 32); @@ -114,6 +121,7 @@ void UITask::renderCurrScreen() { //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); //_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr); } else if (_pin_code != 0) { + _display->setColor(DisplayDriver::RED); _display->setTextSize(2); _display->setCursor(0, 43); sprintf(tmp, "Pin:%d", _pin_code); diff --git a/src/helpers/ui/DisplayDriver.h b/src/helpers/ui/DisplayDriver.h index 7086b807..57aed85c 100644 --- a/src/helpers/ui/DisplayDriver.h +++ b/src/helpers/ui/DisplayDriver.h @@ -7,7 +7,7 @@ class DisplayDriver { protected: DisplayDriver(int w, int h) { _w = w; _h = h; } public: - enum Color { DARK, LIGHT }; + enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light int width() const { return _w; } int height() const { return _h; } diff --git a/src/helpers/ui/SSD1306Display.cpp b/src/helpers/ui/SSD1306Display.cpp index 911dd6fa..55516378 100644 --- a/src/helpers/ui/SSD1306Display.cpp +++ b/src/helpers/ui/SSD1306Display.cpp @@ -38,7 +38,7 @@ void SSD1306Display::setTextSize(int sz) { } void SSD1306Display::setColor(Color c) { - _color = (c == LIGHT) ? SSD1306_WHITE : SSD1306_BLACK; + _color = (c != 0) ? SSD1306_WHITE : SSD1306_BLACK; display.setTextColor(_color); } diff --git a/src/helpers/ui/ST7789Display.cpp b/src/helpers/ui/ST7789Display.cpp index 6f877230..8f04f872 100644 --- a/src/helpers/ui/ST7789Display.cpp +++ b/src/helpers/ui/ST7789Display.cpp @@ -1,3 +1,5 @@ +#ifdef ST7789 + #include "ST7789Display.h" bool ST7789Display::i2c_probe(TwoWire& wire, uint8_t addr) { @@ -59,7 +61,32 @@ void ST7789Display::setTextSize(int sz) { } void ST7789Display::setColor(Color c) { - _color = (c == LIGHT) ? ST77XX_WHITE : ST77XX_BLACK; + switch (c) { + case DisplayDriver::DARK : + _color = ST77XX_BLACK; + break; + case DisplayDriver::LIGHT : + _color = ST77XX_WHITE; + break; + case DisplayDriver::RED : + _color = ST77XX_RED; + break; + case DisplayDriver::GREEN : + _color = ST77XX_GREEN; + break; + case DisplayDriver::BLUE : + _color = ST77XX_BLUE; + break; + case DisplayDriver::YELLOW : + _color = ST77XX_YELLOW; + break; + case DisplayDriver::ORANGE : + _color = ST77XX_ORANGE; + break; + default: + _color = ST77XX_WHITE; + break; + } display.setTextColor(_color); } @@ -80,9 +107,11 @@ void ST7789Display::drawRect(int x, int y, int w, int h) { } void ST7789Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { - display.drawBitmap(x, y, bits, w, h, ST77XX_BLUE); + display.drawBitmap(x, y, bits, w, h, _color); } void ST7789Display::endFrame() { // display.display(); } + +#endif \ No newline at end of file diff --git a/src/helpers/ui/ST7789Display.h b/src/helpers/ui/ST7789Display.h index 0ddc7ae2..af319ef0 100644 --- a/src/helpers/ui/ST7789Display.h +++ b/src/helpers/ui/ST7789Display.h @@ -9,7 +9,7 @@ class ST7789Display : public DisplayDriver { Adafruit_ST7789 display; bool _isOn; - uint8_t _color; + uint16_t _color; bool i2c_probe(TwoWire& wire, uint8_t addr); public: diff --git a/variants/heltec_v2/platformio.ini b/variants/heltec_v2/platformio.ini index b8235906..bb1a8038 100644 --- a/variants/heltec_v2/platformio.ini +++ b/variants/heltec_v2/platformio.ini @@ -32,7 +32,7 @@ build_flags = ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} +<../examples/simple_repeater> - + + + lib_deps = ${Heltec_lora32_v2.lib_deps} ${esp32_ota.lib_deps} @@ -50,7 +50,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} - + + + +<../examples/simple_room_server> lib_deps = ${Heltec_lora32_v2.lib_deps} @@ -81,7 +81,7 @@ build_flags = ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} + - + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v2.lib_deps} @@ -102,7 +102,7 @@ build_flags = ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} + - + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v2.lib_deps} diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index 370ec8f2..49fa7434 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -34,7 +34,7 @@ build_flags = -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} - + + + +<../examples/simple_repeater> lib_deps = ${Heltec_lora32_v3.lib_deps} @@ -53,7 +53,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} - + + + +<../examples/simple_room_server> lib_deps = ${Heltec_lora32_v3.lib_deps} @@ -85,7 +85,7 @@ build_flags = ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} - + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v3.lib_deps} @@ -105,7 +105,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} - + + + + +<../examples/companion_radio> lib_deps = @@ -127,7 +127,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} - + + + + +<../examples/companion_radio> lib_deps = diff --git a/variants/lilygo_t3s3/platformio.ini b/variants/lilygo_t3s3/platformio.ini index 43b8d16d..c857d51d 100644 --- a/variants/lilygo_t3s3/platformio.ini +++ b/variants/lilygo_t3s3/platformio.ini @@ -45,7 +45,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} - + + + +<../examples/simple_repeater> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} @@ -78,7 +78,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} - + + + +<../examples/simple_room_server> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} @@ -96,7 +96,7 @@ build_flags = ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} - + + + +<../examples/companion_radio> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} @@ -117,7 +117,7 @@ build_flags = ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} + - + + + +<../examples/companion_radio> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} diff --git a/variants/lilygo_tbeam/platformio.ini b/variants/lilygo_tbeam/platformio.ini index 01ab38e7..129d2d32 100644 --- a/variants/lilygo_tbeam/platformio.ini +++ b/variants/lilygo_tbeam/platformio.ini @@ -39,7 +39,7 @@ build_flags = ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_TBeam.build_src_filter} + - + + + +<../examples/companion_radio> lib_deps = ${LilyGo_TBeam.lib_deps} @@ -57,7 +57,7 @@ build_flags = -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_TBeam.build_src_filter} - + + + +<../examples/simple_repeater> lib_deps = ${LilyGo_TBeam.lib_deps} diff --git a/variants/lilygo_tlora_v2_1/platformio.ini b/variants/lilygo_tlora_v2_1/platformio.ini index da183b2b..078efc9c 100644 --- a/variants/lilygo_tlora_v2_1/platformio.ini +++ b/variants/lilygo_tlora_v2_1/platformio.ini @@ -34,7 +34,7 @@ lib_deps = [env:LilyGo_TLora_V2_1_1_6_Repeater] extends = LilyGo_TLora_V2_1_1_6 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} - + + + +<../examples/simple_repeater> build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} @@ -58,7 +58,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} - + + + +<../examples/simple_repeater> lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} @@ -75,7 +75,7 @@ build_flags = ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} - + + + +<../examples/companion_radio> lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} @@ -95,7 +95,7 @@ build_flags = ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + - + + + +<../examples/companion_radio> lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} @@ -104,7 +104,7 @@ lib_deps = [env:LilyGo_TLora_V2_1_1_6_room_server] extends = LilyGo_TLora_V2_1_1_6 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} - + + + +<../examples/simple_room_server> build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 49955722..49319512 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -34,7 +34,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} - + + + +<../examples/simple_repeater> [env:RAK_4631_room_server] @@ -50,7 +50,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} - + + + +<../examples/simple_room_server> [env:RAK_4631_companion_radio_usb] @@ -65,7 +65,7 @@ build_flags = ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} - + + + +<../examples/companion_radio> lib_deps = ${rak4631.lib_deps} @@ -85,7 +85,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} - + + + + +<../examples/companion_radio> lib_deps = diff --git a/variants/t114/platformio.ini b/variants/t114/platformio.ini index d1be32e5..2abdfc69 100644 --- a/variants/t114/platformio.ini +++ b/variants/t114/platformio.ini @@ -60,9 +60,6 @@ build_flags = extends = Heltec_t114 build_flags = ${Heltec_t114.build_flags} - -I src/helpers/ui - -D ST7789 - -D DISPLAY_CLASS=ST7789Display -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 @@ -74,11 +71,20 @@ build_flags = build_src_filter = ${Heltec_t114.build_src_filter} + +<../examples/companion_radio/main.cpp> - +<../examples/companion_radio/UITask.cpp> - + lib_deps = ${Heltec_t114.lib_deps} densaugeo/base64 @ ~1.4.0 + +[env:Heltec_t114_companion_radio_ble_screen] +extends = env:Heltec_t114_companion_radio_ble +build_flags = ${env:Heltec_t114_companion_radio_ble.build_flags} + -I src/helpers/ui + -D ST7789 + -D DISPLAY_CLASS=ST7789Display +build_src_filter = ${env:Heltec_t114_companion_radio_ble.build_src_filter} + +<../examples/companion_radio/UITask.cpp> + + +lib_deps = ${env:Heltec_t114_companion_radio_ble.lib_deps} adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0 [env:Heltec_t114_companion_radio_usb] From fbfa8bbe57f4f240cfb2bcb805bbda97a5a123be Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Tue, 15 Apr 2025 15:15:06 +1000 Subject: [PATCH 3/5] * fix: compilation error for T1000e --- src/helpers/nrf52/T1000eBoard.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/helpers/nrf52/T1000eBoard.h b/src/helpers/nrf52/T1000eBoard.h index 9511706b..24584757 100644 --- a/src/helpers/nrf52/T1000eBoard.h +++ b/src/helpers/nrf52/T1000eBoard.h @@ -29,12 +29,16 @@ public: uint16_t getBattMilliVolts() override { #ifdef BATTERY_PIN + #ifdef PIN_3V3_EN digitalWrite(PIN_3V3_EN, HIGH); + #endif analogReference(AR_INTERNAL_3_0); analogReadResolution(12); delay(10); float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096; + #ifdef PIN_3V3_EN digitalWrite(PIN_3V3_EN, LOW); + #endif analogReference(AR_DEFAULT); // put back to default analogReadResolution(10); From b17196acb4aac75e155593862c509c5f9e79ad16 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Wed, 16 Apr 2025 16:51:04 +1000 Subject: [PATCH 4/5] * room server login response now includes unsynced posts counter --- examples/simple_room_server/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 235638f8..c778e81a 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -232,6 +232,17 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks { } } + uint8_t getUnsyncedCount(ClientInfo* client) { + uint8_t count = 0; + for (int k = 0; k < MAX_UNSYNCED_POSTS; k++) { + if (posts[k].post_timestamp > client->sync_since // is new post for this Client? + && !posts[k].author.matches(client->id)) { // don't push posts to the author + count++; + } + } + return count; + } + bool processAck(const uint8_t *data) { for (int i = 0; i < num_clients; i++) { auto client = &known_clients[i]; @@ -398,7 +409,7 @@ protected: reply_data[4] = RESP_SERVER_LOGIN_OK; reply_data[5] = (CLIENT_KEEP_ALIVE_SECS >> 4); // NEW: recommended keep-alive interval (secs / 16) reply_data[6] = (perm == RoomPermission::ADMIN ? 1 : (perm == RoomPermission::GUEST ? 0 : 2)); - reply_data[7] = 0; // FUTURE: reserved + reply_data[7] = getUnsyncedCount(client); // NEW memcpy(&reply_data[8], "OK", 2); // REVISIT: not really needed next_push = futureMillis(PUSH_NOTIFY_DELAY_MILLIS); // delay next push, give RESPONSE packet time to arrive first From 7b1582a0b91258a6a9f525e58967ea5ef3ca12da Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Thu, 17 Apr 2025 15:46:51 +1000 Subject: [PATCH 5/5] * room server keep_alive ACKs now have unsynced_count appended. --- examples/simple_room_server/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index c778e81a..3afe76c8 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -583,6 +583,7 @@ protected: auto reply = createAck(ack_hash); if (reply) { + reply->payload[reply->payload_len++] = getUnsyncedCount(client); // NEW: add unsynced counter to end of ACK packet sendDirect(reply, client->out_path, client->out_path_len); } }