Projet

Général

Profil

« Précédent | Suivant » 

Révision 480

Ajouté par ahkurklu il y a presque 4 ans

Fin de séance tpb2

Voir les différences:

Sp4b2.c
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
/***********************************************************************/
#include"sfr32c87.h"
#include <stdlib.h>
void lcd_4b(unsigned char car);
void lcd_8b(unsigned char car);
......
void tpo_us(unsigned short duree);
void tpo_ms(unsigned short duree);
void lcd_str(unsigned char * str);
char touche(void);
void affiche_touche(void);
//void add(void);
int decode_int(char c);
void main(void){
char t;
pd3 = 0xff;
pd10 = 0x0f;
lcd_init();
lcd_str("2003!");
// affiche_touche();
add();
}
void lcd_4b(unsigned char car){
p3_2 = 1;
if(car & 0x10){
p3_4 = 1;
}
......
}
char touche(void){
char touche;
char t;
pu31 = 1;
p10 = 0x00;
while(1){
t=p10;
if(t!= 0xF0){
p10 =0xFE;
t=p10;
if(t==0xDE){
touche ='2';
return touche;
exit(1);
}
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);
}
if(t==0xEB){
touche ='7';
return touche;
exit(1);
}
p10 =0xF7;
t=p10;
if(t==0xE7){
touche ='*';
return touche;
exit(1);
}
if(t==0x77){
touche ='#';
return touche;
exit(1);
}
if(t==0xD7){
touche ='0';
return touche;
exit(1);
}
}
}
}
void affiche_touche(void){
char a;
a = touche();
lcd_char(a);
}
int decode_int(char c)
{
int resultat= c-48;
if (resultat>-1 && resultat<10){
return resultat;
}
else return -1;
}
//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);
......
lcd_com(0x01);
tpo_ms(5);
}

Formats disponibles : Unified diff