I am try to write a program when press touch button , number 20 will display on the screen and keep on the screen .
when i press the button again the number will change to 50
i want this button work as toggle button
my code doesn't work
#include <EEPROM.h>
#include <SPI.h>
#include <Wire.h>
#include <FT_ADAM_4DLCD_FT843.h>
sTagXY sTagxy;
int old=0;
int prev=0;
int tagval;
FT800IMPL_SPI FTImpl(10,5,3);
void setup()
{
FTImpl.Init(FT_DISPLAY_WQVGA_480x272);
FTImpl.SetDisplayEnablePin(FT_DISPENABLE_PIN);
FTImpl.SetAudioEnablePin(FT_AUDIOENABLE_PIN);
FTImpl.DisplayOn();
FTImpl.AudioOn();
FTImpl.Cmd_Calibrate(0);
FTImpl.DLStart();
FTImpl.Finish();
FTImpl.DLStart();
FTImpl.DLEnd();
FTImpl.Finish();
}
void loop()
{
FTImpl.DLStart();
FTImpl.Tag(12);
FTImpl.Cmd_Button(172, 134, 120, 36, 27, 0, "Button");
FTImpl.GetTagXY(sTagxy);
tagval = sTagxy.tag;
old=tagval;
if(12 == old && prev==0)
{
FTImpl.Cmd_Number(130, 55, 28, 0, 20);
delay(100);
prev=1+prev;
}
if(12 == old && prev==1 )
{
FTImpl.Cmd_Number(130, 55, 28, 0, 50);
delay(100);
prev= 1-prev;
}
FTImpl.DLEnd();
FTImpl.Finish();
}