« Back to documentation index
Touch Class Reference
Touch driver class for VK-LCD panels.
More...
#include <Touch.hpp >
Data Structures
struct MSGQ_t
Touch Message structure. More...
Public Types
enum init_err_t { TOUCH_OK = 0,
TOUCH_INIT_ERR = -1,
TOUCH_UNSUPP_ERR = -2,
TOUCH_ERR = -3
}
enum EVENTLIST_t
Type of the Event:
More...
Public Member Functions
Touch (const touch_config_t *tp_cfg=&STMPE811_cfg)
Constructor method of Touch object.
virtual ~Touch (void)
Destructor method of Touch object.
init_err_t Init ()
Touch controller initialization.
virtual init_err_t Clb_Setup ()
Set Calibration data (raw data interpretation)
virtual init_err_t Drv_Setup ()
Set Touch Controller settings.
virtual bool Get_Pen_Status ()
Get Status of the pen.
virtual void Get_Data (unsigned long long *raw)
Get one sample of data.
virtual int Get_Fifo (unsigned long long *raw)
Get all available samples of data.
virtual void Get_XYZ (int points)
Transfer function (from raw coordinates to screen coordinates)
virtual void Handle_touch ()
Pull the new samples if new data is available.
virtual int Get_Last_Idx ()
Get index of the last sample in the ring buffer.
virtual int Get_Dot_thd ()
Get the minimum amounts of dots when pen is hold down.
virtual osEvent Wait_MSG (uint32_t millisec=osWaitForever)
Wait message from the touch thread.
virtual osStatus Del_MSG (MSGQ_t *ptr)
Delete message from the mail queue.
Static Public Member Functions
static void Irq_Alert ()
New Data available.
Data Fields
unsigned short adc_x
raw coordinates of the last received dot
short x
Coordinates of the last received dot.
const touch_raw_data_t * adc_data
Raw History of the received dots.
const touch_screen_data_t * xyz_data
History of the received dots.
Protected Member Functions
osStatus MSG (EVENTLIST_t touch_msg, unsigned short touch_on, unsigned short touch_off)
Send message to the main application.
Detailed Description
Touch driver class for VK-LCD panels.
Example:
#include "mbed.h"
#include "Touch.hpp"
using namespace Vekatech;
Touch STMPE811;
int main()
{
osEvent evt;
STMPE811.Init();
while (true )
{
evt = STMPE811.Wait_MSG();
if (evt.status == osEventMail)
{
Touch::MSGQ_t* msg = (Touch::MSGQ_t*)evt.value.p;
printf("[EV (%d)], start_idx: %d end_idx: %d\r\n" , msg->event, msg->start_idx, msg->stop_idx);
switch (msg->event)
{
case Touch::EV_STYLUS_UP:
printf("[UP (%d)] X: %d Y: %d Z: %f\r\n" , msg->stop_idx, STMPE811.xyz_data[msg->stop_idx].axis.x, STMPE811.xyz_data[msg->stop_idx].axis.y, STMPE811.xyz_data[msg->stop_idx].axis.z );
break ;
case Touch::EV_STYLUS_DOWN:
printf("[DOWN (%d)] X: %d Y: %d Z: %f\r\n" , msg->start_idx, STMPE811.xyz_data[msg->start_idx].axis.x, STMPE811.xyz_data[msg->start_idx].axis.y, STMPE811.xyz_data[msg->start_idx].axis.z );
break ;
case Touch::EV_STYLUS_HOLD:
if (msg->stop_idx >= (STMPE811.Get_Dot_thd()-1) )
for (int i = (msg->stop_idx+1 - STMPE811.Get_Dot_thd()); i<=msg->stop_idx; i++)
printf("[HOLD (%d)] X: %d Y: %d Z: %f\r\n" , i, STMPE811.xyz_data[i].axis.x, STMPE811.xyz_data[i].axis.y, STMPE811.xyz_data[i].axis.z );
break ;
default : break ;
}
STMPE811.Del_MSG((Touch::MSGQ_t*)evt.value.p);
}
}
}
Definition at line 130 of file Touch.hpp .
Member Enumeration Documentation
Type of the Event:
Definition at line 146 of file Touch.hpp .
Enumerator:
TOUCH_OK
Initialization successful
TOUCH_INIT_ERR
Communication interface err while configuring driver
TOUCH_UNSUPP_ERR
Unsupported driver
TOUCH_ERR
unknown error
Definition at line 136 of file Touch.hpp .
Constructor & Destructor Documentation
Constructor method of Touch object.
Constructor of the Touch class.
Parameters:
Definition at line 69 of file Touch.cpp .
~Touch
(
void
)
[virtual]
Destructor method of Touch object.
Destructor of the Touch class.
Definition at line 89 of file Touch.cpp .
Member Function Documentation
Set Calibration data (raw data interpretation)
Set Calibration data.
Return values:
Definition at line 158 of file Touch.cpp .
virtual osStatus Del_MSG
(
MSGQ_t *
ptr )
[virtual]
Delete message from the mail queue.
Definition at line 230 of file Touch.hpp .
Set Touch Controller settings.
Return values:
Definition at line 202 of file Touch.cpp .
void Get_Data
(
unsigned long long *
raw )
[virtual]
Get one sample of data.
Parameters:
[in] raw,: pointer to ring buffer to store the samples
[in] * raw : pointer to ring buffer to store the samples
Definition at line 267 of file Touch.cpp .
int Get_Dot_thd
(
)
[virtual]
Get the minimum amounts of dots when pen is hold down.
Get dot collection threshold.
Return values:
Definition at line 399 of file Touch.cpp .
int Get_Fifo
(
unsigned long long *
raw )
[virtual]
Get all available samples of data.
Parameters:
[in] raw,: pointer to ring buffer to store the samples
Return values:
Parameters:
[in] * raw : pointer to ring buffer to store the samples
Return values:
Definition at line 299 of file Touch.cpp .
int Get_Last_Idx
(
)
[virtual]
Get index of the last sample in the ring buffer.
Return values:
Definition at line 393 of file Touch.cpp .
bool Get_Pen_Status
(
)
[virtual]
Get Status of the pen.
Return values:
true : StylusDown false : StyluUp
Definition at line 246 of file Touch.cpp .
void Get_XYZ
(
int
points )
[virtual]
Transfer function (from raw coordinates to screen coordinates)
Coordinates Transfer function.
Parameters:
[in] points : number of samples to transfer
[in] points : number of samples which have to become meaningful
Definition at line 345 of file Touch.cpp .
void Handle_touch
(
)
[virtual]
Pull the new samples if new data is available.
Pull the new samples if new touch data is available.
Definition at line 404 of file Touch.cpp .
Touch controller initialization.
Return values:
Definition at line 111 of file Touch.cpp .
void Irq_Alert
(
)
[static]
New Data available.
IRQ interrupt handler : indicates "New Touch Data available" which activates i2c data transfer in Handle_touch()
Definition at line 380 of file Touch.cpp .
osStatus MSG
(
EVENTLIST_t
touch_msg ,
unsigned short
touch_on ,
unsigned short
touch_off
)
[protected]
Send message to the main application.
Definition at line 255 of file Touch.hpp .
virtual osEvent Wait_MSG
(
uint32_t
millisec = osWaitForever )
[virtual]
Wait message from the touch thread.
Definition at line 226 of file Touch.hpp .
Field Documentation
Raw History of the received dots.
Definition at line 246 of file Touch.hpp .
raw coordinates of the last received dot
Definition at line 230 of file Touch.hpp .
Coordinates of the last received dot.
Definition at line 240 of file Touch.hpp .
History of the received dots.
Definition at line 250 of file Touch.hpp .