升级页面的动画制作
- 图片准备
- 图片需要BMP格式,这种格式的显示效果好
-
使用Image2Lcd将图片转换成bin文件:
只需2步就可得到bin文件
- 合并bin文件
- 打开合成Bin文件包,将新增的Bin按顺序序号放到文件夹里
- 修改marge.bat,修改文件最大值
- 双击bat即可
- 将dat文件烧进SPI FLASH里
- 修改驱动程序
-
#include "gd32f450z_lcd.h" //#include "800480.c" //#include "turnoff_long.c" //#include "turnoff.c" #include "wating1.c" #define PIC_SIZE_MAX 4096 #define PIC_NUM 8 #define PIC_TOTAL_SIZE 62244 //一下宏定义要跟GD2工程的一致 #define BIN_SIZE_BOOT_ONE 0x9647 #define MULTIEDIT_KB_SIZE 11590 #define ALGO_PIC_SIZE (3592+4) #define ALGO_NUM (146+4) #define BIN_ADDR_BOOT_MV 0x100000 UINT8 __EXRAM UpdatePicBuf[PIC_TOTAL_SIZE]; uint16_t __EXRAM lcd_framebuf_t[800*480]; typedef enum { UPDATE_PIC_TURNOFF, UPDATE_PIC_REBOOT, UPDATE_PIC_UPDATED, UPDATE_PIC_UPDATING1, UPDATE_PIC_UPDATING2, UPDATE_PIC_UPDATING3, UPDATE_PIC_WAITING1, UPDATE_PIC_WAITING2, UPDATE_PIC_WAITING3, UPDATE_PIC_NUM }ENUM_UPDATE_PIC; typedef struct { UINT16 x; UINT16 y; }UPDATE_PIC_SIZE_TYPE; UPDATE_PIC_SIZE_TYPE UpdatePicSize[UPDATE_PIC_NUM] = { {258,26}, {125,26}, {109,26}, {121,26}, {121,26}, {121,26}, {105,26}, {105,26}, {105,26}, }; UINT32 UpdatePicAddr[UPDATE_PIC_NUM+1] = { 0, 13416, 13416+7904, 13416+7904+5668, 13416+7904+5668+6292, 13416+7904+5668+6292+6292, 13416+7904+5668+6292+6292+6292, 13416+7904+5668+6292+6292+6292+5460, 13416+7904+5668+6292+6292+6292+5460+5460, 13416+7904+5668+6292+6292+6292+5460+5460+5460, }; UINT8 g_UpdageState = 0; /* 0 = wating 进入升级界面,但未进行文件烧写时进入此模式 1 = updating 正在烧写文件 2 = updated 文件烧写完成 3 = turnoff 理论上应该跟1一起显示 4 = reboot 烧写完成后1s */ void UpdateStateSet(UINT8 state) { g_UpdageState = state; } UINT8 UpdateStateGet(void) { return g_UpdageState; } void UpdatePicLoad(void) { UINT32 picsize = BIN_SIZE_BOOT_ONE*74+(MULTIEDIT_KB_SIZE+4)*5 + ALGO_PIC_SIZE*ALGO_NUM; SpiFlashReadData((UINT8*)UpdatePicBuf, BIN_ADDR_BOOT_MV+picsize, PIC_TOTAL_SIZE); } void PictureLoad(UINT8 picId) { memset(lcd_framebuf_t, 0, 800*480*2); UINT32 w = UpdatePicSize[picId].x; UINT32 h = UpdatePicSize[picId].y; UINT32 hs = 240-h/2; UINT32 ws = 400-w/2; UINT32 sourceAddr = UpdatePicAddr[picId]/2; UINT16 * ptr = (UINT16 *)UpdatePicBuf; UINT32 addr =0; for(UINT32 i=hs; i<h+hs; i++) { for(UINT32 j=ws; j<w+ws; j++) { lcd_framebuf_t[i*800+j] = ptr[sourceAddr+addr]; addr++; } } lcd_pic_show1(lcd_framebuf_t); } void WaitDisplay(void) { static UINT32 timer = 0, state = 0; if(get_time_ms()-timer<500) { return; } if(state == 0) { PictureLoad(UPDATE_PIC_WAITING1); state = 1; } else if(state ==1) { PictureLoad(UPDATE_PIC_WAITING2); state = 2; } else if(state ==2) { PictureLoad(UPDATE_PIC_WAITING3); state = 0; } timer = get_time_ms(); } void UpdatingDisplay(void) { static UINT32 timer = 0, state = 0; if(get_time_ms()-timer<500) { return; } if(state == 0) { PictureLoad(UPDATE_PIC_UPDATING1); state = 1; } else if(state ==1) { PictureLoad(UPDATE_PIC_UPDATING2); state = 2; } else if(state ==2) { PictureLoad(UPDATE_PIC_UPDATING3); state = 0; } timer = get_time_ms(); } void UpdatedDisplay(void) { PictureLoad(UPDATE_PIC_UPDATED); } void RebootDisplay(void) { PictureLoad(UPDATE_PIC_REBOOT); } void UpdatePicDisplay(void) { UINT8 state = UpdateStateGet(); if(state == 0)//wating { WaitDisplay(); } else if(state == 1)//updating { UpdatingDisplay(); } else if(state == 2)//updated { UpdatedDisplay(); } else if(state == 3)//turnoff { } else if(state == 4)//reboot { RebootDisplay(); } }
-
- 完成
本文来自博客园,作者:xjxcxjx,转载请注明原文链接:https://www.cnblogs.com/xjxcxjx/p/17822427.html,谢绝CSDN转载!