This library controls the IC TSC2046 included in some displays with touch screen. Buttons, Push Buttons, Switches and Potentiometers can be added in few seconds. This is a library designed for automation projects. You can use this library to control relays, leds, pwm and on-off control.
Using the library.
The control BUTTON makes a button with text. The size of button is determined by the text dimension.
Example. Draw and read a button at x = 10, y = 20, text = Power, state = 0.
The button is determined by a structure. The format of the structure is as follows.
BUTTON b = {10, 20, "Power", 0};
To draw the button is necessary to define the type of font. The button takes the size automatically.
TFT_SetFont(Courier_New_Bold_20, 1);
Draw_Button(&b);
To Read the button the statement if or while can be used.
TFT_SetFont(Courier_New_Bold_20, 1);
if(Read_Button(&b) == 1)
{
// Your Code Here.
}
The control PUSH_BUTTON makes a push button.
Example. Draw and a read a push button at x = 10, y = 60, state = 0.
The push button is determined by a structure. The format of the structure is as follows.
PUSH_BUTTON pb = {10, 60, 0};
To draw the push button is used the following function.
Draw_PushButton(&pb);
To read the push button the statement while can be used.
while(Read_PushButton(&pb))
{
// Your Code Here.
}
The control ON_OFF_SWITCH makes a on-off switch.
Example. Draw and read a switch at x = 10, y = 100, state = normally closed.
The on-off switch is determined by a structure. The format of the structure is as follows.
ON_OFF_SWITCH s = {10, 100, 1};
To draw an on-off switch is used the following function.
Draw_Switch(&s);
To read an on-off switch the statement switch can be used.
switch(Read_Switch(&s))
{
case 0: /* Your Code Here */ break;
case 1: /* Your Code Here */ break;
}
The control POTENTIOMETER makes a potentiometer.
Example. Draw and make a potentiometer at x = 10, y = 140, range from -20 to 20, default value = 0, state = 0.
The potentiometer is defined by a structure. The format of the structure is as follows.
POTENTIOMETER p = {10, 140, -20, 20, 0, 0};
To draw the potentiometer is used the following function.
Draw_Potentiometer(&p);
To read the potentiometer the statement do while can be used.
do{
Read_Potentiometer(&p);
// Your Code Here
Delay_ms(100);
}while(p.state > 0);
Connection.
0 comments:
Post a Comment