初级会员
- 积分
- 120
- 金钱
- 120
- 注册时间
- 2020-3-24
- 在线时间
- 54 小时
|
楼主 |
发表于 2023-3-24 17:01:01
|
显示全部楼层
void write_txt(char file_name[],unsigned long int num,FIL fnew,float *volta)
{
//дÈëtxt
u8 i;
uint32_t fil_size; //ÎļþÖ¸Õë
UINT fnum; //Îļþ³É¹¦¶ÁдÊýÁ¿
char name[23]="0:/";//¿ªÍ·
char wrap[] = "\r\n"; //»»ÐÐ
char space[] = " "; //¼ä¸ô
char tab[]="\t";
char WriteBuffer[9]; //Ò»¸öÊý¾ÝÕ¼9λ
char ch_num[8];//×î´ó°ÙÍò¼Æ´Î
strcat(name,file_name);
f_open(&fnew,name, FA_OPEN_ALWAYS|FA_WRITE); //´ò¿ª/´´½¨Îļþ¶ÔÏó
fil_size = f_size(&fnew); //»ñµÃÎļþ´óС
f_lseek(&fnew,fil_size);//Îļþ¶ÔÏóµÄ¶ÁдָÕëÒƶ¯µ½Îļþ½áÊø
sprintf(ch_num,"%ld",num); //ת»¯¸ñʽ
f_write(&fnew, ch_num , strlen(ch_num), &fnum);//¼ÆÊý
f_write(&fnew, tab , sizeof(tab)-1, &fnum); //ÖƱí·û
for(i=0;i<12;i++)
{
sprintf(WriteBuffer,"%f",*(volta+i)); //ת»¯¸ñʽ£¬¸¡µãÊýµ½×Ö·û´®
f_write(&fnew, WriteBuffer , sizeof(WriteBuffer)-1, &fnum);//дÈëÊý¾Ý£¬×Ö·û´®ÒÔ/0½áÊø£¬-1ɾȥ
f_write(&fnew, space , sizeof(space)-1, &fnum); //дÈë¿Õ¸ñ
}
f_write(&fnew, wrap , sizeof(wrap)-1, &fnum);//»»ÐÐ
f_sync(&fnew); //»º´æ²»Êǹرգ¬µôµç±£»¤£¬¼õÉÙ¿ª¹ØÎļþ
} |
|