2014-10-11 16:24:12 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2015-11-21 09:27:08 +00:00
|
|
|
#include "../../../../src/ginput/ginput_driver_mouse.h"
|
2014-10-11 16:24:12 +00:00
|
|
|
|
|
|
|
// Get the hardware interface
|
|
|
|
#include "gmouse_lld_ADS7843_board.h"
|
|
|
|
|
2014-10-11 21:54:50 +00:00
|
|
|
#define CMD_X 0xD1
|
|
|
|
#define CMD_Y 0x91
|
|
|
|
#define CMD_ENABLE_IRQ 0x80
|
2014-10-11 16:24:12 +00:00
|
|
|
|
2018-06-23 03:02:07 +00:00
|
|
|
static gBool MouseXYZ(GMouse* m, GMouseReading* pdr)
|
2014-10-11 16:24:12 +00:00
|
|
|
{
|
|
|
|
(void)m;
|
|
|
|
|
|
|
|
// No buttons
|
|
|
|
pdr->buttons = 0;
|
2014-10-13 06:37:04 +00:00
|
|
|
pdr->z = 0;
|
2014-10-11 16:24:12 +00:00
|
|
|
|
2014-10-13 06:37:04 +00:00
|
|
|
if (getpin_pressed(m)) {
|
2014-10-11 21:54:50 +00:00
|
|
|
pdr->z = 1; // Set to Z_MAX as we are pressed
|
|
|
|
|
2014-10-13 06:37:04 +00:00
|
|
|
aquire_bus(m);
|
2014-10-11 21:54:50 +00:00
|
|
|
|
2014-10-13 06:37:04 +00:00
|
|
|
read_value(m, CMD_X); // Dummy read - disable PenIRQ
|
|
|
|
pdr->x = read_value(m, CMD_X); // Read X-Value
|
2014-10-11 21:54:50 +00:00
|
|
|
|
2014-10-13 06:37:04 +00:00
|
|
|
read_value(m, CMD_Y); // Dummy read - disable PenIRQ
|
|
|
|
pdr->y = read_value(m, CMD_Y); // Read Y-Value
|
2014-10-11 21:54:50 +00:00
|
|
|
|
2014-10-13 06:37:04 +00:00
|
|
|
read_value(m, CMD_ENABLE_IRQ); // Enable IRQ
|
2014-10-11 21:54:50 +00:00
|
|
|
|
2014-10-13 06:37:04 +00:00
|
|
|
release_bus(m);
|
2014-10-11 16:24:12 +00:00
|
|
|
}
|
2018-06-23 03:02:07 +00:00
|
|
|
return gTrue;
|
2014-10-11 16:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2015-01-02 18:52:04 +00:00
|
|
|
sizeof(GMouse)+GMOUSE_ADS7843_BOARD_DATA_SIZE,
|
2014-10-11 16:24:12 +00:00
|
|
|
_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
|
2014-10-13 06:37:04 +00:00
|
|
|
MouseXYZ, // get
|
2014-10-11 16:24:12 +00:00
|
|
|
0, // calsave
|
|
|
|
0 // calload
|
|
|
|
}};
|
|
|
|
|
|
|
|
#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
|
|
|
|
|