diff options
Diffstat (limited to 'drivers/ginput/touch/MCU')
-rw-r--r-- | drivers/ginput/touch/MCU/driver.mk | 5 | ||||
-rw-r--r-- | drivers/ginput/touch/MCU/ginput_lld_mouse.c | 80 | ||||
-rw-r--r-- | drivers/ginput/touch/MCU/ginput_lld_mouse_board_template.h | 41 | ||||
-rw-r--r-- | drivers/ginput/touch/MCU/ginput_lld_mouse_config_template.h | 21 | ||||
-rw-r--r-- | drivers/ginput/touch/MCU/gmouse_lld_MCU.c | 50 | ||||
-rw-r--r-- | drivers/ginput/touch/MCU/gmouse_lld_MCU_board_template.h | 32 |
6 files changed, 83 insertions, 146 deletions
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 */ |