Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,8 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32);

#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR) || \
defined(ELECROW_PANEL) || defined(HELTEC_V4_TFT) || defined(HELTEC_V4_R8_TFT) || defined(RAK_WISMESH_TAP_V2)) && \
defined(ELECROW_PANEL) || defined(HELTEC_V4_TFT) || defined(HELTEC_V4_R8_TFT) || defined(HELTEC_V4_R2) || \
defined(RAK_WISMESH_TAP_V2)) && \
HAS_TFT
// switch BT off by default; use TFT programming mode or hotkey to enable
config.bluetooth.enabled = false;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/esp32/architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
#define HW_VENDOR meshtastic_HardwareModel_TBEAM_1_WATT
#elif defined(T_LORA_PAGER)
#define HW_VENDOR meshtastic_HardwareModel_T_LORA_PAGER
#elif defined(HELTEC_V4_R2)
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_V4
#elif defined(HELTEC_V4)
#define HW_VENDOR meshtastic_HardwareModel_HELTEC_V4
#elif defined(M5STACK_UNITC6L)
Expand Down
58 changes: 58 additions & 0 deletions variants/esp32s3/heltec_v4_r2/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define USB_VID 0x303a
#define USB_PID 0x1001

static const uint8_t TX = 43;
static const uint8_t RX = 44;

static const uint8_t SDA = 4;
static const uint8_t SCL = 3;

static const uint8_t SS = 8;
static const uint8_t MOSI = 10;
static const uint8_t MISO = 11;
static const uint8_t SCK = 9;

static const uint8_t A0 = 1;
static const uint8_t A1 = 2;
static const uint8_t A2 = 3;
static const uint8_t A3 = 4;
static const uint8_t A4 = 5;
static const uint8_t A5 = 6;
static const uint8_t A6 = 7;
static const uint8_t A7 = 8;
static const uint8_t A8 = 9;
static const uint8_t A9 = 10;
static const uint8_t A10 = 11;
static const uint8_t A11 = 12;
static const uint8_t A12 = 13;
static const uint8_t A13 = 14;
static const uint8_t A14 = 15;
static const uint8_t A15 = 16;
static const uint8_t A16 = 17;
static const uint8_t A17 = 18;
static const uint8_t A18 = 19;
static const uint8_t A19 = 20;

static const uint8_t T1 = 1;
static const uint8_t T2 = 2;
static const uint8_t T3 = 3;
static const uint8_t T4 = 4;
static const uint8_t T5 = 5;
static const uint8_t T6 = 6;
static const uint8_t T7 = 7;
static const uint8_t T8 = 8;
static const uint8_t T9 = 9;
static const uint8_t T10 = 10;
static const uint8_t T11 = 11;
static const uint8_t T12 = 12;
static const uint8_t T13 = 13;
static const uint8_t T14 = 14;

static const uint8_t Vext = 36;

#endif /* Pins_Arduino_h */
119 changes: 119 additions & 0 deletions variants/esp32s3/heltec_v4_r2/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
; Heltec WiFi LoRa 32 V4-R2 — ESP32-S3 + SX1262
; External 2.8" ILI9341V SPI display (240x320) + FT6336G capacitive touch (I2C)
; No on-board LCD screen
;
; Display SPI wiring (SPI3_HOST):
; GPIO47 → SCK GPIO33 → MOSI GPIO26 → MISO
; GPIO34 → LCD_CS GPIO21 → LCD_RS GPIO48 → LCD_RST GPIO35 → LED/BL
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
;
; Touch I2C wiring (Wire, port 0):
; GPIO4 → CTP_SDA GPIO3 → CTP_SCL
; GPIO45 → CTP_RST not connected → CTP_INT (polling)
;
; NOTE: this base intentionally extends esp32s3_base (not heltec_v4_base) so
; that only variants/esp32s3/heltec_v4_r2/variant.h is on the include path.
; Inheriting heltec_v4_base would prepend -I variants/esp32s3/heltec_v4 first,
; causing the V4's variant.h (which contains #if HAS_TFT → USE_TFTDISPLAY) to
; shadow the R2 header and incorrectly compile TFTDisplay.cpp.

