1.题目概述
2.功能模块
2.1 LED功能
1.简单的亮灭功能;
2.使用位操作。
#include "led.h"
void led_init(void)
{
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_All, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_RESET);
}
void led_process(uint8_t led)
{
led_init();
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC, led<<8, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_RESET);
}
led &= 0xfd;
led |= 0x02;
if( ALL_spare_count > 0 )
led |= 0x01;
else
led &= 0xfe;
2.2 LCD功能
1.引入官方例程;
2.两个显示界面。
void lcd_process(uint8_t Screen)
{
if(Screen == 0)
{
sprintf ((char*)show_data ," Data");
LCD_DisplayStringLine(Line1 , show_data);
sprintf ((char*)show_data ," CNBR: %d ",CNBR_used_count);
LCD_DisplayStringLine(Line3 , show_data);
sprintf ((char*)show_data ," VNBR: %d ",VNBR_used_count);
LCD_DisplayStringLine(Line4 , show_data);
sprintf ((char*)show_data ," IDLE: %d ",ALL_spare_count);
LCD_DisplayStringLine(Line5 , show_data);
}
else
{
sprintf ((char*)show_data ," Para");
LCD_DisplayStringLine(Line1 , show_data);
sprintf ((char*)show_data ," CNBR: %.2f ",CNBR_unit_price);
LCD_DisplayStringLine(Line3 , show_data);
sprintf ((char*)show_data ," VNBR: %.2f ",VNBR_unit_price);
LCD_DisplayStringLine(Line4 , show_data);
sprintf ((char*)show_data ," ");
LCD_DisplayStringLine(Line5 , show_data);
}
}
2.3 按键功能
1.按键基础功能,短按;
2.定时器式的按键(具体代码请看我前两此博客);
3.注意加减按键只能在费率设置界面有