st7735s 显示ASCII字符

#include "show_menu.h"
#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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值