STMPE610 Library

The STMPE610 is a GPIO (general purpose input/output) port expander able to interface a main digital ASIC via the two-line bidirectional bus (I2C). A 4-wire touchscreen controller is built into the STMPE610. The touchscreen controller is enhanced with a movement tracking algorithm to avoid excessive data, 128 x 32 bit buffer and a programmable active window feature. This library will focus on Touchscreen controlling part od the IC.


  Important :

Library Routines

STMPE610_WriteReg

Prototype

char STMPE610_WriteReg(char RegisterAddr, char RegisterValue) ;

Description

This function sets desired STMPE610 register (on RegisterAddr address) with given value (RegisterValue).

Parameters
  • RegisterAddr: STMPE610 register address.
  • RegisterValue: STMPE610 register value to write.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
// Initialize the STMPE610_SYS_CTRL1_REG register with the value 0x02
STMPE610_WriteReg(STMPE610_SYS_CTRL1_REG, 0x02);
Notes
  • None.

STMPE610_ReadReg

Prototype

char STMPE610_ReadReg(char RegisterAddr);

Description

This function reads desired STMPE610 register (on RegisterAddr address) and returns its value.

Parameters
  • RegisterAddr: STMPE610 register address.
Returns

Value of the STMPE610 register at given address.

Requires

Properly initialized I²C, and STMPE610 module.

Example
// Initialize the STMPE610_SYS_CTRL1_REG register with the value 0x02
char temp;
temp = STMPE610_WriteReg(STMPE610_SYS_CTRL1_REG, 0x02);
Notes
  • None.

STMPE610_ReadID

Prototype

unsigned int STMPE610_ReadID();

Description

This routine reads STMPE610 ID register, and returns its value.

Parameters

None.

Returns

If I²C, and STMPE610 modules have been properly initialized function should return correct ID nimber and that is 0x0811.

Requires

Properly initialized I²C, and STMPE610 module.

Example
unsigned int temp;
temp = STMPE610_ReadID();
Notes
  • None.

STMPE610_IsOperational

Prototype

char STMPE610_IsOperational();

Description

This routine checks if STMPE610 responds correctly via I²C communication.

Parameters

None.

Returns

STMPE610_OK if STMPE610 responds correctly, otherwise function returns STMPE610_FAILURE.

Requires

Properly initialized I²C, and STMPE610 module.

Example
if (STMPE610_IsOperational() == STMPE610_OK) {
  // STMPE610 initialized OK
} else {
  // STMPE610 did not initialize OK
}
Notes
  • None.

STMPE610_SetI2CAddress

Prototype

void STMPE610_SetI2CAddress(char DeviceAddr);

Description

This procedure sets default addres which will be used fo all further commnunication with STMPE610 IC.

Parameters
  • RegisterAddr: STMPE610 I²C address.
Requires

Adress set must be either 0x82 or 0x88, any other values will cause IC to not work properly.

Example
// Initialize the STMPE610 I2C communication address at 0x88
STMPE610_SetI2CAddress(STMPE610_I2C_ADDR1);
Notes
  • None.

STMPE610_Reset

Prototype

char STMPE610_Reset();

Description

This is a reset routine for STMPE610.

Parameters

None.

Returns

STMPE610_OK if STMPE610 responds correctly, otherwise function returns STMPE610_FAILURE.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_Reset();
Notes
  • None.

STMPE610_Module

Prototype

unsigned char STMPE610_Module(char module_mask, char newState);

Description

Enable or Disable the various STMPE610 modules.

Parameters
  • module_mask: mask of STMPE610 module.
  • Value Description
    STMPE610_MODULE_ADC Mask to Enable/Disable ADC Module.
    STMPE610_MODULE_TS Mask to Enable/Disable TouchScreen Module.
    STMPE610_MODULE_GPIO Mask to Enable/Disable GPIO.
    STMPE610_MODULE_TEMPSENS Mask to Enable/Disable temperature sensor.
  • newState: STMPE610 Enable or Disable module :
    Value Description
    STMPE610_ENABLE Module Enable.
    STMPE610_DISABLE Module disable.
Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_Module(STMPE610_MODULE_TS | STMPE610_MODULE_ADC, STMPE610_ENABLE);
Notes
  • Multiple modules can be Enabled/Disabled at one time, as shown in example.

