需求完结的首要作业有:
1)区分显现方位
2)制作状态栏布景
3)制作电池图标:总共7种图标baTIcos[7]
4)制作时刻:只显现时和分
5)循环检测时刻改动,并更改显现时刻数值,同步判别电池电量,制作相应图标
源文件: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)
{
//制作状态栏
//1)制作状态栏布景320×12 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)制作时刻30×16 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); }
}
//由其他界面函数中的while(1)里边调用,例如主函数中
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)制作电池电量//现在没有增加电池,仅仅循环改动罢了,假如之后增加电池,依据取得的电池量,修正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);
}
}
在头文件中增加,以便其他源文件中的函数调用
//add by joqian for statusbar
extern u8 bat_status;
extern u8 tmer_min;
extern void statusbar_change(void);
显现作用:
来历;21ic