Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Files | Defines | Functions | Variables

TouchPanel
[Mindsensors]

Files

file  mindsensors-touchpanel.h
 

Mindsensors TouchPanel.


Defines

#define MSTP_I2C_ADDR   0x04
#define MSTP_REG_TOUCH_X   0x42
#define MSTP_REG_TOUCH_Y   0x43
#define MSTP_REG_BUTTONS   0x44
#define MSTP_REG_CAL_XD1   0x45
#define MSTP_REG_CAL_YD1   0x46
#define MSTP_REG_CAL_XT1   0x47
#define MSTP_REG_CAL_YT1   0x48
#define MSTP_REG_CAL_XD2   0x49
#define MSTP_REG_CAL_YD2   0x4A
#define MSTP_REG_CAL_XT2   0x4B
#define MSTP_REG_CAL_YT2   0x4C
#define MSTP_REG_G_AVAIL   0x4D
#define MSTP_REG_G_NEXTX   0x4E
#define MSTP_REG_G_NEXTY   0x4F
#define BUTTON_L1   0
#define BUTTON_L2   1
#define BUTTON_L3   2
#define BUTTON_L4   3
#define BUTTON_R1   4
#define BUTTON_R2   5
#define BUTTON_R3   6
#define BUTTON_R4   7
#define MSTP_REG_RAW_BC   0x4D
#define MSTP_REG_RAW_X   0x4E
#define MSTP_REG_RAW_Y   0x4F
#define isButtonTouched(X, Y)   (X >> Y) & 0x01
#define isButtonL1Touched(X)   (X >> BUTTON_L1) & 0x01
#define isButtonL2Touched(X)   (X >> BUTTON_L2) & 0x01
#define isButtonL3Touched(X)   (X >> BUTTON_L3) & 0x01
#define isButtonL4Touched(X)   (X >> BUTTON_L4) & 0x01
#define isButtonR1Touched(X)   (X >> BUTTON_R1) & 0x01
#define isButtonR2Touched(X)   (X >> BUTTON_R2) & 0x01
#define isButtonR3Touched(X)   (X >> BUTTON_R3) & 0x01
#define isButtonR4Touched(X)   (X >> BUTTON_R4) & 0x01
#define MSTPresetCalibration(x)   MSTPsendCmd(tSensors link, ubyte cmd, ubyte addr = MSTP_I2C_ADDR);

Functions

bool MSTPgetTouch (tSensors link, int &x, int &y, ubyte &buttons, ubyte addr=MSTP_I2C_ADDR)
bool MSTPsendCmd (tSensors link, ubyte cmd, ubyte addr=MSTP_I2C_ADDR)

Variables

tByteArray MSTP_I2CRequest
tByteArray MSTP_I2CReply

Detailed Description

TouchPanel


Define Documentation

#define BUTTON_L1   0
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 59 of file mindsensors-touchpanel.h.

#define BUTTON_L2   1
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 60 of file mindsensors-touchpanel.h.

#define BUTTON_L3   2
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 61 of file mindsensors-touchpanel.h.

#define BUTTON_L4   3
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 62 of file mindsensors-touchpanel.h.

#define BUTTON_R1   4
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 63 of file mindsensors-touchpanel.h.

#define BUTTON_R2   5
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 64 of file mindsensors-touchpanel.h.

#define BUTTON_R3   6
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 65 of file mindsensors-touchpanel.h.

#define BUTTON_R4   7
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 66 of file mindsensors-touchpanel.h.

#define isButtonL1Touched (   X )    (X >> BUTTON_L1) & 0x01

Check if the L1 button is pressed

Definition at line 81 of file mindsensors-touchpanel.h.

#define isButtonL2Touched (   X )    (X >> BUTTON_L2) & 0x01

Check if the L2 button is pressed

Definition at line 82 of file mindsensors-touchpanel.h.

#define isButtonL3Touched (   X )    (X >> BUTTON_L3) & 0x01

Check if the L3 button is pressed

Definition at line 83 of file mindsensors-touchpanel.h.

#define isButtonL4Touched (   X )    (X >> BUTTON_L4) & 0x01

Check if the L4 button is pressed