STMPE610_AlternateFunction

Prototype

char STMPE610_AlternateFunction(char IO_Pin, char NewState);

Description

Sets weather STMPE610 GPIO pins will have alternate function(s) or not.

Parameters
  • IO_Pin: STMPE610 pin number.
  • Value Description
    STMPE610_GPIO_PIN0 GPIO Pin No 0
    STMPE610_GPIO_PIN1 GPIO Pin No 1
    STMPE610_GPIO_PIN2 GPIO Pin No 2
    STMPE610_GPIO_PIN3 GPIO Pin No 3
    STMPE610_GPIO_PIN4 GPIO Pin No 4
    STMPE610_GPIO_PIN5 GPIO Pin No 5
    STMPE610_GPIO_PIN6 GPIO Pin No 6
    STMPE610_GPIO_PIN7 GPIO Pin No 7
    STMPE610_GPIO_PINALL Select all GPIO pins.
  • newState: STMPE610 Enable or Disable module :
    Value Description
    STMPE610_ENABLE Module Enable.
    STMPE610_DISABLE Module disable.
Returns

STMPE610_OK if STMPE610 responds correctly, otherwise function returns STMPE610_FAILURE.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_AlternateFunction(STMPE610_GPIO_PIN6 | STMPE610_GPIO_PIN4, _STMPE610_ENABLE);
Notes
  • Multiple pins can be Enabled/Disabled at one time, as shown in example.

STMPE610_SetGPIOPin

Prototype

char STMPE610_SetGPIOPin(char IO_Pin, char BitVal);

Description

Sets or clears STMPE610 GPIO pin.

Parameters
  • IO_Pin: STMPE610 pin number.
  • Value Description
    STMPE610_GPIO_PIN0 GPIO Pin No 0
    STMPE610_GPIO_PIN1 GPIO Pin No 1
    STMPE610_GPIO_PIN2 GPIO Pin No 2
    STMPE610_GPIO_PIN3 GPIO Pin No 3
    STMPE610_GPIO_PIN4 GPIO Pin No 4
    STMPE610_GPIO_PIN5 GPIO Pin No 5
    STMPE610_GPIO_PIN6 GPIO Pin No 6
    STMPE610_GPIO_PIN7 GPIO Pin No 7
    STMPE610_GPIO_PINALL Select all GPIO pins.
  • BitVal: STMPE610 GPIO pin value:
    Value Description
    0 Set GPIO pin to zero.
    1 Set GPIO pin to one.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

MCU with at least one STMPE610 module.

Used STMPE610 module must be initialized before using this function. See STMPE610x_Init and STMPE610x_Init_Advanced routines.

Example
STMPE610_SetGPIOPin(STMPE610_GPIO_PIN7 | STMPE610_GPIO_PIN6, 1);
Notes
  • Multiple pins can be Set/Cleared at one time, as shown in example.

STMPE610_EnableInterrupt

Prototype

char STMPE610_EnableInterrupt(char interrupt_mask, char enable);

Description

Enables/Disables different types of STMPE610 interrupt generation.

Parameters
  • interrupt_mask: Enable/Disable STMPE610 interrupt module.
  • Value Description
    STMPE610_IE_TOUCH_DET Generate interrupt on screen touched.
    STMPE610_IE_FIFO_TH Generate interrupt when FIFO threshold is reached.
    STMPE610_IE_FIFO_0FLOW Generate interrupt when FIFO overflows.
    STMPE610_IE_FIFO_FULL Generate interrupt when FIFO is full.
    STMPE610_IE_FIFO_EMPTY Generate interrupt when FIFO is empty.
    STMPE610_IE_TEMP_SENS Generate interrupt from temperature sensor.
    STMPE610_IE_ADC Generate interrupt from ADC conversion.
    STMPE610_IE_GPIO Generate interrupt from GPIO.
  • enable: STMPE610 Enable or Disable module :
    Value Description
    STMPE610_ENABLE Module Enable.
    STMPE610_DISABLE Module disable.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_EnableInterrupt(STMPE610_IE_ADC | STMPE610_IE_TOUCH_DET, STMPE610_ENABLE);
