Tidy up MCU mouse defines

ugfx_release_2.6
inmarket 2014-10-13 16:35:57 +10:00
parent dc1ff7afa8
commit eb0cc21872
4 changed files with 33 additions and 48 deletions

View File

@ -8,15 +8,20 @@
#ifndef _LLD_GMOUSE_MCU_BOARD_H
#define _LLD_GMOUSE_MCU_BOARD_H
// We directly define the jitter settings
// 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
#define GMOUSE_MCU_Z_MAX 4095
#define GMOUSE_MCU_Z_TOUCHON 3090
#define GMOUSE_MCU_Z_TOUCHOFF 400
// Now board specific settings...
// 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
#define ADC_NUM_CHANNELS 2
#define ADC_BUF_DEPTH 1
@ -36,13 +41,6 @@ static const ADCConversionGroup adcgrpcfg = {
ADC_SQR3_SQ2_N(ADC_CHANNEL_IN8) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9)
};
#define BOARD_DATA_SIZE 0 // How many extra bytes to add on the end of the mouse structure for the board's use
#define Z_MIN 0 // The minimum Z reading
#define Z_MAX 4095 // The maximum Z reading (12 bits)
#define Z_TOUCHON 3090 // Values between this and Z_MAX are definitely pressed
#define Z_TOUCHOFF 400 // Values between this and Z_MIN are definitely not pressed
static bool_t init_board(GMouse *m, unsigned driverinstance) {
(void) m;
@ -71,7 +69,7 @@ static void read_xyz(GMouse *m, GMouseReading *prd) {
prd->z = samples[0];
// Take a shortcut and don't read x, y if we know we are definitely not touched.
if (prd->z >= Z_TOUCHOFF) {
if (prd->z >= GMOUSE_MCU_Z_TOUCHOFF) {
// Get the x reading
palSetPad(GPIOB, GPIOB_DRIVEA);

View File

@ -8,15 +8,20 @@
#ifndef _LLD_GMOUSE_MCU_BOARD_H
#define _LLD_GMOUSE_MCU_BOARD_H
// We directly define the jitter settings
// 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
#define GMOUSE_MCU_Z_MAX 1
#define GMOUSE_MCU_Z_TOUCHON 1
#define GMOUSE_MCU_Z_TOUCHOFF 0
// Now board specific settings...
// 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
#define ADC_NUM_CHANNELS 2
#define ADC_BUF_DEPTH 1
@ -45,13 +50,6 @@ static const ADCConversionGroup adc_x_config = {
ADC_SQR3_SQ2_N(ADC_CHANNEL_IN10) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11)
};
#define BOARD_DATA_SIZE 0 // How many extra bytes to add on the end of the mouse structure for the board's use
#define Z_MIN 0 // The minimum Z reading
#define Z_MAX 1 // The maximum Z reading
#define Z_TOUCHON 1 // Values between this and Z_MAX are definitely pressed
#define Z_TOUCHOFF 0 // Values between this and Z_MIN are definitely not pressed
static inline void setup_z(void) {
palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(GPIOC, 1, PAL_MODE_INPUT);

View File

@ -15,11 +15,6 @@
// Get the hardware interface
#include "gmouse_lld_MCU_board.h"
// If the board file doesn't specify how many extra bytes it wants - assume 0
#ifndef BOARD_DATA_SIZE
#define BOARD_DATA_SIZE 0
#endif
const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
{
GDRIVER_TYPE_TOUCH,
@ -28,13 +23,13 @@ const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
// 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)+BOARD_DATA_SIZE,
sizeof(GMouse) + GMOUSE_MCU_BOARD_DATA_SIZE,
_gmouseInitDriver, _gmousePostInitDriver, _gmouseDeInitDriver
},
Z_MAX, // z_max
Z_MIN, // z_min
Z_TOUCHON, // z_touchon
Z_TOUCHOFF, // z_touchoff
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

View File

@ -8,26 +8,20 @@
#ifndef _LLD_GMOUSE_MCU_BOARD_H
#define _LLD_GMOUSE_MCU_BOARD_H
// Either define your jitter settings here or define them in the config include file
#if 0
#include "gmouse_lld_MCU_config.h"
#else
#define GMOUSE_MCU_PEN_CALIBRATE_ERROR 2
#define GMOUSE_MCU_PEN_CLICK_ERROR 2
#define GMOUSE_MCU_PEN_MOVE_ERROR 2
#define GMOUSE_MCU_FINGER_CALIBRATE_ERROR 4
#define GMOUSE_MCU_FINGER_CLICK_ERROR 4
#define GMOUSE_MCU_FINGER_MOVE_ERROR 4
#endif
// 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
// Now board specific settings...
#define BOARD_DATA_SIZE 0 // How many extra bytes to add on the end of the mouse structure for the board's use
#define Z_MIN 0 // The minimum Z reading
#define Z_MAX 100 // The maximum Z reading
#define Z_TOUCHON 80 // Values between this and Z_MAX are definitely pressed
#define 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) {
}