Hello,
Voici à quoi ressemble le code, je me suis inspiré des exemples "Touch" et "HelloWorld" de la librairie :
/* Arduino standard includes */
#include "SPI.h"
#include "Wire.h"
/* Platform specific includes */
#include "FT_NHD_43CTP_SHIELD.h"
/* Global object for FT801 Implementation */
FT801IMPL_SPI FTImpl(FT_CS_PIN,FT_PDN_PIN,FT_INT_PIN);
/* Api to bootup FT801, verify FT801 hardware and configure display/audio pins */
/* Returns 0 in case of success and 1 in case of failure */
int16_t BootupConfigure()
{
uint32_t chipid = 0;
FTImpl.Init(FT_DISPLAY_RESOLUTION);//configure the display to the WQVGA
delay(20);//for safer side
chipid = FTImpl.Read32(FT_ROM_CHIPID);
/* Identify the chip */
if(FT801_CHIPID != chipid)
{
Serial.print("Error in chip id read ");
Serial.println(chipid,HEX);
return 1;
}
/* Set the Display & audio pins */
FTImpl.SetDisplayEnablePin(FT_DISPENABLE_PIN);
FTImpl.SetAudioEnablePin(FT_AUDIOENABLE_PIN);
FTImpl.DisplayOn();
FTImpl.AudioOn();
return 0;
}
/* Helper API to convert decimal to ascii - pSrc shall contain NULL terminated string */
int32_t Dec2Ascii(char *pSrc,int32_t value)
{
int16_t Length;
char *pdst,charval;
int32_t CurrVal = value,tmpval,i;
char tmparray[16],idx = 0;//assumed that output string will not exceed 16 characters including null terminated character
//get the length of the string
Length = strlen(pSrc);
pdst = pSrc + Length;
//cross check whether 0 is sent
if(0 == value)
{
*pdst++ = '0';
*pdst++ = '\0';
return 0;
}
//handling of -ve number
if(CurrVal < 0)
{
*pdst++ = '-';
CurrVal = - CurrVal;
}
/* insert the digits */
while(CurrVal > 0){
tmpval = CurrVal;
CurrVal /= 10;
tmpval = tmpval - CurrVal*10;
charval = '0' + tmpval;
tmparray[idx++] = charval;
}
//flip the digits for the normal order
for(i=0;i<idx;i++)
{
*pdst++ = tmparray[idx - i - 1];
}
*pdst++ = '\0';
return 0;
}
/* API to display Hello World string on the screen */
void Slide()
{
int32_t wbutton,hbutton,tagval,tagoption;
char StringArray[100],StringArray1[100];
uint32_t ReadWord;
int16_t xvalue,yvalue,pendown;
sCTouchXY cTouchXY;
wbutton = FT_DISPLAYWIDTH/8;
hbutton = FT_DISPLAYHEIGHT/8;
FTImpl.SetCTouchMode(FT_CTOUCH_MODE_EXTENDED); //set mode to extended for FT801
/* Change the below string for experimentation */
const char Display_string[12] = "Animal";
const char Display_string1[12] = "Véhicule";
const char Display_string2[12] = "Taille";
while(1)
{
/* Read the touch screen xy and tag from GetCTouchXY API */
FTImpl.GetCTouchXY(cTouchXY);
/* Construct a screen shot with grey color as background, check constantly the touch registers,
form the infromative string for the coordinates of the touch, check for tag */
// FTImpl.DLStart(); //start the display list. Note DLStart and DLEnd are helper apis, Cmd_DLStart() and Display() can also be utilized.
// FTImpl.ClearColorRGB(64,64,64);
// FTImpl.Clear(1,1,1); //clear color component
// FTImpl.ColorRGB(0xff,0xff,0xff);
FTImpl.TagMask(0);
/* Display list to display "Hello World" at the centre of display area */
FTImpl.DLStart();//start the display list. Note DLStart and DLEnd are helper apis, Cmd_DLStart() and Display() can also be utilized.
FTImpl.ColorRGB(0x33,0xFF,0x00);//set the color of the string to yellow/green color
FTImpl.Cmd_Text(FT_DISPLAYWIDTH/10, FT_DISPLAYHEIGHT/10, 29, FT_OPT_CENTER, Display_string);//display "Hello World at the center of the screen using inbuilt font handle 29 "
FTImpl.Cmd_Text(FT_DISPLAYWIDTH/9.5, FT_DISPLAYHEIGHT/4, 29, FT_OPT_CENTER, Display_string1);//display "Hello World at the center of the screen using inbuilt font handle 29 "
FTImpl.Cmd_Text(FT_DISPLAYWIDTH/3.6, FT_DISPLAYHEIGHT/10, 29, FT_OPT_CENTER, Display_string2);//display "Hello World at the center of the screen using inbuilt font handle 29 "
yvalue = cTouchXY.y0;
xvalue = cTouchXY.x0;
if (xvalue > 300 && (yvalue > 60 && yvalue < 90)){
FTImpl.Cmd_Text(FT_DISPLAYWIDTH/2, FT_DISPLAYHEIGHT/1.7, 31, FT_OPT_CENTER, "Chat");
}
if (xvalue > 310 && (yvalue > 0 && yvalue < 60)){
FTImpl.Cmd_Text(FT_DISPLAYWIDTH/2, FT_DISPLAYHEIGHT/1.7, 31, FT_OPT_CENTER, « Land Rover");
}
if ((xvalue > 120 && xvalue < 300) && (yvalue > 60 && yvalue < 90)){
FTImpl.Cmd_Text(FT_DISPLAYWIDTH/2, FT_DISPLAYHEIGHT/1.7, 31, FT_OPT_CENTER, "182cm");
}
FTImpl.DLEnd();
FTImpl.Finish();
}
}
void setup()
{
/* Initialize serial print related functionality */
Serial.begin(9600);
/* Set the Display Enable pin*/
Serial.println("--Start Application--");
if(BootupConfigure())
{
//error case - do not do any thing
}
else
{
Slide();
}
Serial.println("--End Application--");
}
/* Nothing in loop api */
void loop()
{
}
Le comportement est le suivant :
Lorsque j'appuie sur la zone "Véhicule", le texte "Land Rover" s'affiche à l'écran, mais disparaît si je relâche, alors que j'aimerai qu'il reste en place, jusqu'à ce que j'appuie sur un autre item (par exemple "Taille", qui devra afficher "182cm").