Update main.c

清理无用代码
添加无存储卡情况
This commit is contained in:
greedyhao 2019-08-29 12:02:54 +08:00
parent e5186aad1a
commit ff58662ca2

View File

@ -34,14 +34,12 @@ void init_uart0(void)
int main(void) int main(void)
{ {
u8 i,m; uint8_t mount_is_ok = 1; /* 0: mount successful ; 1: mount failed */
float t=0;
int offset = 0; int offset = 0;
uint64_t start_mtime, delta_mtime;
FIL fil; FIL fil;
FRESULT fr; /* FatFs return code */ FRESULT fr; /* FatFs return code */
UINT br, bw; UINT br;
rcu_periph_clock_enable(RCU_GPIOA); rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_GPIOC); rcu_periph_clock_enable(RCU_GPIOC);
@ -58,44 +56,56 @@ int main(void)
LEDG(1); LEDG(1);
LEDB(1); LEDB(1);
fr = f_mount(&fs, "", 1); fr = f_mount(&fs, "", 1);
if (fr == 0)
mount_is_ok = 0;
else
mount_is_ok = 1;
while(1) while(1)
{ {
offset = 0; if (mount_is_ok == 0)
fr = f_open(&fil, "logo.bin", FA_READ);
if (fr) printf("open error: %d!\n\r", (int)fr);
f_lseek(&fil, offset);
fr = f_read(&fil, image, sizeof(image), &br);
LCD_ShowPicture(0,0,159,39);
offset += 12800;
LEDB_TOG;
f_lseek(&fil, offset);
fr = f_read(&fil, image, sizeof(image), &br);
LCD_ShowPicture(0,40,159,79);
LEDB_TOG;
delay_1ms(1500);
f_close(&fil);
fr = f_open(&fil, "bmp.bin", FA_READ);
if (fr) printf("open error: %d!\n\r", (int)fr);
offset = 0;
for (int i=0; i<2189;i++)
{ {
offset = 0;
fr = f_open(&fil, "logo.bin", FA_READ);
if (fr) printf("open error: %d!\n\r", (int)fr);
f_lseek(&fil, offset);
fr = f_read(&fil, image, sizeof(image), &br); fr = f_read(&fil, image, sizeof(image), &br);
LCD_ShowPicture(0,0,159,39); LCD_ShowPicture(0,0,159,39);
offset += 12800; offset += 12800;
f_lseek(&fil, offset);
LEDB_TOG; LEDB_TOG;
f_lseek(&fil, offset);
fr = f_read(&fil, image, sizeof(image), &br); fr = f_read(&fil, image, sizeof(image), &br);
LCD_ShowPicture(0,40,159,79); LCD_ShowPicture(0,40,159,79);
offset += 12800;
f_lseek(&fil, offset);
LEDB_TOG; LEDB_TOG;
} delay_1ms(1500);
f_close(&fil);
/* Close the file */ fr = f_open(&fil, "bmp.bin", FA_READ);
f_close(&fil); if (fr) printf("open error: %d!\n\r", (int)fr);
offset = 0;
for (int i=0; i<2189;i++)
{
fr = f_read(&fil, image, sizeof(image), &br);
LCD_ShowPicture(0,0,159,39);
offset += 12800;
f_lseek(&fil, offset);
LEDB_TOG;
fr = f_read(&fil, image, sizeof(image), &br);
LCD_ShowPicture(0,40,159,79);
offset += 12800;
f_lseek(&fil, offset);
LEDB_TOG;
}
/* Close the file */
f_close(&fil);
}
else
{
LEDR_TOG;
delay_1ms(500);
}
} }
} }