Definition at line 84 of file mindsensors-touchpanel.h.

#define isButtonR1Touched (   X )    (X >> BUTTON_R1) & 0x01

Check if the R1 button is pressed

Definition at line 85 of file mindsensors-touchpanel.h.

#define isButtonR2Touched (   X )    (X >> BUTTON_R2) & 0x01

Check if the R2 button is pressed

Definition at line 86 of file mindsensors-touchpanel.h.

#define isButtonR3Touched (   X )    (X >> BUTTON_R3) & 0x01

Check if the R3 button is pressed

Definition at line 87 of file mindsensors-touchpanel.h.

#define isButtonR4Touched (   X )    (X >> BUTTON_R4) & 0x01

Check if the R4 button is pressed

Definition at line 88 of file mindsensors-touchpanel.h.

#define isButtonTouched (   X,
 
)    (X >> Y) & 0x01

Check if the specified button is pressed

Examples:
mindsensors-touchpanel-test1.c.

Definition at line 79 of file mindsensors-touchpanel.h.

#define MSTP_I2C_ADDR   0x04

Definition at line 42 of file mindsensors-touchpanel.h.

#define MSTP_REG_BUTTONS   0x44

Definition at line 45 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_XD1   0x45

Definition at line 47 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_XD2   0x49

Definition at line 51 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_XT1   0x47

Definition at line 49 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_XT2   0x4B

Definition at line 53 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_YD1   0x46

Definition at line 48 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_YD2   0x4A

Definition at line 52 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_YT1   0x48

Definition at line 50 of file mindsensors-touchpanel.h.

#define MSTP_REG_CAL_YT2   0x4C

Definition at line 54 of file mindsensors-touchpanel.h.

#define MSTP_REG_G_AVAIL   0x4D

Definition at line 55 of file mindsensors-touchpanel.h.

#define MSTP_REG_G_NEXTX   0x4E

Definition at line 56 of file mindsensors-touchpanel.h.

#define MSTP_REG_G_NEXTY   0x4F

Definition at line 57 of file mindsensors-touchpanel.h.

#define MSTP_REG_RAW_BC   0x4D

Definition at line 69 of file mindsensors-touchpanel.h.

#define MSTP_REG_RAW_X   0x4E

Definition at line 70 of file mindsensors-touchpanel.h.

#define MSTP_REG_RAW_Y   0x4F

Definition at line 71 of file mindsensors-touchpanel.h.

#define MSTP_REG_TOUCH_X   0x42

Definition at line 43 of file mindsensors-touchpanel.h.

#define MSTP_REG_TOUCH_Y   0x43

Definition at line 44 of file mindsensors-touchpanel.h.

#define MSTPresetCalibration (   x )    MSTPsendCmd(tSensors link, ubyte cmd, ubyte addr = MSTP_I2C_ADDR);

Definition at line 94 of file mindsensors-touchpanel.h.


Function Documentation

bool MSTPgetTouch ( tSensors  link,
int &  x,
int &  y,
ubyte &  buttons,
ubyte  addr 
)

Fetch all the information from the TouchPanel, including coordinates of current touch and button state. by configuring the sensor as sensorLightInactive

Parameters:
linkthe TouchPanel port number
xthe X coordinate of the current pen position, 0 if nothing is detected
ythe Y coordinate of the current pen position, 0 if nothing is detected
buttonsthe currently touched buttons, use isButtonXXTouched() to check the individual status.
addrthe I2C address of the TouchPanel, is optional, defaults to 0x04
Returns:
true if no error has occured, false if it did
Examples:
mindsensors-touchpanel-test1.c.

Definition at line 108 of file mindsensors-touchpanel.h.

bool MSTPsendCmd ( tSensors  link,
ubyte  cmd,
ubyte  addr 
)

Send a command to the TouchPanel

Parameters:
linkthe TouchPanel port number
cmdthe command to be sent
addrthe I2C address of the TouchPanel, is optional, defaults to 0x04
Returns:
true if no error has occured, false if it did

Definition at line 133 of file mindsensors-touchpanel.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 76 of file mindsensors-touchpanel.h.

Array to hold I2C command data

Definition at line 75 of file mindsensors-touchpanel.h.