📄 main.c
字号:
void Delay(int Delai)
{
int i;
for ( i = -Delai; i < Delai; i++ );
}
/*---------------------------------------------------------------
Nom : LcdLittleChr
Description : Dessin d'un caract鑢e de la police 8x11
Arguments : x, y : coordonn閑s
ch : code ascii du caract鑢e
Valeur renvoy閑 : abscisse x du prochain caract鑢e
-----------------------------------------------------------------*/
char LcdLittleChr(char x, char y, char ch)
{
int index, i, j, k, t;
int index_byte, index_pixel;
char Cmd_H, Cmd_V;
char Hor, Ver;
index=ch-0x20;
if (index < 0) return 0;
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
if (Sens_texte & 1) //Sens du texte ?
{ Cmd_H=PASET; Cmd_V=CASET;// Sens Y
Hor=y; Ver=x; }
else
{ Cmd_H=CASET; Cmd_V=PASET;// Sens X
Hor=x; Ver=y; }
LcdSend_Cmd(Cmd_V);
LcdSend_Data(Ver);
LcdSend_Data(Ver+Font8x11.Heigth-1);
LcdSend_Cmd(Cmd_H);
LcdSend_Data(Hor);
LcdSend_Data(Hor+Font8x11.Char_Widths[index]);
LcdSend_Cmd(RAMWR);
}
else //Controleur Philips
{
if (Sens_texte & 1) //Sens du texte ?
{ Cmd_H=SET_Y_ADDR; Cmd_V=SET_X_ADDR;// Sens Y
Hor=y; Ver=x; }
else
{ Cmd_H=SET_X_ADDR; Cmd_V=SET_Y_ADDR;// Sens X
Hor=x; Ver=y; }
LcdSend_Cmd(Cmd_V);
LcdSend_Data(Ver);
LcdSend_Data(Ver+Font8x11.Heigth-1);
LcdSend_Cmd(Cmd_H);
LcdSend_Data(Hor);
LcdSend_Data(Hor+Font8x11.Char_Widths[index]);
LcdSend_Cmd(MEM_WRITE);
}
i=0;
k=0;
//k = nb de pixels pour atteindre le caract鑢e
for (j=0; j<index; j++) k=k+Font8x11.Char_Widths[j]*Font8x11.Heigth;
index_byte=(k >> 3);// = k div 8
index_pixel=k-(index_byte << 3);// = k mod 8
for (i=0; i<Font8x11.Char_Widths[index]*Font8x11.Heigth; i++)
{
t=Font8x11.Font_data[index_byte];
if ((t & (1 << index_pixel))==0) LcdSend_Data(Fond_texte);
else LcdSend_Data(Couleur_texte);
index_pixel++;
if (index_pixel==8) {index_pixel=0; index_byte++;}
}
for (i=0; i<Font8x11.Heigth; i++) LcdSend_Data(Fond_texte);
return Font8x11.Char_Widths[index];
}
/*---------------------------------------------------------------
Nom : LcdBigChr
Description : Dessin d'un caract鑢e de la police 13x16
Arguments : x, y : coordonn閑s
ch : code ascii du caract鑢e
Valeur renvoy閑 : abscisse x du prochain caract鑢e
-----------------------------------------------------------------*/
/*char LcdBigChr(char x, char y, char ch)
{
int index, i, j, k, t;
int index_byte, index_pixel;
char Cmd_H, Cmd_V;
char Hor, Ver;
index=ch-0x20;
if (index < 0) return 0;
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
if (Sens_texte & 1) //Sens du texte ?
{ Cmd_H=PASET; Cmd_V=CASET;// Sens Y
Hor=y; Ver=x; }
else
{ Cmd_H=CASET; Cmd_V=PASET;// Sens X
Hor=x; Ver=y; }
LcdSend_Cmd(Cmd_V);
LcdSend_Data(Ver);
LcdSend_Data(Ver+Font13x16.Heigth-1);
LcdSend_Cmd(Cmd_H);
LcdSend_Data(Hor);
LcdSend_Data(Hor+Font13x16.Char_Widths[index]);
LcdSend_Cmd(RAMWR);
}
else //Controleur Philips
{
if (Sens_texte & 1) //Sens du texte ?
{ Cmd_H=SET_Y_ADDR; Cmd_V=SET_X_ADDR;// Sens Y
Hor=y; Ver=x; }
else
{ Cmd_H=SET_X_ADDR; Cmd_V=SET_Y_ADDR;// Sens X
Hor=x; Ver=y; }
LcdSend_Cmd(Cmd_V);
LcdSend_Data(Ver);
LcdSend_Data(Ver+Font13x16.Heigth-1);
LcdSend_Cmd(Cmd_H);
LcdSend_Data(Hor);
LcdSend_Data(Hor+Font13x16.Char_Widths[index]);
LcdSend_Cmd(MEM_WRITE);
}
i=0;
k=0;
//k = nb de pixels pour atteindre le caract鑢e
for (j=0; j<index; j++) k=k+Font13x16.Char_Widths[j]*Font13x16.Heigth;
index_byte=(k >> 3);// = k div 8
index_pixel=k-(index_byte << 3);// = k mod 8
for (i=0; i<Font8x11.Char_Widths[index]*Font13x16.Heigth; i++)
{
t=Font13x16.Font_data[index_byte];
if ((t & (1 << index_pixel))==0) LcdSend_Data(Fond_texte);
else LcdSend_Data(Couleur_texte);
index_pixel++;
if (index_pixel==8) {index_pixel=0; index_byte++;}
}
for (i=0; i<Font13x16.Heigth; i++) LcdSend_Data(Fond_texte);
return Font13x16.Char_Widths[index];
}*/
/*---------------------------------------------------------------
Nom : LcdLittleStr
Description : Dessin d'une cha頽e de caract鑢e ds la police 8x11
Arguments : x, y : coordonn閑s
s : cha頽e du caract鑢e
Valeur renvoy閑 : aucune
-----------------------------------------------------------------*/
void LcdLittleStr(char x, char y, char *s)
{
if (*s==0) return;
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
LcdSend_Cmd(DATCTL);
LcdSend_Data(Texte_DATCTL);//Attributs pour texte
LcdSend_Data(0); //Arrangements segments = RGB
LcdSend_Data(1); //Echelle de 8 niveaux par couleur
}
else
{ //Controleur Philips
LcdSend_Cmd(MEM_CONTROL); LcdSend_Data(Texte_MEM_CONTROL);
}
while (*s)
{
if (Sens_texte & 1) //Sens du texte ?
y=y+LcdLittleChr(x,y,*s++)+1; // Sens Y
else x=x+LcdLittleChr(x,y,*s++)+1; // Sens X
}
}
/*---------------------------------------------------------------
Nom : LcdBigStr
Description : Dessin d'une cha頽e de caract鑢e ds la police 8x11
Arguments : x, y : coordonn閑s
s : cha頽e du caract鑢e
Valeur renvoy閑 : aucune
-----------------------------------------------------------------*/
/*void LcdBigStr(char x, char y, char *s)
{
if (*s==0) return;
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
LcdSend_Cmd(DATCTL);
LcdSend_Data(Texte_DATCTL);//Attributs pour texte
LcdSend_Data(0); //Arrangements segments = RGB
LcdSend_Data(1); //Echelle de 8 niveaux par couleur
}
else
{ //Controleur Philips
LcdSend_Cmd(MEM_CONTROL); LcdSend_Data(Texte_MEM_CONTROL);
}
while (*s)
{
if (Sens_texte & 1) //Sens du texte ?
y=y+LcdBigChr(x,y,*s++)+1; // Sens Y
else x=x+LcdBigChr(x,y,*s++)+1; // Sens X
}
}*/
/*---------------------------------------------------------------
Nom : Texte_0_degre
Description : Parametrage du LCD pour un dessin de texte horizontal
Arguments : aucun
Valeur renvoy閑 : aucune.
-----------------------------------------------------------------*/
void Texte_0_degre(void)
{
Sens_texte=0;
Texte_MEM_CONTROL=MEM_MX|MEM_VW|MEM_RGB; //Sens X normal (Philips)
Texte_DATCTL=WR_DIR ;//Sens X normal (Epson)
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
LcdSend_Cmd(DATCTL);
LcdSend_Data(Texte_DATCTL);//Attributs pour texte
LcdSend_Data(0); //Arrangements segments = RGB
LcdSend_Data(1); //Echelle de 8 niveaux par couleur
}
else //Controleur Philips
{
LcdSend_Cmd(MEM_CONTROL); LcdSend_Data(Texte_MEM_CONTROL);
}
}
/*---------------------------------------------------------------
Nom : Texte_90_degre
Description : Parametrage du LCD pour un dessin de texte ?90? Arguments : aucun
Valeur renvoy閑 : aucune.
-----------------------------------------------------------------*/
void Texte_90_degre(void)
{
Sens_texte=1;
Texte_MEM_CONTROL=MEM_RGB;//Sens Y normal
Texte_DATCTL=INV_X ;//Sens Y normal
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
LcdSend_Cmd(DATCTL);
LcdSend_Data(Texte_DATCTL);//Attributs pour texte
LcdSend_Data(0); //Arrangements segments = RGB
LcdSend_Data(1); //Echelle de 8 niveaux par couleur
}
else //Controleur Philips
{
LcdSend_Cmd(MEM_CONTROL); LcdSend_Data(Texte_MEM_CONTROL);
}
}
/*---------------------------------------------------------------
Nom : Texte_180_degre
Description : Parametrage du LCD pour un dessin de texte ?180? Arguments : aucun
Valeur renvoy閑 : aucune.
-----------------------------------------------------------------*/
void Texte_180_degre(void)
{
Sens_texte=2;
Texte_MEM_CONTROL=MEM_MY|MEM_VW|MEM_RGB;//Sens X invers? Texte_DATCTL=INV_Y|INV_X|WR_DIR;//Sens X invers?
if ((P3IN & Type_Controler_Pin)==Epson)
{ //Controleur Epson
LcdSend_Cmd(DATCTL);
LcdSend_Data(Texte_DATCTL);//Attributs pour texte
LcdSend_Data(0); //Arrangements segments = RGB
LcdSend_Data(1); //Echelle de 8 niveaux par couleur
}
else //Controleur Philips
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -