Browse Source

🚑️ Fix BIQU BX touch freeze (#24383)

Victor Oliveira 3 years ago
parent
commit
3c13be165b
No account linked to committer's email address
2 changed files with 11 additions and 7 deletions
  1. 10
    6
      Marlin/src/HAL/STM32/tft/gt911.cpp
  2. 1
    1
      Marlin/src/HAL/STM32/tft/gt911.h

+ 10
- 6
Marlin/src/HAL/STM32/tft/gt911.cpp View File

@@ -159,24 +159,28 @@ void GT911::read_reg(uint16_t reg, uint8_t reg_len, uint8_t* r_data, uint8_t r_l
159 159
 void GT911::Init() {
160 160
   OUT_WRITE(GT911_RST_PIN, LOW);
161 161
   OUT_WRITE(GT911_INT_PIN, LOW);
162
-  delay(20);
162
+  delay(11);
163
+  WRITE(GT911_INT_PIN, HIGH);
164
+  delayMicroseconds(110);
163 165
   WRITE(GT911_RST_PIN, HIGH);
166
+  delay(6);
167
+  WRITE(GT911_INT_PIN, LOW);
168
+  delay(55);
164 169
   SET_INPUT(GT911_INT_PIN);
165 170
 
166 171
   sw_iic.init();
167 172
 
168
-  uint8_t clear_reg = 0x0000;
169
-  write_reg(0x814E, 2, &clear_reg, 2); // Reset to 0 for start
173
+  uint8_t clear_reg = 0x00;
174
+  write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start
170 175
 }
171 176
 
172 177
 bool GT911::getFirstTouchPoint(int16_t *x, int16_t *y) {
173 178
   read_reg(0x814E, 2, &reg.REG.status, 1);
174 179
 
175
-  if (reg.REG.status & 0x80) {
180
+  if (reg.REG.status >= 0x80 && reg.REG.status <= 0x85) {
181
+    read_reg(0x8150, 2, reg.map + 2, 38);
176 182
     uint8_t clear_reg = 0x00;
177 183
     write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start
178
-    read_reg(0x8150, 2, reg.map + 2, 8 * (reg.REG.status & 0x0F));
179
-
180 184
     // First touch point
181 185
     *x = ((reg.REG.point[0].xh & 0x0F) << 8) | reg.REG.point[0].xl;
182 186
     *y = ((reg.REG.point[0].yh & 0x0F) << 8) | reg.REG.point[0].yl;

+ 1
- 1
Marlin/src/HAL/STM32/tft/gt911.h View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 #include "../../../inc/MarlinConfig.h"
25 25
 
26
-#define GT911_SLAVE_ADDRESS   0xBA
26
+#define GT911_SLAVE_ADDRESS   0x28
27 27
 
28 28
 #if !PIN_EXISTS(GT911_RST)
29 29
   #error "GT911_RST_PIN is not defined."

Loading…
Cancel
Save