Skip to content

Commit 12e0869

Browse files
committed
CYD-3248W535C fix and port
#108
1 parent 2626fb6 commit 12e0869

5 files changed

Lines changed: 34 additions & 4 deletions

File tree

boards/CYD-2432S028/custom_flags.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def generate_build_flags(board_config):
2424
flags = []
2525

2626
# Configurações de hardware
27-
flags.append("-DROTATION=3")
2827
flags.append("-DHAS_BTN=0")
2928
flags.append("-DSEL_BTN=-1")
3029
flags.append("-DUP_BTN=-1")
@@ -60,6 +59,7 @@ def generate_build_flags(board_config):
6059
flags.append("-DTFT_ROW_OFS1=0")
6160
flags.append("-DTFT_COL_OFS2=0")
6261
flags.append("-DTFT_ROW_OFS2=0")
62+
flags.append("-DROTATION=3")
6363

6464
elif any("DISPLAY_ST7796_SPI" in flag for flag in extra_flags):
6565
flags.append("-DST7796_DRIVER=1")
@@ -77,6 +77,7 @@ def generate_build_flags(board_config):
7777
flags.append("-DTFT_ROW_OFS1=0")
7878
flags.append("-DTFT_COL_OFS2=0")
7979
flags.append("-DTFT_ROW_OFS2=0")
80+
flags.append("-DROTATION=3")
8081

8182
elif any("DISPLAY_ST7789_SPI" in flag for flag in extra_flags):
8283
flags.append("-DST7789_DRIVER=1")
@@ -94,6 +95,7 @@ def generate_build_flags(board_config):
9495
flags.append("-DTFT_ROW_OFS1=0")
9596
flags.append("-DTFT_COL_OFS2=0")
9697
flags.append("-DTFT_ROW_OFS2=0")
98+
flags.append("-DROTATION=3")
9799

98100
elif any("DISPLAY_AXS15231B_QSPI" in flag for flag in extra_flags):
99101
flags.append("-DAXS15231B_QSPI=1")
@@ -115,6 +117,7 @@ def generate_build_flags(board_config):
115117
flags.append("-DTFT_ROW_OFS1=0")
116118
flags.append("-DTFT_COL_OFS2=0")
117119
flags.append("-DTFT_ROW_OFS2=0")
120+
flags.append("-DROTATION=0")
118121

119122

120123
elif any("DISPLAY_ST7789_I80" in flag for flag in extra_flags):
@@ -147,18 +150,21 @@ def generate_build_flags(board_config):
147150
flags.append("-DTFT_IPS=0")
148151
flags.append("-DTFT_COL_OFS1=0")
149152
flags.append("-DTFT_ROW_OFS1=0")
153+
flags.append("-DROTATION=3")
150154

151155
elif any("DISPLAY_ST7262_PAR" in flag for flag in extra_flags):
152156
flags.append("-DRGB_PANEL=1")
153157
flags.append("-DTFT_BL=GPIO_BCKL")
154158
flags.append("-DTFT_WIDTH=DISPLAY_WIDTH")
155159
flags.append("-DTFT_HEIGHT=DISPLAY_HEIGHT")
160+
flags.append("-DROTATION=3")
156161

157162
elif any("DISPLAY_ST7701_PAR" in flag for flag in extra_flags):
158163
flags.append("-DRGB_PANEL=1")
159164
flags.append("-DTFT_BL=GPIO_BCKL")
160165
flags.append("-DTFT_WIDTH=DISPLAY_WIDTH")
161166
flags.append("-DTFT_HEIGHT=DISPLAY_HEIGHT")
167+
flags.append("-DROTATION=3")
162168

163169

164170
else:
@@ -177,6 +183,7 @@ def generate_build_flags(board_config):
177183
flags.append("-DTFT_ROW_OFS1=0")
178184
flags.append("-DTFT_COL_OFS2=0")
179185
flags.append("-DTFT_ROW_OFS2=0")
186+
flags.append("-DROTATION=3")
180187

181188
# Verifica suporte ao touch
182189
if any("TOUCH_XPT2046_SPI" in flag for flag in extra_flags):

