STMPE610 touch sensor driver library

Dependents:   TS_Eyes Tokei testUniGraphic_150217 AfficheurTFTAdafruit ... more

Embed: (wiki syntax)

« Back to documentation index

SPI_STMPE610 Class Reference

SPI_STMPE610 Class Reference

SPI_STMPE610 Touch Sensor Example: More...

#include <SPI_STMPE610.h>

Public Member Functions

 SPI_STMPE610 (PinName mosi, PinName miso, PinName sclk, PinName cs)
 STMPE610 constructor.
 ~SPI_STMPE610 ()
 Destructor.
void spi_frequency (unsigned long freq)
 specify spi frequency from this class
void spi_format (int bits, int mode)
 specify spi format from this class
int getRAWPoint (uint16_t *x, uint16_t *y, uint16_t *z)
 get RAW value of x, y, z
int getPoint (uint16_t *x, uint16_t *y, uint16_t *z=0)
 get value of x, y, z

Detailed Description

SPI_STMPE610 Touch Sensor Example:

 #include "mbed.h"
 #include "SPI_STMPE610.h"

 #define PIN_MOSI        PTD2
 #define PIN_MISO        PTD3 
 #define PIN_SCLK        PTD1 
 #define PIN_CS_TSC      PTA13
 #define PIN_TSC_INTR    PTC9
 
 SPI_STMPE610 TSC(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TSC) ;

 int main()
 {
    uint16_t touched, x, y, z ;
    printf("Test SPI STMPE610\n\r") ;
    while (true) {
        touched = TSC.getRAWPoint(&x, &y, &z) ;
        if (touched) {
            printf("x = %d, y = %d, z = %d\n\r", x, y, z) ;
        }
        wait(0.1) ;
    }
 }

Definition at line 57 of file SPI_STMPE610.h.


Constructor & Destructor Documentation

SPI_STMPE610 ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs 
)

STMPE610 constructor.

Parameters:
mosiSPI_MOSI pin
misoSPI_MISO pin
sclkSPI_CLK pin
csSPI_CS pin

Definition at line 135 of file SPI_STMPE610.cpp.

~SPI_STMPE610 (  )

Destructor.

Definition at line 163 of file SPI_STMPE610.cpp.


Member Function Documentation

int getPoint ( uint16_t *  x,
uint16_t *  y,
uint16_t *  z = 0 
)

get value of x, y, z

Parameters:
*xx value relative to TFT
*yy value relative to TFT
*zz RAW value if non-null pointer is passed
Note:
default calibration was for my particular device
for more accuracy measure your device and modify
those values in SPI_STMPE610.c

Definition at line 260 of file SPI_STMPE610.cpp.

int getRAWPoint ( uint16_t *  x,
uint16_t *  y,
uint16_t *  z 
)

get RAW value of x, y, z

Parameters:
*xraw value of x
*yraw value of y
*zraw value of z
Returns:
if touched
Note:
For my device usually the value seems to be between 300 ~ 3000
when it fails to acquire value the value of 0 seems to be returned

Definition at line 227 of file SPI_STMPE610.cpp.

void spi_format ( int  bits,
int  mode 
)

specify spi format from this class

Parameters:
bitsnumber of bits per spi frame
modeclock polarity and phase mode
Note:
please refer to the spi class for more details

Definition at line 222 of file SPI_STMPE610.cpp.

void spi_frequency ( unsigned long  freq )

specify spi frequency from this class

Parameters:
freqfrequency in Hz

Definition at line 217 of file SPI_STMPE610.cpp.