Browse Source

Add XPT2046 calibration functions (#15140)

Tanguy Pruvot 5 years ago
parent
commit
85f0556118
2 changed files with 12 additions and 1 deletions
  1. 8
    0
      Marlin/src/feature/touch/xpt2046.cpp
  2. 4
    1
      Marlin/src/feature/touch/xpt2046.h

+ 8
- 0
Marlin/src/feature/touch/xpt2046.cpp View File

@@ -135,4 +135,12 @@ uint16_t XPT2046::getInTouch(const XPTCoordinate coordinate) {
135 135
   return (data[1] + data[2]) >> 1;
136 136
 }
137 137
 
138
+bool XPT2046::getTouchPoint(uint16_t &x, uint16_t &y) {
139
+  if (isTouched()) {
140
+    x = getInTouch(XPT2046_X);
141
+    y = getInTouch(XPT2046_Y);
142
+  }
143
+  return isTouched();
144
+}
145
+
138 146
 #endif // TOUCH_BUTTONS

+ 4
- 1
Marlin/src/feature/touch/xpt2046.h View File

@@ -42,8 +42,11 @@ class XPT2046 {
42 42
 public:
43 43
   static void init(void);
44 44
   static uint8_t read_buttons();
45
-private:
45
+  bool getTouchPoint(uint16_t &x, uint16_t &y);
46 46
   static bool isTouched();
47
+  inline void waitForRelease(void) { while (isTouched()) { /* nada */ } }
48
+  inline void waitForTouch(uint16_t &x, uint16_t &y) { while (!getTouchPoint(x, y)) { /* nada */ } }
49
+private:
47 50
   static uint16_t getInTouch(const XPTCoordinate coordinate);
48 51
 };
49 52
 

Loading…
Cancel
Save