Skip to content

Commit d4856a5

Browse files
authored
Merge pull request #617 from Quency-D/dev-heltec_t190_board
Add heltec_vision_master_t190 board.
2 parents e1c169b + ec6d119 commit d4856a5

File tree

9 files changed

+390
-2
lines changed

9 files changed

+390
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "esp32s3_out.ld",
5+
"partitions": "default_16MB.csv",
6+
"memory_type": "qio_opi"
7+
},
8+
"core": "esp32",
9+
"extra_flags": [
10+
"-DBOARD_HAS_PSRAM",
11+
"-DARDUINO_USB_MODE=0",
12+
"-DARDUINO_USB_CDC_ON_BOOT=1",
13+
"-DARDUINO_RUNNING_CORE=1",
14+
"-DARDUINO_EVENT_RUNNING_CORE=1"
15+
],
16+
"f_cpu": "240000000L",
17+
"f_flash": "80000000L",
18+
"flash_mode": "qio",
19+
"psram_type": "opi",
20+
"hwids": [
21+
["0x303A", "0x1001"],
22+
["0x303A", "0x0002"]
23+
],
24+
"mcu": "esp32s3",
25+
"variant": "heltec_vision_master_t190"
26+
},
27+
"connectivity": ["wifi", "bluetooth", "lora"],
28+
"debug": {
29+
"openocd_target": "esp32s3.cfg"
30+
},
31+
"frameworks": ["arduino", "espidf"],
32+
"name": "Heltec Vision Master T190",
33+
"upload": {
34+
"flash_size": "16MB",
35+
"maximum_ram_size": 8388608,
36+
"maximum_size": 16777216,
37+
"use_1200bps_touch": true,
38+
"wait_for_upload_port": true,
39+
"require_upload_port": true,
40+
"speed": 921600
41+
},
42+
"url": "https://heltec.org/project/vision-master-t190/",
43+
"vendor": "Heltec"
44+
}

src/helpers/ui/ST7789Display.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ bool ST7789Display::begin() {
1818
pinMode(PIN_TFT_VDD_CTL, OUTPUT);
1919
pinMode(PIN_TFT_LEDA_CTL, OUTPUT);
2020
digitalWrite(PIN_TFT_VDD_CTL, LOW);
21+
#ifdef PIN_TFT_LEDA_CTL_ACTIVE
22+
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
23+
#else
2124
digitalWrite(PIN_TFT_LEDA_CTL, LOW);
25+
#endif
2226
digitalWrite(PIN_TFT_RST, HIGH);
2327

2428
display.init();
@@ -43,15 +47,22 @@ void ST7789Display::turnOn() {
4347
delay(20);
4448

4549
// Now turn on the backlight
50+
#ifdef PIN_TFT_LEDA_CTL_ACTIVE
51+
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
52+
#else
4653
digitalWrite(PIN_TFT_LEDA_CTL, LOW);
47-
54+
#endif
4855
_isOn = true;
4956
}
5057
}
5158

5259
void ST7789Display::turnOff() {
5360
digitalWrite(PIN_TFT_VDD_CTL, HIGH);
61+
#ifdef PIN_TFT_LEDA_CTL_ACTIVE
62+
digitalWrite(PIN_TFT_LEDA_CTL, !PIN_TFT_LEDA_CTL_ACTIVE);
63+
#else
5464
digitalWrite(PIN_TFT_LEDA_CTL, HIGH);
65+
#endif
5566
digitalWrite(PIN_TFT_RST, LOW);
5667
_isOn = false;
5768
}