[heltec_v4_r2_base]
extends = esp32s3_base
board = heltec_v4
board_check = true
board_build.partitions = default_16MB.csv
build_flags =
${esp32s3_base.build_flags}
-D HELTEC_V4
-D HELTEC_V4_R2
-D HAS_LORA_FEM=1
-I variants/esp32s3/heltec_v4_r2

[env:heltec-v4-r2]
custom_meshtastic_hw_model = 110
custom_meshtastic_hw_model_slug = HELTEC_V4
custom_meshtastic_architecture = esp32-s3
custom_meshtastic_actively_supported = true
custom_meshtastic_support_level = 2
custom_meshtastic_display_name = Heltec V4 R2 ILI9341 Touch
custom_meshtastic_tags = Heltec
custom_meshtastic_requires_dfu = true
custom_meshtastic_partition_scheme = 16MB
custom_meshtastic_has_mui = true

extends = heltec_v4_r2_base
build_flags =
${heltec_v4_r2_base.build_flags}
; ---- System ----
-D CONFIG_ARDUHAL_LOG_COLORS
-D RADIOLIB_DEBUG_SPI=0
-D RADIOLIB_DEBUG_PROTOCOL=0
-D RADIOLIB_DEBUG_BASIC=0
-D RADIOLIB_VERBOSE_ASSERT=0
-D RADIOLIB_SPI_PARANOID=0
-D CONFIG_DISABLE_HAL_LOCKS=1
-D INPUTDRIVER_BUTTON_TYPE=0
-D USE_LOG_DEBUG
-D LOG_DEBUG_INC=\"DebugConfiguration.h\"
-D USE_PACKET_API
; ---- Display ----
-D HAS_SCREEN=0
-D HAS_TFT=1
; ---- LVGL / MUI ----
-D LV_LVGL_H_INCLUDE_SIMPLE
-D LV_CONF_INCLUDE_SIMPLE
-D LV_COMP_CONF_INCLUDE_SIMPLE
-D LV_USE_SYSMON=0
-D LV_USE_PROFILER=0
-D LV_USE_PERF_MONITOR=0
-D LV_USE_MEM_MONITOR=0
-D LV_USE_LOG=0
-D LV_BUILD_TEST=0
; ---- RAM / tile budget (2 MB PSRAM) ----
-D MAP_TILES_GREY
-D RAM_SIZE=1432
-D STBI_ARENA_SIZE=450000
-D LV_CACHE_DEF_SIZE=0
; ---- LGFX Generic driver (device-ui) ----
-D LGFX_DRIVER_TEMPLATE
-D LGFX_DRIVER=LGFX_GENERIC
-D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_GENERIC.h\"
-D LGFX_CFG_HOST=SPI3_HOST
-D LGFX_PIN_SCK=47
-D LGFX_PIN_MOSI=33
-D LGFX_PIN_MISO=-1
-D LGFX_PIN_DC=21
-D LGFX_PIN_CS=34
-D LGFX_PIN_RST=48
-D LGFX_PIN_BL=35
-D LGFX_PANEL=ILI9341
-D LGFX_INVERT_COLOR=false
-D LGFX_SCREEN_WIDTH=240
-D LGFX_SCREEN_HEIGHT=320
-D VIEW_320x240
-D DISPLAY_SET_RESOLUTION
-D DISPLAY_SIZE=320x240
-D LGFX_ROTATION=2
-D SPI_FREQUENCY=40000000
-D SPI_READ_FREQUENCY=16000000
-D BRIGHTNESS_DEFAULT=130
; ---- FT6336G capacitive touch (FT5x06-compatible, I2C address 0x38) ----
-D HAS_TOUCHSCREEN=1
-D LGFX_TOUCH=FT5x06
-D LGFX_TOUCH_I2C_FREQ=400000
-D LGFX_TOUCH_I2C_PORT=0
-D LGFX_TOUCH_I2C_ADDR=0x38
-D LGFX_TOUCH_I2C_SDA=4
-D LGFX_TOUCH_I2C_SCL=3
-D LGFX_TOUCH_RST=45
-D LGFX_TOUCH_INT=-1
-D LGFX_TOUCH_X_MIN=0
-D LGFX_TOUCH_X_MAX=239
-D LGFX_TOUCH_Y_MIN=0
-D LGFX_TOUCH_Y_MAX=319
-D LGFX_TOUCH_ROTATION=0

