Skip to content

Commit d8f80f2

Browse files
committed
Refactor display driver inclusion for Heltec T114 to support configurations without a display
1 parent f907998 commit d8f80f2

File tree

3 files changed

+127
-11
lines changed

3 files changed

+127
-11
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <helpers/ui/DisplayDriver.h>
4+
5+
class NullDisplayDriver : public DisplayDriver {
6+
public:
7+
NullDisplayDriver() : DisplayDriver(128, 64) { }
8+
bool begin() { return false; } // not present
9+
10+
bool isOn() override { return false; }
11+
void turnOn() override { }
12+
void turnOff() override { }
13+
void clear() override { }
14+
void startFrame(Color bkg = DARK) override { }
15+
void setTextSize(int sz) override { }
16+
void setColor(Color c) override { }
17+
void setCursor(int x, int y) override { }
18+
void print(const char* str) override { }
19+
void fillRect(int x, int y, int w, int h) override { }
20+
void drawRect(int x, int y, int w, int h) override { }
21+
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override { }
22+
uint16_t getTextWidth(const char* str) override { return 0; }
23+
void endFrame() { }
24+
};

variants/heltec_t114/platformio.ini

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
;
2+
; Heltec T114 without display
3+
;
14
[Heltec_t114]
25
extends = nrf52_base
36
board = heltec_t114
@@ -24,23 +27,19 @@ build_flags = ${nrf52_base.build_flags}
2427
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
2528
-D SX126X_CURRENT_LIMIT=140
2629
-D SX126X_RX_BOOSTED_GAIN=1
30+
-D DISPLAY_CLASS=NullDisplayDriver
2731
-D ST7789
28-
-D DISPLAY_CLASS=ST7789Display
2932
build_src_filter = ${nrf52_base.build_src_filter}
3033
+<helpers/*.cpp>
3134
+<../variants/heltec_t114>
32-
+<helpers/ui/ST7789Display.cpp>
33-
+<helpers/ui/MomentaryButton.cpp>
34-
+<helpers/ui/OLEDDisplay.cpp>
35-
+<helpers/ui/OLEDDisplayFonts.cpp>
3635
lib_deps =
3736
${nrf52_base.lib_deps}
3837
stevemarple/MicroNMEA @ ^2.0.6
3938
adafruit/Adafruit GFX Library @ ^1.12.1
4039
debug_tool = jlink
4140
upload_protocol = nrfutil
4241

43-
[env:Heltec_t114_repeater]
42+
[env:Heltec_t114_without_display_repeater]
4443
extends = Heltec_t114
4544
build_src_filter = ${Heltec_t114.build_src_filter}
4645
+<../examples/simple_repeater>
@@ -55,7 +54,7 @@ build_flags =
5554
; -D MESH_PACKET_LOGGING=1
5655
; -D MESH_DEBUG=1
5756

58-
[env:Heltec_t114_room_server]
57+
[env:Heltec_t114_without_display_room_server]
5958
extends = Heltec_t114
6059
build_src_filter = ${Heltec_t114.build_src_filter}
6160
+<../examples/simple_room_server>
@@ -69,7 +68,7 @@ build_flags =
6968
; -D MESH_PACKET_LOGGING=1
7069
; -D MESH_DEBUG=1
7170

72-
[env:Heltec_t114_companion_radio_ble]
71+
[env:Heltec_t114_without_display_companion_radio_ble]
7372
extends = Heltec_t114
7473
build_flags =
7574
${Heltec_t114.build_flags}
@@ -89,7 +88,7 @@ lib_deps =
8988
${Heltec_t114.lib_deps}
9089
densaugeo/base64 @ ~1.4.0
9190

92-
[env:Heltec_t114_companion_radio_usb]
91+
[env:Heltec_t114_without_display_companion_radio_usb]
9392
extends = Heltec_t114
9493
build_flags =
9594
${Heltec_t114.build_flags}
@@ -106,4 +105,92 @@ build_src_filter = ${Heltec_t114.build_src_filter}
106105
+<../examples/companion_radio/ui-new/*.cpp>
107106
lib_deps =
108107
${Heltec_t114.lib_deps}
108+
densaugeo/base64 @ ~1.4.0
109+
110+
;
111+
; Heltec T114 with ST7789 display
112+
;
113+
[Heltec_t114_with_display]
114+
extends = Heltec_t114
115+
board = heltec_t114
116+
board_build.ldscript = boards/nrf52840_s140_v6.ld
117+
build_flags = ${Heltec_t114.build_flags}
118+
-D HELTEC_T114_WITH_DISPLAY
119+
-D DISPLAY_CLASS=ST7789Display
120+
build_src_filter = ${Heltec_t114.build_src_filter}
121+
+<helpers/ui/ST7789Display.cpp>
122+
+<helpers/ui/MomentaryButton.cpp>
123+
+<helpers/ui/OLEDDisplay.cpp>
124+
+<helpers/ui/OLEDDisplayFonts.cpp>
125+
lib_deps =
126+
${Heltec_t114.lib_deps}
127+
debug_tool = jlink
128+
upload_protocol = nrfutil
129+
130+
[env:Heltec_t114_repeater]
131+
extends = Heltec_t114_with_display
132+
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
133+
+<../examples/simple_repeater>
134+
135+
build_flags =
136+
${Heltec_t114_with_display.build_flags}
137+
-D ADVERT_NAME='"Heltec_T114 Repeater"'
138+
-D ADVERT_LAT=0.0
139+
-D ADVERT_LON=0.0
140+
-D ADMIN_PASSWORD='"password"'
141+
-D MAX_NEIGHBOURS=8
142+
; -D MESH_PACKET_LOGGING=1
143+
; -D MESH_DEBUG=1
144+
145+
[env:Heltec_t114_room_server]
146+
extends = Heltec_t114_with_display
147+
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
148+
+<../examples/simple_room_server>
149+
build_flags =
150+
${Heltec_t114_with_display.build_flags}
151+
-D ADVERT_NAME='"Heltec_T114 Room"'
152+
-D ADVERT_LAT=0.0
153+
-D ADVERT_LON=0.0
154+
-D ADMIN_PASSWORD='"password"'
155+
-D ROOM_PASSWORD='"hello"'
156+
; -D MESH_PACKET_LOGGING=1
157+
; -D MESH_DEBUG=1
158+
159+
[env:Heltec_t114_companion_radio_ble]
160+
extends = Heltec_t114_with_display
161+
build_flags =
162+
${Heltec_t114_with_display.build_flags}
163+
-I examples/companion_radio/ui-new
164+
-D MAX_CONTACTS=100
165+
-D MAX_GROUP_CHANNELS=8
166+
-D BLE_PIN_CODE=123456
167+
; -D BLE_DEBUG_LOGGING=1
168+
-D OFFLINE_QUEUE_SIZE=256
169+
; -D MESH_PACKET_LOGGING=1
170+
; -D MESH_DEBUG=1
171+
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
172+
+<helpers/nrf52/SerialBLEInterface.cpp>
173+
+<../examples/companion_radio/*.cpp>
174+
+<../examples/companion_radio/ui-new/*.cpp>
175+
lib_deps =
176+
${Heltec_t114_with_display.lib_deps}
177+
densaugeo/base64 @ ~1.4.0
178+
179+
[env:Heltec_t114_companion_radio_usb]
180+
extends = Heltec_t114_with_display
181+
build_flags =
182+
${Heltec_t114_with_display.build_flags}
183+
-I examples/companion_radio/ui-new
184+
-D MAX_CONTACTS=100
185+
-D MAX_GROUP_CHANNELS=8
186+
; -D BLE_PIN_CODE=123456
187+
; -D BLE_DEBUG_LOGGING=1
188+
; -D MESH_PACKET_LOGGING=1
189+
; -D MESH_DEBUG=1
190+
build_src_filter = ${Heltec_t114_with_display.build_src_filter}
191+
+<helpers/nrf52/*.cpp>
192+
+<../examples/companion_radio/*.cpp>
193+
+<../examples/companion_radio/ui-new/*.cpp>
194+
lib_deps =
195+
${Heltec_t114_with_display.lib_deps}
109196
densaugeo/base64 @ ~1.4.0

variants/heltec_t114/target.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
#include <helpers/AutoDiscoverRTCClock.h>
99
#include <helpers/SensorManager.h>
1010
#include <helpers/sensors/LocationProvider.h>
11+
1112
#ifdef DISPLAY_CLASS
12-
#include <helpers/ui/ST7789Display.h>
13-
#include <helpers/ui/MomentaryButton.h>
13+
#include <helpers/ui/MomentaryButton.h>
14+
#ifdef HELTEC_T114_WITH_DISPLAY
15+
#include <helpers/ui/ST7789Display.h>
16+
#else
17+
#include "NullDisplayDriver.h"
18+
#endif
1419
#endif
1520

1621
class T114SensorManager : public SensorManager {

0 commit comments

Comments
 (0)