-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTouchScreen_STM32.h
41 lines (34 loc) · 1.01 KB
/
TouchScreen_STM32.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Touch screen library with X, Y and Z (pressure) readings
// includes simple averaging samples to de-bounce
#ifndef _ADAFRUIT_TOUCHSCREEN_STM_H_
#define _ADAFRUIT_TOUCHSCREEN_STM_H_
#include <stdint.h>
class TSPoint {
public:
TSPoint(void);
TSPoint(int16_t x, int16_t y);
int x, y, z, x_old, y_old, repeat, dbl;
};
class TouchScreen {
public:
TouchScreen(uint8_t xp, uint8_t yp, uint8_t xm, uint8_t ym);
void rangeSet(int xmax, int ymax);
bool getPoint(TSPoint* tsp);
void calibratePoint(void);
void getCalibrationParameters(int *xmin, int *xmax, int *ymin, int *ymax);
void setCalibrationParameters(int xmin, int xmax, int ymin, int ymax);
int pressureThreshhold;
private:
bool getPoint(void);
int readADC(uint8_t pin);
int readPressure(void);
void readTouchY(void);
void readTouchX(void);
void waitForTouch(void);
void waitForRelease(void);
uint8_t _yp, _ym, _xm, _xp; // resistive plate pins
int xmax, ymax, xmin, ymin, x_range, y_range;
int x_rep, y_rep;
uint32_t last_touch_time;
};
#endif