diff --git a/src/configuration.h b/src/configuration.h
index 524dacdea..8ec3b2211 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -251,6 +251,7 @@ along with this program. If not, see .
// -----------------------------------------------------------------------------
#define FT6336U_ADDR 0x48
#define CST328_ADDR 0x1A
+#define CHSC6X_ADDR 0x2E
// -----------------------------------------------------------------------------
// RAK12035VB Soil Monitor (using RAK12023 up to 3 RAK12035 monitors can be connected)
diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h
index cca867851..55980face 100644
--- a/src/detect/ScanI2C.h
+++ b/src/detect/ScanI2C.h
@@ -84,7 +84,8 @@ class ScanI2C
TSL2561,
DRV2605,
BH1750,
- DA217
+ DA217,
+ CHSC6X
} DeviceType;
// typedef uint8_t DeviceAddress;
diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp
index 66697c109..167728ad3 100644
--- a/src/detect/ScanI2CTwoWire.cpp
+++ b/src/detect/ScanI2CTwoWire.cpp
@@ -500,6 +500,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
SCAN_SIMPLE_CASE(CST328_ADDR, CST328, "CST328", (uint8_t)addr.address);
+ SCAN_SIMPLE_CASE(CHSC6X_ADDR, CHSC6X, "CHSC6X", (uint8_t)addr.address);
case LTR553ALS_ADDR:
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x86), 1); // Part ID register
if (registerValue == 0x92) { // LTR553ALS Part ID
diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp
index 0663602d9..b662869dd 100644
--- a/src/graphics/TFTDisplay.cpp
+++ b/src/graphics/TFTDisplay.cpp
@@ -422,7 +422,54 @@ static LGFX *tft = nullptr;
#elif defined(ST7789_CS)
#include // Graphics and font library for ST7735 driver chip
+#ifdef HELTEC_V4_TFT
+#include "chsc6x.h"
+#include "lgfx/v1/Touch.hpp"
+namespace lgfx
+{
+ inline namespace v1
+ {
+class TOUCH_CHSC6X : public ITouch
+{
+public:
+ TOUCH_CHSC6X(void)
+ {
+ _cfg.i2c_addr = TOUCH_SLAVE_ADDRESS;
+ _cfg.x_min = 0;
+ _cfg.x_max = 240;
+ _cfg.y_min = 0;
+ _cfg.y_max = 320;
+ };
+ bool init(void) override {
+ if(chsc6xTouch==nullptr) {
+ chsc6xTouch=new chsc6x(&Wire1,TOUCH_SDA_PIN,TOUCH_SCL_PIN,TOUCH_INT_PIN,TOUCH_RST_PIN);
+ }
+ chsc6xTouch->chsc6x_init();
+ return true;
+ };
+
+ uint_fast8_t getTouchRaw(touch_point_t* tp, uint_fast8_t count) override {
+ uint16_t raw_x,raw_y;
+ if (chsc6xTouch->chsc6x_read_touch_info(&raw_x, &raw_y)==0) {
+ tp[0].x = 320-1-raw_y;
+ tp[0].y = 240-1-raw_x ;
+ tp[0].size = 1;
+ tp[0].id = 1;
+ return 1;
+ }
+ tp[0].size = 0;
+ return 0;
+ };
+
+ void wakeup(void) override {};
+ void sleep(void) override {};
+ private:
+ chsc6x *chsc6xTouch=nullptr;
+ };
+}
+}
+#endif
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ST7789 _panel_instance;
@@ -431,6 +478,8 @@ class LGFX : public lgfx::LGFX_Device
#if HAS_TOUCHSCREEN
#if defined(T_WATCH_S3) || defined(ELECROW)
lgfx::Touch_FT5x06 _touch_instance;
+#elif defined(HELTEC_V4_TFT)
+ lgfx::TOUCH_CHSC6X _touch_instance;
#else
lgfx::Touch_GT911 _touch_instance;
#endif
@@ -465,8 +514,8 @@ class LGFX : public lgfx::LGFX_Device
auto cfg = _panel_instance.config(); // Gets a structure for display panel settings.
cfg.pin_cs = ST7789_CS; // Pin number where CS is connected (-1 = disable)
- cfg.pin_rst = -1; // Pin number where RST is connected (-1 = disable)
- cfg.pin_busy = -1; // Pin number where BUSY is connected (-1 = disable)
+ cfg.pin_rst = ST7789_RESET; // Pin number where RST is connected (-1 = disable)
+ cfg.pin_busy = ST7789_BUSY; // Pin number where BUSY is connected (-1 = disable)
// The following setting values are general initial values for each panel, so please comment out any
// unknown items and try them.
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 76915397f..6291fa4cc 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -653,7 +653,7 @@ 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(ELECROW_PANEL)||defined(HELTEC_V4_TFT)) && \
HAS_TFT
// switch BT off by default; use TFT programming mode or hotkey to enable
config.bluetooth.enabled = false;
diff --git a/variants/esp32s3/heltec_v4/pins_arduino.h b/variants/esp32s3/heltec_v4/pins_arduino.h
index 45561b4b5..d4485016d 100644
--- a/variants/esp32s3/heltec_v4/pins_arduino.h
+++ b/variants/esp32s3/heltec_v4/pins_arduino.h
@@ -13,8 +13,8 @@ static const uint8_t LED_BUILTIN = 35;
static const uint8_t TX = 43;
static const uint8_t RX = 44;
-static const uint8_t SDA = 3;
-static const uint8_t SCL = 4;
+static const uint8_t SDA = 4;
+static const uint8_t SCL = 3;
static const uint8_t SS = 8;
static const uint8_t MOSI = 10;
diff --git a/variants/esp32s3/heltec_v4/platformio.ini b/variants/esp32s3/heltec_v4/platformio.ini
index 7057f9646..4ff7ff253 100644
--- a/variants/esp32s3/heltec_v4/platformio.ini
+++ b/variants/esp32s3/heltec_v4/platformio.ini
@@ -1,4 +1,4 @@
-[env:heltec-v4]
+[heltec_v4_base]
extends = esp32s3_base
board = heltec_v4
board_check = true
@@ -7,3 +7,106 @@ build_flags =
${esp32s3_base.build_flags}
-D HELTEC_V4
-I variants/esp32s3/heltec_v4
+lib_deps =
+ ${esp32s3_base.lib_deps}
+
+
+[env:heltec-v4]
+extends = heltec_v4_base
+build_flags =
+ ${heltec_v4_base.build_flags}
+ -D HELTEC_V4_OLED
+ -D USE_SSD1306 ; Heltec_v4 has an SSD1315 display (compatible with SSD1306 driver)
+ -D LED_PIN=35
+ -D RESET_OLED=21
+ -D I2C_SDA=17
+ -D I2C_SCL=18
+ -D I2C_SDA1=4
+ -D I2C_SCL1=3
+lib_deps =
+ ${heltec_v4_base.lib_deps}
+
+[env:heltec-v4-tft]
+extends = heltec_v4_base
+build_flags =
+ ${heltec_v4_base.build_flags} ;-Os
+ -D HELTEC_V4_TFT
+ -D I2C_SDA=4
+ -D I2C_SCL=3
+ -D I2C_SDA1=47
+ -D I2C_SCL1=48
+ -D PIN_BUTTON2=35
+ -D PIN_BUZZER=6
+ -D USE_PIN_BUZZER=PIN_BUZZER
+ -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 HAS_SCREEN=1
+ -D HAS_TFT=1
+ -D RAM_SIZE=1560
+ -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
+ -D USE_LOG_DEBUG
+ -D LOG_DEBUG_INC=\"DebugConfiguration.h\"
+ -D USE_PACKET_API
+ -D LGFX_DRIVER=LGFX_HELTEC_V4_TFT
+ -D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_HELTEC_V4_TFT.h\"
+ -D VIEW_320x240
+ -D MAP_FULL_REDRAW
+ -D DISPLAY_SIZE=320x240 ; landscape mode
+ -D LGFX_PIN_SCK=17
+ -D LGFX_PIN_MOSI=33
+ -D LGFX_PIN_DC=16
+ -D LGFX_PIN_CS=15
+ -D LGFX_PIN_BL=21
+ -D LGFX_PIN_RST=18
+ -D CUSTOM_TOUCH_DRIVER
+ -D TOUCH_SDA_PIN=I2C_SDA1
+ -D TOUCH_SCL_PIN=I2C_SCL1
+ -D TOUCH_INT_PIN=-1 ;45
+ -D TOUCH_RST_PIN=44
+;base UI
+ -D TFT_CS=LGFX_PIN_CS
+ -D ST7789_CS=TFT_CS
+ -D ST7789_RS=LGFX_PIN_DC
+ -D ST7789_SDA=LGFX_PIN_MOSI
+ -D ST7789_SCK=LGFX_PIN_SCK
+ -D ST7789_RESET=LGFX_PIN_RST
+ -D ST7789_MISO=-1
+ -D ST7789_BUSY=-1
+ -D ST7789_BL=LGFX_PIN_BL
+ -D ST7789_SPI_HOST=SPI3_HOST
+ -D TFT_BL=ST7789_BL
+ -D SPI_FREQUENCY=40000000
+ -D SPI_READ_FREQUENCY=4000000
+ -D TFT_HEIGHT=320
+ -D TFT_WIDTH=240
+ -D TFT_OFFSET_X=0
+ -D TFT_OFFSET_Y=0
+ -D TFT_OFFSET_ROTATION=0
+ -D SCREEN_ROTATE
+ -D SCREEN_TRANSITION_FRAMERATE=5
+ -D BRIGHTNESS_DEFAULT=130 ; Medium Low Brightness
+ -D HAS_TOUCHSCREEN=1
+ -D TOUCH_I2C_PORT=0
+ -D TOUCH_SLAVE_ADDRESS=0x2E
+ -D SCREEN_TOUCH_INT=TOUCH_INT_PIN
+ -D SCREEN_TOUCH_RST=TOUCH_RST_PIN
+
+lib_deps = ${heltec_v4_base.lib_deps}
+ ; ${device-ui_base.lib_deps}
+ lovyan03/LovyanGFX@1.2.0
+ https://github.com/Quency-D/chsc6x/archive/5cbead829d6b432a8d621ed1aafd4eb474fd4f27.zip
+ https://github.com/Quency-D/device-ui/archive/7c9870b8016641190b059bdd90fe16c1012a39eb.zip
diff --git a/variants/esp32s3/heltec_v4/variant.h b/variants/esp32s3/heltec_v4/variant.h
index 1c9516e39..72bbf14fc 100644
--- a/variants/esp32s3/heltec_v4/variant.h
+++ b/variants/esp32s3/heltec_v4/variant.h
@@ -1,11 +1,3 @@
-#define LED_PIN 35
-
-#define USE_SSD1306 // Heltec_v4 has an SSD1315 display (compatible with SSD1306 driver)
-
-#define RESET_OLED 21
-#define I2C_SDA 17 // I2C pins for this board
-#define I2C_SCL 18
-
#define VEXT_ENABLE 36 // active low, powers the oled display and the lora antenna boost
#define BUTTON_PIN 0