2012-08-02 22:15:55 +02:00
|
|
|
/*
|
|
|
|
ChibiOS/RT - Copyright (C) 2012
|
|
|
|
Joel Bodenmann aka Tectu <joel@unormal.org>
|
|
|
|
|
|
|
|
This file is part of ChibiOS-LCD-Driver.
|
|
|
|
|
|
|
|
ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ChibiOS-LCD-Driver is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-06-01 10:33:08 +02:00
|
|
|
#ifndef TOUCHPAD_H
|
|
|
|
#define TOUCHPAD_H
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
2012-06-11 00:00:07 +02:00
|
|
|
#include "glcd.h"
|
2012-08-02 09:56:54 +02:00
|
|
|
#include "glcdconf.h"
|
2012-06-17 01:35:21 +02:00
|
|
|
#include "ads7843_lld.h"
|
|
|
|
#include "xpt2046_lld.h"
|
2012-06-01 10:33:08 +02:00
|
|
|
|
2012-06-01 12:44:48 +02:00
|
|
|
#define CONVERSIONS 3
|
|
|
|
|
2012-07-10 03:13:38 +02:00
|
|
|
#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS)
|
|
|
|
#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS)
|
2012-06-01 10:33:08 +02:00
|
|
|
|
2012-06-11 14:34:17 +02:00
|
|
|
struct cal {
|
2012-06-04 16:40:38 +02:00
|
|
|
float xm;
|
|
|
|
float ym;
|
|
|
|
float xn;
|
|
|
|
float yn;
|
2012-06-04 09:06:55 +02:00
|
|
|
};
|
|
|
|
|
2012-06-19 20:05:01 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-06-08 00:07:43 +02:00
|
|
|
/*
|
|
|
|
* Description: initializes touchpad (SPI)
|
|
|
|
*
|
2012-06-11 13:07:44 +02:00
|
|
|
* param: SPI driver
|
2012-06-08 00:07:43 +02:00
|
|
|
*
|
|
|
|
* return: none
|
|
|
|
*/
|
2012-06-11 13:07:44 +02:00
|
|
|
void tpInit(SPIDriver *spip);
|
2012-06-08 00:07:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: reads out PEN_IRQ from touchpad controller
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: 1 = touchpad pressed / 0 = touchpad not pressed
|
|
|
|
*/
|
2012-06-04 00:15:38 +02:00
|
|
|
uint8_t tpIRQ(void);
|
2012-06-08 00:07:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: reads-out X coordinate, calibrated
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: X coordinate, relative to screen zero-point
|
|
|
|
*/
|
2012-06-01 10:33:08 +02:00
|
|
|
uint16_t tpReadX(void);
|
2012-06-08 00:07:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: reads-out Y coordinate, calibrated
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: Y coordinate, relative to screen zero-point
|
|
|
|
*/
|
2012-06-01 10:33:08 +02:00
|
|
|
uint16_t tpReadY(void);
|
2012-06-08 00:07:43 +02:00
|
|
|
|
2012-06-15 10:18:52 +02:00
|
|
|
/*
|
|
|
|
* Description: reads-out Z value / pressure
|
|
|
|
* only available when controller supports, returns
|
|
|
|
* zero otherwise.
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: pressure on the touchpad
|
|
|
|
*/
|
|
|
|
uint16_t tpReadZ(void);
|
|
|
|
|
2012-06-08 00:07:43 +02:00
|
|
|
/*
|
|
|
|
* Description: calibration routine
|
|
|
|
*
|
|
|
|
* param: none
|
|
|
|
*
|
|
|
|
* return: none
|
|
|
|
*/
|
2012-06-04 09:06:55 +02:00
|
|
|
void tpCalibrate(void);
|
2012-06-01 10:33:08 +02:00
|
|
|
|
2012-06-19 20:05:01 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-01 10:33:08 +02:00
|
|
|
#endif
|
2012-06-10 18:59:54 +02:00
|
|
|
|