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

Recommended ReadingLatest update time:2024-11-22 09:36

Basic understanding of stm32 clock
STM32 is a powerful microcontroller with rich peripherals and powerful functions. Designers must pay attention to its power consumption at first, so clocks are generated. This is easy to understand. Just like our computers, will you open all the software when using them? Do you want to open any video software or games
[Microcontroller]
USART receive interrupt problem in STM32 causes MCU to freeze
Problem Description: When using USART for serial communication, I only turned on the receive interrupt and set the preemption priority to the lowest level. The previous priority of the receive interrupt handles more things, which may take up 2ms. When I use 9600 baud rate to send data to the lower computer, the speed
[Microcontroller]
Summary of STM32 serial port setting process
The registers that need to be configured for the STM32 serial port configuration include: 1. Clock configuration, turn on the clock of the corresponding IO port and the clock of the serial port module.       Serial port 1 module clock register: RCC_APB2Periph_USART1;       The ports of serial port 1 are PA9 and PA10,
[Microcontroller]
[STM32 Motor Vector Control] Record 11——DMA Transfer
DMA transfer: Principle: DMA transfer copies data from one address space to another. DMA transfers data, but does not need to occupy the MCU, that is, when transferring data, the MCU can do other things, such as multithreading. Data is transferred from peripherals to memory or from memory to memory. The DMA controller
[Microcontroller]
Verify that STM32 is little-endian storage
I recently wrote an STM32 program and used a union, which caused a question.  For example, 0x12345678 is stored in a U32 type variable. The big endian and little endian are stored like this.  Big-endian storage:        Low address ... High address        0x   12      34      56      78 Little endian storage:        Lo
[Microcontroller]
Solution to setting I2C_FLAG_BUSY in STM32
The touch screen IC on the stm32f429-disco is STMPE811, which uses I2C communication. The use of this IC is not difficult. It includes 8-channel 12-bit AD, 8 GPIO ports, plus 128set FIFO and several registers. The problem lies with the I2C IP core of STM32. Many people have complained about it online. The main probl
[Microcontroller]
Solution to setting I2C_FLAG_BUSY in STM32
File structure for programming STM32 HAL firmware library
  For a novice like me who has only been exposed to 51 and AVR microcontroller programming before, now I start to learn STM32 programming. The functions and the syntax of C language are easy to understand, but the difficult part is how the hardware abstraction layer (HAL) driver it provides is combined with other thin
[Microcontroller]
File structure for programming STM32 HAL firmware library
Voice guidance system based on STM32 control
Abstract: A sound guidance system based on STM32 control is designed. The system consists of a movable sound source S and three sound receivers A, B, and C. A slave STM32 microcontroller controls the wireless transmission module to send the sound guidance signal. The master microcontroller determines the start and s
[Microcontroller]
Voice guidance system based on STM32 control
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号