@@ -19,8 +19,8 @@ class Panel_HELTEC_V4_TFT : public lgfx::Panel_ST7789
1919#ifdef CUSTOM_TOUCH_DRIVER
2020#include " chsc6x.h"
2121
22- #define SCREEN_X 320
23- #define SCREEN_Y 240
22+ #define SCREEN_X 320
23+ #define SCREEN_Y 240
2424
2525// custom class for redirecting getTouch() calls and to alternative implementation
2626class LGFX_Touch : public lgfx ::LGFX_Device
@@ -29,8 +29,8 @@ class LGFX_Touch : public lgfx::LGFX_Device
2929 bool init_impl (bool use_reset, bool use_clear) override
3030 {
3131 bool result = LGFX_Device::init_impl (use_reset, use_clear);
32- if (chsc6xTouch== nullptr ){
33- chsc6xTouch= new chsc6x (&Wire1,TOUCH_SDA_PIN ,TOUCH_SCL_PIN ,TOUCH_INT_PIN ,TOUCH_RST_PIN );
32+ if (chsc6xTouch == nullptr ) {
33+ chsc6xTouch = new chsc6x (&Wire1, TOUCH_SDA_PIN , TOUCH_SCL_PIN , TOUCH_INT_PIN , TOUCH_RST_PIN );
3434 }
3535 chsc6xTouch->chsc6x_init ();
3636 return result;
@@ -40,25 +40,25 @@ class LGFX_Touch : public lgfx::LGFX_Device
4040 void rotate_touch_coord (uint16_t raw_x, uint16_t raw_y, uint16_t rotation, uint16_t *out_x, uint16_t *out_y)
4141 {
4242 switch (rotation) {
43- case 0 : // 0°
44- *out_x = raw_x;
45- *out_y = raw_y;
46- break ;
47- case 1 : // 90°
48- *out_x = raw_y;
49- *out_y = SCREEN_X - 1 - raw_x;
50- break ;
51- case 2 : // 180°
52- *out_x = SCREEN_X - 1 - raw_x;
53- *out_y = SCREEN_Y - 1 - raw_y;
54- break ;
55- case 3 : // 270°
56- *out_x = SCREEN_Y - 1 - raw_y;
57- *out_y = raw_x;
58- break ;
59- default : // fallback
60- *out_x = raw_x;
61- *out_y = raw_y;
43+ case 0 : // 0°
44+ *out_x = raw_x;
45+ *out_y = raw_y;
46+ break ;
47+ case 1 : // 90°
48+ *out_x = raw_y;
49+ *out_y = SCREEN_X - 1 - raw_x;
50+ break ;
51+ case 2 : // 180°
52+ *out_x = SCREEN_X - 1 - raw_x;
53+ *out_y = SCREEN_Y - 1 - raw_y;
54+ break ;
55+ case 3 : // 270°
56+ *out_x = SCREEN_Y - 1 - raw_y;
57+ *out_y = raw_x;
58+ break ;
59+ default : // fallback
60+ *out_x = raw_x;
61+ *out_y = raw_y;
6262 }
6363 }
6464
@@ -68,18 +68,19 @@ class LGFX_Touch : public lgfx::LGFX_Device
6868
6969 bool getTouchXY (uint16_t *touchX, uint16_t *touchY)
7070 {
71- uint16_t rwa_x,raw_y;
72- if (chsc6xTouch->chsc6x_read_touch_info (&rwa_x, &raw_y)== 0 ) {
73- rotate_touch_coord (rwa_x, raw_y,0 , touchX, touchY);
71+ uint16_t rwa_x, raw_y;
72+ if (chsc6xTouch->chsc6x_read_touch_info (&rwa_x, &raw_y) == 0 ) {
73+ rotate_touch_coord (rwa_x, raw_y, 0 , touchX, touchY);
7474 return true ;
7575 }
7676 return false ;
7777 };
7878
79- void wakeup (void ) {};
80- void sleep (void ) {};
81- private:
82- chsc6x *chsc6xTouch=nullptr ;
79+ void wakeup (void ){};
80+ void sleep (void ){};
81+
82+ private:
83+ chsc6x *chsc6xTouch = nullptr ;
8384};
8485
8586class LGFX_HELTEC_V4_TFT : public LGFX_Touch
@@ -105,16 +106,16 @@ class LGFX_HELTEC_V4_TFT : public lgfx::LGFX_Device
105106 cfg.spi_host = SPI3_HOST ;
106107 cfg.spi_mode = 0 ;
107108 cfg.freq_write = 80000000 ; // SPI clock for transmission (up to 80MHz, rounded to
108- // the value obtained by dividing 80MHz by an integer)
109- cfg.freq_read = 16000000 ; // SPI clock when receiving
109+ // the value obtained by dividing 80MHz by an integer)
110+ cfg.freq_read = 16000000 ; // SPI clock when receiving
110111 cfg.spi_3wire = true ;
111112 cfg.use_lock = true ; // Set to true to use transaction locking
112113 cfg.dma_channel = SPI_DMA_CH_AUTO ; // SPI_DMA_CH_AUTO; // Set DMA channel
113114 // to use (0=not use DMA / 1=1ch / 2=ch
114115 // / SPI_DMA_CH_AUTO=auto setting)
115116 cfg.pin_sclk = LGFX_PIN_SCK ; // Set SPI SCLK pin number
116117 cfg.pin_mosi = LGFX_PIN_MOSI ; // Set SPI MOSI pin number
117- cfg.pin_miso = -1 ; // Set SPI MISO pin number (-1 = disable)
118+ cfg.pin_miso = -1 ; // Set SPI MISO pin number (-1 = disable)
118119 cfg.pin_dc = LGFX_PIN_DC ; // Set SPI DC pin number (-1 = disable)
119120
120121 _bus_instance.config (cfg); // applies the set value to the bus.
@@ -124,27 +125,27 @@ class LGFX_HELTEC_V4_TFT : public lgfx::LGFX_Device
124125 { // Set the display panel control.
125126 auto cfg = _panel_instance.config (); // Gets a structure for display panel settings.
126127
127- cfg.pin_cs = LGFX_PIN_CS ; // Pin number where CS is connected (-1 = disable)
128- cfg.pin_rst = LGFX_PIN_RST ; // Pin number where RST is connected (-1 = disable)
129- cfg.pin_busy = -1 ; // Pin number where BUSY is connected (-1 = disable)
128+ cfg.pin_cs = LGFX_PIN_CS ; // Pin number where CS is connected (-1 = disable)
129+ cfg.pin_rst = LGFX_PIN_RST ; // Pin number where RST is connected (-1 = disable)
130+ cfg.pin_busy = -1 ; // Pin number where BUSY is connected (-1 = disable)
130131
131132 // The following setting values are general initial values for
132133 // each panel, so please comment out any unknown items and try them.
133134
134- cfg.panel_width = screenWidth; // actual displayable width
135- cfg.panel_height = screenHeight; // actual displayable height
136- cfg.offset_x = 0 ; // Panel offset amount in X direction
137- cfg.offset_y = 0 ; // Panel offset amount in Y direction
138- cfg.offset_rotation = 0 ; // Rotation direction value offset 0~7 (4~7 is upside down)
139- cfg.dummy_read_pixel = 9 ; // Number of bits for dummy read before pixel readout
140- cfg.dummy_read_bits = 1 ; // Number of bits for dummy read before non-pixel data read
141- cfg.readable = false ; // Set to true if data can be read
142- cfg.invert = true ; // Set to true if the light/darkness of the panel is reversed
143- cfg.rgb_order = false ; // Set to true if the panel's red and blue are swapped
144- cfg.dlen_16bit = false ; // Set to true for panels that transmit data length in 16-bit
145- // units with 16-bit parallel or SPI
146- cfg.bus_shared = false ; // If the bus is shared with the SD card, set to
147- // true (bus control with drawJpgFile etc.)
135+ cfg.panel_width = screenWidth; // actual displayable width
136+ cfg.panel_height = screenHeight; // actual displayable height
137+ cfg.offset_x = 0 ; // Panel offset amount in X direction
138+ cfg.offset_y = 0 ; // Panel offset amount in Y direction
139+ cfg.offset_rotation = 0 ; // Rotation direction value offset 0~7 (4~7 is upside down)
140+ cfg.dummy_read_pixel = 9 ; // Number of bits for dummy read before pixel readout
141+ cfg.dummy_read_bits = 1 ; // Number of bits for dummy read before non-pixel data read
142+ cfg.readable = false ; // Set to true if data can be read
143+ cfg.invert = true ; // Set to true if the light/darkness of the panel is reversed
144+ cfg.rgb_order = false ; // Set to true if the panel's red and blue are swapped
145+ cfg.dlen_16bit = false ; // Set to true for panels that transmit data length in 16-bit
146+ // units with 16-bit parallel or SPI
147+ cfg.bus_shared = false ; // If the bus is shared with the SD card, set to
148+ // true (bus control with drawJpgFile etc.)
148149
149150 // Set the following only when the display is shifted with a driver with a
150151 // variable number of pixels, such as the ST7735 or ILI9163.
0 commit comments