Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T-Watch S3 Support #2632

Merged
merged 19 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions boards/t-watch-s3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DT_WATCH_S3",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "dio",
"hwids": [["0X303A", "0x1001"]],
"mcu": "esp32s3",
"variant": "t-watch"
thebentern marked this conversation as resolved.
Show resolved Hide resolved
},
"connectivity": ["wifi"],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": ["arduino"],
"name": "LilyGo T-Watch 2020 V3",
"upload": {
"flash_size": "8MB",
"maximum_ram_size": 327680,
"maximum_size": 8388608,
"require_upload_port": true,
"speed": 921600
},
"url": "http://www.lilygo.cn/",
"vendor": "LilyGo"
}
3 changes: 2 additions & 1 deletion src/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ bool Power::axpChipInit()
// GNSS VDD 3300mV
PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
PMU->enablePowerOutput(XPOWERS_ALDO3);
} else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) {
} else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE ||
HW_VENDOR == meshtastic_HardwareModel_T_WATCH_S3) {
// t-beam s3 core
/**
* gnss module power channel
Expand Down
4 changes: 2 additions & 2 deletions src/graphics/TFTDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bool TFTDisplay::connect()
#endif

tft.init();
#if defined(M5STACK) || defined(T_DECK)
#if defined(M5STACK) || defined(T_DECK) || defined(T_WATCH_S3)
tft.setRotation(1); // M5Stack/T-Deck have the TFT in landscape
#else
tft.setRotation(3); // Orient horizontal and wide underneath the silkscreen name label
Expand All @@ -311,4 +311,4 @@ bool TFTDisplay::connect()
return true;
}

#endif
#endif
2 changes: 2 additions & 0 deletions src/platform/esp32/architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
#define HW_VENDOR meshtastic_HardwareModel_TLORA_V2_1_1P8
#elif defined(T_DECK)
#define HW_VENDOR meshtastic_HardwareModel_T_DECK
#elif defined(T_WATCH_S3)
#define HW_VENDOR meshtastic_HardwareModel_T_WATCH_S3
#elif defined(GENIEBLOCKS)
#define HW_VENDOR meshtastic_HardwareModel_GENIEBLOCKS
#elif defined(PRIVATE_HW)
Expand Down
5 changes: 3 additions & 2 deletions src/sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ void doDeepSleep(uint32_t msecToWake)
if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) {
// t-beam v1.2 radio power channel
PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel
} else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) {
} else if (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE ||
HW_VENDOR == meshtastic_HardwareModel_T_WATCH_S3) {
PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel
}
} else if (model == XPOWERS_AXP192) {
Expand Down Expand Up @@ -388,4 +389,4 @@ void enableModemSleep()
int rv = esp_pm_configure(&esp32_config);
LOG_DEBUG("Sleep request result %x\n", rv);
}
#endif
#endif
64 changes: 64 additions & 0 deletions variants/t-watch-s3/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

#define EXTERNAL_NUM_INTERRUPTS 46
#define NUM_DIGITAL_PINS 48
#define NUM_ANALOG_INPUTS 20

#define analogInputToDigitalPin(p) (((p) < NUM_ANALOG_INPUTS) ? (analogChannelToDigitalPin(p)) : -1)
#define digitalPinToInterrupt(p) (((p) < NUM_DIGITAL_PINS) ? (p) : -1)
#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS)

// static const uint8_t LED_BUILTIN = -1;

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

static const uint8_t SDA = 10;
static const uint8_t SCL = 11;

// Default SPI will be mapped to Radio
static const uint8_t SS = 5;
static const uint8_t MOSI = 1;
static const uint8_t MISO = 4;
static const uint8_t SCK = 3;

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;

#endif /* Pins_Arduino_h */
14 changes: 14 additions & 0 deletions variants/t-watch-s3/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; LilyGo T-Watch S3
[env:t-watch-s3]
extends = esp32s3_base
board = t-watch-s3
upload_protocol = esp-builtin
monitor_port = /dev/tty.usbmodem3485188D636C1
monitor_speed = 115200

build_flags = ${esp32_base.build_flags}
-DT_WATCH_S3
-Ivariants/t-watch-s3

lib_deps = ${esp32s3_base.lib_deps}
lovyan03/LovyanGFX@^1.1.7
90 changes: 90 additions & 0 deletions variants/t-watch-s3/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// ST7789 TFT LCD
#define ST7789_CS 12
#define ST7789_RS 38 // DC
#define ST7789_SDA 13 // MOSI
#define ST7789_SCK 18
#define ST7789_RESET -1
#define ST7789_MISO -1
#define ST7789_BUSY -1
#define ST7789_BL 45
#define ST7789_SPI_HOST SPI2_HOST
//#define ST7789_BACKLIGHT_EN 15
thebentern marked this conversation as resolved.
Show resolved Hide resolved
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 16000000
#define TFT_HEIGHT 240
#define TFT_WIDTH 240
#define TFT_OFFSET_X 0
#define TFT_OFFSET_Y 0
#define SCREEN_ROTATE
#define SCREEN_TRANSITION_FRAMERATE 1 // fps
#define SCREEN_TOUCH_INT 16
#define TOUCH_SLAVE_ADDRESS 0x5D // GT911

// #define TWATCH_TFT_MISO (GPIO_NUM_MAX)
// #define TWATCH_TFT_MOSI (GPIO_NUM_19)
// #define TWATCH_TFT_SCLK (GPIO_NUM_18)
// #define TWATCH_TFT_CS (GPIO_NUM_5)
// #define TWATCH_TFT_DC (GPIO_NUM_27)
// #define TWATCH_TFT_RST (GPIO_NUM_MAX)
// #define TWATCH_TFT_BL (GPIO_NUM_15)

// Leave undefined to disable our PMU IRQ handler. DO NOT ENABLE THIS because the pmuirq can cause sperious interrupts
// and waking from light sleep
// #define PMU_IRQ 40
#define HAS_AXP2101

#define HAS_RTC 1

// Specify the PMU as Wire1. In the t-beam-s3 core, PCF8563 and PMU share the bus
#define PMU_USE_WIRE1
#define RTC_USE_WIRE1

// #define TOUCH_SDA (23)
// #define TOUCH_SCL (32)
// #define TOUCH_INT (38)
// #define TOUCH_RST (14)

// #define SEN_SDA (21)
// #define SEN_SCL (22)

// #define RTC_INT_PIN (37)
// #define AXP202_INT (35)
// #define BMA423_INT1 (39)

// #define TWATCH_DAC_IIS_BCK (26)
// #define TWATCH_DAC_IIS_WS (25)
// #define TWATCH_DAC_IIS_DOUT (33)

// #define MOTOR_PIN (4)

#define I2C_SDA 10 // For QMC6310 sensors and screens
#define I2C_SCL 11 // For QMC6310 sensors and screens

#define BUTTON_PIN 0
// #define BUTTON_NEED_PULLUP

#define HAS_GPS 0
#undef GPS_RX_PIN
#undef GPS_TX_PIN

#define USE_SX1262
#define USE_SX1268

#define RF95_SCK 3
#define RF95_MISO 4
#define RF95_MOSI 1
#define RF95_NSS 5

#define LORA_DIO0 -1 // a No connect on the SX1262 module
#define LORA_RESET 8
#define LORA_DIO1 9 // SX1262 IRQ
#define LORA_DIO2 7 // SX1262 BUSY
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled

#define SX126X_CS RF95_NSS // FIXME - we really should define LORA_CS instead
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
#define SX126X_E22 // Not really an E22 but TTGO seems to be trying to clone that
// Internally the TTGO module hooks the SX1262-DIO2 in to control the TX/RX switch (which is the default for the sx1262interface
// code)
4 changes: 2 additions & 2 deletions variants/tbeam-s3-core/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
// #define PMU_IRQ 40
#define HAS_AXP2101

#define HAS_RTC 1

// Specify the PMU as Wire1. In the t-beam-s3 core, PCF8563 and PMU share the bus
#define PMU_USE_WIRE1
#define RTC_USE_WIRE1
Expand All @@ -59,8 +61,6 @@
// PCF8563 RTC Module
// #define PCF8563_RTC 0x51 //Putting definitions in variant. h does not compile correctly

#define HAS_RTC 1

// has 32768 Hz crystal
#define HAS_32768HZ

Expand Down
Loading