boards/CYD-2432S028/interface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,14 @@ void _setBrightness(uint8_t brightval) {
187187
**********************************************************************/
188188
void InputHandler(void) {
189189
static long d_tmp = millis();
190+
bool touched = touch.touched(); // read every cycle to skip bad readings
190191
if (millis() - d_tmp > 250 || LongPress) { // I know R3CK.. I Should NOT nest if statements..
191192
// but it is needed to not keep SPI bus used without need, it save resources
192193
TouchPoint t;
193194
#ifdef DONT_USE_INPUT_TASK
194195
checkPowerSaveTime();
195196
#endif
196-
if (touch.touched()) {
197+
if (touched) {
197198
auto t = touch.getPointScaled();
198199
d_tmp = millis();
199200
#ifdef DONT_USE_INPUT_TASK // need to reset the variables to avoid ghost click

boards/CYD-2432S028/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ build_flags =
245245
-DTFT_WIDTH=DISPLAY_WIDTH
246246
-DTFT_HEIGHT=DISPLAY_HEIGHT
247247
-DTFT_BL=GPIO_BCKL
248+
-DUSE_CANVAS=1
248249

249250

250251
[env:CYD-4827S043R]

boards/_jsonfiles/esp32s3-3248W535N.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@
5454
"'-D AXS15231B_TOUCH_I2C_IRQ=3'",
5555
"'-D DISPLAY_SWAP_XY=false'",
5656
"'-D DISPLAY_MIRROR_X=false'",
57-
"'-D DISPLAY_MIRROR_Y=false'"
57+
"'-D DISPLAY_MIRROR_Y=false'",
58+
"'-D BOARD_HAS_TF'",
59+
"'-D TF_CS=10'",
60+
"'-D TF_SPI_MOSI=11'",
61+
"'-D TF_SPI_SCLK=12'",
62+
"'-D TF_SPI_MISO=13'"
5863
],
5964
"f_cpu": "240000000L",
6065
"f_flash": "80000000L",
@@ -85,4 +90,4 @@
8590
},
8691
"url": "https://nl.aliexpress.com/item/1005007593889279.html",
8792
"vendor": "Guition"
88-
}
93+
}

src/tft.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,20 @@ class Ard_eSPI : public ARD_TFT_BASE {
600600
uint16_t ro1, uint16_t co2, uint16_t ro2
601601
)
602602
#ifdef USE_CANVAS
603+
#ifdef ARDUINO_T_WATCH_S3_ULTRA
603604
: ARD_TFT_BASE(rotation & 0x1 ? h : w, rotation & 0x1 ? w : h, nullptr, 0, 0, 0),
604605
_outputDriver(_TFT_DRVF(bus, rst, rotation, ips, w, h, co1, ro1, co2, ro2)) {
605606
this->_output = &_outputDriver;
606607
}
608+
#else
609+
// Canvas must be created with the physical (unrotated) dimensions and the
610+
// desired rotation so that its internal framebuffer layout matches what
611+
// the output driver expects when flush() calls draw16bitRGBBitmap(WIDTH, HEIGHT).
612+
: ARD_TFT_BASE(w, h, nullptr, 0, 0, rotation),
613+
_outputDriver(_TFT_DRVF(bus, rst, 0, 1, w, h, co1, ro1, co2, ro2)) {
614+
this->_output = &_outputDriver;
615+
}
616+
#endif
607617
#else
608618
: _TFT_DRVF(bus, rst, rotation, ips, w, h, co1, ro1, co2, ro2) {
609619
}
@@ -619,8 +629,14 @@ class Ard_eSPI : public ARD_TFT_BASE {
619629
#ifdef USE_CANVAS
620630
inline bool begin(int32_t speed = GFX_NOT_DEFINED) { return ARD_TFT_BASE::begin(speed); }
621631
inline void setRotation(uint8_t rot) {
632+
#ifdef ARDUINO_T_WATCH_S3_ULTRA
622633
// ARD_TFT_BASE::setRotation(rot);
623634
_outputDriver.setRotation(rot);
635+
#else
636+
637+
// Canvas handles rotation in the framebuffer; do not rotate the output driver.
638+
ARD_TFT_BASE::setRotation(rot);
639+
#endif
624640
}
625641
inline void invertDisplay(bool i) { _outputDriver.invertDisplay(i); }
626642
#endif

0 commit comments

Comments
 (0)