Projet

Général

Profil

« Précédent | Suivant » 

Révision 587

Ajouté par celasherme il y a presque 4 ans

programme clavier + afficheur fonctionnel et amélioration du programme

Voir les différences:

SP4b2.c
/***********************************************************************/
#include "sfr32c87.h"
void lcd_4b(unsigned char car);
void lcd_8b(unsigned char car);
void lcd_com(unsigned char com);
void lcd_init(void);
void lcd_car(unsigned char car);
void tpo_us(unsigned short duree);// temporisation en ?s
void tpo_ms(unsigned short duree);// temporisation en ms
// declaration fonctions LCD
void main(void)
{
unsigned char c='C';
pd3=0xFF;
lcd_init(); //initialiser avant d'envoyer !!
lcd_car(c);
}
void lcd_4b(unsigned char car) // envoi des 4 bits de poids fort
{
//pd3=0xFF; // definir les ports du registres pDi ouvert
......
lcd_8b(car);
}
void lcd_init(void)
{
p3_0=0;
tpo_ms(15);
lcd_4b(0x30);
tpo_ms(5);
lcd_4b(0x30);
tpo_us(100);
lcd_4b(0x30);
tpo_us(100);
lcd_4b(0x20);
lcd_com(0x28);
lcd_com(0x06);
lcd_com(0x0E);
lcd_com(0x01);
tpo_ms(5);
}
void tpo_us(unsigned short duree) // temporisation en ?s
{
tcspr = 0x8A;
......
ta0s = 0;
}
void lcd_init(void)
{
p3_0=0;
tpo_ms(15);
lcd_4b(0x30);
tpo_ms(5);
lcd_4b(0x30);
tpo_us(100);
lcd_4b(0x30);
tpo_us(100);
lcd_4b(0x20);
lcd_com(0x28);
lcd_com(0x06);
lcd_com(0x0E);
lcd_com(0x01);
tpo_ms(5);
}
void lcd_str(unsigned char *str)
{
int i=0;
while(str[i]!='\0')
{
lcd_car(str[i]);
i++;
}
}
//void lcd_clear (void)
//{
// lcd_com(0x01);
//}
// Declaration Fonctions KeyBoard
void init_keyboard(void){
pd10 = 0x0F; // mettre broche 0 a 3 = 1 (sorties) et broches 4 a 7 =0 (entr?e)
p10=0;
pu31 = 1; // activation resistance pull-up ( broches 4 a 7 au VDD)
}
/*void keyboard (void)
{
init_keyboard();
lcd_init();
while(1)
{
if ( (p10 & 0xf0)!= 0xf0 )//les colonnes sont en entrees
{
touche= p10 ; // on enleve le phenomene de rebon en ajoutant la tempo
// tempo car quand j'appuis sur le boutton il affiche rien
// et quand je lache il affiche
tpo_ms() ;
//test ligne 4
p10=0x07;
t=p10;
if (t==0x77)
{
//lcd_com(0x01); // clear
//tpo_ms(15); // tempo car quand j'appuis sur le boutton il affiche rien
// et quand je lache il affiche
touche_ap='#';
lcd_str("#");
}
if(t==0xD7)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='0';
lcd_str("Arret Alarme");
}
if (t==0xE7)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='*';
lcd_str("*");
}
// test ligne 3
p10=0x0B;
t=p10;
if (t==0x7B)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='9';
lcd_str("...");
}
if(t==0xDB)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='8';
lcd_str("...");
}
if (t==0xEB)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='7';
lcd_str("Ajout Zone");
}
// test ligne 2
p10=0x0D;
t=p10;
if (t==0x7D)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='6';
lcd_str("...");
}
if(t==0xDD)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='5';
lcd_str("130 km/h");
}
if (t==0xBD)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='4';
lcd_str("110 km/h");
}
// test ligne 1
p10=0x0E;
t=p10;
if (t==0x7E)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='3';
lcd_str("90 km/h");
}
if(t==0xDE)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='2';
lcd_str("70 km/h");
}
if (t==0xBE)
{
//lcd_com(0x01); // clear
//tpo_ms(15);
touche_ap='1';
lcd_str("50 km/h");
}
pu31=1;
}
}
}*/
void main(void)
{
// declaration variables
char t;
unsigned char touche = 0;
unsigned char touche_ap;
touche=p10;
//unsigned char c[]="j'ai reussi";
//pd3=0xFF;
//lcd_init(); //initialiser avant d'envoyer !!
//lcd_car(c);
//lcd_str(c);
//keyboard();
init_keyboard();
lcd_init();
while(1)
{
//test ligne 4
p10=0x07;
t=p10;
if (t==0x77)
{
lcd_com(0x01); // clear
//tpo_ms(15); // tempo car quand j'appuis sur le boutton il affiche rien
// et quand je lache il affiche
touche_ap='#';
lcd_str("#");
}
if(t==0xD7)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='0';
lcd_str("Arret Alarme");
}
if (t==0xE7)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='*';
lcd_str("*");
}
// test ligne 3
p10=0x0B;
t=p10;
if (t==0x7B)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='9';
lcd_str("...");
}
if(t==0xDB)
{
//lcd_com(0x01);
//tpo_ms(15);
touche_ap='8';
lcd_str("...");
}
if (t==0xEB)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='7';
lcd_str("Ajout Zone");
}
// test ligne 2
p10=0x0D;
t=p10;
if (t==0x7D)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='6';
lcd_str("...");
}
if(t==0xDD)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='5';
lcd_str("130 km/h");
}
if (t==0xBD)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='4';
lcd_str("110 km/h");
}
// test ligne 1
p10=0x0E;
t=p10;
if (t==0x7E)
{
touche=t;
lcd_com(0x01);
//tpo_ms(15);
touche_ap='3';
lcd_str("90 km/h");
}
if(t==0xDE)
{
lcd_com(0x01);
//tpo_ms(15);
touche_ap='2';
lcd_str("70 km/h");
}
if (t==0xBE)
{
lcd_com(0x01); // clear
//tpo_ms(15);
touche_ap='1';
lcd_str("50 km/h");
}
pu31=1;
}
while(t==touche_ap)
{
//touche= p10; // on enleve le phenomene de rebon en ajoutant la tempo
// tempo car quand j'appuis sur le boutton il affiche rien
// et quand je lache il affiche
tpo_ms(15) ;
}
lcd_car(touche_ap);
lcd_init();
}
......
//void lcd_4b(unsigned char car);
//void lcd_8b(unsigned char car);
//void lcd_com(unsigned char com);
//void lcd_init(void);
//void lcd_car(unsigned char car);
//void tpo_us(unsigned short duree); // temporisation en ?s
//void tpo_ms(unsigned short duree); // temporisation en ms
//void lcd_str(unsigned char *str); // envoi d'une cha?ne de caract?re/*
......

Formats disponibles : Unified diff