From d14d42ba2c13bf7ff901169b466dbe382dd5e260 Mon Sep 17 00:00:00 2001
From: Tom Fifield <tom@tomfifield.net>
Date: Mon, 28 Oct 2024 19:23:49 +1100
Subject: [PATCH] diy mesh-tab initial files (#5169)

Co-authored-by: mverch67 <manuel.verch@gmx.de>
---
 variants/diy/mesh-tab/variant.h | 49 +++++++++++++++++++++++
 variants/diy/platformio.ini     | 70 +++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)
 create mode 100644 variants/diy/mesh-tab/variant.h

diff --git a/variants/diy/mesh-tab/variant.h b/variants/diy/mesh-tab/variant.h
new file mode 100644
index 000000000..0a23a3c36
--- /dev/null
+++ b/variants/diy/mesh-tab/variant.h
@@ -0,0 +1,49 @@
+#ifndef _VARIANT_MESHTAB_DIY_
+#define _VARIANT_MESHTAB_DIY_
+
+#define HAS_TOUCHSCREEN 1
+
+#define SLEEP_TIME 120
+
+// Analog pins
+#define BATTERY_PIN 4 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
+// ratio of voltage divider = 2.0
+#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage.
+#define ADC_CHANNEL ADC1_GPIO4_CHANNEL
+
+// LED
+#define LED_PIN 21
+
+// Button
+#define BUTTON_PIN 0
+
+// GPS
+#define GPS_RX_PIN 18
+#define GPS_TX_PIN 17
+
+// #define HAS_SDCARD 1
+#define SPI_MOSI 13
+#define SPI_SCK 12
+#define SPI_MISO 11
+#define SPI_CS 10
+#define SDCARD_CS 6
+
+// LORA SPI
+#define LORA_SCK 36
+#define LORA_MISO 37
+#define LORA_MOSI 35
+#define LORA_CS 39
+
+// LORA MODULES
+#define USE_SX1262
+
+// LORA CONFIG
+#define SX126X_CS LORA_CS
+#define SX126X_DIO1 15
+#define SX126X_DIO2_AS_RF_SWITCH
+#define SX126X_BUSY 40
+#define SX126X_RESET 14
+#define SX126X_RXEN 47
+#define SX126X_TXEN RADIOLIB_NC // Assuming that DIO2 is connected to TXEN pin
+
+#endif
diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini
index f3c22b7a8..00ff88da2 100644
--- a/variants/diy/platformio.ini
+++ b/variants/diy/platformio.ini
@@ -88,3 +88,73 @@ build_flags =
   -D ARDUINO_USB_MODE=0
   -D ARDUINO_USB_CDC_ON_BOOT=1
   -I variants/diy/t-energy-s3_e22
+
+; esp32-s3 + ra-sh01 lora + 3.2" ILI9143
+[env:mesh-tab]
+extends = esp32s3_base
+board = um_feathers3
+board_level = extra
+board_upload.flash_size = 16MB
+board_build.partitions = default_16MB.csv
+upload_protocol = esptool
+build_flags = ${esp32s3_base.build_flags}
+  -D MESH_TAB
+  -D PRIVATE_HW
+  -D CONFIG_ARDUHAL_ESP_LOG
+  -D CONFIG_ARDUHAL_LOG_COLORS=1
+  -D CONFIG_DISABLE_HAL_LOCKS=1 ; "feels" to be a bit more stable without locks
+  -D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1
+  -D MESHTASTIC_EXCLUDE_INPUTBROKER=1
+  -D MESHTASTIC_EXCLUDE_BLUETOOTH=1
+  -D MESHTASTIC_EXCLUDE_WEBSERVER=1
+  -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 RADIOLIB_SPI_PARANOID=0
+  -D MAX_NUM_NODES=250
+  -D MAX_THREADS=40
+  -D HAS_SCREEN=0
+  -D HAS_TFT=1
+  -D RAM_SIZE=1024
+  -D LGFX_DRIVER_TEMPLATE
+  -D LGFX_DRIVER=LGFX_GENERIC
+  -D LGFX_PANEL=ILI9341
+  -D LGFX_OFFSET_ROTATION=1
+  -D LGFX_TOUCH=XPT2046
+  -D LGFX_PIN_SCK=12
+  -D LGFX_PIN_MOSI=13
+  -D LGFX_PIN_MISO=11
+  -D LGFX_PIN_DC=16
+  -D LGFX_PIN_CS=10
+  -D LGFX_PIN_RST=-1
+  -D LGFX_PIN_BL=42
+  -D LGFX_TOUCH_INT=41
+  -D LGFX_TOUCH_CS=7
+  -D LGFX_TOUCH_CLK=12
+  -D LGFX_TOUCH_DO=11
+  -D LGFX_TOUCH_DIN=13
+  -D LGFX_TOUCH_X_MIN=300
+  -D LGFX_TOUCH_X_MAX=3900
+  -D LGFX_TOUCH_Y_MIN=400
+  -D LGFX_TOUCH_Y_MAX=3900
+  -D VIEW_320x240
+  -D USE_PACKET_API
+  -I lib/device-ui/generated/ui_320x240
+  -I variants/diy/mesh-tab
+build_src_filter = ${esp32_base.build_src_filter}
+  +<../lib/device-ui/generated/ui_320x240>
+  +<../lib/device-ui/resources>
+  +<../lib/device-ui/locale>
+  +<../lib/device-ui/source>
+lib_deps = ${esp32_base.lib_deps}
+  lovyan03/LovyanGFX@^1.1.16
+  earlephilhower/ESP8266Audio@^1.9.7
+  earlephilhower/ESP8266SAM@^1.0.1