101 lines
1.8 KiB
C
101 lines
1.8 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
|
|
|
|
#define text_size 16
|
|
#define max_page_y 14
|
|
#define max_page_x 20
|
|
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};
|
|
|
|
char dis_text_buff[600];
|
|
uint16_t page_num=0;
|
|
char text_buff[2];
|
|
uint16_t data_num=0;
|
|
uint16_t page_y=0;
|
|
uint16_t page_x=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);
|
|
page_num++;
|
|
data_num=0;;
|
|
for(page_y=0;page_y<max_page_y;page_y++)
|
|
{
|
|
for(page_x=0;page_x<max_page_x;page_x++)
|
|
{
|
|
f_read(&fil,text_buff,2,(UINT*)&br);
|
|
dis_text_buff[data_num]=text_buff[0];
|
|
dis_text_buff[data_num+1]=text_buff[1];
|
|
data_num+=2;
|
|
|
|
if((text_buff[0]=='\n')||(text_buff[1]=='\n'))
|
|
{
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|
|
dis_text_buff[data_num]='\0';
|
|
dis_text_buff[data_num+1]='\0';
|
|
dis_text_buff[data_num+2]='\0';
|
|
LCD_ShowString(0,0,dis_text_buff,16,WHITE,BLACK,data_num);
|
|
|
|
sprintf(str,"µÚ%dÒ³",page_num);
|
|
LCD_ShowString(0,14*16,str,16,RED,BLACK,fuck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|