Library for MI0283QT-2 LCD

Embed: (wiki syntax)

« Back to documentation index

TOUCHS Class Reference

TouchScreen ADS7846 Library From the DS: The ADS7846 is a classic successive approximation register (SAR) analog-to-digital converter (ADC). More...

#include <Touchlib.h>

Public Member Functions

 TOUCHS (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName penirq)
 Create the touch object.
void init (void)
 Initalize the touchscreen chip.
unsigned int setcalibration (_TS_COORD *ts)
 This function computes a matrix of data to be used for the conversion from touch to screen coord.
void do_tap (void)
 I use a pool metod to read the touch.
unsigned int getcrocino_x (unsigned char idx)
 Get the x coord of the crocino speicifyed by idx.
unsigned int getcrocino_y (unsigned char idx)
 Get the y coord of the crocino speicifyed by idx.
unsigned int crocino_size (void)
 Get the pixel size of the crocino.
unsigned int gettsmatrixsize (void)
 Return the size of the TS_Matrix size.
void gettsmatrix (unsigned char *pmatrix)
 Get the TS_Matrix.
void settsmatrix (unsigned char *pmatrix)
 Set the TS_Matrix with the content of the buffer.

Protected Member Functions

unsigned int calibrate (void)
 This function convert from touch to screen coord.
void read (_TS_COORD *ts)
 Read the raw coordinate from the touchscreen.

Detailed Description

TouchScreen ADS7846 Library From the DS: The ADS7846 is a classic successive approximation register (SAR) analog-to-digital converter (ADC).

The architecture is based on capacitive redistribution which inherently includes a sample-and-hold function. The converter is fabricated on a 0.6μm CMOS process.

The device features an internal 2.5V reference and an external clock. Operation is maintained from a single supply of 2.7V to 5.25V. The internal reference can be overdriven with an external, low impedance source between 1V and +VCC. The value of the reference voltage directly sets the input range of the converter. The analog input (X-, Y-, and Z-position coordinates, auxiliary input, battery voltage, and chip temperature) to the converter is provided via a multiplexer. A unique configuration of low on-resistance touch panel driver switches allows an unselected ADC input channel to provide power and its accompanying pin to provide ground for an external device, such as a touch screen

Example:

 // Please the main.c code as an elabora example.

Definition at line 109 of file Touchlib.h.


Constructor & Destructor Documentation

TOUCHS ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs,
PinName  penirq 
)

Create the touch object.

Parameters:
pinmosi, pin miso, pin sclk, pin chip select and pin penirq

Definition at line 54 of file Touchlib.c.


Member Function Documentation

unsigned int calibrate ( void   ) [protected]

This function convert from touch to screen coord.

The value are stored inside the struct ts_val

Definition at line 75 of file Touchlib.c.

unsigned int crocino_size ( void   )

Get the pixel size of the crocino.

Returns:
the pixel size of the crocino.

Definition at line 90 of file Touchlib.c.

void do_tap ( void   )

I use a pool metod to read the touch.

Each time I need to read the touch I loop until this function set a flag. It's also possible to configure this fuction as an handle of a Ticker class, checkin for the flag inside the main loop.

Definition at line 194 of file Touchlib.c.

unsigned int getcrocino_x ( unsigned char  idx )

Get the x coord of the crocino speicifyed by idx.

There are three crocino defined inside the crocino.h header file

Parameters:
idxOne of the three crocino.
Returns:
the x coord.

Definition at line 95 of file Touchlib.c.

unsigned int getcrocino_y ( unsigned char  idx )

Get the y coord of the crocino speicifyed by idx.

There are three crocino defined inside the crocino.h header file

Parameters:
idxOne of the three crocino.
Returns:
the x coord.

Definition at line 103 of file Touchlib.c.

void gettsmatrix ( unsigned char *  pmatrix )

Get the TS_Matrix.

Parameters:
pmatrixPointer to an area of RAM where the function store the content of the TS_Matrix

Definition at line 116 of file Touchlib.c.

unsigned int gettsmatrixsize ( void   )

Return the size of the TS_Matrix size.

Returns:
the size of the TS_Matrix

Definition at line 111 of file Touchlib.c.

void init ( void   )

Initalize the touchscreen chip.

Parameters:
none

Definition at line 186 of file Touchlib.c.

void read ( _TS_COORD *  ts ) [protected]

Read the raw coordinate from the touchscreen.

Parameters:
structts that will old the data.

Definition at line 249 of file Touchlib.c.

unsigned int setcalibration ( _TS_COORD *  ts )

This function computes a matrix of data to be used for the conversion from touch to screen coord.

Parameters:
thecoord of each crocino tapped by the user.

Definition at line 59 of file Touchlib.c.

void settsmatrix ( unsigned char *  pmatrix )

Set the TS_Matrix with the content of the buffer.

Parameters:
pmatrixPointer to a buffer

Definition at line 150 of file Touchlib.c.