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
   return (data[1] + data[2]) >> 1;
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
 #endif // TOUCH_BUTTONS
146
 #endif // TOUCH_BUTTONS

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

42
 public:
42
 public:
43
   static void init(void);
43
   static void init(void);
44
   static uint8_t read_buttons();
44
   static uint8_t read_buttons();
45
-private:
45
+  bool getTouchPoint(uint16_t &x, uint16_t &y);
46
   static bool isTouched();
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
   static uint16_t getInTouch(const XPTCoordinate coordinate);
50
   static uint16_t getInTouch(const XPTCoordinate coordinate);
48
 };
51
 };
49
 
52
 

Loading…
Cancel
Save