由于不明原因Flash字库的头索引乱了,导致一直无法定位,重新计算了位置。
给show str函数加入长度限制。 Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
+13
-7
@@ -20,19 +20,25 @@ int my_main()
|
||||
char str[16];
|
||||
LCD_BL(0);
|
||||
LCDx_Init();
|
||||
LCD_Clear(GRAY);
|
||||
|
||||
if(font_init())
|
||||
{
|
||||
LCD_ShowString(0,16,(uint8_t *)"erro",16,RED,BLUE);
|
||||
LCD_ShowString(0,16,(uint8_t *)"erro",16,RED,BLUE,64);
|
||||
}
|
||||
LCD_Clear(GRAY);
|
||||
/*
|
||||
|
||||
f_mount(&SD,"0:",1);
|
||||
res=f_open(&fil,"0:/demo.txt",FA_READ);
|
||||
res=f_read(&fil,fil_buff,16,(UINT*)&br);
|
||||
res=f_read(&fil,fil_buff,32,(UINT*)&br);
|
||||
sprintf(str,"%s\0\0",fil_buff);
|
||||
LCD_ShowString(0,0,str,16,RED,BLUE);
|
||||
*/
|
||||
LCD_ShowString(0,0,"123dsjvn°¡",12,RED,BLUE);
|
||||
LCD_ShowString(0,0,str,16,RED,BLUE,64);
|
||||
|
||||
/*
|
||||
sprintf(str,"%02x\n%02x\n%02x\n%02x\n%02x",ftinfo.fontok,ftinfo.ugbkaddr,ftinfo.ugbksize,ftinfo.f12addr,ftinfo.gbk12size);
|
||||
LCD_ShowString(0,0,str,12,RED,BLUE);
|
||||
|
||||
LCD_ShowString(0,100,"163165sdf°¢¶û·¨",12,RED,BLUE);
|
||||
*/
|
||||
while(1)
|
||||
{
|
||||
|
||||
|
||||
+9
-4
@@ -223,7 +223,8 @@ uint8_t font_init(void)
|
||||
W25QXX_Read((uint8_t*)&ftinfo,FONTINFOADDR,sizeof(ftinfo));//读出ftinfo结构体数据
|
||||
if(ftinfo.fontok==0XAA)
|
||||
{
|
||||
ftinfo.f12addr+=1;
|
||||
ftinfo.f12addr=0x0042a929;
|
||||
ftinfo.f16addr=0x004b6d89;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -343,9 +344,9 @@ void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t num,uint8_t size,uint16_t bg,uin
|
||||
//size:字体大小
|
||||
//*p:字符串起始地址
|
||||
|
||||
void LCD_ShowString(uint16_t x,uint16_t y,uint8_t *p,uint8_t size,uint16_t bg,uint16_t color)
|
||||
void LCD_ShowString(uint16_t x,uint16_t y,uint8_t *p,uint8_t size,uint16_t bg,uint16_t color,uint16_t len)
|
||||
{
|
||||
while(*p!='\0')
|
||||
while(len--)
|
||||
{
|
||||
|
||||
if(x>=lcddev.width)
|
||||
@@ -353,6 +354,10 @@ void LCD_ShowString(uint16_t x,uint16_t y,uint8_t *p,uint8_t size,uint16_t bg,ui
|
||||
x=0;
|
||||
y+=size;
|
||||
}
|
||||
if(*p=='\0')
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(*p=='\r')
|
||||
{
|
||||
p++;
|
||||
@@ -371,7 +376,7 @@ void LCD_ShowString(uint16_t x,uint16_t y,uint8_t *p,uint8_t size,uint16_t bg,ui
|
||||
{
|
||||
Show_Font(x,y,p,size,bg,color);
|
||||
p++;
|
||||
x+=size;
|
||||
x+=size;
|
||||
}
|
||||
p++;
|
||||
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
//前面4M被fatfs占用了.
|
||||
//4M以后紧跟3个字库+UNIGBK.BIN,总大小3.09M,被字库占用了,不能动!
|
||||
//5.10M以后,用户可以自由使用.建议用最后的100K字节比较好.
|
||||
__packed typedef struct
|
||||
typedef struct
|
||||
{
|
||||
uint8_t fontok; //字库存在标志,0XAA,字库正常;其他,字库不存在
|
||||
uint32_t ugbkaddr; //unigbk的地址
|
||||
@@ -32,6 +32,6 @@ extern _font_info ftinfo;
|
||||
uint8_t font_init(void);
|
||||
void Show_Font(uint16_t x,uint16_t y,uint8_t *font,uint8_t size,uint16_t bg,uint16_t color);
|
||||
void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t num,uint8_t size,uint16_t bg,uint16_t color);
|
||||
void LCD_ShowString(uint16_t x,uint16_t y,uint8_t *p,uint8_t size,uint16_t bg,uint16_t color);
|
||||
void LCD_ShowString(uint16_t x,uint16_t y,uint8_t *p,uint8_t size,uint16_t bg,uint16_t color,uint16_t len);
|
||||
|
||||
#endif /* TEXT_H_ */
|
||||
|
||||
Reference in New Issue
Block a user