找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3298|回复: 1
收起左侧

基于stm32+znFAT的电子相册源码

[复制链接]
ID:417182 发表于 2018-10-29 20:21 | 显示全部楼层 |阅读模式
包含所有源代码,测试可用
本例程使用的库是:STM32F10x_StdPeriph_Lib_V3.3.0
例程默认调试工具为Jlink V8
0.png
单片机源程序如下:
  1. #include "stm32f10x_rcc.h"
  2. #include "stm32f10x_gpio.h"
  3. #include "stm32f10x_flash.h"

  4. #include "stm32f10x.h"
  5. #include "ili9320.h"
  6. #include "sdx.h"
  7. #include "znfat.h"
  8. #include "pic.h"
  9. #include <key.h>
  10. #include <control.h>
  11.                   
  12. struct znFAT_Init_Args Init_Args; //初始化参数集合
  13. struct FileInfo fileinfo; //文件信息集合

  14. unsigned char buf[21];



  15. int main()
  16. {
  17.         unsigned int res=0,len=0;
  18.         u16 c2len;
  19.         u8 c2[] = "TFT LCD 320X240";
  20.         u8 fixed=0;
  21.         u16 charColor;
  22.         u16 bkColor;
  23.         
  24.         c2len = sizeof(c2)-1;
  25.         
  26.         
  27.         GPIO_KEY_Config();
  28.         SD_IO_Init();
  29.         
  30.         ili9320_Initializtion();
  31.         charColor = Yellow;
  32.         bkColor = Red;
  33.         
  34.         znFAT_Device_Init(); //存储设备初始化
  35.         
  36.         znFAT_Select_Device(0,&Init_Args); //选择设备
  37.         
  38.         res=znFAT_Init(); //文件系统初始化         
  39.         
  40.         if(!res) //文件系统初始化成功
  41.         {
  42.           ili9320_Clear(Grey);
  43.           ili9320_PutStr_16x24_Center(200, c2, c2len,charColor, bkColor);
  44.           Delay_ARMJISHU(4000000);
  45.         }
  46.         else //文件系统初始化失败
  47.         {
  48.           ili9320_Clear(Green);
  49.           ili9320_PutStr_16x24_Center(200, c2, c2len,charColor, bkColor);
  50.           Delay_ARMJISHU(4000000);
  51.         }
  52. //==================================================================

  53.         res=znFAT_Open_File(&fileinfo,"/mcu.txt",0,1); //打开文件
  54.         if(!res) //打开文件成功
  55.         {
  56.          
  57.                 len=znFAT_ReadData(&fileinfo,9,20,buf); //从文件偏移量9位置开始读取20个字节
  58.         
  59.                 buf[20]=0;
  60.     ili9320_PutStr_16x24_Center(44, buf, len,charColor, bkColor);
  61.         
  62.           znFAT_Close_File(&fileinfo); //关闭文件
  63.         }
  64.         else
  65.         {
  66.     ili9320_Clear(Yellow);
  67.     Delay_ARMJISHU(4000000);
  68.         }

  69.         znFAT_Flush_FS(); //刷新文件系统

  70.         ili9320_DrawPicture(0,0,319,239,(u16 *)(pic + BmpHeadSize));

  71.         Fixed_GUI_Rectangle(1,Black); //画文件夹边框
  72.         Fixed_GUI_Rectangle(2,Black);
  73.         Fixed_GUI_Rectangle(3,Black);
  74.         Fixed_GUI_Rectangle(fixed,White);         //画选中文件夹边框
  75.         while(1)
  76.         {
  77.                 switch(ReadKeyDown())
  78.                 {
  79.                         case 1 :        
  80.                                                                 break;

  81.                         case 2 :        
  82.                                                                 Open_X_File(fixed);                        
  83.                                                                 break;

  84.                         case 3 :        
  85.                                                                 Fixed_GUI_Rectangle(fixed,Black);
  86.                                                                 if(fixed==0)
  87.                                                                         fixed=3;
  88.                                                                 else
  89.                                                                         fixed--;
  90.                                                                 Fixed_GUI_Rectangle(fixed,White);
  91.                                                                 break;

  92.                         case 4 :        
  93.                                                                 Fixed_GUI_Rectangle(fixed,Black);
  94.                                                                 if(fixed>=3)
  95.                                                                         fixed=0;
  96.                                                                 else
  97.                                                                         fixed++;
  98.                                                                 Fixed_GUI_Rectangle(fixed,White);
  99.                                                                 break;
  100.                 }        
  101.         }

  102. }
复制代码

所有资料51hei提供下载:
电子相册完成版.rar (1.6 MB, 下载次数: 57)
回复

使用道具 举报

ID:273624 发表于 2020-1-6 14:17 | 显示全部楼层
感谢分享,正好在找
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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