Révision 638
Ajouté par ahkurklu il y a environ 4 ans
Sp4b2.c | ||
---|---|---|
void affiche_touche(void);
|
||
//void add(void);
|
||
int decode_int(char c);
|
||
void multiple_touche(int n);
|
||
|
||
void main(void){
|
||
char t;
|
||
pd3 = 0xff;
|
||
pd10 = 0x0f;
|
||
lcd_init();
|
||
// affiche_touche();
|
||
add();
|
||
multiple_touche(50);
|
||
// add();
|
||
|
||
}
|
||
|
||
... | ... | |
t=p10;
|
||
if(t==0xDE){
|
||
touche ='2';
|
||
return touche;
|
||
exit(1);
|
||
return touche;
|
||
}
|
||
if(t==0x7E){
|
||
touche ='3';
|
||
return touche;
|
||
exit(1);
|
||
}
|
||
if(t==0xBE){
|
||
touche ='1';
|
||
return touche;
|
||
exit(1);
|
||
}
|
||
p10 =0xFD;
|
||
t=p10;
|
||
if(t==0xDD){
|
||
touche ='5';
|
||
return touche;
|
||
exit(1);
|
||
}
|
||
if(t==0x7D){
|
||
touche ='6';
|
||
return touche;
|
||
exit(1);
|
||
}
|
||
if(t==0xBD){
|
||
touche ='4';
|
||
return touche;
|
||
exit(1);
|
||
}
|
||
p10 =0xFB;
|
||
t=p10;
|
||
if(t==0xDB){
|
||
touche ='8';
|
||
return touche;
|
||
exit(1);
|
||
}
|
||
if(t==0x7B){
|
||
touche ='9';
|
||
return touche;
|
||
exit(1);
|
||
return touche;
|
||
}
|
||
if(t==0xEB){
|
||
touche ='7';
|
||
return touche;
|
||
exit(1);
|
||
return touche;
|
||
}
|
||
p10 =0xF7;
|
||
t=p10;
|
||
if(t==0xE7){
|
||
touche ='*';
|
||
return touche;
|
||
exit(1);
|
||
return touche;
|
||
}
|
||
if(t==0x77){
|
||
touche ='#';
|
||
return touche;
|
||
exit(1);
|
||
return touche;
|
||
}
|
||
if(t==0xD7){
|
||
touche ='0';
|
||
return touche;
|
||
exit(1);
|
||
return touche;
|
||
}
|
||
|
||
}
|
||
... | ... | |
lcd_char(a);
|
||
}
|
||
|
||
|
||
void multiple_touche(int n){
|
||
int i;
|
||
for(i=0;i<n;i++){
|
||
affiche_touche();
|
||
tpo_ms(500);
|
||
tpo_ms(500);
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
int decode_int(char c)
|
||
{
|
||
|
||
... | ... | |
|
||
}
|
||
|
||
//ne marche pas fonction add
|
||
/*
|
||
void add(void){
|
||
char a,b;
|
||
int ia,ib;
|
||
char res[2];
|
||
int i;
|
||
lcd_str("Entree deux chiffre ");
|
||
for(i=0;i<60;i++){
|
||
tpo_ms(500);
|
||
}
|
||
lcd_com(0x01);
|
||
tpo_ms(500);
|
||
lcd_str("A = ");
|
||
tpo_ms(500);
|
||
a = touche();
|
||
lcd_char(a);
|
||
for(i=0;i<60;i++){
|
||
tpo_ms(500);
|
||
}
|
||
lcd_com(0x01);
|
||
|
||
tpo_ms(500);
|
||
lcd_str("B = ");
|
||
tpo_ms(500);
|
||
b = touche();
|
||
lcd_char(b);
|
||
for(i=0;i<60;i++){
|
||
tpo_ms(500);
|
||
}
|
||
lcd_com(0x01);
|
||
|
||
tpo_ms(500);
|
||
ia= decode_int(a);
|
||
ib = decode_int(b);
|
||
ia = ia+ib;
|
||
|
||
ib = ia%10;
|
||
res[1] = (char)ib;
|
||
ia = ia-ib;
|
||
ia = ia/10;
|
||
res[0] = (char)ib;
|
||
|
||
lcd_str("A+B = ");
|
||
for(i=0;i<60;i++){
|
||
tpo_ms(500);
|
||
}
|
||
lcd_char(res[0]);
|
||
lcd_char(res[1]);
|
||
|
||
}
|
||
*/
|
||
|
||
void lcd_init(void){
|
||
p3_0 = 0;
|
||
tpo_ms(15);
|
Formats disponibles : Unified diff
Modification fonction affichage