Révision 585
Ajouté par jgsoleilla il y a presque 4 ans
SP4b2.c | ||
---|---|---|
|
||
void tpo_us(unsigned short duree);// temporisation en ?s
|
||
void tpo_ms(unsigned short duree);// temporisation en ms
|
||
void lcd_init_port(void); // initialisation des broches du ?C
|
||
void init(void); // initialisation des broches du ?C / initialisation de l'afficheur et du clavier
|
||
void lcd_4b(unsigned char car); // envoi des 4 bits
|
||
void lcd_8b(unsigned char car); // envoi des 8 bits de donn?e
|
||
void lcd_car(unsigned char car);// envoi d'une donn?e ? afficher
|
||
void lcd_com(unsigned char com);// envoi d'une commande
|
||
void lcd_init(void); // initialisation de l'afficheur
|
||
void lcd_str(unsigned char *str); // envoi d'une cha?ne de caract?re
|
||
void clavier(void); // detection des touches du clavier
|
||
void affichage(unsigned char *str); // Affichage sur l'ecran
|
||
|
||
|
||
void main(void)
|
||
{
|
||
|
||
char t;
|
||
unsigned char touche;
|
||
pu31 =1;
|
||
pd10 = 0x0F;
|
||
|
||
lcd_init_port();
|
||
lcd_init();
|
||
//lcd_str("Bonjour");
|
||
char touche = 0;
|
||
init();
|
||
|
||
// while(1){
|
||
while(1){
|
||
|
||
// touche = clavier();
|
||
// }
|
||
touche = p10;
|
||
|
||
if (touche != 0xF0){
|
||
clavier();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void lcd_init_port(void){
|
||
void init(void){
|
||
|
||
// Init port
|
||
|
||
pd3 = 0xFF;
|
||
}
|
||
|
||
void lcd_init(void){
|
||
pd10 = 0x0F;
|
||
p10 = 0;
|
||
pu31 = 1;
|
||
|
||
//Init lcd
|
||
|
||
tpo_ms(15);
|
||
lcd_4b(0x30);
|
||
tpo_ms(5);
|
||
... | ... | |
lcd_com(0x0E); //LCD ? on, curseur ? on
|
||
lcd_com(0x01); //Clear LCD
|
||
tpo_ms(5);
|
||
|
||
}
|
||
|
||
void lcd_4b(unsigned char car){
|
||
... | ... | |
tpo_us(5);
|
||
}
|
||
|
||
|
||
void lcd_8b(unsigned char car){
|
||
|
||
lcd_4b(car);
|
||
... | ... | |
int i = 0;
|
||
while (str[i] != '\0'){
|
||
lcd_car(str[i]);
|
||
i++;
|
||
i += 1;
|
||
}
|
||
}
|
||
/*
|
||
unsigned char clavier(void){
|
||
|
||
void clavier(void){
|
||
unsigned char t;
|
||
|
||
p10 = 0x0E;
|
||
t = p10;
|
||
unsigned char touche;
|
||
|
||
if (t == 0xBE){
|
||
touche = '1';
|
||
affichage("50 Km/h");
|
||
}
|
||
|
||
if (t == 0xDE){
|
||
touche = '2';
|
||
affichage("70 Km/h");
|
||
}
|
||
|
||
|
||
if (t == 0x7E){
|
||
touche = '3';
|
||
affichage("90 Km/h");
|
||
}
|
||
|
||
|
||
p10 = 0x0D;
|
||
t = p10;
|
||
if (t == 0xBD){
|
||
touche = '4';
|
||
affichage("110 Km/h");
|
||
}
|
||
|
||
if (t == 0xDD){
|
||
touche = '5';
|
||
affichage("130 Km/h");
|
||
}
|
||
|
||
if (t == 0x7D){
|
||
touche = '6';
|
||
affichage("...");
|
||
}
|
||
|
||
p10 = 0x0B;
|
||
t = p10;
|
||
if (t == 0xEB){
|
||
touche = '7';
|
||
affichage("Ajout Zone");
|
||
}
|
||
|
||
if (t == 0xDB){
|
||
touche = '8';
|
||
affichage("...");
|
||
}
|
||
|
||
|
||
if (t == 0x7B){
|
||
touche = '9';
|
||
affichage("...");
|
||
}
|
||
|
||
|
||
p10 = 0x07;
|
||
t = p10;
|
||
if (t == 0xE7){
|
||
touche = '*';
|
||
affichage("*");
|
||
}
|
||
|
||
if (t == 0xD7){
|
||
touche = '0';
|
||
affichage("Arret Alarme");
|
||
}
|
||
|
||
|
||
if (t == 0x77){
|
||
touche = '#';
|
||
affichage("#");
|
||
}
|
||
return touche;
|
||
}
|
||
*/
|
||
|
||
void affichage(unsigned char *str){
|
||
lcd_com(0x01);
|
||
tpo_ms(50);
|
||
lcd_str(str);
|
||
}
|
||
|
||
void tpo_ms(unsigned short duree){
|
||
tcspr = 0x8A;
|
||
ta0mr = 0x82;
|
Formats disponibles : Unified diff
SP4b3 : Modifications code TP12 + finalisation code clavier/afficheur.