需要完成的主要工作有:
1)劃分顯示位置
2)繪制狀態(tài)欄背景
3)繪制電池圖標(biāo):一共7種圖標(biāo)baticos[7]
4)繪制時間:只顯示時和分
5)循環(huán)檢測時間變化,并更改顯示時間數(shù)值,同步判斷電池電量,繪制相應(yīng)圖標(biāo)
源文件:satusbar.c
#include《 includes.h 》
#include
const u8* baticos[7] =
{
“0:/STATUSBAR/BAT/battery0.bmp”,
“0:/STATUSBAR/BAT/battery1.bmp”,
“0:/STATUSBAR/BAT/battery2.bmp”,
“0:/STATUSBAR/BAT/battery3.bmp”,
“0:/STATUSBAR/BAT/battery4.bmp”,
“0:/STATUSBAR/BAT/battery5.bmp”,
“0:/STATUSBAR/BAT/battery6.bmp”
};
u8 bat_status = 0;
u8 tmer_min = 0;
void statusbar_fun(void)
{
//繪制狀態(tài)欄
//1)繪制狀態(tài)欄背景320x12 x=0,y=0,w=320,h=22
LCD_Fill(0,0,320,22,BLACK);
//2)繪制電池電量 24X14右邊顯示,x=320-5-24,y=2,w=24,h=14
bat_status = 6;
minibmp_decode((u8*)baticos[bat_status],320-5-24,4,24,14,0,0);
//3)繪制時間30x16 x=320-5-24-10-40 y=3,w=40,h=16
{
POINT_COLOR = WHITE;
tmer_min = calendar.min;
LCD_ShowChar(320-5-24-10-40+16,3,‘:’,16,1);
LCD_ShowNum(320-5-24-10-40,3,calendar.hour,2,16);
LCD_ShowNum(320-5-24-10-40+24,3,calendar.min,2,16); }
}
//由其他界面函數(shù)中的while(1)里面調(diào)用,例如主函數(shù)中
void statusbar_change(void)
{
if(tmer_min!=calendar.min)
{
tmer_min = calendar.min;
//1)繪制時間
POINT_COLOR = WHITE;
LCD_Fill(320-5-24-10-40,3,320-5-24-10,19,BLACK);
LCD_ShowChar(320-5-24-10-40+16,3,‘:’,16,1);
LCD_ShowNum(320-5-24-10-40,3,calendar.hour,2,16);
LCD_ShowNum(320-5-24-10-40+24,3,calendar.min,2,16);
//2)繪制電池電量//目前沒有添加電池,只是循環(huán)改變而已,如果之后添加電池,根據(jù)獲得的電池量,修改bat_status的值
if(bat_status == 0||bat_status》6)
bat_status =6;
else
bat_status--;
minibmp_decode((u8*)baticos[bat_status],320-5-24,4,24,14,0,0);
}
}
在頭文件中添加,以便其他源文件中的函數(shù)調(diào)用
extern u8 bat_status;
extern u8 tmer_min;
extern void statusbar_change(void);
顯示效果:
來源;21ic
評論
查看更多