Notes
  • Multiple interrupts can be Enabled/Disabled at one time, as shown in example.

STMPE610_ConfigureInterrupt

Prototype

function STMPE610_ConfigureInterrupt(interrupt_mask : byte) : byte;

Description

Configure Interrupt Type.

Parameters
  • interrupt_mask: Enable/Disable STMPE610 interrupt module.
  • Value Description
    STMPE610_INT_POLARITY_ACTIVE_HIGH Generate interrupt on low.
    STMPE610_INT_POLARITY_ACTIVE_LOW Generate interrupt on high.
    STMPE610_INT_TYPE_EDGE Interrupt is of edge type.
    STMPE610_INT_TYPE_LEVEL Interrupt is of level type.
    STMPE610_INT_ENABLE_ALL Enable all interrupts.
    STMPE610_INT_STOP_ALL Disable all interrupts.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_ConfigureInterrupt(STMPE610_INT_POLARITY_ACTIVE_HIGH or STMPE610_INT_TYPE_EDGE);
Notes
  • Multiple interrupts can be Enabled/Disabled at one time, as shown in example.

STMPE610_SetADC

Prototype

char STMPE610_SetADC(char mode);

Description

Configure STMPE610 ADC module.

Parameters
  • mode: Configure parameter is acquired using various predefined constants.
  • Value Description
    STMPE610_ADC_CTRL1_SAMPLETIME_44 Set ADC sample time to 44 clocks.
    STMPE610_ADC_CTRL1_SAMPLETIME_56 Set ADC sample time to 56 clocks.
    STMPE610_ADC_CTRL1_SAMPLETIME_64 Set ADC sample time to 64 clocks.
    STMPE610_ADC_CTRL1_SAMPLETIME_80 Set ADC sample time to 80 clocks.
    STMPE610_ADC_CTRL1_SAMPLETIME_96 Set ADC sample time to 96 clocks.
    STMPE610_ADC_CTRL1_SAMPLETIME_124 Set ADC sample time to 124 clocks.
    STMPE610_ADC_CTRL1_ADC_12BIT Set ADC conversion result to 12bit.
    STMPE610_ADC_CTRL1_ADC_10BIT Set ADC conversion result to 10bit.
    STMPE610_ADC_CTRL1_EXT_REFERENCE Set ADC voltage reference to external.
    STMPE610_ADC_CTRL1_INT_REFERENCE Set ADC voltage reference to internal.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_SetADC(STMPE610_ADC_CTRL1_SAMPLETIME_56 | STMPE610_ADC_CTRL1_ADC_12BIT | STMPE610_ADC_CTRL1_INT_REFERENCE);
Notes
  • Set ADC using one of sample time constants, conversion result and voltage refference each, as shown in Example.

STMPE610_SetADCClock

Prototype

char STMPE610_SetADCClock(char clock);

Description

Configure STMPE610 ADC clock.

Parameters
  • clock: Configure parameter is acquired using various predefined constants.
  • Value Description
    STMPE610_ADC_CTRL2_1625_kHZ Set ADC cock to 1625 kHZ.
    STMPE610_ADC_CTRL2_3250_kHZ Set ADC cock to 3250 kHZ.
    STMPE610_ADC_CTRL2_6500_kHZ Set ADC cock to 6500 kHZ.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_SetADCClock(STMPE610_ADC_CTRL2_6500_kHZ);
Notes
  • None.

STMPE610_ConfigureTSC

Prototype

