Skip to content

Commit 5f946cd

Browse files
author
sgrimee
committed
lilygo_tlora_v1_6_1_tcxo: initial port
1 parent 405f703 commit 5f946cd

File tree

4 files changed

+222
-0
lines changed

4 files changed

+222
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include <Arduino.h>
4+
#include <helpers/ESP32Board.h>
5+
6+
// LILYGO T-LoRa V1.6.1 board with SX1276 and TCXO
7+
class LilyGoTLoraTCXOBoard : public ESP32Board {
8+
public:
9+
const char *getManufacturerName() const override { return "LILYGO T-LoRa V1.6.1 TCXO"; }
10+
11+
uint16_t getBattMilliVolts() override {
12+
analogReadResolution(12);
13+
14+
uint32_t raw = 0;
15+
for (int i = 0; i < 8; i++) {
16+
raw += analogReadMilliVolts(PIN_VBAT_READ);
17+
}
18+
raw = raw / 8;
19+
20+
return (2 * raw);
21+
}
22+
};
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
[LilyGo_TLora_V1_6_1_TCXO]
2+
extends = esp32_base
3+
board = ttgo-lora32-v1 ; LILYGO T-LoRa V1.6.1 ESP32 with SX1276 and TCXO
4+
build_unflags = -Os
5+
build_type = release
6+
board_build.partitions = min_spiffs.csv
7+
build_flags =
8+
${esp32_base.build_flags}
9+
${sensor_base.build_flags}
10+
-UENV_INCLUDE_GPS
11+
-I variants/lilygo_tlora_v1_6_1_tcxo
12+
-Os -ffunction-sections -fdata-sections
13+
-D LILYGO_TLORA_TCXO
14+
-D P_LORA_DIO_0=26
15+
-D P_LORA_DIO_1=RADIOLIB_NC ; TCXO variant uses NC for DIO1
16+
-D P_LORA_NSS=18
17+
-D P_LORA_RESET=23
18+
-D P_LORA_TCXO_EN=33 ; TCXO enable pin (required for this variant)
19+
-D P_LORA_SCLK=5
20+
-D P_LORA_MISO=19
21+
-D P_LORA_MOSI=27
22+
-D P_LORA_TX_LED=2
23+
-D PIN_BOARD_SDA=21
24+
-D PIN_BOARD_SCL=22
25+
-D PIN_VBAT_READ=35
26+
-D PIN_USER_BTN=0
27+
-D ARDUINO_LOOP_STACK_SIZE=16384
28+
-D DISPLAY_CLASS=SSD1306Display
29+
-D RADIO_CLASS=CustomSX1276
30+
-D WRAPPER_CLASS=CustomSX1276Wrapper
31+
-D SX127X_CURRENT_LIMIT=120
32+
-D LORA_TX_POWER=20
33+
build_src_filter = ${esp32_base.build_src_filter}
34+
+<helpers/ui/SSD1306Display.cpp>
35+
+<../variants/lilygo_tlora_v1_6_1_tcxo>
36+
+<helpers/sensors>
37+
lib_deps =
38+
${esp32_base.lib_deps}
39+
${sensor_base.lib_deps}
40+
41+
; === LILYGO T-LoRa V1.6.1 TCXO with SX1276 environments ===
42+
[env:LilyGo_TLora_V1_6_1_TCXO_companion_radio_ble]
43+
extends = LilyGo_TLora_V1_6_1_TCXO
44+
build_flags =
45+
${LilyGo_TLora_V1_6_1_TCXO.build_flags}
46+
-I examples/companion_radio/ui-new
47+
-D MAX_CONTACTS=160
48+
-D MAX_GROUP_CHANNELS=8
49+
-D BLE_PIN_CODE=123456
50+
-D OFFLINE_QUEUE_SIZE=256
51+
-D BLE_DEBUG_LOGGING=1
52+
-D MESH_PACKET_LOGGING=1
53+
-D MESH_DEBUG=1
54+
build_src_filter = ${LilyGo_TLora_V1_6_1_TCXO.build_src_filter}
55+
+<helpers/esp32/*.cpp>
56+
+<helpers/ui/MomentaryButton.cpp>
57+
+<../examples/companion_radio/*.cpp>
58+
+<../examples/companion_radio/ui-new/*.cpp>
59+
lib_deps =
60+
${LilyGo_TLora_V1_6_1_TCXO.lib_deps}
61+
densaugeo/base64 @ ~1.4.0
62+
63+
[env:LilyGo_TLora_V1_6_1_TCXO_companion_radio_usb]
64+
extends = LilyGo_TLora_V1_6_1_TCXO
65+
build_flags =
66+
${LilyGo_TLora_V1_6_1_TCXO.build_flags}
67+
-I examples/companion_radio/ui-new
68+
-D MAX_CONTACTS=160
69+
-D MAX_GROUP_CHANNELS=8
70+
; -D MESH_PACKET_LOGGING=1
71+
; -D MESH_DEBUG=1
72+
build_src_filter = ${LilyGo_TLora_V1_6_1_TCXO.build_src_filter}
73+
+<helpers/ui/MomentaryButton.cpp>
74+
+<../examples/companion_radio/*.cpp>
75+
+<../examples/companion_radio/ui-new/*.cpp>
76+
lib_deps =
77+
${LilyGo_TLora_V1_6_1_TCXO.lib_deps}
78+
densaugeo/base64 @ ~1.4.0
79+
80+
[env:LilyGo_TLora_V1_6_1_TCXO_repeater]
81+
extends = LilyGo_TLora_V1_6_1_TCXO
82+
build_src_filter = ${LilyGo_TLora_V1_6_1_TCXO.build_src_filter}
83+
+<../examples/simple_repeater>
84+
build_flags =
85+
${LilyGo_TLora_V1_6_1_TCXO.build_flags}
86+
-D ADVERT_NAME='"TLora-V1.6.1-TCXO Repeater"'
87+
-D ADVERT_LAT=0.0
88+
-D ADVERT_LON=0.0
89+
-D ADMIN_PASSWORD='"password"'
90+
-D MAX_NEIGHBOURS=50
91+
; -D MESH_PACKET_LOGGING=1
92+
; -D MESH_DEBUG=1
93+
; -D CORE_DEBUG_LEVEL=3
94+
lib_deps =
95+
${LilyGo_TLora_V1_6_1_TCXO.lib_deps}
96+
${esp32_ota.lib_deps}
97+
98+
[env:LilyGo_TLora_V1_6_1_TCXO_room_server]
99+
extends = LilyGo_TLora_V1_6_1_TCXO
100+
build_src_filter = ${LilyGo_TLora_V1_6_1_TCXO.build_src_filter}
101+
+<helpers/ui/SSD1306Display.cpp>
102+
+<../examples/simple_room_server>
103+
build_flags =
104+
${LilyGo_TLora_V1_6_1_TCXO.build_flags}
105+
-D ADVERT_NAME='"TLora-V1.6.1-TCXO Room"'
106+
-D ADVERT_LAT=0.0
107+
-D ADVERT_LON=0.0
108+
-D ADMIN_PASSWORD='"password"'
109+
-D ROOM_PASSWORD='"hello"'
110+
; -D MESH_PACKET_LOGGING=1
111+
; -D MESH_DEBUG=1
112+
lib_deps =
113+
${LilyGo_TLora_V1_6_1_TCXO.lib_deps}
114+
${esp32_ota.lib_deps}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include "target.h"
2+
3+
#include <Arduino.h>
4+
5+
LilyGoTLoraTCXOBoard board;
6+
7+
static SPIClass spi;
8+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
9+
10+
WRAPPER_CLASS radio_driver(radio, board);
11+
12+
ESP32RTCClock fallback_clock;
13+
AutoDiscoverRTCClock rtc_clock(fallback_clock);
14+
EnvironmentSensorManager sensors;
15+
16+
#ifdef DISPLAY_CLASS
17+
DISPLAY_CLASS display;
18+
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
19+
#endif
20+
21+
bool radio_init() {
22+
fallback_clock.begin();
23+
rtc_clock.begin(Wire);
24+
25+
// Enable TCXO before radio initialization (required for SX1276 TCXO variant)
26+
#ifdef P_LORA_TCXO_EN
27+
pinMode(P_LORA_TCXO_EN, OUTPUT);
28+
digitalWrite(P_LORA_TCXO_EN, HIGH);
29+
delay(50); // Allow TCXO to stabilize
30+
#endif
31+
32+
#if defined(P_LORA_SCLK)
33+
return radio.std_init(&spi);
34+
#else
35+
return radio.std_init();
36+
#endif
37+
}
38+
39+
uint32_t radio_get_rng_seed() {
40+
return radio.random(0x7FFFFFFF);
41+
}
42+
43+
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
44+
radio.setFrequency(freq);
45+
radio.setSpreadingFactor(sf);
46+
radio.setBandwidth(bw);
47+
radio.setCodingRate(cr);
48+
}
49+
50+
void radio_set_tx_power(uint8_t dbm) {
51+
radio.setOutputPower(dbm);
52+
}
53+
54+
mesh::LocalIdentity radio_new_identity() {
55+
RadioNoiseListener rng(radio);
56+
return mesh::LocalIdentity(&rng); // create new random identity
57+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#define RADIOLIB_STATIC_ONLY 1
4+
#include <LilyGoTLoraTCXOBoard.h>
5+
#include <RadioLib.h>
6+
#include <helpers/AutoDiscoverRTCClock.h>
7+
#include <helpers/radiolib/CustomSX1276Wrapper.h>
8+
#include <helpers/radiolib/RadioLibWrappers.h>
9+
#include <helpers/sensors/EnvironmentSensorManager.h>
10+
#ifdef DISPLAY_CLASS
11+
#include <helpers/ui/MomentaryButton.h>
12+
#include <helpers/ui/SSD1306Display.h>
13+
#endif
14+
15+
extern LilyGoTLoraTCXOBoard board;
16+
extern WRAPPER_CLASS radio_driver;
17+
extern AutoDiscoverRTCClock rtc_clock;
18+
extern EnvironmentSensorManager sensors;
19+
20+
#ifdef DISPLAY_CLASS
21+
extern DISPLAY_CLASS display;
22+
extern MomentaryButton user_btn;
23+
#endif
24+
25+
bool radio_init();
26+
uint32_t radio_get_rng_seed();
27+
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
28+
void radio_set_tx_power(uint8_t dbm);
29+
mesh::LocalIdentity radio_new_identity();

0 commit comments

Comments
 (0)