src/helpers/ui/ST7789Display.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ class ST7789Display : public DisplayDriver {
1414

1515
bool i2c_probe(TwoWire& wire, uint8_t addr);
1616
public:
17+
#ifdef HELTEC_VISION_MASTER_T190
18+
ST7789Display() : DisplayDriver(128, 64), display(&SPI, PIN_TFT_RST, PIN_TFT_DC, PIN_TFT_CS, GEOMETRY_RAWMODE, 320, 170,PIN_TFT_SDA,-1,PIN_TFT_SCL) {_isOn = false;}
19+
#else
1720
ST7789Display() : DisplayDriver(128, 64), display(&SPI1, PIN_TFT_RST, PIN_TFT_DC, PIN_TFT_CS, GEOMETRY_RAWMODE, 240, 135) {_isOn = false;}
18-
21+
#endif
1922
bool begin();
2023

2124
bool isOn() override { return _isOn; }
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "HeltecT190Board.h"
2+
3+
void HeltecT190Board::begin() {
4+
ESP32Board::begin();
5+
6+
pinMode(PIN_ADC_CTRL, OUTPUT);
7+
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
8+
9+
periph_power.begin();
10+
11+
esp_reset_reason_t reason = esp_reset_reason();
12+
if (reason == ESP_RST_DEEPSLEEP) {
13+
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
14+
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
15+
startup_reason = BD_STARTUP_RX_PACKET;
16+
}
17+
18+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
19+
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
20+
}
21+
}
22+
23+
void HeltecT190Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
24+
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
25+
26+
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
27+
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
28+
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
29+
30+
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
31+
32+
if (pin_wake_btn < 0) {
33+
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
34+
} else {
35+
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
36+
}
37+
38+
if (secs > 0) {
39+
esp_sleep_enable_timer_wakeup(secs * 1000000);
40+
}
41+
42+
// Finally set ESP32 into sleep
43+
esp_deep_sleep_start(); // CPU halts here and never returns!
44+
}
45+
46+
void HeltecT190Board::powerOff() {
47+
// TODO: re-enable this when there is a definite wake-up source pin:
48+
// enterDeepSleep(0);
49+
}
50+
51+
uint16_t HeltecT190Board::getBattMilliVolts() {
52+
analogReadResolution(10);
53+
digitalWrite(PIN_ADC_CTRL, HIGH);
54+
delay(10);
55+
uint32_t raw = 0;
56+
for (int i = 0; i < 8; i++) {
57+
raw += analogRead(PIN_VBAT_READ);
58+
}
59+
raw = raw / 8;
60+
61+
digitalWrite(PIN_ADC_CTRL, LOW);
62+
63+
return (5.42 * (3.3 / 1024.0) * raw) * 1000;
64+
}
65+
66+
const char* HeltecT190Board::getManufacturerName() const {
67+
return "Heltec T190";
68+
}
69+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include <Arduino.h>
4+
#include <helpers/RefCountedDigitalPin.h>
5+
#include <helpers/ESP32Board.h>
6+
#include <driver/rtc_io.h>
7+
8+
// LoRa radio module pins for heltec_vision_master_e290
9+
#define P_LORA_DIO_1 14
10+
#define P_LORA_NSS 8
11+
#define P_LORA_RESET 12
12+
#define P_LORA_BUSY 13
13+
#define P_LORA_SCLK 9
14+
#define P_LORA_MISO 11
15+
#define P_LORA_MOSI 10
16+
17+
class HeltecT190Board : public ESP32Board {
18+
19+
public:
20+
RefCountedDigitalPin periph_power;
21+
22+
HeltecT190Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
23+
24+
void begin();
25+
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
26+
void powerOff() override;
27+
uint16_t getBattMilliVolts() override;
28+
const char* getManufacturerName() const override ;
29+
30+
};
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
static const uint8_t LED_BUILTIN = 45; // LED is not populated on earliest board variant
7+
#define BUILTIN_LED LED_BUILTIN // Backward compatibility
8+
#define LED_BUILTIN LED_BUILTIN
9+
10+
static const uint8_t TX = 43;
11+
static const uint8_t RX = 44;
12+
13+
static const uint8_t SDA = 2;
14+
static const uint8_t SCL = 1;
15+
16+
static const uint8_t SS = 8;
17+
static const uint8_t MOSI = 10;
18+
static const uint8_t MISO = 11;
19+
static const uint8_t SCK = 9;
20+
21+
static const uint8_t A0 = 1;
22+
static const uint8_t A1 = 2;
23+
static const uint8_t A2 = 3;
24+
static const uint8_t A3 = 4;
25+
static const uint8_t A4 = 5;
26+
static const uint8_t A5 = 6;
27+
static const uint8_t A6 = 7;
28+
static const uint8_t A7 = 8;
29+
static const uint8_t A8 = 9;
30+
static const uint8_t A9 = 10;
31+
static const uint8_t A10 = 11;
32+
static const uint8_t A11 = 12;
33+
static const uint8_t A12 = 13;
34+
static const uint8_t A13 = 14;
35+
static const uint8_t A14 = 15;
36+
static const uint8_t A15 = 16;
37+
static const uint8_t A16 = 17;
38+
static const uint8_t A17 = 18;
39+
static const uint8_t A18 = 19;
40+
static const uint8_t A19 = 20;
41+
42+
static const uint8_t T1 = 1;
43+
static const uint8_t T2 = 2;
44+
static const uint8_t T3 = 3;
45+
static const uint8_t T4 = 4;
46+
static const uint8_t T5 = 5;
47+
static const uint8_t T6 = 6;
48+
static const uint8_t T7 = 7;
49+
static const uint8_t T8 = 8;
50+
static const uint8_t T9 = 9;
51+
static const uint8_t T10 = 10;
52+
static const uint8_t T11 = 11;
53+
static const uint8_t T12 = 12;
54+
static const uint8_t T13 = 13;
55+
static const uint8_t T14 = 14;
56+
57+
static const uint8_t RST_LoRa = 12;
58+
static const uint8_t BUSY_LoRa = 13;
59+
static const uint8_t DIO1 = 14;
60+
61+
#endif /* Pins_Arduino_h */
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[Heltec_Vision_Master_T190_base]
2+
extends = esp32_base
3+
board = heltec_vision_master_t190
4+
build_flags =
5+
${esp32_base.build_flags}
6+
-I variants/heltec_vision_master_t190
7+
-I src/helpers/ui
8+
-D HELTEC_VISION_MASTER_T190
9+
-D RADIO_CLASS=CustomSX1262
10+
-D WRAPPER_CLASS=CustomSX1262Wrapper
11+
-D LORA_TX_POWER=22
12+
-D PIN_USER_BTN=0
13+
-D PIN_VEXT_EN=5
14+
-D PIN_VEXT_EN_ACTIVE=HIGH
15+
-D PIN_VBAT_READ=6
16+
-D PIN_ADC_CTRL=46
17+
-D SX126X_DIO2_AS_RF_SWITCH=true
18+
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
19+
-D SX126X_CURRENT_LIMIT=140
20+
-D SX126X_RX_BOOSTED_GAIN=1
21+
-D PIN_BOARD_SDA=2
22+
-D PIN_BOARD_SCL=1
23+
-D PIN_TFT_SCL=38
24+
-D PIN_TFT_SDA=48
25+
-D PIN_TFT_RST=40
26+
-D PIN_TFT_VDD_CTL=7
27+
-D PIN_TFT_LEDA_CTL=17
28+
-D PIN_TFT_LEDA_CTL_ACTIVE=HIGH
29+
-D PIN_TFT_CS=39
30+
-D PIN_TFT_DC=47
31+
-D ST7789
32+
-D DISPLAY_CLASS=ST7789Display
33+
build_src_filter = ${esp32_base.build_src_filter}
34+
+<../variants/heltec_vision_master_t190>
35+
+<helpers/*.cpp>
36+
+<helpers/ui/ST7789Display.cpp>
37+
+<helpers/ui/OLEDDisplay.cpp>
38+
+<helpers/ui/OLEDDisplayFonts.cpp>
39+
lib_deps =
40+
${esp32_base.lib_deps}
41+
adafruit/Adafruit GFX Library @ ^1.12.1
42+
43+
[env:Heltec_Vision_Master_T190_radio_ble]
44+
extends = Heltec_Vision_Master_T190_base
45+
build_flags =
46+
${Heltec_Vision_Master_T190_base.build_flags}
47+
-I examples/companion_radio/ui-new
48+
-D MAX_CONTACTS=100
49+
-D MAX_GROUP_CHANNELS=8
50+
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
51+
-D BLE_DEBUG_LOGGING=1
52+
-D OFFLINE_QUEUE_SIZE=256
53+
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter}
54+
+<helpers/esp32/*.cpp>
55+
+<../examples/companion_radio/*.cpp>
56+
+<../examples/companion_radio/ui-new/*.cpp>
57+
lib_deps =
58+
${Heltec_Vision_Master_T190_base.lib_deps}
59+
densaugeo/base64 @ ~1.4.0
60+
61+
[env:Heltec_Vision_Master_T190_repeater]
62+
extends = Heltec_Vision_Master_T190_base
63+
build_flags =
64+
${Heltec_Vision_Master_T190_base.build_flags}
65+
-D ADVERT_NAME='"Heltec T190 Repeater"'
66+
-D ADVERT_LAT=0.0
67+
-D ADVERT_LON=0.0
68+
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter}
69+
+<../examples/simple_repeater>
70+
lib_deps =
71+
${Heltec_Vision_Master_T190_base.lib_deps}
72+
${esp32_ota.lib_deps}
73+
74+
[env:Heltec_Vision_Master_T190_room_server]
75+
extends = Heltec_Vision_Master_T190_base
76+
build_flags =
77+
${Heltec_Vision_Master_T190_base.build_flags}
78+
-D ADVERT_NAME='"Heltec T190 Room"'
79+
-D ADVERT_LAT=0.0
80+
-D ADVERT_LON=0.0
81+
-D ADMIN_PASSWORD='"password"'
82+
-D ROOM_PASSWORD='"hello"'
83+
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter}
84+
+<../examples/simple_room_server>
85+
lib_deps =
86+
${Heltec_Vision_Master_T190_base.lib_deps}
87+
${esp32_ota.lib_deps}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include "target.h"
2+
#include <Arduino.h>
3+
4+
HeltecT190Board board;
5+
6+
#if defined(P_LORA_SCLK)
7+
static SPIClass spi(FSPI);
8+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
9+
#else
10+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
11+
#endif
12+
13+
WRAPPER_CLASS radio_driver(radio, board);
14+
15+
ESP32RTCClock fallback_clock;
16+
AutoDiscoverRTCClock rtc_clock(fallback_clock);
17+
18+
SensorManager sensors;
19+
20+
#ifdef DISPLAY_CLASS
21+
DISPLAY_CLASS display;
22+
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
23+
#endif
24+
25+
bool radio_init() {
26+
fallback_clock.begin();
27+
rtc_clock.begin(Wire);
28+
29+
#if defined(P_LORA_SCLK)
30+
return radio.std_init(&spi);
31+
#else
32+
return radio.std_init();
33+
#endif
34+
}
35+
36+
uint32_t radio_get_rng_seed() {
37+
return radio.random(0x7FFFFFFF);
38+
}
39+
40+
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
41+
radio.setFrequency(freq);
42+
radio.setSpreadingFactor(sf);
43+
radio.setBandwidth(bw);
44+
radio.setCodingRate(cr);
45+
}
46+
47+
void radio_set_tx_power(uint8_t dbm) {
48+
radio.setOutputPower(dbm);
49+
}
50+
51+
mesh::LocalIdentity radio_new_identity() {
52+
RadioNoiseListener rng(radio);
53+
return mesh::LocalIdentity(&rng); // create new random identity
54+
}

0 commit comments

Comments
 (0)