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
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- [NXP & e-Network Live Review] High-performance i.MX RT processors help smart nodes achieve machine learning without the need for an internet connection...
- Hangzhou Songyangheng Technology Co., Ltd.--Recruiting ADC/DAC field application engineers
- ADI & Shijian will help you understand chemical analysis and analytical instrument application solutions. Answer questions and win prizes!
- The generation, measurement and suppression of switching power supply ripples are all covered in one article!
- Circuit reference ground potential issues
- Developers must-have: Sharing common commands of Docker client
- [NXP Rapid IoT Review] Unboxing the Rapid IoT Kit and Understanding the Development Environment
- Recommended China chip + SI522 ultra-low power consumption 13.56M card reader chip, CI522 ultra-low cost 13.56M card reader chip
- It is said that the instructions executed by the ARM core are provided by SRAM. Are the instructions not read directly from FLASH?
- In-depth explanation of how to choose the inductor value for DC-DC boost converter