char STMPE610_ConfigureTSC(char average_sample, char touch_detect_delay, char settling_time);

Description

Configure various parameters of STMPE610 module.

Parameters
  • average_sample: Decides how many samples will be taken per ADC acquisition (improves accuracy).
  • Value Description
    STMPE610_TSC_CFG_AVE_CTRL_1S Set 1 ADC sample as average.
    STMPE610_TSC_CFG_AVE_CTRL_2S Set 2 ADC sample as average.
    STMPE610_TSC_CFG_AVE_CTRL_4S Set 4 ADC sample as average.
    STMPE610_TSC_CFG_AVE_CTRL_8S Set 8 ADC sample as average.
  • touch_detect_delay: Sets time for touch detect delay.
  • Value Description
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_10uS Set delay time to 10us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_50uS Set delay time to 50us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_100uS Set delay time to 100us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_500uS Set delay time to 500us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_1mS Set delay time to 1ms.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_5mS Set delay time to 5ms.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_10mS Set delay time to 10ms.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_50mS Set delay time to 50ms.
  • settling_time: Sets time for touch panel to settle.
  • Value Description
    STMPE610_TSC_CFG_TOUCH_SETTLING_10uS Set settle time to 10us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_50uS Set delay time to 50us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_100uS Set delay time to 100us.
    STMPE610_TSC_CFG_TOUCH_DET_DELAY_500uS Set delay time to 500us.
    STMPE610_TSC_CFG_TOUCH_SETTLING_1mS Set delay time to 1ms.
    STMPE610_TSC_CFG_TOUCH_SETTLING_5mS Set delay time to 5ms.
    STMPE610_TSC_CFG_TOUCH_SETTLING_10mS Set delay time to 10ms.
    STMPE610_TSC_CFG_TOUCH_SETTLING_50mS Set delay time to 50ms.
    STMPE610_TSC_CFG_TOUCH_SETTLING_100mS Set delay time to 100ms.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_ConfigureTSC(STMPE610_TSC_CFG_AVE_CTRL_2S, STMPE610_TSC_CFG_TOUCH_DET_DELAY_500uS, STMPE610_TSC_CFG_TOUCH_DET_DELAY_500uS);
Notes
  • None.

STMPE610_SetFIFOThreshold

Prototype

char STMPE610_SetFIFOThreshold(char point);

Description

Configure threshold of STMPE610 FIFO register.

Parameters
  • point: Sets number of samples taken before STMPE610 generates a FIFO threshold interrupt.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

FIFO threshold value must be within 1-128 range.

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_SetFIFOThreshold(5);
Notes
  • None.

STMPE610_ResetFIFO

Prototype

char STMPE610_ResetFIFO();

Description

Procedure resets STMPE610 FIFO register.

Parameters
  • None.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_ResetFIFO();
Notes
  • None.

STMPE610_ZDataFraction

Prototype

function STMPE610_ZDataFraction(_value : byte) : byte;

Description

Procedure sets the range and accuracy of the STMPE610 pressure measurement.

Parameters
  • _drive: Sets current limit value.
  • Value Description
    STMPE610_FRACP0_WHOLP8 Fractional part is 0, whole part is 8.
    STMPE610_FRACP1_WHOLP7 Fractional part is 1, whole part is 7.
    STMPE610_FRACP2_WHOLP6 Fractional part is 2, whole part is 6.
    STMPE610_FRACP3_WHOLP5 Fractional part is 3, whole part is 5.
    STMPE610_FRACP4_WHOLP4 Fractional part is 4, whole part is 4.
    STMPE610_FRACP5_WHOLP3 Fractional part is 5, whole part is 3.
    STMPE610_FRACP6_WHOLP2 Fractional part is 6, whole part is 2.
    STMPE610_FRACP7_WHOLP1 Fractional part is 7, whole part is 1.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_ZDataFraction(STMPE610_FRACP0_WHOLP8);
Notes
  • None.

STMPE610_SetTouchPressureThreshold

