Browse Source

Add XPT2046 calibration functions (#15140)

pull/1/head
Tanguy Pruvot 5 years ago
committed by Scott Lahteine
parent
commit
85f0556118
  1. 8
      Marlin/src/feature/touch/xpt2046.cpp
  2. 5
      Marlin/src/feature/touch/xpt2046.h

8
Marlin/src/feature/touch/xpt2046.cpp

@ -135,4 +135,12 @@ uint16_t XPT2046::getInTouch(const XPTCoordinate coordinate) {
return (data[1] + data[2]) >> 1;
}
bool XPT2046::getTouchPoint(uint16_t &x, uint16_t &y) {
if (isTouched()) {
x = getInTouch(XPT2046_X);
y = getInTouch(XPT2046_Y);
}
return isTouched();
}
#endif // TOUCH_BUTTONS

5
Marlin/src/feature/touch/xpt2046.h

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

Loading…
Cancel
Save