Adding a status bar to the STM32 development board display interface

Publisher:未来感知Latest update time:2017-12-01 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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 for function calls in other source files

//add by joqian for statusbar

extern u8 bat_status;

extern u8 tmer_min;

extern void statusbar_change(void);

 

display effect:


Keywords:STM32 Reference address:Adding a status bar to the STM32 development board display interface

Previous article:STM32 development board capacitive touch screen driver, single point effective
Next article:STM32 power management and low power mode

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号