Prototype

void STMPE610_SetTouchPressureThreshold(char threshold);

Description

Use this function to set desired touch panel pressure value. This value is compare with Z readout value, based on result touch is qualified as valid or invalid. If the Z value is lager then trashold value, press is invalid. (Z value decreases with increase of touch pressure)

Parameters
  • threshold: Value of touch panel press trashold.
Requires

Properly initialized I²C, and STMPE610 module.

Example
// Discard the press if Z value is grater then 45 
STMPE610_SetTouchPressureThreshold(45);
Notes
  • STMPE610 FRACTION_Z register is set in mode: "100: Fractional part is 4, whole part is 4"

STMPE610_TSIDrive

Prototype

char STMPE610_TSIDrive(char _drive);

Description

This function sets the current limit value of the STMPE610 touchscreen drivers.

Parameters
  • _drive: Sets current limit value.
  • Value Description
    STMPE610_TSC_I_DRIVE_20mA Sets current limit value to 20mA.
    STMPE610_TSC_I_DRIVE_50mA Sets current limit value to 50mA.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_TSIDrive(STMPE610_TSC_I_DRIVE_50mA);
Notes
  • None.

STMPE610_TSControl

Prototype

char STMPE610_TSControl(char _ctrl);

Description

This function sets tracking index, and value ADC acquisition of STMPE610.

Parameters
  • _ctrl: Sets tracking index, and value ADC acquisition using following parameters:
  • Value Description
    STMPE610_TSC_CTRL_TRACK0 Sets tracking index to zero (no tracking).
    STMPE610_TSC_CTRL_TRACK4 Sets tracking index to 4 pixels.
    STMPE610_TSC_CTRL_TRACK8 Sets tracking index to 8 pixels.
    STMPE610_TSC_CTRL_TRACK16 Sets tracking index to 16 pixels.
    STMPE610_TSC_CTRL_TRACK32 Sets tracking index to 32 pixels.
    STMPE610_TSC_CTRL_TRACK64 Sets tracking index to 64 pixels.
    STMPE610_TSC_CTRL_TRACK92 Sets tracking index to 92 pixels.
    STMPE610_TSC_CTRL_TRACK127 Sets tracking index to 127 pixels.
    STMPE610_TSC_CTRL_ACQU_XYZ ADC acquizition generates X, Y and Z data.
    STMPE610_TSC_CTRL_ACQU_XY ADC acquizition generates X and Y data.
    STMPE610_TSC_CTRL_ACQU_X ADC acquizition generates only X data.
    STMPE610_TSC_CTRL_ACQU_Y ADC acquizition generates only Y data.
    STMPE610_TSC_CTRL_ACQU_Z ADC acquizition generates only Z data.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_TSControl(STMPE610_TSC_CTRL_TRACK4 | STMPE610_TSC_CTRL_ACQU_XYZ);
Notes
  • Input parameter should be combination of one acquizition and one tracking index parameter, as shown in Example.

STMPE610_ClearInterrupts

Prototype

char STMPE610_ClearInterrupts();

Description

Procedure clears all STMPE610 interrupts.

Parameters
  • None.
Returns

STMPE610_OK: if all operations are OK. Other value if error.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_ClearInterrupts();
Notes
  • None.

STMPE610_ClearInterruptFlagsAndFIFO

Prototype

void STMPE610_ClearInterruptFlagsAndFIFO();

Description

Procedure clears all STMPE610 interrupt flags and resets FIFO register.

Parameters
  • None.
Returns

Nothing.

Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_ClearInterruptFlagsAndFIFO();
Notes
  • None.

STMPE610_SetSize

Prototype

char STMPE610_SetSize(unsigned int display_width, unsigned int display_height);

Description

This function sets touch screen size in pixels.

Parameters
  • display_width: Sets touch screen display width.
  • display_height: Sets touch screen display heigth.
Requires

Properly initialized I²C, and STMPE610 module.

