OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3861|回复: 6

请教为啥图片只能保存一次,文字可以多次,但是保存一次图片后,文字也不能保存了

[复制链接]

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
发表于 2015-12-8 20:21:19 | 显示全部楼层 |阅读模式
5金钱
请教为啥图片只能保存一次,文字可以多次,但是保存一次图片后,文字也不能保存了!
下面是程序,请大侠指点。

void savewave(void)
{
     FRESULT res,res1,res2;
     UINT WRBytes;            
     FIL fileW;
     DIR picdir;             //目录
   
     u32 Date,Time;
   static char string10[25]; //根目录={"0:/"}
   static char string11[15];     //日期目录={" "}
   static char string12[3];   //={"/"}
   static char string13[15]; //时间={" "}
   static char string14[5];  //={".bmp"}
     static char dir_path1[25];  //={" "}
   static char file_path1[25];  //={" "}
    
     memset(string10,0,25);
     memset(string11,0,15);
      memset(string12,0,3);
     memset(string13,0,15);
     memset(string14,0,5);
     memset(dir_path1,0,25);
     memset(file_path1,0,25);
    
     strcpy(string10, "0:/");
     strcpy(string11, " ");
     strcpy(string12, "/");
     strcpy(string13, " ");
     strcpy(string14, ".txt");
     strcpy(dir_path1, " ");
     strcpy(file_path1," ");
    
 Date=calendar.w_year*10000+calendar.w_month*100+calendar.w_date;  //获取日期
 convert(string11,Date);          //日期转换为字符串
 Time=calendar.hour*10000+calendar.min*100+calendar.sec;       //获取时间
 convert(string13,Time);          //时间转换为字符串
 
 strcat(string10,string11);         //合成文件夹路径
 strcpy(dir_path1,string10);

 strcat(string10,string12);                //合成文件路径
 strcat(string13,string14);
 strcat(string10,string13);
 strcpy(file_path1,string10);
 
 res=f_mount(fs[0],"0:",1);     //挂载SD卡
    if(res)
        {
          Show_Str(0,450,192,24,"SD mount failed!",24,0);
          delay_ms(1000);
            LCD_Fill(0,450,192,474,BLACK);
      }
        
 res1 = f_opendir(&picdir,(TCHAR *)dir_path1);//打开目录
if(res1!=FR_OK)
{    
 res2 = f_mkdir((TCHAR *)dir_path1);           //创建目录
}

 if((res2==FR_EXIST)||(res1==FR_OK))
     {                  //如果目录存在,根据时间创建文件
  res = f_open(&fileW,(TCHAR *)file_path1,  FA_CREATE_ALWAYS|FA_WRITE);  //文件不存在则创建新文件   //f_open (FIL* fp, const TCHAR* path, BYTE mode);
  Show_Str(40,450,192,24,"saving......",24,0);
    f_write (&fileW, "test", 4, &WRBytes);  //f_write (FIL* fp, const void* buff, UINT btw ,//写入数量字节, UINT* bw//);
  f_close (&fileW);               //关闭文件
 
  Show_Str(40,450,192,24,"Save .txt finished!",24,0);
    delay_ms(2000);
    LCD_Fill(0,450,192,474,BLACK);        
 }

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
 楼主| 发表于 2015-12-8 20:22:12 | 显示全部楼层
void savepicture(void)
{
 FRESULT res,res1,res2;
 UINT WRBytes;            
 FIL fileW;
   DIR picdir;   //目录
 u16 i,j;
 u16 Line_buf[600];
static char char_i[1];

 u32 Date,Time;
   static char string20[25]; //根目录={"0:/"}
   static char string21[15];     //日期目录={" "}
   static char string22[3];   //={"/"}
   static char string23[15]; //时间={" "}
   static char string24[5];  //={".bmp"}
 static char dir_path2[25];  //={" "}
   static char file_path2[25];  //={" "}
 
 memset(string20,0,25);
 memset(string21,0,15);
   memset(string22,0,3);
 memset(string23,0,15);
 memset(string24,0,5);
 memset(dir_path2,0,25);
 memset(file_path2,0,25);
 
 strcpy(string20, "0:/"); 
 strcpy(string21, " ");
 strcpy(string22, "/");
 strcpy(string23, " ");
 strcpy(string24, ".bmp");
 strcpy(dir_path2, " ");
 strcpy(file_path2," ");
 
 Date=calendar.w_year*10000+calendar.w_month*100+calendar.w_date;  //获取日期
 convert(string21,Date);          //日期转换为字符串
 Time=calendar.hour*10000+calendar.min*100+calendar.sec;       //获取时间
 convert(string23,Time);          //时间转换为字符串
 
 strcat(string20,string21);         //合成文件夹路径
 strcpy(dir_path2,string20);

 strcat(string20,string22);                //合成文件路径
 strcat(string23,string24);
 strcat(string20,string23);
 strcpy(file_path2,string20);
 
 res=f_mount(fs[0],"0:",1);  //挂载SD卡 
if(res)
{
  Show_Str(0,450,192,24,"SD mount failed!",24,0);
  delay_ms(1000);
LCD_Fill(0,450,192,474,BLACK);
  }
  
 res1 = f_opendir(&picdir,(TCHAR *)dir_path2);//打开目录
if(res1!=FR_OK)
{
 res2 = f_mkdir((TCHAR *)dir_path2);           //创建目录
}

 if((res2==FR_EXIST)||(res1==FR_OK))
  {                  //如果目录存在,根据时间创建文件
  res = f_open(&fileW,(TCHAR *)file_path2,  FA_CREATE_ALWAYS|FA_WRITE);  //文件不存在则创建新文件   //f_open (FIL* fp, const TCHAR* path, BYTE mode);
  Show_Str(40,450,192,24,"saving......",24,0);
WriteHeader(&fileW);
WriteBMPInfo(&fileW);
for(i=440;i>40;i--)
{
memset(char_i,0,1);
convert(char_i,i);
Show_Str(140,450,192,24,(u8 *)char_i,24,0);
for(j=40;j<640;j++)
{
Line_buf[j-40]=LCD_ReadPoint(j,i);
}
f_write(&fileW,(u8*)Line_buf,1200,&WRBytes);
}
 
    f_close (&fileW);               //关闭文件 
   Show_Str(40,450,192,24,"Save .bmp finished!",24,0);
  delay_ms(2000);
  LCD_Fill(40,450,192,474,BLACK);
 }
回复

使用道具 举报

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
 楼主| 发表于 2015-12-8 20:22:46 | 显示全部楼层
坐等!~~~~~~~
回复

使用道具 举报

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
 楼主| 发表于 2015-12-9 11:08:39 | 显示全部楼层
哪位大神给看看啊
回复

使用道具 举报

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
 楼主| 发表于 2015-12-9 11:10:36 | 显示全部楼层
@正点原子,谢谢啊
回复

使用道具 举报

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
 楼主| 发表于 2015-12-9 11:28:32 | 显示全部楼层
@八度空间 ,请指教
回复

使用道具 举报

3

主题

24

帖子

0

精华

初级会员

Rank: 2

积分
82
金钱
82
注册时间
2015-3-12
在线时间
9 小时
 楼主| 发表于 2015-12-9 22:38:34 | 显示全部楼层
没人回答,自己顶顶
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-15 20:59

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表