2019-07-15 01:16:26 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2019-07-15 01:16:26 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 05:20:14 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-07-15 01:16:26 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
// Relies on XPT2046-compatible mode of ADS7843,
|
|
|
|
// hence no Z1 / Z2 measurements are possible.
|
|
|
|
|
|
|
|
#define XPT2046_DFR_MODE 0x00
|
|
|
|
#define XPT2046_SER_MODE 0x04
|
|
|
|
#define XPT2046_CONTROL 0x80
|
|
|
|
|
|
|
|
enum XPTCoordinate : uint8_t {
|
2019-07-17 11:41:10 +02:00
|
|
|
XPT2046_X = 0x10,
|
|
|
|
XPT2046_Y = 0x50,
|
|
|
|
XPT2046_Z1 = 0x30,
|
|
|
|
XPT2046_Z2 = 0x40
|
2019-07-15 01:16:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class XPT2046 {
|
|
|
|
public:
|
2019-09-17 03:31:08 +02:00
|
|
|
static void init();
|
2019-07-15 01:16:26 +02:00
|
|
|
static uint8_t read_buttons();
|
2019-09-05 00:32:20 +02:00
|
|
|
bool getTouchPoint(uint16_t &x, uint16_t &y);
|
2019-07-17 11:41:10 +02:00
|
|
|
static bool isTouched();
|
2019-09-17 03:31:08 +02:00
|
|
|
inline void waitForRelease() { while (isTouched()) { /* nada */ } }
|
2019-09-05 00:32:20 +02:00
|
|
|
inline void waitForTouch(uint16_t &x, uint16_t &y) { while (!getTouchPoint(x, y)) { /* nada */ } }
|
|
|
|
private:
|
2019-07-15 01:16:26 +02:00
|
|
|
static uint16_t getInTouch(const XPTCoordinate coordinate);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern XPT2046 touch;
|