#include "ascii.h"
st_lab lab;
void Lab_Init()
{
lab.x = 50;
lab.y = 10;
lab.w = 8;
lab.h = 16;
}
unsigned char *get_ascii_8_16_dot(unsigned char ascii)
{
unsigned char dat = 0;
if((ascii<'0')||(ascii>'9'))
{
if(ascii=='-')
{
return (unsigned char *)gImage_8_16_0_9[11];
}
else if(ascii=='.')
{
return (unsigned char *)gImage_8_16_0_9[10];
}
else if(ascii=='_')
{
return (unsigned char *)gImage_8_16_0_9[12];
}
else
{
return (unsigned char *)gImage_8_16_0_9[13];//返回空格
}
}
dat = ascii-'0';
return (unsigned char *)gImage_8_16_0_9[dat];
}
/*
在显示屏上显示字符串
pos:字符模型
str:字符串
*/
void show_ascii_str(st_lab pos,unsigned char *str)
{
unsigned short i=0;
unsigned short j=0;
unsigned short tl=0;
unsigned short y=pos.y;
unsigned short x=pos.x;
unsigned short w=pos.w;
unsigned short h=pos.h;
unsigned char *dat;
unsigned char temp;
for(j=0;str[j]!='\0';j++)
{
dat = (unsigned char *)get_ascii_8_16_dot(str[j]);
#if DOT_SHOW_HALF
if(ascii[j]=='-'||ascii[j]=='.')
{
w=pos.w;
}
else
{
w=pos.w/2;
}
#endif
for(i = 0;i < h;i++)
{
temp = dat[i];
for(tl=0;tl<w;tl++)
{
LCD_WriteCommand(0x2A); //设置列地址
LCD_WriteData(0x00);
LCD_WriteData(x+1+tl+j*8);
LCD_WriteData(0x00);
LCD_WriteData(x+1+tl+j*8);
LCD_WriteCommand(0x2B); //设置行地址
LCD_WriteData(0x00);
LCD_WriteData(y+1+i);
LCD_WriteData(0x00);