Skip to content

Commit 55e708d

Browse files
committed
Added touch config to pico sdk example
1 parent 3e2c03d commit 55e708d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples_for_picosdk/spi/LGFX_config.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414
#endif
1515
#define SPI_PORT 0
1616

17+
#ifdef USE_TOUCH
18+
#define TOUCH_CS 29
19+
#endif
20+
1721
class LGFX : public lgfx::LGFX_Device
1822
{
1923
lgfx::Panel_ST7735S _panel_instance;
2024
lgfx::Bus_SPI _bus_instance; // SPIバスのインスタンス
2125
#ifdef USE_BACKLIGHT
2226
lgfx::Light_PWM _light_instance;
2327
#endif
28+
#ifdef USE_TOUCH
29+
lgfx::Touch_XPT2046 _touch_instance;
30+
#endif
2431

2532
public:
2633
LGFX(void)
@@ -76,6 +83,22 @@ class LGFX : public lgfx::LGFX_Device
7683
}
7784
#endif
7885

86+
#ifdef USE_TOUCH
87+
{
88+
auto cfg = _touch_instance.config();
89+
cfg.bus_shared = true;
90+
cfg.spi_host = SPI_PORT;
91+
cfg.pin_sclk = TFT_SCLK;
92+
cfg.pin_mosi = TFT_MOSI;
93+
cfg.pin_miso = TFT_MISO;
94+
cfg.pin_cs = TOUCH_CS;
95+
96+
_touch_instance.config(cfg);
97+
_panel_instance.setTouch(&_touch_instance);
98+
}
99+
#endif
100+
101+
79102
setPanel(&_panel_instance); // 使用するパネルをセットします。
80103
}
81104
};

0 commit comments

Comments
 (0)