tien voila le code que j'ai mi en place pour mon projet je me suis inspirer en grande partie de ce que j'ai trover sur http://www.mon-club-elec.fr/
aprés i te sufira d'utiliser les fonction atoi() ou atof()
pour convertier ton resultat qui est en char en int ou float a toi de voir
Ps: quel ecrant tu uttilise car tu a de beau dessin de touche?
/*________________________________________fonction clavier_____________________________*/
void Menu_clavier(char *tableauChar, int nbEntree){
const char touchesMaj[5][10]PROGMEM = {
{'0','1','2','3','4','5','6','7','8','9'},
{'A','Z','E','R','T','Y','U','I','O','P'},
{'Q','S','D','F','G','H','J','K','L','M'},
{'W','X','C','V','B','N','.',':','-','!'},
{'<','>',0,0,0,0,0,'_','@','/'}
};
const char touchesMin[5][10]PROGMEM = {
{'0','1','2','3','4','5','6','7','8','9'},
{'a','z','e','r','t','y','u','i','o','p'},
{'q','s','d','f','g','h','j','k','l','m'},
{'w','x','c','v','b','n','.',':','-','!'},
{'<','>',0,0,0,0,0,'_','@','/'}
};
int Xposition=55;
int Yposition=90;
//static char Message=' ';
static byte indexDePosition=0;
int ligne;
int colone;
byte appui=0;
static boolean maj=false;
switch (comptAff){
case 0 :
bandeau();
lcd.drawTextPGM(5, 7, PSTR(" clavier"), 1, COLOR_WHITE,COLOR_BLACK );
for (ligne=0; ligne<5;ligne++){
for (colone=0;colone<10; colone++){
traceTouche(Xposition, Yposition,COLOR_BLACK,20,20,PSTR(" "),1); //trace les touches
if (maj==true){
if (touchesMaj[ligne][colone]==0){ lcd.drawChar(Xposition-4,Yposition-4,' ',1,COLOR_WHITE,COLOR_BLACK);}
else{lcd.drawChar(Xposition-4,Yposition-4,touchesMaj[ligne][colone],1,COLOR_WHITE,COLOR_BLACK);};//trace les caracter majuscule
}else{
if (touchesMin[ligne][colone]==0){ lcd.drawChar(Xposition-4,Yposition-4,' ',1,COLOR_WHITE,COLOR_BLACK);}
else{lcd.drawChar(Xposition-4,Yposition-4,touchesMin[ligne][colone],1,COLOR_WHITE,COLOR_BLACK);};//trace les caracter minuscule
};
Xposition=Xposition+25;
}
Yposition=Yposition+25;
Xposition=55;
}
traceTouche(283, 227,COLOR_BLACK,68,22,PSTR(" RETOUR"),1);
traceTouche(39 , 227,COLOR_BLACK,68,22,PSTR(" MAJ"),1);
traceTouche(117 , 227,COLOR_BLACK,68,22,PSTR(" MIN"),1);
comptAff=1;
break;
case 1:
lcd.printOptions(1,COLOR_WHITE,COLOR_BLACK);
lcd.printXY(100,40);
lcd.print(tableauChar);
lcd.drawChar((100+(indexDePosition*8)),40,tableauChar[indexDePosition],1,COLOR_RED,COLOR_BLACK);//trace le caracter en cours en Rouge
//lcd.fillRect((100+(indexDePosition*8)),40,(100+(indexDePosition*8)+8),(40+10),COLOR_BLACK);
//lcd.drawChar(100,40,tableauChar,1,COLOR_WHITE,COLOR_BLACK);//trace les caracter
break;
};
touchpad.service(); // appel de la routine service touchpad
if (touchpad.getPressure()>10){ // si appui touchpad
for ( ligne=0; ligne<5;ligne++){
for (colone=0;colone<10; colone++){
if (testTouche((Xposition+(0*25)),(Yposition+(4*25)),20,20)==true){appui=1;indexDePosition=constrainCycle(indexDePosition-1,0,nbEntree-2);break;};
if (testTouche((Xposition+(1*25)),(Yposition+(4*25)),20,20)==true){appui=1;indexDePosition=constrainCycle(indexDePosition+1,0,nbEntree-2);break;};
if(testTouche((Xposition+(colone*25)),(Yposition+(ligne*25)),20,20)==true){
#ifdef DEBUG_SERIAL
Serial.print("X="); Serial.println(Xposition+(colone*25));
Serial.print("Y="); Serial.println(Yposition+(ligne*25));
if (maj==true){Serial.print("Mess="); Serial.println(touchesMaj[ligne][colone]);}
else{ Serial.print("Mess="); Serial.println(touchesMin[ligne][colone]); };
#endif
if (maj==true){tableauChar[indexDePosition]=touchesMaj[ligne][colone];}
else{tableauChar[indexDePosition]=touchesMin[ligne][colone];};
appui=1;
indexDePosition=constrainCycle(indexDePosition+1,0,nbEntree-2);
break;
};
}
if (appui==1){break;};
}
if(testTouche(283,227,68,22)==true){
//delay(100);
lcd.clear(couleur_fond);
selecteurPage=selecteurPage/10;
indexDePosition=0;
comptAff=0;
};
if(testTouche(39,227,68,22)==true){
maj=true;
//delay(100);
comptAff=0;
};
if(testTouche(117,227,68,22)==true){
maj=false;
// delay(100);
comptAff=0;
};
};
return;}