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

function STMPE610_WriteReg(RegisterAddr, RegisterValue : byte) : byte;

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

function STMPE610_ReadReg(RegisterAddr : byte) : byte;

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
var temp : byte;
...
temp := STMPE610_WriteReg(STMPE610_SYS_CTRL1_REG, 0x02);
Notes
  • None.

STMPE610_ReadID

Prototype

function STMPE610_ReadID() : word;

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
var temp : word;
temp := STMPE610_ReadID();
Notes
  • None.

STMPE610_IsOperational

Prototype

function STMPE610_IsOperational() : byte;

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) then
  // STMPE610 initialized OK
 else 
  // STMPE610 did not initialize OK
Notes
  • None.

STMPE610_SetI2CAddress

Prototype

procedure STMPE610_SetI2CAddress(DeviceAddr : byte);

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

function STMPE610_Reset() : byte;

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

function STMPE610_Module(module_mask, newState : byte) : byte;

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 or STMPE610_MODULE_ADC, STMPE610_ENABLE);
Notes
  • Multiple modules can be Enabled/Disabled at one time, as shown in example.

STMPE610_AlternateFunction

Prototype

function STMPE610_AlternateFunction(IO_Pin, NewState : byte) : byte;

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 or STMPE610_GPIO_PIN4, _STMPE610_ENABLE);
Notes
  • Multiple pins can be Enabled/Disabled at one time, as shown in example.

STMPE610_SetGPIOPin

Prototype

function STMPE610_SetGPIOPin(IO_Pin, BitVal : byte) : byte;

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 or STMPE610_GPIO_PIN6, 1);
Notes
  • Multiple pins can be Set/Cleared at one time, as shown in example.

STMPE610_EnableInterrupt

Prototype

function STMPE610_EnableInterrupt(interrupt_mask, enable : byte) : byte;

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 or 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

function STMPE610_SetADC(mode : byte) : byte;

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 or STMPE610_ADC_CTRL1_ADC_12BIT or 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

function STMPE610_SetADCClock(clock : byte) : byte;

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

function STMPE610_ConfigureTSC(average_sample, touch_detect_delay, settling_time : byte) : byte;

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

function STMPE610_SetFIFOThreshold(point : byte) : byte;

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

function STMPE610_ResetFIFO() : byte;

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

procedure STMPE610_SetTouchPressureThreshold(threshold : byte);

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

function STMPE610_TSIDrive(_drive : byte) : byte;

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

function STMPE610_TSControl(_ctrl : byte) : byte;

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 or 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

function STMPE610_ClearInterrupts() : byte;

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

procedure 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

function STMPE610_SetSize(display_width, display_height : word) : byte;

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

function STMPE610_GetRawXYZ(x_data, y_data : ^word; z_data : ^byte) : byte;

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

function STMPE610_GetXYZ(x_data, y_data : ^word; z_data : ^byte) : byte;

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

function STMPE610_PressDetect() : byte;

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() <> 0) then
...
Notes
  • Function resets FIFO buffer.

STMPE610_GetCoordinates

Prototype

function STMPE610_GetCoordinates(x_coordinate, y_coordinate : ^word) : byte;

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) then
...
Notes
  • None.

STMPE610_GetLastCoordinates

Prototype

function STMPE610_GetLastCoordinates(x_coordinate, y_coordinate : ^word) : byte;

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

procedure STMPE610_SetCalibrationConsts(TPConstsStruct : ^TTPConstants);

Description

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

Parameters
  • TPConstsStruct: Pointer to TTPConstants previously filled with correct values.
  • Value Description
    type TTPConstants = record
    X_Min : word; X Min parameter goes here.
    X_Max : word; X Max value goes here.
    Y_Min : word; Y Min parameter goes here.
    Y_Max : word; Sets tracking index to 32 pixels.
    Rotate : byte; 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).
    end;
Requires

Properly initialized I²C, and STMPE610 module.

Example
var TPConstsStruct : TTPConstants;

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

STMPE610_GetCalibrationConsts

Prototype

procedure STMPE610_GetCalibrationConsts(TPConstsStruct : ^TTPConstants);

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
    type TTPConstants = record
    X_Min : word; X Min parameter goes here.
    X_Max : word; X Max value goes here.
    Y_Min : word; Y Min parameter goes here.
    Y_Max : word; Sets tracking index to 32 pixels.
    Rotate : byte; 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).
    end;
Requires

Properly initialized I²C, and STMPE610 module.

Example
var TPConstsStruct : TTPConstants;

STMPE610_GetCalibrationConsts(@TPConstsStruct);
Notes
  • None.

STMPE610_SetDefaultMode

Prototype

procedure 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

procedure STMPE610_Rotate180(rotate : byte);

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

procedure STMPE610_CalibratePoint(_point : byte);

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.