Skip to content

Commit f09e6ff

Browse files
committed
t-watch s3
1 parent 9740e1c commit f09e6ff

File tree

8 files changed

+426
-1
lines changed

8 files changed

+426
-1
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
- { env: "lilygo-t5-epaper-s3-pro" }
6868
- { env: "lilygo-t-hmi" }
6969
- { env: "lilygo-t-display-S3-amoled" }
70+
- { env: "lilygo-t-watch-s3" }
7071
- { env: "lilygo-t-watch-ultra" }
7172
- { env: "smoochiee-board" }
7273
- { env: "Marauder-v4-OG" }

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ Things that needs to be done in next updates
8686
## Latest Changelog
8787
* 2.6.8:
8888
* [ ] Custom partition builder (no more hardcoded partition lists)
89-
89+
* [x] New Device: [Lilygo T-Watch-S3] (https://lilygo.cc/products/t-watch-s3?bg_ref=sDI8Bh4HmO)
90+
* [x] New Device: [Lilygo T-Watch-Ultra] (https://lilygo.cc/products/t-watch-ultra?bg_ref=sDI8Bh4HmO)
91+
9092
* 2.6.7:
9193
* [x] Restablished Tab5 SdCard on SPI for WiFi compatibility and refactored reboot process to powercycle the SDCard, resetting the Sdcard communication bus.
9294
* [x] Tab5 Now has MassStorage interface!
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
"-DT_WATCH_S3",
11+
"-DBOARD_HAS_PSRAM",
12+
"-DARDUINO_USB_MODE=1",
13+
"-DARDUINO_RUNNING_CORE=1",
14+
"-DARDUINO_EVENT_RUNNING_CORE=1",
15+
"-DARDUINO_USB_CDC_ON_BOOT"
16+
],
17+
"f_cpu": "240000000L",
18+
"f_flash": "80000000L",
19+
"flash_mode": "qio",
20+
"hwids": [
21+
[
22+
"0x303A",
23+
"0x1001"
24+
]
25+
],
26+
"mcu": "esp32s3",
27+
"variant": "pinouts"
28+
},
29+
"connectivity": [
30+
"wifi",
31+
"bluetooth",
32+
"lora"
33+
],
34+
"debug": {
35+
"default_tool": "esp-builtin",
36+
"onboard_tools": [
37+
"esp-builtin"
38+
],
39+
"openocd_target": "esp32s3.cfg"
40+
},
41+
"frameworks": [
42+
"arduino",
43+
"espidf"
44+
],
45+
"name": "LilyGo T-Deck (16M Flash 8M OPI PSRAM)",
46+
"upload": {
47+
"flash_size": "16MB",
48+
"maximum_ram_size": 327680,
49+
"maximum_size": 16777216,
50+
"require_upload_port": true,
51+
"speed": 921600
52+
},
53+
"url": "https://www.lilygo.cc",
54+
"vendor": "LilyGo"
55+
}
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
#include "core/powerSave.h"
2+
#include "core/utils.h"
3+
#include <Wire.h>
4+
#include <XPowersLib.h>
5+
#include <interface.h>
6+
7+
XPowersAXP2101 axp192;
8+
#include <TouchDrvFT6X36.hpp>
9+
TouchDrvFT6X36 touch;
10+
11+
// Haptic
12+
#include "SensorDRV2605.hpp"
13+
SensorDRV2605 drv;
14+
15+
/***************************************************************************************
16+
** Function name: _setup_gpio()
17+
** Location: main.cpp
18+
** Description: initial setup for the device
19+
***************************************************************************************/
20+
void _setup_gpio() {
21+
pinMode(16, INPUT); // Touch IRQ
22+
Wire.begin(10, 11); // sensors
23+
delay(10);
24+
Wire1.begin(39, 40); // touchscreen
25+
delay(10);
26+
_rtc.setWire(&Wire); // Cplus uses Wire1 default, the lib had been changed to accept setting I2C bus
27+
// StickCPlus uses BM8563 that is the same as PCF8536
28+
axp192.init(Wire, 10, 11);
29+
axp192.setVbusVoltageLimit(XPOWERS_AXP2101_VBUS_VOL_LIM_4V36);
30+
axp192.setVbusCurrentLimit(XPOWERS_AXP2101_VBUS_CUR_LIM_900MA);
31+
axp192.setSysPowerDownVoltage(2600);
32+
axp192.setALDO1Voltage(3300);
33+
axp192.setALDO2Voltage(3300);
34+
axp192.setALDO3Voltage(3300);
35+
axp192.setALDO4Voltage(3300);
36+
axp192.setBLDO2Voltage(3300);
37+
axp192.setDC3Voltage(3300);
38+
axp192.enableDC3(); // gps
39+
axp192.disableDC2();
40+
axp192.disableDC4();
41+
axp192.disableDC5();
42+
axp192.disableBLDO1();
43+
axp192.disableCPUSLDO();
44+
axp192.disableDLDO1();
45+
axp192.disableDLDO2();
46+
axp192.enableALDO1(); //! RTC VBAT
47+
axp192.enableALDO2(); //! TFT BACKLIGHT VDD
48+
axp192.enableALDO3(); //! Screen touch VDD
49+
axp192.enableALDO4(); //! Radio VDD
50+
axp192.enableBLDO2(); //! drv2605 enable
51+
// Set the time of pressing the button to turn off
52+
axp192.setPowerKeyPressOffTime(XPOWERS_POWEROFF_4S);
53+
// Set the button power-on press time
54+
axp192.setPowerKeyPressOnTime(XPOWERS_POWERON_128MS);
55+
// It is necessary to disable the detection function of the TS pin on the board
56+
// without the battery temperature detection function, otherwise it will cause abnormal charging
57+
axp192.disableTSPinMeasure();
58+
// Enable internal ADC detection
59+
axp192.enableBattDetection();
60+
axp192.enableVbusVoltageMeasure();
61+
axp192.enableBattVoltageMeasure();
62+
axp192.enableSystemVoltageMeasure();
63+
// t-watch no chg led
64+
axp192.setChargingLedMode(XPOWERS_CHG_LED_OFF);
65+
axp192.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
66+
// Enable the required interrupt function
67+
axp192.enableIRQ(
68+
XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | // BATTERY
69+
XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | // VBUS
70+
XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | // POWER KEY
71+
XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ // CHARGE
72+
);
73+
74+
// Clear all interrupt flags
75+
axp192.clearIrqStatus();
76+
// Set the precharge charging current
77+
axp192.setPrechargeCurr(XPOWERS_AXP2101_PRECHARGE_50MA);
78+
// Set constant current charge current limit
79+
axp192.setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_300MA);
80+
// Set stop charging termination current
81+
axp192.setChargerTerminationCurr(XPOWERS_AXP2101_CHG_ITERM_25MA);
82+
// Set charge cut-off voltage
83+
axp192.setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V35);
84+
// Set RTC Battery voltage to 3.3V
85+
axp192.setButtonBatteryChargeVoltage(3300);
86+
axp192.enableButtonBatteryCharge();
87+
88+
touch.begin(Wire1, FT6X36_SLAVE_ADDRESS, 39, 40);
89+
touch.setSwapXY(true);
90+
touch.interruptPolling();
91+
92+
// Haptic driver
93+
if (!drv.begin(Wire, 10, 11)) {
94+
Serial.println("Failed to find DRV2605.");
95+
} else {
96+
Serial.println("Init DRV2605 Sensor success!");
97+
drv.selectLibrary(1);
98+
drv.setMode(SensorDRV2605::MODE_INTTRIG);
99+
drv.useERM();
100+
101+
// Startup buzz
102+
drv.setWaveform(0, 70);
103+
drv.setWaveform(1, 0);
104+
drv.run();
105+
}
106+
}
107+
108+
/***************************************************************************************
109+
** Function name: _post_setup_gpio()
110+
** Location: main.cpp
111+
** Description: second stage gpio setup to make a few functions work
112+
***************************************************************************************/
113+
void _post_setup_gpio() {
114+
pinMode(TFT_BL, OUTPUT);
115+
digitalWrite(TFT_BL, HIGH);
116+
ledcAttach(TFT_BL, TFT_BRIGHT_FREQ, TFT_BRIGHT_Bits);
117+
ledcWrite(TFT_BL, 255);
118+
}
119+
120+
/***************************************************************************************
121+
** Function name: getBattery()
122+
** location: display.cpp
123+
** Description: Delivers the battery value from 1-100
124+
***************************************************************************************/
125+
int getBattery() {
126+
int percent = axp192.getBatteryPercent();
127+
return percent;
128+
}
129+
130+
/*********************************************************************
131+
** Function: setBrightness
132+
** location: settings.cpp
133+
** set brightness value
134+
**********************************************************************/
135+
void _setBrightness(uint8_t brightval) {
136+
int dutyCycle;
137+
if (brightval == 100) dutyCycle = 255;
138+
else if (brightval == 75) dutyCycle = 130;
139+
else if (brightval == 50) dutyCycle = 70;
140+
else if (brightval == 25) dutyCycle = 20;
141+
else if (brightval == 0) dutyCycle = 0;
142+
else dutyCycle = ((brightval * 255) / 100);
143+
144+
// log_i("dutyCycle for bright 0-255: %d", dutyCycle);
145+
ledcWrite(TFT_BL, dutyCycle);
146+
}
147+
148+
bool getTouched() { return digitalRead(16) == LOW; }
149+
struct TP {
150+
int16_t x[1], y[1];
151+
};
152+
/*********************************************************************
153+
** Function: InputHandler
154+
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
155+
**********************************************************************/
156+
void InputHandler(void) {
157+
TP t;
158+
static unsigned long tm = 0;
159+
if (millis() - tm > 200 || LongPress) {
160+
// I know R3CK.. I Should NOT nest if statements..
161+
// but it is needed to not keep SPI bus used without need, it save resources
162+
if (getTouched()) {
163+
touch.getPoint(t.x, t.y, 1);
164+
// Serial.printf("\nRAW: Touch Pressed on x=%d, y=%d",t.x, t.y);
165+
if (rotation == 3) {
166+
t.y[0] = (tftHeight + 20) - t.y[0];
167+
t.x[0] = t.x[0];
168+
}
169+
if (rotation == 0) {
170+
int tmp = t.x[0];
171+
t.x[0] = tftWidth - t.y[0];
172+
t.y[0] = tftHeight - tmp;
173+
}
174+
if (rotation == 2) {
175+
int tmp = t.x[0];
176+
t.x[0] = t.y[0];
177+
t.y[0] = tmp;
178+
}
179+
if (rotation == 1) { t.x[0] = tftWidth - t.x[0]; }
180+
// Serial.printf("\nROT: Touch Pressed on x=%d, y=%d\n",t.x[0], t.y[0]);
181+
182+
if (!wakeUpScreen()) AnyKeyPress = true;
183+
else return;
184+
185+
// Touch point global variable
186+
touchPoint.x = t.x[0];
187+
touchPoint.y = t.y[0];
188+
touchPoint.pressed = true;
189+
touchHeatMap(touchPoint);
190+
191+
tm = millis();
192+
drv.setWaveform(0, 75);
193+
drv.setWaveform(1, 0); // end waveform
194+
drv.run();
195+
}
196+
}
197+
}
198+
199+
/*********************************************************************
200+
** Function: powerOff
201+
** location: mykeyboard.cpp
202+
** Turns off the device (or try to)
203+
**********************************************************************/
204+
void powerOff() {}
205+
206+
/*********************************************************************
207+
** Function: checkReboot
208+
** location: mykeyboard.cpp
209+
** Btn logic to turn off the device (name is odd btw)
210+
**********************************************************************/
211+
void checkReboot() {}
212+
213+
/***************************************************************************************
214+
** Function name: isCharging()
215+
** Description: Determines if the device is charging
216+
***************************************************************************************/
217+
bool isCharging() {
218+
return axp192.isCharging(); // Return the charging status from AXP
219+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:lilygo-t-watch-s3]
12+
board = lilygo-t-watch-s3
13+
board_build.partitions = support_files/custom_16Mb_ultra.csv
14+
build_src_filter =${env.build_src_filter} +<../boards/lilygo-t-watch-s3>
15+
build_flags =
16+
${env.build_flags}
17+
-Iboards/lilygo-t-watch-s3
18+
-mfix-esp32-psram-cache-issue
19+
-mfix-esp32-psram-cache-strategy=memw
20+
-DOTA_TAG='"t-watch-s3"'
21+
22+
;-DPART_04MB =0
23+
;-DPART_08MB=0
24+
-DPART_16MB=1
25+
26+
;Font sizes, depending on device
27+
-DFP=1
28+
-DFM=2
29+
-DFG=3
30+
31+
;Screen Setup
32+
-DHAS_SCREEN=1
33+
-DROTATION=2
34+
35+
;tft Brighness Control
36+
-DTFT_BRIGHT_CHANNEL=3
37+
-DTFT_BRIGHT_Bits=8
38+
-DTFT_BRIGHT_FREQ=1000
39+
40+
;TFT_eSPI display
41+
-DUSE_TFT_ESPI
42+
-DUSER_SETUP_LOADED=1
43+
-DUSE_HSPI_PORT=1
44+
;-DUSER_SETUP_ID=214
45+
-DST7789_DRIVER=1
46+
-DTFT_WIDTH=240
47+
-DTFT_HEIGHT=240
48+
-DTFT_INVERSION_ON
49+
-DTFT_BL=45
50+
-DTFT_MISO=-1
51+
-DTFT_MOSI=13
52+
-DTFT_SCLK=18
53+
-DTFT_CS=12
54+
-DTFT_DC=38
55+
-DTFT_RST=-1
56+
-DTOUCH_CS=-1
57+
58+
;TouchScreen Controller
59+
-DHAS_TOUCH=1
60+
61+
-DSMOOTH_FONT=1
62+
63+
;SD Card Setup pins
64+
-DSDCARD_CS=-1
65+
-DSDCARD_SCK=-1
66+
-DSDCARD_MISO=-1
67+
-DSDCARD_MOSI=-1
68+
69+
lib_deps =
70+
${env.lib_deps}
71+
lewisxhe/XPowersLib @0.2.7
72+
lewisxhe/SensorLib@0.3.4

0 commit comments

Comments
 (0)