包含所有源代码,测试可用
本例程使用的库是:STM32F10x_StdPeriph_Lib_V3.3.0
例程默认调试工具为Jlink V8
单片机源程序如下:
- #include "stm32f10x_rcc.h"
- #include "stm32f10x_gpio.h"
- #include "stm32f10x_flash.h"
- #include "stm32f10x.h"
- #include "ili9320.h"
- #include "sdx.h"
- #include "znfat.h"
- #include "pic.h"
- #include <key.h>
- #include <control.h>
-
- struct znFAT_Init_Args Init_Args; //初始化参数集合
- struct FileInfo fileinfo; //文件信息集合
- unsigned char buf[21];
- int main()
- {
- unsigned int res=0,len=0;
- u16 c2len;
- u8 c2[] = "TFT LCD 320X240";
- u8 fixed=0;
- u16 charColor;
- u16 bkColor;
-
- c2len = sizeof(c2)-1;
-
-
- GPIO_KEY_Config();
- SD_IO_Init();
-
- ili9320_Initializtion();
- charColor = Yellow;
- bkColor = Red;
-
- znFAT_Device_Init(); //存储设备初始化
-
- znFAT_Select_Device(0,&Init_Args); //选择设备
-
- res=znFAT_Init(); //文件系统初始化
-
- if(!res) //文件系统初始化成功
- {
- ili9320_Clear(Grey);
- ili9320_PutStr_16x24_Center(200, c2, c2len,charColor, bkColor);
- Delay_ARMJISHU(4000000);
- }
- else //文件系统初始化失败
- {
- ili9320_Clear(Green);
- ili9320_PutStr_16x24_Center(200, c2, c2len,charColor, bkColor);
- Delay_ARMJISHU(4000000);
- }
- //==================================================================
-
- res=znFAT_Open_File(&fileinfo,"/mcu.txt",0,1); //打开文件
- if(!res) //打开文件成功
- {
-
- len=znFAT_ReadData(&fileinfo,9,20,buf); //从文件偏移量9位置开始读取20个字节
-
- buf[20]=0;
- ili9320_PutStr_16x24_Center(44, buf, len,charColor, bkColor);
-
- znFAT_Close_File(&fileinfo); //关闭文件
- }
- else
- {
- ili9320_Clear(Yellow);
- Delay_ARMJISHU(4000000);
- }
- znFAT_Flush_FS(); //刷新文件系统
- ili9320_DrawPicture(0,0,319,239,(u16 *)(pic + BmpHeadSize));
- Fixed_GUI_Rectangle(1,Black); //画文件夹边框
- Fixed_GUI_Rectangle(2,Black);
- Fixed_GUI_Rectangle(3,Black);
- Fixed_GUI_Rectangle(fixed,White); //画选中文件夹边框
- while(1)
- {
- switch(ReadKeyDown())
- {
- case 1 :
- break;
- case 2 :
- Open_X_File(fixed);
- break;
- case 3 :
- Fixed_GUI_Rectangle(fixed,Black);
- if(fixed==0)
- fixed=3;
- else
- fixed--;
- Fixed_GUI_Rectangle(fixed,White);
- break;
- case 4 :
- Fixed_GUI_Rectangle(fixed,Black);
- if(fixed>=3)
- fixed=0;
- else
- fixed++;
- Fixed_GUI_Rectangle(fixed,White);
- break;
- }
- }
- }
复制代码
所有资料51hei提供下载:
电子相册完成版.rar
(1.6 MB, 下载次数: 57)
|