aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ginput
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ginput')
-rw-r--r--drivers/ginput/touch/ADS7843/driver.mk5
-rw-r--r--drivers/ginput/touch/ADS7843/ginput_lld_mouse.c94
-rw-r--r--drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h31
-rw-r--r--drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h21
-rw-r--r--drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c79
-rw-r--r--drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h42
-rw-r--r--drivers/ginput/touch/FT5x06/driver.mk5
-rw-r--r--drivers/ginput/touch/FT5x06/ginput_lld_mouse.c88
-rw-r--r--drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_template.h27
-rw-r--r--drivers/ginput/touch/FT5x06/ginput_lld_mouse_config.h21
-rw-r--r--drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c120
-rw-r--r--drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06_board_template.h46
-rw-r--r--drivers/ginput/touch/MCU/driver.mk5
-rw-r--r--drivers/ginput/touch/MCU/ginput_lld_mouse.c80
-rw-r--r--drivers/ginput/touch/MCU/ginput_lld_mouse_board_template.h41
-rw-r--r--drivers/ginput/touch/MCU/ginput_lld_mouse_config_template.h21
-rw-r--r--drivers/ginput/touch/MCU/gmouse_lld_MCU.c50
-rw-r--r--drivers/ginput/touch/MCU/gmouse_lld_MCU_board_template.h32
-rw-r--r--drivers/ginput/touch/STMPE811/driver.mk5
-rw-r--r--drivers/ginput/touch/STMPE811/ginput_lld_mouse.c132
-rw-r--r--drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_template.h27
-rw-r--r--drivers/ginput/touch/STMPE811/ginput_lld_mouse_config.h25
-rw-r--r--drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c164
-rw-r--r--drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811_board_template.h58
-rw-r--r--drivers/ginput/touch/STMPE811/stmpe811.h3
25 files changed, 595 insertions, 627 deletions
diff --git a/drivers/ginput/touch/ADS7843/driver.mk b/drivers/ginput/touch/ADS7843/driver.mk
index 31e9ab2c..1a0eaf8e 100644
--- a/drivers/ginput/touch/ADS7843/driver.mk
+++ b/drivers/ginput/touch/ADS7843/driver.mk
@@ -1,5 +1,2 @@
# List the required driver.
-GFXSRC += $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c
-
-# Required include directories
-GFXINC += $(GFXLIB)/drivers/ginput/touch/ADS7843
+GFXSRC += $(GFXLIB)/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c b/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c
deleted file mode 100644
index cb9b6f4e..00000000
--- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/
-
-#include "src/ginput/driver_mouse.h"
-
-#include "ginput_lld_mouse_board.h"
-
-#if defined(GINPUT_MOUSE_YX_INVERTED) && GINPUT_MOUSE_YX_INVERTED
- #define CMD_X 0x91
- #define CMD_Y 0xD1
-#else
- #define CMD_X 0xD1
- #define CMD_Y 0x91
-#endif
-
-
-static uint16_t sampleBuf[7];
-static coord_t lastx, lasty;
-
-static void filter(void) {
- uint16_t temp;
- int i,j;
-
- for(i = 0; i < 4; i++) {
- for(j = i; j < 7; j++) {
- if(sampleBuf[i] > sampleBuf[j]) {
- /* Swap the values */
- temp = sampleBuf[i];
- sampleBuf[i] = sampleBuf[j];
- sampleBuf[j] = temp;
- }
- }
- }
-}
-
-void ginput_lld_mouse_init(void) {
- init_board();
-}
-
-void ginput_lld_mouse_get_reading(MouseReading *pt) {
- uint16_t i;
-
- // If touch-off return the previous results
- if (!getpin_pressed()) {
- pt->x = lastx;
- pt->y = lasty;
- pt->z = 0;
- pt->buttons = 0;
- return;
- }
-
- // Read the port to get the touch settings
- aquire_bus();
-
- /* Get the X value
- * Discard the first conversion - very noisy and keep the ADC on hereafter
- * till we are done with the sampling. Note that PENIRQ is disabled while reading.
- * Finally switch on PENIRQ once again - perform a dummy read.
- * Once we have the readings, find the medium using our filter function
- */
- read_value(CMD_X);
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_value(CMD_X);
- read_value(CMD_X-1);
- filter();
- lastx = (coord_t)sampleBuf[3];
-
- /* Get the Y value using the same process as above */
- read_value(CMD_Y);
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_value(CMD_Y);
- read_value(CMD_Y-1);
- filter();
- lasty = (coord_t)sampleBuf[3];
-
- // Release the bus
- release_bus();
-
- // Return the results
- pt->x = lastx;
- pt->y = lasty;
- pt->z = 100;
- pt->buttons = GINPUT_TOUCH_PRESSED;
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h
deleted file mode 100644
index 09783adf..00000000
--- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_template.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static inline void init_board(void) {
-
-}
-
-static inline bool_t getpin_pressed(void) {
-
-}
-
-static inline void aquire_bus(void) {
-
-}
-
-static inline void release_bus(void) {
-
-}
-
-static inline uint16_t read_value(uint16_t port) {
-
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h
deleted file mode 100644
index 31840a51..00000000
--- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
-#define _LLD_GINPUT_MOUSE_CONFIG_H
-
-#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
-#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
-#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
-#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
-#define GINPUT_MOUSE_READ_CYCLES 4
-#define GINPUT_MOUSE_POLL_PERIOD 25
-#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
-#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
-#define GINPUT_MOUSE_CLICK_TIME 500
-
-#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
diff --git a/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c
new file mode 100644
index 00000000..ac315262
--- /dev/null
+++ b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843.c
@@ -0,0 +1,79 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#include "gfx.h"
+
+#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE)
+
+#define GMOUSE_DRIVER_VMT GMOUSEVMT_ADS7843
+#include "src/ginput/driver_mouse.h"
+
+// Get the hardware interface
+#include "gmouse_lld_ADS7843_board.h"
+
+#define CMD_X 0xD1
+#define CMD_Y 0x91
+#define CMD_ENABLE_IRQ 0x80
+
+static void MouseXYZ(GMouse* m, GMouseReading* pdr)
+{
+ (void)m;
+
+ // No buttons
+ pdr->buttons = 0;
+ pdr->z = 0;
+
+ if (getpin_pressed(m)) {
+ pdr->z = 1; // Set to Z_MAX as we are pressed
+
+ aquire_bus(m);
+
+ read_value(m, CMD_X); // Dummy read - disable PenIRQ
+ pdr->x = read_value(m, CMD_X); // Read X-Value
+
+ read_value(m, CMD_Y); // Dummy read - disable PenIRQ
+ pdr->y = read_value(m, CMD_Y); // Read Y-Value
+
+ read_value(m, CMD_ENABLE_IRQ); // Enable IRQ
+
+ release_bus(m);
+ }
+}
+
+const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
+ {
+ GDRIVER_TYPE_TOUCH,
+ GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_CALIBRATE | GMOUSE_VFLG_CAL_TEST |
+ GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN,
+ sizeof(GMouse)+BOARD_DATA_SIZE,
+ _gmouseInitDriver,
+ _gmousePostInitDriver,
+ _gmouseDeInitDriver
+ },
+ 1, // z_max - (currently?) not supported
+ 0, // z_min - (currently?) not supported
+ 1, // z_touchon
+ 0, // z_touchoff
+ { // pen_jitter
+ GMOUSE_ADS7843_PEN_CALIBRATE_ERROR, // calibrate
+ GMOUSE_ADS7843_PEN_CLICK_ERROR, // click
+ GMOUSE_ADS7843_PEN_MOVE_ERROR // move
+ },
+ { // finger_jitter
+ GMOUSE_ADS7843_FINGER_CALIBRATE_ERROR, // calibrate
+ GMOUSE_ADS7843_FINGER_CLICK_ERROR, // click
+ GMOUSE_ADS7843_FINGER_MOVE_ERROR // move
+ },
+ init_board, // init
+ 0, // deinit
+ MouseXYZ, // get
+ 0, // calsave
+ 0 // calload
+}};
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
+
diff --git a/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h
new file mode 100644
index 00000000..5a09b5bd
--- /dev/null
+++ b/drivers/ginput/touch/ADS7843/gmouse_lld_ADS7843_board_template.h
@@ -0,0 +1,42 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _GINPUT_LLD_MOUSE_BOARD_H
+#define _GINPUT_LLD_MOUSE_BOARD_H
+
+// Resolution and Accuracy Settings
+#define GMOUSE_ADS7843_PEN_CALIBRATE_ERROR 2
+#define GMOUSE_ADS7843_PEN_CLICK_ERROR 2
+#define GMOUSE_ADS7843_PEN_MOVE_ERROR 2
+#define GMOUSE_ADS7843_FINGER_CALIBRATE_ERROR 4
+#define GMOUSE_ADS7843_FINGER_CLICK_ERROR 4
+#define GMOUSE_ADS7843_FINGER_MOVE_ERROR 4
+
+// How much extra data to allocate at the end of the GMouse structure for the board's use
+#define GMOUSE_ADS7843_BOARD_DATA_SIZE 0
+
+static bool_t init_board(GMouse* m, unsigned driverinstance) {
+
+}
+
+static inline bool_t getpin_pressed(GMouse* m) {
+
+}
+
+static inline void aquire_bus(GMouse* m) {
+
+}
+
+static inline void release_bus(GMouse* m) {
+
+}
+
+static inline uint16_t read_value(GMouse* m, uint16_t port) {
+
+}
+
+#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/FT5x06/driver.mk b/drivers/ginput/touch/FT5x06/driver.mk
index 17d38c61..741464e8 100644
--- a/drivers/ginput/touch/FT5x06/driver.mk
+++ b/drivers/ginput/touch/FT5x06/driver.mk
@@ -1,5 +1,2 @@
# List the required driver.
-GFXSRC += $(GFXLIB)/drivers/ginput/touch/FT5x06/ginput_lld_mouse.c
-
-# Required include directories
-GFXINC += $(GFXLIB)/drivers/ginput/touch/FT5x06
+GFXSRC += $(GFXLIB)/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c
diff --git a/drivers/ginput/touch/FT5x06/ginput_lld_mouse.c b/drivers/ginput/touch/FT5x06/ginput_lld_mouse.c
deleted file mode 100644
index 7a50c5f6..00000000
--- a/drivers/ginput/touch/FT5x06/ginput_lld_mouse.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/
-
-#include "src/ginput/driver_mouse.h"
-
-#include "drivers/ginput/touch/FT5x06/ft5x06.h"
-
-// include board abstraction
-#include "ginput_lld_mouse_board.h"
-
-static coord_t x, y, z;
-static uint8_t touched;
-
-void ginput_lld_mouse_init(void) {
- init_board();
-
- // Init default values. (From NHD-3.5-320240MF-ATXL-CTP-1 datasheet)
- // Valid touching detect threshold
- write_reg(FT5x06_ID_G_THGROUP, 1, 0x16);
-
- // valid touching peak detect threshold
- write_reg(FT5x06_ID_G_THPEAK, 1, 0x3C);
-
- // Touch focus threshold
- write_reg(FT5x06_ID_G_THCAL, 1, 0xE9);
-
- // threshold when there is surface water
- write_reg(FT5x06_ID_G_THWATER, 1, 0x01);
-
- // threshold of temperature compensation
- write_reg(FT5x06_ID_G_THTEMP, 1, 0x01);
-
- // Touch difference threshold
- write_reg(FT5x06_ID_G_THDIFF, 1, 0xA0);
-
- // Delay to enter 'Monitor' status (s)
- write_reg(FT5x06_ID_G_TIME_ENTER_MONITOR, 1, 0x0A);
-
- // Period of 'Active' status (ms)
- write_reg(FT5x06_ID_G_PERIODACTIVE, 1, 0x06);
-
- // Timer to enter ÔidleÕ when in 'Monitor' (ms)
- write_reg(FT5x06_ID_G_PERIODMONITOR, 1, 0x28);
-}
-
-void ginput_lld_mouse_get_reading(MouseReading *pt) {
- // Poll to get the touched status
- uint8_t last_touched;
-
- last_touched = touched;
- touched = (uint8_t)read_reg(FT5x06_TOUCH_POINTS, 1) & 0x07;
-
- // If not touched, return the previous results
- if (touched == 0) {
- pt->x = x;
- pt->y = y;
- pt->z = 0;
- pt->buttons = 0;
- return;
- }
-
- /* Get the X, Y, Z values */
- x = (coord_t)(read_reg(FT5x06_TOUCH1_XH, 2) & 0x0fff);
- y = (coord_t)read_reg(FT5x06_TOUCH1_YH, 2);
- z = 100;
-
- // Rescale X,Y,Z - X & Y don't need scaling when you are using calibration!
-#if !GINPUT_MOUSE_NEED_CALIBRATION
- x = gdispGetWidth() - x / (4096/gdispGetWidth());
- y = y / (4096/gdispGetHeight());
-#endif
-
- // Return the results. ADC gives values from 0 to 2^12 (4096)
- pt->x = x;
- pt->y = y;
- pt->z = z;
- pt->buttons = GINPUT_TOUCH_PRESSED;
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
diff --git a/drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_template.h b/drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_template.h
deleted file mode 100644
index b7744a49..00000000
--- a/drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_template.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static void init_board(void) {
-
-}
-
-static inline bool_t getpin_irq(void) {
-
-}
-
-static void write_reg(uint8_t reg, uint8_t n, uint16_t val) {
-
-}
-
-static uint16_t read_reg(uint8_t reg, uint8_t n) {
-
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/FT5x06/ginput_lld_mouse_config.h b/drivers/ginput/touch/FT5x06/ginput_lld_mouse_config.h
deleted file mode 100644
index 24335a0a..00000000
--- a/drivers/ginput/touch/FT5x06/ginput_lld_mouse_config.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
-#define _LLD_GINPUT_MOUSE_CONFIG_H
-
-#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
-#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
-#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
-#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 15
-#define GINPUT_MOUSE_READ_CYCLES 1
-#define GINPUT_MOUSE_POLL_PERIOD 25
-#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
-#define GINPUT_MOUSE_MAX_MOVE_JITTER 5
-#define GINPUT_MOUSE_CLICK_TIME 450
-
-#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
diff --git a/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c b/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c
new file mode 100644
index 00000000..ed2e68fa
--- /dev/null
+++ b/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06.c
@@ -0,0 +1,120 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
+
+#define GMOUSE_DRIVER_VMT GMOUSEVMT_FT5x06
+#include "src/ginput/driver_mouse.h"
+
+// Get the hardware interface
+#include "gmouse_lld_FT5x06_board.h"
+
+// Hardware definitions
+#include "drivers/ginput/touch/FT5x06/ft5x06.h"
+
+static bool_t MouseInit(GMouse* m, unsigned driverinstance) {
+ if (!init_board(m, driverinstance))
+ return FALSE;
+
+ aquire_bus(m);
+
+ // Init default values. (From NHD-3.5-320240MF-ATXL-CTP-1 datasheet)
+ // Valid touching detect threshold
+ write_reg(m, FT5x06_ID_G_THGROUP, 0x16);
+
+ // valid touching peak detect threshold
+ write_reg(m, FT5x06_ID_G_THPEAK, 0x3C);
+
+ // Touch focus threshold
+ write_reg(m, FT5x06_ID_G_THCAL, 0xE9);
+
+ // threshold when there is surface water
+ write_reg(m, FT5x06_ID_G_THWATER, 0x01);
+
+ // threshold of temperature compensation
+ write_reg(m, FT5x06_ID_G_THTEMP, 0x01);
+
+ // Touch difference threshold
+ write_reg(m, FT5x06_ID_G_THDIFF, 0xA0);
+
+ // Delay to enter 'Monitor' status (s)
+ write_reg(m, FT5x06_ID_G_TIME_ENTER_MONITOR, 0x0A);
+
+ // Period of 'Active' status (ms)
+ write_reg(m, FT5x06_ID_G_PERIODACTIVE, 0x06);
+
+ // Timer to enter 'idle' when in 'Monitor' (ms)
+ write_reg(m, FT5x06_ID_G_PERIODMONITOR, 0x28);
+
+ release_bus(m);
+ return TRUE;
+}
+
+static void MouseXYZ(GMouse* m, GMouseReading* pdr)
+{
+ // Assume not touched.
+ pdr->buttons = 0;
+ pdr->z = 0;
+
+ aquire_bus(m);
+
+ // Only take a reading if we are touched.
+ if ((read_byte(m, FT5x06_TOUCH_POINTS) & 0x07)) {
+
+ /* Get the X, Y, Z values */
+ pdr->x = (coord_t)(read_word(m, FT5x06_TOUCH1_XH) & 0x0fff);
+ pdr->y = (coord_t)read_word(m, FT5x06_TOUCH1_YH);
+ pdr->z = 1;
+
+ #if GMOUSE_FT5x06_SELF_CALIBRATE
+ // Rescale X,Y,Z - If we are using self-calibration
+ pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display));
+ pdr->y = pdr->y / (4096/gdispGGetHeight(m->display));
+ #endif
+ }
+
+ release_bus(m);
+}
+
+const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
+ {
+ GDRIVER_TYPE_TOUCH,
+ #if GMOUSE_FT5x06_SELF_CALIBRATE
+ GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN,
+ #else
+ GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN | GMOUSE_VFLG_CALIBRATE | GMOUSE_VFLG_CAL_TEST,
+ #endif
+ sizeof(GMouse) + GMOUSE_FT5x06_BOARD_DATA_SIZE,
+ _gmouseInitDriver,
+ _gmousePostInitDriver,
+ _gmouseDeInitDriver
+ },
+ 1, // z_max - (currently?) not supported
+ 0, // z_min - (currently?) not supported
+ 1, // z_touchon
+ 0, // z_touchoff
+ { // pen_jitter
+ GMOUSE_FT5x06_PEN_CALIBRATE_ERROR, // calibrate
+ GMOUSE_FT5x06_PEN_CLICK_ERROR, // click
+ GMOUSE_FT5x06_PEN_MOVE_ERROR // move
+ },
+ { // finger_jitter
+ GMOUSE_FT5x06_FINGER_CALIBRATE_ERROR, // calibrate
+ GMOUSE_FT5x06_FINGER_CLICK_ERROR, // click
+ GMOUSE_FT5x06_FINGER_MOVE_ERROR // move
+ },
+ MouseInit, // init
+ 0, // deinit
+ read_xyz, // get
+ 0, // calsave
+ 0 // calload
+}};
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
+
diff --git a/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06_board_template.h b/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06_board_template.h
new file mode 100644
index 00000000..46680a16
--- /dev/null
+++ b/drivers/ginput/touch/FT5x06/gmouse_lld_FT5x06_board_template.h
@@ -0,0 +1,46 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _GINPUT_LLD_MOUSE_BOARD_H
+#define _GINPUT_LLD_MOUSE_BOARD_H
+
+// Resolution and Accuracy Settings
+#define GMOUSE_FT5x06_PEN_CALIBRATE_ERROR 8
+#define GMOUSE_FT5x06_PEN_CLICK_ERROR 6
+#define GMOUSE_FT5x06_PEN_MOVE_ERROR 4
+#define GMOUSE_FT5x06_FINGER_CALIBRATE_ERROR 14
+#define GMOUSE_FT5x06_FINGER_CLICK_ERROR 18
+#define GMOUSE_FT5x06_FINGER_MOVE_ERROR 14
+
+// How much extra data to allocate at the end of the GMouse structure for the board's use
+#define GMOUSE_FT5x06_BOARD_DATA_SIZE 0
+
+// Set this to TRUE if you want self-calibration.
+// NOTE: This is not as accurate as real calibration.
+// It requires the orientation of the touch panel to match the display.
+// It requires the active area of the touch panel to exactly match the display size.
+#define GMOUSE_FT5x06_SELF_CALIBRATE FALSE
+
+static bool_t init_board(GMouse* m, unsigned driverinstance) {
+}
+
+static inline void aquire_bus(GMouse* m) {
+}
+
+static inline void release_bus(GMouse* m) {
+}
+
+static void write_reg(GMouse* m, uint8_t reg, uint8_t val) {
+}
+
+static uint8_t read_byte(GMouse* m, uint8_t reg) {
+}
+
+static uint16_t read_word(GMouse* m, uint8_t reg) {
+}
+
+#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/MCU/driver.mk b/drivers/ginput/touch/MCU/driver.mk
index e771236a..c8c792b2 100644
--- a/drivers/ginput/touch/MCU/driver.mk
+++ b/drivers/ginput/touch/MCU/driver.mk
@@ -1,5 +1,2 @@
# List the required driver.
-GFXSRC += $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld_mouse.c
-
-# Required include directories
-GFXINC += $(GFXLIB)/drivers/ginput/touch/MCU
+GFXSRC += $(GFXLIB)/drivers/ginput/touch/MCU/gmouse_lld_MCU.c
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse.c b/drivers/ginput/touch/MCU/ginput_lld_mouse.c
deleted file mode 100644
index ad2519e4..00000000
--- a/drivers/ginput/touch/MCU/ginput_lld_mouse.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/
-
-#include "src/ginput/driver_mouse.h"
-
-#include "ginput_lld_mouse_board.h"
-
-static uint16_t sampleBuf[7];
-
-static void filter(void) {
- uint16_t temp;
- int i,j;
-
- for(i = 0; i < 4; i++) {
- for(j = i; j < 7; j++) {
- if(sampleBuf[i] > sampleBuf[j]) {
- /* Swap the values */
- temp = sampleBuf[i];
- sampleBuf[i] = sampleBuf[j];
- sampleBuf[j] = temp;
- }
- }
- }
-}
-
-void ginput_lld_mouse_init(void) {
- init_board();
-}
-
-void ginput_lld_mouse_get_reading(MouseReading *pt) {
- uint16_t i;
-
- // Obtain access to the bus
- aquire_bus();
-
- // Read the ADC for z, x, y and then z again
- while(1) {
- setup_z();
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_z();
- filter();
- pt->z = (coord_t)sampleBuf[3];
-
- setup_x();
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_x();
- filter();
- pt->x = (coord_t)sampleBuf[3];
-
- setup_y();
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_y();
- filter();
- pt->y = (coord_t)sampleBuf[3];
-
- pt->buttons = pt->z >= 80 ? GINPUT_TOUCH_PRESSED : 0;
-
- setup_z();
- for(i = 0; i < 7; i++)
- sampleBuf[i] = read_z();
- filter();
- i = (coord_t)sampleBuf[3] >= 80 ? GINPUT_TOUCH_PRESSED : 0;
-
- if (pt->buttons == i)
- break;
- }
-
- // Release the bus
- release_bus();
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_template.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_template.h
deleted file mode 100644
index e213bcb9..00000000
--- a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_template.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static inline void init_board(void) {
-}
-
-static inline void aquire_bus(void) {
-}
-
-static inline void release_bus(void) {
-}
-
-static inline void setup_x(void) {
-}
-
-static inline void setup_y(void) {
-}
-
-static inline void setup_z(void) {
- palClearPad(GPIOB, GPIOB_DRIVEA);
- palClearPad(GPIOB, GPIOB_DRIVEB);
- chThdSleepMilliseconds(2);
-}
-
-static inline uint16_t read_x(void) {
-}
-
-static inline uint16_t read_y(void) {
-}
-
-static inline uint16_t read_z(void) {
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_config_template.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_config_template.h
deleted file mode 100644
index 328e6337..00000000
--- a/drivers/ginput/touch/MCU/ginput_lld_mouse_config_template.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
-#define _LLD_GINPUT_MOUSE_CONFIG_H
-
-#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
-#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
-#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
-#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12
-#define GINPUT_MOUSE_READ_CYCLES 1
-#define GINPUT_MOUSE_POLL_PERIOD 25
-#define GINPUT_MOUSE_MAX_CLICK_JITTER 2
-#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
-#define GINPUT_MOUSE_CLICK_TIME 500
-
-#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
diff --git a/drivers/ginput/touch/MCU/gmouse_lld_MCU.c b/drivers/ginput/touch/MCU/gmouse_lld_MCU.c
new file mode 100644
index 00000000..babf8bc3
--- /dev/null
+++ b/drivers/ginput/touch/MCU/gmouse_lld_MCU.c
@@ -0,0 +1,50 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
+
+#define GMOUSE_DRIVER_VMT GMOUSEVMT_MCU
+#include "src/ginput/driver_mouse.h"
+
+// Get the hardware interface
+#include "gmouse_lld_MCU_board.h"
+
+const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
+ {
+ GDRIVER_TYPE_TOUCH,
+ GMOUSE_VFLG_TOUCH|GMOUSE_VFLG_CALIBRATE|GMOUSE_VFLG_CAL_TEST
+ |GMOUSE_VFLG_ONLY_DOWN|GMOUSE_VFLG_POORUPDOWN,
+ // Extra flags for testing only
+ //GMOUSE_VFLG_DEFAULTFINGER|GMOUSE_VFLG_CAL_EXTREMES - Possible
+ //GMOUSE_VFLG_NOPOLL|GMOUSE_VFLG_DYNAMICONLY|GMOUSE_VFLG_SELFROTATION|GMOUSE_VFLG_CAL_LOADFREE - unlikely
+ sizeof(GMouse) + GMOUSE_MCU_BOARD_DATA_SIZE,
+ _gmouseInitDriver, _gmousePostInitDriver, _gmouseDeInitDriver
+ },
+ GMOUSE_MCU_Z_MAX, // z_max
+ GMOUSE_MCU_Z_MIN, // z_min
+ GMOUSE_MCU_Z_TOUCHON, // z_touchon
+ GMOUSE_MCU_Z_TOUCHOFF, // z_touchoff
+ { // pen_jitter
+ GMOUSE_MCU_PEN_CALIBRATE_ERROR, // calibrate
+ GMOUSE_MCU_PEN_CLICK_ERROR, // click
+ GMOUSE_MCU_PEN_MOVE_ERROR // move
+ },
+ { // finger_jitter
+ GMOUSE_MCU_FINGER_CALIBRATE_ERROR, // calibrate
+ GMOUSE_MCU_FINGER_CLICK_ERROR, // click
+ GMOUSE_MCU_FINGER_MOVE_ERROR // move
+ },
+ init_board, // init
+ 0, // deinit
+ read_xyz, // get
+ 0, // calsave
+ 0 // calload
+}};
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
diff --git a/drivers/ginput/touch/MCU/gmouse_lld_MCU_board_template.h b/drivers/ginput/touch/MCU/gmouse_lld_MCU_board_template.h
new file mode 100644
index 00000000..07583fa9
--- /dev/null
+++ b/drivers/ginput/touch/MCU/gmouse_lld_MCU_board_template.h
@@ -0,0 +1,32 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _LLD_GMOUSE_MCU_BOARD_H
+#define _LLD_GMOUSE_MCU_BOARD_H
+
+// Resolution and Accuracy Settings
+#define GMOUSE_MCU_PEN_CALIBRATE_ERROR 8
+#define GMOUSE_MCU_PEN_CLICK_ERROR 6
+#define GMOUSE_MCU_PEN_MOVE_ERROR 4
+#define GMOUSE_MCU_FINGER_CALIBRATE_ERROR 14
+#define GMOUSE_MCU_FINGER_CLICK_ERROR 18
+#define GMOUSE_MCU_FINGER_MOVE_ERROR 14
+#define GMOUSE_MCU_Z_MIN 0 // The minimum Z reading
+#define GMOUSE_MCU_Z_MAX 100 // The maximum Z reading
+#define GMOUSE_MCU_Z_TOUCHON 80 // Values between this and Z_MAX are definitely pressed
+#define GMOUSE_MCU_Z_TOUCHOFF 70 // Values between this and Z_MIN are definitely not pressed
+
+// How much extra data to allocate at the end of the GMouse structure for the board's use
+#define GMOUSE_MCU_BOARD_DATA_SIZE 0
+
+static bool_t init_board(GMouse *m, unsigned driverinstance) {
+}
+
+static void read_xyz(GMouse *m, GMouseReading *prd) {
+}
+
+#endif /* _LLD_GMOUSE_MCU_BOARD_H */
diff --git a/drivers/ginput/touch/STMPE811/driver.mk b/drivers/ginput/touch/STMPE811/driver.mk
index 5147e989..cf12507b 100644
--- a/drivers/ginput/touch/STMPE811/driver.mk
+++ b/drivers/ginput/touch/STMPE811/driver.mk
@@ -1,5 +1,2 @@
# List the required driver.
-GFXSRC += $(GFXLIB)/drivers/ginput/touch/STMPE811/ginput_lld_mouse.c
-
-# Required include directories
-GFXINC += $(GFXLIB)/drivers/ginput/touch/STMPE811
+GFXSRC += $(GFXLIB)/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c
diff --git a/drivers/ginput/touch/STMPE811/ginput_lld_mouse.c b/drivers/ginput/touch/STMPE811/ginput_lld_mouse.c
deleted file mode 100644
index e658fae2..00000000
--- a/drivers/ginput/touch/STMPE811/ginput_lld_mouse.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/
-
-#include "src/ginput/driver_mouse.h"
-
-#include "drivers/ginput/touch/STMPE811/stmpe811.h"
-
-#include "ginput_lld_mouse_board.h"
-
-#ifndef STMP811_NO_GPIO_IRQPIN
- #define STMP811_NO_GPIO_IRQPIN FALSE
-#endif
-#ifndef STMP811_SLOW_CPU
- #define STMP811_SLOW_CPU FALSE
-#endif
-
-static coord_t x, y, z;
-static uint8_t touched;
-
-/* set the active window of the stmpe811. bl is bottom left, tr is top right */
-static void setActiveWindow(uint16_t bl_x, uint16_t bl_y, uint16_t tr_x, uint16_t tr_y)
-{
- write_reg(STMPE811_REG_WDW_TR_X, 2, tr_x);
- write_reg(STMPE811_REG_WDW_TR_Y, 2, tr_y);
- write_reg(STMPE811_REG_WDW_BL_X, 2, bl_x);
- write_reg(STMPE811_REG_WDW_BL_Y, 2, bl_y);
-}
-
-void ginput_lld_mouse_init(void)
-{
- init_board();
-
- write_reg(STMPE811_REG_SYS_CTRL1, 1, 0x02); // Software chip reset
- gfxSleepMilliseconds(10);
-
- write_reg(STMPE811_REG_SYS_CTRL2, 1, 0x0C); // Temperature sensor clock off, GPIO clock off, touch clock on, ADC clock on
-#if STMP811_NO_GPIO_IRQPIN
- write_reg(STMPE811_REG_INT_EN, 1, 0x00); // Interrupt on INT pin when touch is detected
-#else
- write_reg(STMPE811_REG_INT_EN, 1, 0x01); // Interrupt on INT pin when touch is detected
-#endif
- write_reg(STMPE811_REG_ADC_CTRL1, 1, 0x48); // ADC conversion time = 80 clock ticks, 12-bit ADC, internal voltage refernce
- gfxSleepMilliseconds(2);
-
- write_reg(STMPE811_REG_ADC_CTRL2, 1, 0x01); // ADC speed 3.25MHz
- write_reg(STMPE811_REG_GPIO_AF, 1, 0x00); // GPIO alternate function - OFF
- write_reg(STMPE811_REG_TSC_CFG, 1, 0x9A); // Averaging 4, touch detect delay 500 us, panel driver settling time 500 us
- write_reg(STMPE811_REG_FIFO_TH, 1, 0x40); // FIFO threshold = 64
- write_reg(STMPE811_REG_FIFO_STA, 1, 0x01); // FIFO reset enable
- write_reg(STMPE811_REG_FIFO_STA, 1, 0x00); // FIFO reset disable
- write_reg(STMPE811_REG_TSC_FRACT_XYZ, 1, 0x07); // Z axis data format
- write_reg(STMPE811_REG_TSC_I_DRIVE, 1, 0x01); // 50mA touchscreen line current
- write_reg(STMPE811_REG_TSC_CTRL, 1, 0x00); // X&Y&Z
- write_reg(STMPE811_REG_TSC_CTRL, 1, 0x01); // X&Y&Z, TSC enable
- write_reg(STMPE811_REG_INT_STA, 1, 0xFF); // Clear all interrupts
-#if !STMP811_NO_GPIO_IRQPIN
- touched = (uint8_t)read_reg(STMPE811_REG_TSC_CTRL, 1) & 0x80;
-#endif
- write_reg(STMPE811_REG_INT_CTRL, 1, 0x01); // Level interrupt, enable intrrupts
-}
-
-void ginput_lld_mouse_get_reading(MouseReading *pt)
-{
- bool_t clearfifo; // Do we need to clear the FIFO
-
-#if STMP811_NO_GPIO_IRQPIN
- // Poll to get the touched status
- uint8_t last_touched;
-
- last_touched = touched;
- touched = (uint8_t)read_reg(STMPE811_REG_TSC_CTRL, 1) & 0x80;
- clearfifo = (touched != last_touched);
-#else
- // Check if the touch controller IRQ pin has gone off
- clearfifo = false;
- if(getpin_irq()) { // please rename this to getpin_irq
- write_reg(STMPE811_REG_INT_STA, 1, 0xFF); // clear all interrupts
- touched = (uint8_t)read_reg(STMPE811_REG_TSC_CTRL, 1) & 0x80; // set the new touched status
- clearfifo = true; // only take the last FIFO reading
- }
-#endif
-
- // If not touched, return the previous results
- if (!touched) {
- pt->x = x;
- pt->y = y;
- pt->z = 0;
- pt->buttons = 0;
- return;
- }
-
-#if !STMP811_SLOW_CPU
- if (!clearfifo && (read_reg(STMPE811_REG_FIFO_STA, 1) & 0xD0))
-#endif
- clearfifo = true;
-
- do {
- /* Get the X, Y, Z values */
- /* This could be done in a single 4 byte read to STMPE811_REG_TSC_DATA_XYZ (incr or non-incr) */
- x = (coord_t)read_reg(STMPE811_REG_TSC_DATA_X, 2);
- y = (coord_t)read_reg(STMPE811_REG_TSC_DATA_Y, 2);
- z = (coord_t)read_reg(STMPE811_REG_TSC_DATA_Z, 1);
- } while(clearfifo && !(read_reg(STMPE811_REG_FIFO_STA, 1) & 0x20));
-
- // Rescale X,Y,Z - X & Y don't need scaling when you are using calibration!
-#if !GINPUT_MOUSE_NEED_CALIBRATION
- x = gdispGetWidth() - x / (4096/gdispGetWidth());
- y = y / (4096/gdispGetHeight());
-#endif
- z = (((z&0xFF) * 100)>>8) + 1;
-
- // Return the results. ADC gives values from 0 to 2^12 (4096)
- pt->x = x;
- pt->y = y;
- pt->z = z;
- pt->buttons = GINPUT_TOUCH_PRESSED;
-
- /* Force another read if we have more results */
- if (!clearfifo && !(read_reg(STMPE811_REG_FIFO_STA, 1) & 0x20))
- ginputMouseWakeup();
-
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
diff --git a/drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_template.h b/drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_template.h
deleted file mode 100644
index b7744a49..00000000
--- a/drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_template.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static void init_board(void) {
-
-}
-
-static inline bool_t getpin_irq(void) {
-
-}
-
-static void write_reg(uint8_t reg, uint8_t n, uint16_t val) {
-
-}
-
-static uint16_t read_reg(uint8_t reg, uint8_t n) {
-
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/STMPE811/ginput_lld_mouse_config.h b/drivers/ginput/touch/STMPE811/ginput_lld_mouse_config.h
deleted file mode 100644
index 5cd512eb..00000000
--- a/drivers/ginput/touch/STMPE811/ginput_lld_mouse_config.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
-#define _LLD_GINPUT_MOUSE_CONFIG_H
-
-#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
-#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
-#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
-#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
-#define GINPUT_MOUSE_READ_CYCLES 1
-#define GINPUT_MOUSE_POLL_PERIOD 25
-#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
-#define GINPUT_MOUSE_MAX_MOVE_JITTER 5
-#define GINPUT_MOUSE_CLICK_TIME 450
-
-/* default values - over write these in your boad files */
-#define STMP811_SLOWER_RESPONSE FALSE
-#define STMP811_NO_GPIO_IRQPIN FALSE
-
-#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
diff --git a/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c b/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c
new file mode 100644
index 00000000..6951f3ab
--- /dev/null
+++ b/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c
@@ -0,0 +1,164 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
+
+#define GMOUSE_DRIVER_VMT GMOUSEVMT_STMPE811
+#include "src/ginput/driver_mouse.h"
+
+#define GMOUSE_STMPE811_FLG_TOUCHED (GMOUSE_FLG_DRIVER_FIRST<<0)
+
+// Hardware definitions
+#include "drivers/ginput/touch/STMPE811/stmpe811.h"
+
+// Get the hardware interface
+#include "gmouse_lld_STMPE811_board.h"
+
+static bool_t MouseInit(GMouse* m, unsigned driverinstance) {
+ if (!init_board(m, driverinstance))
+ return FALSE;
+
+ aquire_bus(m);
+
+ write_reg(m, STMPE811_REG_SYS_CTRL1, 0x02); // Software chip reset
+ gfxSleepMilliseconds(10);
+
+ write_reg(m, STMPE811_REG_SYS_CTRL2, 0x0C); // Temperature sensor clock off, GPIO clock off, touch clock on, ADC clock on
+
+ #if GMOUSE_STMPE811_GPIO_IRQPIN
+ write_reg(m, STMPE811_REG_INT_EN, 0x01); // Interrupt on INT pin when touch is detected
+ #else
+ write_reg(m, STMPE811_REG_INT_EN, 0x00); // Don't Interrupt on INT pin when touch is detected
+ #endif
+
+ write_reg(m, STMPE811_REG_ADC_CTRL1, 0x48); // ADC conversion time = 80 clock ticks, 12-bit ADC, internal voltage refernce
+ gfxSleepMilliseconds(2);
+
+ write_reg(m, STMPE811_REG_ADC_CTRL2, 0x01); // ADC speed 3.25MHz
+ write_reg(m, STMPE811_REG_GPIO_AF, 0x00); // GPIO alternate function - OFF
+ write_reg(m, STMPE811_REG_TSC_CFG, 0x9A); // Averaging 4, touch detect delay 500 us, panel driver settling time 500 us
+ write_reg(m, STMPE811_REG_FIFO_TH, 0x40); // FIFO threshold = 64
+ write_reg(m, STMPE811_REG_FIFO_STA, 0x01); // FIFO reset enable
+ write_reg(m, STMPE811_REG_FIFO_STA, 0x00); // FIFO reset disable
+ write_reg(m, STMPE811_REG_TSC_FRACT_XYZ, 0x07); // Z axis data format
+ write_reg(m, STMPE811_REG_TSC_I_DRIVE, 0x01); // 50mA touchscreen line current
+ write_reg(m, STMPE811_REG_TSC_CTRL, 0x00); // X&Y&Z
+ write_reg(m, STMPE811_REG_TSC_CTRL, 0x01); // X&Y&Z, TSC enable
+ write_reg(m, STMPE811_REG_INT_STA, 0xFF); // Clear all interrupts
+ #if GMOUSE_STMPE811_GPIO_IRQPIN
+ if (read_byte(m, STMPE811_REG_TSC_CTRL) & 0x80)
+ m->flags |= GMOUSE_STMPE811_FLG_TOUCHED;
+ #endif
+ write_reg(m, STMPE811_REG_INT_CTRL, 0x01); // Level interrupt, enable interrupts
+
+ release_bus(m);
+ return TRUE;
+}
+
+static void read_xyz(GMouse* m, GMouseReading* pdr)
+{
+ bool_t clearfifo; // Do we need to clear the FIFO
+
+ // Assume not touched.
+ pdr->buttons = 0;
+ pdr->z = 0;
+
+ aquire_bus(m);
+
+ #if GMOUSE_STMPE811_GPIO_IRQPIN
+ // Check if the touch controller IRQ pin has gone off
+ clearfifo = false;
+ if(getpin_irq(m)) {
+ write_reg(m, STMPE811_REG_INT_STA, 0xFF); // clear all interrupts
+ if (read_byte(m, STMPE811_REG_TSC_CTRL) & 0x80) // set the new touched status
+ m->flags |= GMOUSE_STMPE811_FLG_TOUCHED;
+ else
+ m->flags &= ~GMOUSE_STMPE811_FLG_TOUCHED;
+ clearfifo = TRUE; // only take the last FIFO reading
+ }
+
+ #else
+ // Poll to get the touched status
+ uint16_t last_touched;
+
+ last_touched = m->flags;
+ if (read_byte(m, STMPE811_REG_TSC_CTRL) & 0x80) // set the new touched status
+ m->flags |= GMOUSE_STMPE811_FLG_TOUCHED;
+ else
+ m->flags &= ~GMOUSE_STMPE811_FLG_TOUCHED;
+ clearfifo = ((m->flags ^ last_touched) & GMOUSE_STMPE811_FLG_TOUCHED) ? TRUE : FALSE;
+ #endif
+
+ // If not touched don't do any more
+ if ((m->flags &= ~GMOUSE_STMPE811_FLG_TOUCHED)) {
+
+ // Clear the fifo if it is too full
+ #if !GMOUSE_STMPE811_SLOW_CPU
+ if (!clearfifo && (read_byte(m, STMPE811_REG_FIFO_STA) & 0xD0))
+ #endif
+ clearfifo = true;
+
+ do {
+ /* Get the X, Y, Z values */
+ /* This could be done in a single 4 byte read to STMPE811_REG_TSC_DATA_XYZ (incr or non-incr) */
+ pdr->x = (coord_t)read_word(m, STMPE811_REG_TSC_DATA_X);
+ pdr->y = (coord_t)read_word(m, STMPE811_REG_TSC_DATA_Y);
+ pdr->z = (coord_t)read_byte(m, STMPE811_REG_TSC_DATA_Z);
+ } while(clearfifo && !(read_byte(m, STMPE811_REG_FIFO_STA) & 0x20));
+
+ #if GMOUSE_STMPE811_SELF_CALIBRATE
+ // Rescale X,Y,Z - If we are using self-calibration
+ pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display));
+ pdr->y = pdr->y / (4096/gdispGGetHeight(m->display));
+ #endif
+
+ /* Force another read if we have more results */
+ if (!clearfifo && !(read_byte(m, STMPE811_REG_FIFO_STA) & 0x20))
+ _gmouseWakeup(m);
+ }
+
+ release_bus(m);
+}
+
+const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
+ {
+ GDRIVER_TYPE_TOUCH,
+ #if GMOUSE_STMPE811_SELF_CALIBRATE
+ GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN,
+ #else
+ GMOUSE_VFLG_TOUCH | GMOUSE_VFLG_ONLY_DOWN | GMOUSE_VFLG_POORUPDOWN | GMOUSE_VFLG_CALIBRATE | GMOUSE_VFLG_CAL_TEST,
+ #endif
+ sizeof(GMouse) + GMOUSE_STMPE811_BOARD_DATA_SIZE,
+ _gmouseInitDriver,
+ _gmousePostInitDriver,
+ _gmouseDeInitDriver
+ },
+ 255, // z_max
+ 0, // z_min
+ 200, // z_touchon
+ 20, // z_touchoff
+ { // pen_jitter
+ GMOUSE_STMPE811_PEN_CALIBRATE_ERROR, // calibrate
+ GMOUSE_STMPE811_PEN_CLICK_ERROR, // click
+ GMOUSE_STMPE811_PEN_MOVE_ERROR // move
+ },
+ { // finger_jitter
+ GMOUSE_STMPE811_FINGER_CALIBRATE_ERROR, // calibrate
+ GMOUSE_STMPE811_FINGER_CLICK_ERROR, // click
+ GMOUSE_STMPE811_FINGER_MOVE_ERROR // move
+ },
+ MouseInit, // init
+ 0, // deinit
+ read_xyz, // get
+ 0, // calsave
+ 0 // calload
+}};
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
+
diff --git a/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811_board_template.h b/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811_board_template.h
new file mode 100644
index 00000000..437abc09
--- /dev/null
+++ b/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811_board_template.h
@@ -0,0 +1,58 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+#ifndef _GINPUT_LLD_MOUSE_BOARD_H
+#define _GINPUT_LLD_MOUSE_BOARD_H
+
+// Resolution and Accuracy Settings
+#define GMOUSE_STMPE811_PEN_CALIBRATE_ERROR 8
+#define GMOUSE_STMPE811_PEN_CLICK_ERROR 6
+#define GMOUSE_STMPE811_PEN_MOVE_ERROR 4
+#define GMOUSE_STMPE811_FINGER_CALIBRATE_ERROR 14
+#define GMOUSE_STMPE811_FINGER_CLICK_ERROR 18
+#define GMOUSE_STMPE811_FINGER_MOVE_ERROR 14
+
+// How much extra data to allocate at the end of the GMouse structure for the board's use
+#define GMOUSE_STMPE811_BOARD_DATA_SIZE 0
+
+// Set this to TRUE if you want self-calibration.
+// NOTE: This is not as accurate as real calibration.
+// It requires the orientation of the touch panel to match the display.
+// It requires the active area of the touch panel to exactly match the display size.
+#define GMOUSE_STMPE811_SELF_CALIBRATE FALSE
+
+// If TRUE this board has the STMPE811 IRQ pin connected to a GPIO.
+#define GMOUSE_STMPE811_GPIO_IRQPIN FALSE
+
+// If TRUE this is a really slow CPU and we should always clear the FIFO between reads.
+#define GMOUSE_STMPE811_SLOW_CPU FALSE
+
+static bool_t init_board(GMouse* m, unsigned driverinstance) {
+}
+
+#if GMOUSE_STMPE811_GPIO_IRQPIN
+ static bool_t getpin_irq(GMouse* m) {
+
+ }
+#endif
+
+static inline void aquire_bus(GMouse* m) {
+}
+
+static inline void release_bus(GMouse* m) {
+}
+
+static void write_reg(GMouse* m, uint8_t reg, uint8_t val) {
+}
+
+static uint8_t read_byte(GMouse* m, uint8_t reg) {
+}
+
+static uint16_t read_word(GMouse* m, uint8_t reg) {
+}
+
+#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
diff --git a/drivers/ginput/touch/STMPE811/stmpe811.h b/drivers/ginput/touch/STMPE811/stmpe811.h
index 1ee9c211..f0d2df42 100644
--- a/drivers/ginput/touch/STMPE811/stmpe811.h
+++ b/drivers/ginput/touch/STMPE811/stmpe811.h
@@ -11,9 +11,6 @@
// Slave address
#define STMPE811_ADDR (0x82 >> 1)
-// Maximum timeout
-#define STMPE811_TIMEOUT 0x3000
-
// Identification registers
#define STMPE811_REG_CHP_ID 0x00 // 16-bit
#define STMPE811_REG_ID_VER 0x02