|
发表于 2015-8-7 16:35:43
|
显示全部楼层
截屏代码,保存在SD卡中
void SaveToFile()
{
uint8_t NameBuf[32]="";
static uint16_t SaveCnt=0;
FATFS FatFs_Save;
FIL File_Save;
//FILINFO Info;
FRESULT Result;
//uint8_t Res;
//Store_Log_Status(DISABLE);
printf((const char *)"Mounting SD card ...");
if(FR_OK!=f_mount(&FatFs_Save,(const TCHAR *)"0:/",1))
{
printf((const char *)"Failed\\r\\n");
return;
}
printf((const char *)"OK\\r\\n Creating file on SD card...");
sprintf((char *)NameBuf,(const char *)"CAP_%d.bmp",SaveCnt++);
Result=f_open(&File_Save,(const TCHAR *)NameBuf, FA_CREATE_ALWAYS | FA_WRITE);
if(Result !=FR_OK)
{
printf((const char *)"failed\\r\\n");
goto ErrorProcess;
}
printf((const char *)"OK\\r\\n Saving file with name %s...",NameBuf);
GUI_BMP_Serialize(WriteByte2File,&File_Save);
printf((const char *)"OK\\r\\n");
ErrorProcess:
f_close(&File_Save);
f_mount(NULL,(const TCHAR *)"0:/",1);
}
void WriteByte2File(U8 Data, void *p)
{
UINT WriteCnt;
f_write((FIL *)p,&Data,1,&WriteCnt);
} |
|