Projet

Général

Profil

« Précédent | Suivant » 

Révision 583

Ajouté par nipelloux il y a presque 4 ans

Clavier fonctionnel et qui affiche bien ce qu'il faut sur l'ecran lcd

Voir les différences:

SP4b2.c
/***********************************************************************/
#include "sfr32c87.h"
#include <stdlib.h>
char touche;//***
char t;
void lcd4b(unsigned char car);
void lcd8b(unsigned char car);
void lcdcom(unsigned char car);
......
void tpo_us(unsigned short duree);
void tpo_ms(unsigned short duree);
void lcd_init(void);
void lcd_str(unsigned char * str);
void clavier (void);
void init_keyboard (void);
void main(void)
{
unsigned char c='R';
unsigned char c[]="Je pense que ca marche";
//pd1 = 0xff;
pd3 = 0xff;
pd3 = 0xff;//***
//lcd4b(c);
//lcd8b(c);
//lcdcom(c);
lcd_init();
lcdChar(c);
clavier();
}
void lcd4b(unsigned char car)
{
p3_2=1;
if (car & 0x80)
if (car & 0x80)//****
{
p3_7=1;
}else
......
}
void tpo_ms(unsigned short duree){
tpo_us(duree*1000);
tpo_us(duree*1000);//**** risqu?
}
void lcd_str(unsigned char * str){
int i=0;
while(str[i] != '\0'){
lcdChar(str[i]);//** i++
i++;
}
}
void lcd_init(void)
{
......
lcdcom(0x01);
tpo_ms(5);
}
void clavier (void)
{
init_keyboard();
lcd_init();
while(1){
p10=0x07;
t=p10;
if(t==0x77)
{
lcdcom(0x01);//***
tpo_ms(10);//***
touche='#';
lcd_str("#");//**
}
if(t==0xD7)
{
lcdcom(0x01);//***
tpo_ms(10);//***
touche='0';
lcd_str("Arret Alarme");//***
}
if(t==0xE7)
{
lcdcom(0x01);
tpo_ms(10);
touche='*';
lcd_str("*");
}
p10=0x0B;//**
t=p10;
if(t==0x7B)
{
lcdcom(0x01);
tpo_ms(10);
touche='9';
lcd_str("...");
}
if(t==0xDB)
{
lcdcom(0x01);
tpo_ms(10);
touche='8';
lcd_str("...");
}
if(t==0xEB)
{
lcdcom(0x01);
tpo_ms(10);
touche='7';
lcd_str("Ajout Zone");
}
p10=0x0D;
t=p10;
if(t==0x7D)
{
lcdcom(0x01);
tpo_ms(10);
touche='6';
lcd_str("...");
}
if(t==0xDD)
{
lcdcom(0x01);
tpo_ms(10);
touche='5';
lcd_str("130 km/h");
}
if(t==0xBD)
{
lcdcom(0x01);
tpo_ms(10);
touche='4';
lcd_str("110 km/h");
}
p10=0x0E;
t=p10;
if(t==0x7E)
{
lcdcom(0x01);
tpo_ms(10);
touche='3';
lcd_str("90 km/h");
}
if(t==0xDE)
{
lcdcom(0x01);
tpo_ms(10);
touche='2';
lcd_str("70 km/h");
}
if(t==0xBE)
{
lcdcom(0x01);
tpo_ms(10);
touche='1';
lcd_str("50 km/h");
}
pu31=1;
}
}
void init_keyboard (void)
{
pd10=0x0F;//poids fort en sortie et poids faible en entree
p10=0x00;
pu31=1;//Mise en place de nos pull up
}

Formats disponibles : Unified diff