The main tasks to be completed are:
1) Divide the display position
2) Draw the status bar background
3) Draw the battery icon: a total of 7 baticos[7]
4) Draw time: only show hours and minutes
5) Cycle to detect time changes, change the displayed time value, and simultaneously determine the battery power and draw the corresponding icon
Source file: 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)
{
//Draw the status bar
//1) Draw the status bar background 320x12 x=0, y=0, w=320, h=22
LCD_Fill(0,0,320,22,BLACK);
//2) Draw the battery power 24X14 display on the right, 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) Drawing time 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); }
}
//Called from while(1) in other interface functions, such as the main function
void statusbar_change(void)
{
if(tmer_min!=calendar.min)
{
tmer_min = calendar.min;
//1) Drawing time
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) Draw the battery power //No battery has been added yet, it is just a loop change. If a battery is added later, modify the value of bat_status according to the battery power obtained
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 to the header file
//add by joqian for statusbar
extern u8 bat_status;
extern u8 tmer_min;
extern void statusbar_change(void);
display effect:
Previous article:STM32 development board capacitive touch screen driver, single point effective
Next article:STM32 power management and low power mode
Recommended ReadingLatest update time:2024-11-22 09:36
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Europe's three largest chip giants re-examine their supply chains
- Europe's three largest chip giants re-examine their supply chains
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
- The agency predicts that my country's public electric vehicle charging piles will reach 3.6 million this year, accounting for nearly 70% of the world
- U.S. senators urge NHTSA to issue new vehicle safety rules
- Giants step up investment, accelerating the application of solid-state batteries
- Major breakthrough in complementary bipolar process technology
- SN8P04XX Series
- Is LDO a DC/DC?
- EEWORLD University - Strengthen power knowledge through the TI Power Management Lab Kit (TI-PMLK) series
- Create a flexible EDGE data receiver(Part 2)
- Network practice: Don't ignore DNS settings when establishing a domain controller
- Research and application development on contactless IC smart (radio frequency) card and its reading and writing equipment core technology
- Basic knowledge of automobile body design
- Little Bee SLSTK2010A Learning Sequence 1: Board Drying
- Ask SAMD21 question