Browse Source

Adding EXC7200 driver

Joel Bodenmann 3 years ago
parent
commit
c95a851c77

+ 2 - 1
docs/releases.txt

@@ -2,8 +2,9 @@
2 2
 *** Releases                                                              ***
3 3
 *****************************************************************************
4 4
 
5
-*** Changes after 2.6 ***
6 5
 
6
+*** Changes after 2.6 ***
7
+FEATURE:	Added EXC7200 driver
7 8
 
8 9
 
9 10
 *** Release 2.6 ***

+ 1 - 0
drivers/ginput/touch/EXC7200/driver.mk

@@ -0,0 +1 @@
1
+GFXSRC += $(GFXLIB)/drivers/ginput/touch/EXC7200/gmouse_lld_EXC7200.c

+ 83 - 0
drivers/ginput/touch/EXC7200/gmouse_lld_EXC7200.c

@@ -0,0 +1,83 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+#include "gfx.h"
9
+
10
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
11
+
12
+#define GMOUSE_DRIVER_VMT		GMOUSEVMT_EXC7200
13
+#include "../../../../src/ginput/ginput_driver_mouse.h"
14
+
15
+// Get the hardware interface
16
+#include "gmouse_lld_EXC7200_board.h"
17
+
18
+#define EXC7200_READ_CMD 0x09
19
+
20
+static bool_t MouseInit(GMouse* m, unsigned driverinstance)
21
+{
22
+	if (!init_board(m, driverinstance)) {
23
+		return FALSE;
24
+	}
25
+	
26
+	return TRUE;
27
+}
28
+
29
+static bool_t read_xyz(GMouse* m, GMouseReading* pdr)
30
+{
31
+	uint8_t rxbuf[10];
32
+	
33
+	// We don't support buttons. This is a regular touchscreen
34
+	pdr->buttons = 0;
35
+
36
+	// Read
37
+	if (!read_bytes(m, EXC7200_READ_CMD, rxbuf, 10)) {
38
+		return FALSE;
39
+	}
40
+	
41
+	// Check if touched
42
+	if (rxbuf[1] == 0x83) {
43
+		pdr->x = (((rxbuf[3] & 0x00ff) << 4) | ((rxbuf[2] & 0x00f0) >> 4)) << 1;
44
+		pdr->y = (((rxbuf[5] & 0x00ff) << 4) | ((rxbuf[4] & 0x00f0) >> 4)) << 1;
45
+		pdr->z = 1;
46
+	} else {
47
+		pdr->z = 0;
48
+	}	
49
+
50
+	return TRUE;
51
+}
52
+
53
+const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
54
+	{
55
+		GDRIVER_TYPE_TOUCH,
56
+		GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN | GMOUSE_VFLG_CALIBRATE | GMOUSE_VFLG_CAL_TEST,
57
+		sizeof(GMouse) + GMOUSE_EXC7200_BOARD_DATA_SIZE,
58
+		_gmouseInitDriver,
59
+		_gmousePostInitDriver,
60
+		_gmouseDeInitDriver
61
+	},
62
+	1,				// z_max - not supported
63
+	0,				// z_min - not supported
64
+	1,				// z_touchon
65
+	0,				// z_touchoff
66
+	{				// pen_jitter
67
+		GMOUSE_EXC7200_PEN_CALIBRATE_ERROR,			// calibrate
68
+		GMOUSE_EXC7200_PEN_CLICK_ERROR,				// click
69
+		GMOUSE_EXC7200_PEN_MOVE_ERROR				// move
70
+	},
71
+	{				// finger_jitter
72
+		GMOUSE_EXC7200_FINGER_CALIBRATE_ERROR,		// calibrate
73
+		GMOUSE_EXC7200_FINGER_CLICK_ERROR,			// click
74
+		GMOUSE_EXC7200_FINGER_MOVE_ERROR			// move
75
+	},
76
+	MouseInit, 		// init
77
+	0,				// deinit
78
+	read_xyz,		// get
79
+	0,				// calsave
80
+	0				// calload
81
+}};
82
+
83
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */

+ 46 - 0
drivers/ginput/touch/EXC7200/gmouse_lld_EXC7200_board_template.h

@@ -0,0 +1,46 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+#ifndef _GINPUT_LLD_MOUSE_BOARD_H
9
+#define _GINPUT_LLD_MOUSE_BOARD_H
10
+
11
+// Resolution and Accuracy Settings
12
+#define GMOUSE_EXC7200_PEN_CALIBRATE_ERROR		8
13
+#define GMOUSE_EXC7200_PEN_CLICK_ERROR			6
14
+#define GMOUSE_EXC7200_PEN_MOVE_ERROR			4
15
+#define GMOUSE_EXC7200_FINGER_CALIBRATE_ERROR	14
16
+#define GMOUSE_EXC7200_FINGER_CLICK_ERROR		18
17
+#define GMOUSE_EXC7200_FINGER_MOVE_ERROR		14
18
+
19
+// How much extra data to allocate at the end of the GMouse structure for the board's use
20
+#define GMOUSE_EXC7200_BOARD_DATA_SIZE			0
21
+
22
+static bool_t init_board(GMouse* m, unsigned driverinstance)
23
+{
24
+}
25
+
26
+static GFXINLINE void aquire_bus(GMouse* m)
27
+{
28
+}
29
+
30
+static GFXINLINE void release_bus(GMouse* m)
31
+{
32
+}
33
+
34
+static void write_reg(GMouse* m, uint8_t reg, uint8_t val)
35
+{
36
+}
37
+
38
+static uint8_t read_byte(GMouse* m, uint8_t reg)
39
+{
40
+}
41
+
42
+static uint16_t read_word(GMouse* m, uint8_t reg)
43
+{
44
+}
45
+
46
+#endif /* _GINPUT_LLD_MOUSE_BOARD_H */