下个版本打算两字节两个字节的读取,这样就就不怕数据块中 换行太多导致显示不下。 Signed-off-by: 无闻风 <53944749+wuwenfengmi1998@users.noreply.github.com>
96 lines
1.6 KiB
C
96 lines
1.6 KiB
C
/*
|
|
* c.c
|
|
*
|
|
* Created on: Mar 11, 2021
|
|
* Author: 13370
|
|
*/
|
|
#include "c.h"
|
|
#include "lcd.h"
|
|
#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[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);
|
|
|
|
if(font_init())
|
|
{
|
|
LCD_ShowString(0,16,(uint8_t *)"erro",16,RED,BLUE,64);
|
|
}
|
|
|
|
f_mount(&SD,"0:",1);
|
|
res=f_open(&fil,"0:/demo.txt",FA_READ);
|
|
|
|
|
|
/*
|
|
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)
|
|
{
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|