From d8f80f259a962d4437f9bd69840955a02b0c064e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Br=C3=A1zio?= Date: Thu, 4 Sep 2025 13:25:10 +0100 Subject: [PATCH] Refactor display driver inclusion for Heltec T114 to support configurations without a display --- variants/heltec_t114/NullDisplayDriver.h | 24 ++++++ variants/heltec_t114/platformio.ini | 105 +++++++++++++++++++++-- variants/heltec_t114/target.h | 9 +- 3 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 variants/heltec_t114/NullDisplayDriver.h diff --git a/variants/heltec_t114/NullDisplayDriver.h b/variants/heltec_t114/NullDisplayDriver.h new file mode 100644 index 00000000..2a9670bd --- /dev/null +++ b/variants/heltec_t114/NullDisplayDriver.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +class NullDisplayDriver : public DisplayDriver { +public: + NullDisplayDriver() : DisplayDriver(128, 64) { } + bool begin() { return false; } // not present + + bool isOn() override { return false; } + 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 { } + uint16_t getTextWidth(const char* str) override { return 0; } + void endFrame() { } +}; diff --git a/variants/heltec_t114/platformio.ini b/variants/heltec_t114/platformio.ini index 2cac2eae..e17ac10c 100644 --- a/variants/heltec_t114/platformio.ini +++ b/variants/heltec_t114/platformio.ini @@ -1,3 +1,6 @@ +; +; Heltec T114 without display +; [Heltec_t114] extends = nrf52_base board = heltec_t114 @@ -24,15 +27,11 @@ build_flags = ${nrf52_base.build_flags} -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 + -D DISPLAY_CLASS=NullDisplayDriver -D ST7789 - -D DISPLAY_CLASS=ST7789Display build_src_filter = ${nrf52_base.build_src_filter} + +<../variants/heltec_t114> - + - + - + - + lib_deps = ${nrf52_base.lib_deps} stevemarple/MicroNMEA @ ^2.0.6 @@ -40,7 +39,7 @@ lib_deps = debug_tool = jlink upload_protocol = nrfutil -[env:Heltec_t114_repeater] +[env:Heltec_t114_without_display_repeater] extends = Heltec_t114 build_src_filter = ${Heltec_t114.build_src_filter} +<../examples/simple_repeater> @@ -55,7 +54,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -[env:Heltec_t114_room_server] +[env:Heltec_t114_without_display_room_server] extends = Heltec_t114 build_src_filter = ${Heltec_t114.build_src_filter} +<../examples/simple_room_server> @@ -69,7 +68,7 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -[env:Heltec_t114_companion_radio_ble] +[env:Heltec_t114_without_display_companion_radio_ble] extends = Heltec_t114 build_flags = ${Heltec_t114.build_flags} @@ -89,7 +88,7 @@ lib_deps = ${Heltec_t114.lib_deps} densaugeo/base64 @ ~1.4.0 -[env:Heltec_t114_companion_radio_usb] +[env:Heltec_t114_without_display_companion_radio_usb] extends = Heltec_t114 build_flags = ${Heltec_t114.build_flags} @@ -106,4 +105,92 @@ build_src_filter = ${Heltec_t114.build_src_filter} +<../examples/companion_radio/ui-new/*.cpp> lib_deps = ${Heltec_t114.lib_deps} + densaugeo/base64 @ ~1.4.0 + +; +; Heltec T114 with ST7789 display +; +[Heltec_t114_with_display] +extends = Heltec_t114 +board = heltec_t114 +board_build.ldscript = boards/nrf52840_s140_v6.ld +build_flags = ${Heltec_t114.build_flags} + -D HELTEC_T114_WITH_DISPLAY + -D DISPLAY_CLASS=ST7789Display +build_src_filter = ${Heltec_t114.build_src_filter} + + + + + + + + +lib_deps = + ${Heltec_t114.lib_deps} +debug_tool = jlink +upload_protocol = nrfutil + +[env:Heltec_t114_repeater] +extends = Heltec_t114_with_display +build_src_filter = ${Heltec_t114_with_display.build_src_filter} + +<../examples/simple_repeater> + +build_flags = + ${Heltec_t114_with_display.build_flags} + -D ADVERT_NAME='"Heltec_T114 Repeater"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=8 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + +[env:Heltec_t114_room_server] +extends = Heltec_t114_with_display +build_src_filter = ${Heltec_t114_with_display.build_src_filter} + +<../examples/simple_room_server> +build_flags = + ${Heltec_t114_with_display.build_flags} + -D ADVERT_NAME='"Heltec_T114 Room"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + +[env:Heltec_t114_companion_radio_ble] +extends = Heltec_t114_with_display +build_flags = + ${Heltec_t114_with_display.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 + -D BLE_PIN_CODE=123456 +; -D BLE_DEBUG_LOGGING=1 + -D OFFLINE_QUEUE_SIZE=256 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Heltec_t114_with_display.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Heltec_t114_with_display.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:Heltec_t114_companion_radio_usb] +extends = Heltec_t114_with_display +build_flags = + ${Heltec_t114_with_display.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 +; -D BLE_PIN_CODE=123456 +; -D BLE_DEBUG_LOGGING=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Heltec_t114_with_display.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Heltec_t114_with_display.lib_deps} densaugeo/base64 @ ~1.4.0 \ No newline at end of file diff --git a/variants/heltec_t114/target.h b/variants/heltec_t114/target.h index 053a7c44..3283f009 100644 --- a/variants/heltec_t114/target.h +++ b/variants/heltec_t114/target.h @@ -8,9 +8,14 @@ #include #include #include + #ifdef DISPLAY_CLASS - #include - #include +#include +#ifdef HELTEC_T114_WITH_DISPLAY +#include +#else +#include "NullDisplayDriver.h" +#endif #endif class T114SensorManager : public SensorManager {