lib_deps =
${esp32s3_base.lib_deps}
${device-ui_base.lib_deps}
# renovate: datasource=custom.pio depName=LovyanGFX packageName=lovyan03/library/LovyanGFX
lovyan03/LovyanGFX@1.2.26
86 changes: 86 additions & 0 deletions variants/esp32s3/heltec_v4_r2/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Heltec WiFi LoRa 32 V4-R2 — ESP32-S3 + SX1262
// External 2.8" ILI9341V SPI display (240x320) + FT6336G I2C capacitive touch
// No on-board LCD screen

#define VEXT_ENABLE 36 // active low, powers the LoRa antenna boost
#define VEXT_ON_VALUE LOW
#define BUTTON_PIN 0

#define ADC_CTRL 37
#define ADC_CTRL_ENABLED HIGH
#define BATTERY_PIN 1 // ADC1_CH0 — battery voltage via divider; pull ADC_CTRL high to read
#define ADC_CHANNEL ADC_CHANNEL_0
#define ADC_ATTENUATION ADC_ATTEN_DB_2_5
#define ADC_MULTIPLIER 4.9 * 1.045

#define USE_SX1262

#define LORA_DIO0 -1 // not connected on SX1262
#define LORA_RESET 12
#define LORA_DIO1 14 // SX1262 IRQ
#define LORA_DIO2 13 // SX1262 BUSY
#define LORA_DIO3 // not connected on PCB

#define LORA_SCK 9
#define LORA_MISO 11
#define LORA_MOSI 10
#define LORA_CS 8

#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET

#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8

// Enable Traffic Management Module
#ifndef HAS_TRAFFIC_MANAGEMENT
#define HAS_TRAFFIC_MANAGEMENT 1
#endif

// ---- GC1109 RF FRONT END CONFIGURATION (V4.2) ----
// CTX -> SX1262 DIO2 (automatic via SX126X_DIO2_AS_RF_SWITCH)
// CSD -> GPIO2, CPS -> GPIO46, VCC -> GPIO7
#define LORA_PA_POWER 7 // VFEM_Ctrl
#define LORA_GC1109_PA_EN 2 // CSD — chip enable (HIGH=on)
#define LORA_GC1109_PA_TX_EN 46 // CPS — PA mode (HIGH=full PA)

// ---- KCT8103L RF FRONT END CONFIGURATION (V4.3) ----
// CPS -> SX1262 DIO2 (automatic via SX126X_DIO2_AS_RF_SWITCH)
// CSD -> GPIO2, CTX -> GPIO5, VCC -> GPIO7
#define LORA_KCT8103L_PA_CSD 2 // CSD — chip enable (HIGH=on)
#define LORA_KCT8103L_PA_CTX 5 // CTX — RX bypass (HIGH) / RX LNA (LOW)

/*
* GPS pins — L76K GNSS module
*/
#define GPS_L76K
#define PIN_GPS_RESET (42)
#define GPS_RESET_MODE LOW
#define PIN_GPS_EN (34)
#define GPS_EN_ACTIVE LOW
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
#define PERIPHERAL_WARMUP_MS 1000
#define PIN_GPS_STANDBY (40)
#define PIN_GPS_PPS (41)
#define GPS_TX_PIN (38) // GNSS → CPU
#define GPS_RX_PIN (39) // CPU → GNSS
#define GPS_THREAD_INTERVAL 50

/*
* External display connections (set via LGFX_PIN_* in platformio.ini)
*
* Display SPI (SPI3_HOST):
* SCK → GPIO47 LCD_RS/DC → GPIO21
* MOSI → GPIO33 CS → GPIO34
* MISO → NC (-1) RST → GPIO48 [GPIO26 is PSRAM CS — do not use]
* BL → GPIO35
*
* Touch I2C (Wire, port 0 — GPIO3/4):
* SDA → GPIO4 RST → GPIO45
* SCL → GPIO3 INT → not connected (polling)
*/

// I2C bus used for touch and peripheral scan
#define I2C_SDA 4
#define I2C_SCL 3