Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Marlin/src/feature/touch/xpt2046.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 4 additions & 1 deletion Marlin/src/feature/touch/xpt2046.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down