Example
STMPE610_SetSize(480, 272);
Notes
  • Use STMPE610_SetSize to change oriantation of touchscreen (should be done parallel with changing display orientation).

STMPE610_GetRawXYZ

Prototype

char STMPE610_GetRawXYZ(unsigned int *x_data, unsigned int *y_data, unsigned short *z_data);

Description

Function reads raw(ADC values) Touch panel values from FIFO(first in FIFO, last touched) for X, Y, and Z.

Parameters
  • x_data pointer to value that will recieve X data value.
  • y_data: pointer to value that will recieve Y data value.
  • z_data pointer to value that will recieve Z data value.
Returns

STMPE610_OK if reading goes OK

STMPE610_FAILURE if there are no data sets to be read.(FIFO empty)

Requires

Properly initialized I²C, and STMPE610 module.

Example
// Read raw Touch panel (ADC conversion) values (X, Y, and Z)
STMPE610_GetRawXYZ(&adc_x, &adc_y, &adc_z );
Notes
  • none.

STMPE610_GetXYZ

Prototype

void STMPE610_GetXYZ(unsigned int *x_data, unsigned int *y_data, unsigned short *z_data);

Description

Function reads Touch panel coordinate(pixel) from FIFO(first in FIFO, last touched), for X, Y, and Z

Parameters
  • x_data: pointer to value that will recieve X coordinate.
  • y_data: pointer to value that will recieve Y coordinate.
  • z_data: pointer to value that will recieve Z coordinate.
Returns

STMPE610_OK if reading goes OK

STMPE610_FAILURE if there are no data sets to be read.(FIFO empty)

Requires

Properly initialized I²C, and STMPE610 module.

Example
//  Read raw Touch panel coordinates(pixel) (X, Y, and Z)
STMPE610_GetXYZ(&x_px, &y_px, &z_px);
Notes
  • none.

STMPE610_PressDetect

Prototype

char STMPE610_PressDetect();

Description

This function detects it touch panel has been pressed and also returns pendown value.

Parameters
  • None.
Returns

One: if touchscreen has been pressed.

Zero: if touchscreen hasn't been pressed.

Additionaly, function returns value of PenDown (detects changes on touchscreen, PressDown or PressUp).

Requires

Properly initialized I²C, and STMPE610 module.

