解决了因为汉字在两个数据块直接导致的数据流乱码,
下个版本打算两字节两个字节的读取,这样就就不怕数据块中 换行太多导致显示不下。 Signed-off-by: 无闻风 <53944749+wuwenfengmi1998@users.noreply.github.com>
This commit is contained in:
+51
-5
@@ -9,15 +9,24 @@
|
||||
#include "text.h"
|
||||
#include "fatfs.h"
|
||||
#include "fatfs_sd.h"
|
||||
|
||||
#define KEY_UP HAL_GPIO_ReadPin(KEY_UP_GPIO_Port,KEY_UP_Pin)
|
||||
#define KEY_B HAL_GPIO_ReadPin(KEY_B_GPIO_Port,KEY_B_Pin)
|
||||
#define KEY_DOWN HAL_GPIO_ReadPin(KEY_DOWN_GPIO_Port,KEY_DOWN_Pin)
|
||||
|
||||
FATFS SD;
|
||||
|
||||
#define fuck 256
|
||||
|
||||
int my_main()
|
||||
{
|
||||
uint8_t res;
|
||||
FIL fil;
|
||||
char fil_buff[128];
|
||||
uint16_t br=128;
|
||||
char str[16];
|
||||
char fil_buff[fuck+1]={0};
|
||||
char fuck_flag=0;
|
||||
char fuck_buff;
|
||||
uint16_t br=0;
|
||||
char str[fuck+1]={0};
|
||||
LCD_BL(0);
|
||||
LCDx_Init();
|
||||
LCD_Clear(GRAY);
|
||||
@@ -29,8 +38,7 @@ int my_main()
|
||||
|
||||
f_mount(&SD,"0:",1);
|
||||
res=f_open(&fil,"0:/demo.txt",FA_READ);
|
||||
res=f_read(&fil,fil_buff,64,(UINT*)&br);
|
||||
LCD_ShowString(0,0,fil_buff,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);
|
||||
@@ -40,6 +48,44 @@ int my_main()
|
||||
*/
|
||||
while(1)
|
||||
{
|
||||
if(KEY_UP==0)
|
||||
{
|
||||
HAL_Delay(10);
|
||||
while(KEY_UP==0);
|
||||
LCD_Clear(WHITE);
|
||||
for(int a=0;a<fuck+1;a++)
|
||||
{
|
||||
fil_buff[a]=0;
|
||||
str[a]=0;
|
||||
}
|
||||
|
||||
if(fuck_flag==1)
|
||||
{
|
||||
fuck_flag=0;
|
||||
res=f_read(&fil,fil_buff,fuck-1,(UINT*)&br);
|
||||
for(int a=fuck-2;a>0;a--)
|
||||
{
|
||||
fil_buff[a+1]=fil_buff[a];
|
||||
}
|
||||
fil_buff[0]=fuck_buff;
|
||||
|
||||
}else
|
||||
{
|
||||
res=f_read(&fil,fil_buff,fuck,(UINT*)&br);
|
||||
}
|
||||
|
||||
if((fil_buff[fuck-1]>127)&&(fil_buff[fuck-2]<128))
|
||||
{
|
||||
fuck_buff=fil_buff[fuck-1];
|
||||
fil_buff[fuck-1]='\0';
|
||||
fuck_flag=1;
|
||||
|
||||
}
|
||||
|
||||
sprintf(str,"%s\0",fil_buff);
|
||||
LCD_ShowString(0,0,str,16,WHITE,BLACK,fuck);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user