-
Notifications
You must be signed in to change notification settings - Fork 0
/
NS2009.h
41 lines (34 loc) · 1.04 KB
/
NS2009.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
#ifndef _NS2009_H_
#define _NS2009_H_
#define DEFAULT_NS2009_ADDR 0x48 //10010000
#define THRESHOLD_Z 150 // this is a sensitivity threshold value on how hard the touch screen must be touched to react
#define NS2009_READ_X 0xC0
#define NS2009_READ_Y 0xD0
#define NS2009_READ_Z 0xE0
#define CALIBRATE_MIN_X 200
#define CALIBRATE_MIN_Y 400
#define CALIBRATE_MAX_X 3850
#define CALIBRATE_MAX_Y 3920
#define SCREEN_SIZE_X 240
#define SCREEN_SIZE_Y 320
#define MIN(A,B) (A<B?A:B)
#define MAX(A,B) (A>B?A:B)
class NS2009
{
int Address, MinX=CALIBRATE_MIN_X, MinY=CALIBRATE_MIN_Y, MaxX=CALIBRATE_MAX_X, MaxY=CALIBRATE_MAX_Y;
bool FlipX, FlipY;
unsigned int ReadRegister (unsigned char Command);
public:
int RawX, X, RawY, Y, RawZ;
bool Touched;
NS2009 (void);
NS2009 (unsigned char _Address);
NS2009 (bool _FlipX, bool _FlipY);
NS2009 (unsigned char _Address, bool _FlipX, bool _FlipY);
void Calibrate ();
void Calibrate (int _MinX, int _MaxX, int _MinY, int _MaxY);
bool CheckTouched ();
void Scan ();
void ScanBlocking ();
};
#endif