Example
  if (STMPE610_PressDetect()) {
    ...
Notes
  • Function resets FIFO buffer.

STMPE610_GetCoordinates

Prototype

char STMPE610_GetCoordinates(unsigned int *x_coordinate, unsigned int *y_coordinate);

Description

This function returns coordinates(in pixels) where touchscreen has been pressed.

Parameters
  • x_coordinate: Pointer to 2byte variable that holds X coordinate.
  • y_coordinate: Pointer to 2byte variable that holds Y coordinate.
Returns

    0x00 : if returned values are correct
    0x01 : if returned values are not valid (no data sets available)
    0x02 : if touch pressed didnt exceed threshold

Requires

Properly initialized I²C, and STMPE610 module.

Example
  if (STMPE610_GetCoordinates(&Xcoord, &Ycoord) == 0) {
    ...
Notes
  • None.

STMPE610_GetLastCoordinates

Prototype

char STMPE610_GetLastCoordinates(unsigned int *x_coordinate, unsigned int *y_coordinate);

Description

Returns last display coordinates (from FIFO register) where touch panel has been pressed.

Parameters
  • x_coordinate pointer to x coordinate.
  • y_coordinate pointer to y coordinated.
Returns

0x00 : if returned values are correct
0x01 : if returned values are not valid (no data sets available)
0x02 : if touch pressed didnt exceed threshold

Requires

Properly initialized I²C, and STMPE610 module.

Example
// Get last valid value from FIFO 
STMPE610_GetLastCoordinates(&x_c, &y_c);
Notes
  • If FIFO if full, 128th value is returned.

STMPE610_SetCalibrationConsts

Prototype

void STMPE610_SetCalibrationConsts(TTPConstants *TPConstsStruct);

Description

This function sets calibration constants and orientation by structure defined parameters.

Parameters
  • TPConstsStruct: Pointer to TTPConstants previously filled with correct values.
  • Value Description
    X_Min X Min parameter goes here.
    X_Max X Max value goes here.
    Y_Min Y Min parameter goes here.
    Y_Max Sets tracking index to 32 pixels.
    Rotate Rotation value goes here. To explain this further if minimum of display (coordinates 0,0) are at the samo spot as minimum of touchscreen (lowest X and Y values) Rotate parameter shoud be zero.
    Consequently, if touchscreen minimum is 90 degrees offset (clockwise rotation) rotate parameter should be one (180 degrees translates to Rotate = 2 and 270 degrees translates to Rotate = 3).
Requires

Properly initialized I²C, and STMPE610 module.

Example
TTPConstants TPConstsStruct;

TPConstsStruct.X_Max = 3898;
TPConstsStruct.X_Min = 137;
TPConstsStruct.Y_Max = 3828;
TPConstsStruct.Y_Min = 362;
TPConstsStruct.Rotate = 0;
TSC_set_Calib_Consts(&TPConstsStruct);
Notes
  • Manual calibration procedure does all this automaticaly upon succesful calibration of touchscreen.

STMPE610_GetCalibrationConsts

Prototype

void STMPE610_GetCalibrationConsts(TTPConstants *TPConstsStruct);

Description

This function returns calibration constants and orientation to structure previously defined.

Parameters
  • TPConstsStruct: Pointer to TTPConstants to be filled with values from library.
  • Value Description
    X_Min X Min parameter goes here.
    X_Max X Max value goes here.
    Y_Min Y Min parameter goes here.
    Y_Max Sets tracking index to 32 pixels.
    Rotate Rotation value goes here. To explain this further if minimum of display (coordinates 0,0) are at the samo spot as minimum of touchscreen (lowest X and Y values) Rotate parameter shoud be zero.
    Consequently, if touchscreen minimum is 90 degrees offset (clockwise rotation) rotate parameter should be one (180 degrees translates to Rotate = 2 and 270 degrees translates to Rotate = 3).
Requires

Properly initialized I²C, and STMPE610 module.

Example
TTPConstants TPConstsStruct;

STMPE610_GetCalibrationConsts(&TPConstsStruct);
Notes
  • None.

STMPE610_SetDefaultMode

Prototype

void STMPE610_SetDefaultMode();

Description

Procedure sets default STMPE610 touchscreen values neccesary for normal operation.

Parameters
  • None.
Requires

None.

Example
STMPE610_SetDefaultMode();
Notes
  • None.

STMPE610_Rotate180

Prototype

void STMPE610_Rotate180(char rotate);

Description

This function rotates touchscreen by 180 degrees.

Parameters
  • rotate: Pointer to byte variable that holds information about state of pen/press (weather pen is pressed down or lifted up)
  • Value Description
    STMPE610_ROTATE_0 Rotate touchscreen back to 0 degrees (if it has been previously rotated by 180 degrees)
    STMPE610_ROTATE_180 Rotate touchscreen by 180 degrees.
Requires

None.

Example
STMPE610_Rotate180(STMPE610_ROTATE_180);
Notes
  • None.

STMPE610_CalibratePoint

Prototype

void STMPE610_CalibratePoint(char _point);

Description

This function calibrates touchscreen.

Parameters
  • rotate: Pointer to byte variable that holds information about state of pen/press (weather pen is pressed down or lifted up)
  • Value Description
    STMPE610_FIRST_CORNER First corner point.
    STMPE610_SECOND_CORNER Second corner point.
    STMPE610_THIRD_CORNER Third corner point.
    STMPE610_FOURTH_CORNER Fourth corner point.
Requires

None.

Example
STMPE610_CalibratePoint(_STMPE610_FIRST_CORNER);
Notes
  • None.
Copyright (c) 2002-2019 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code