1. 完成了PWR按键相关的测试,测试通过
2. 完成了语言识别测试,测试基本通过,后续需要修改从sd卡导入模型以配合ota
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#include "PWR_Key.h"
|
||||
|
||||
static uint8_t BAT_State = 0; // 电池/电源状态标志
|
||||
static uint8_t Device_State = 0; // 设备状态标志
|
||||
static uint16_t Long_Press = 0; // 按键按下持续时间计数器
|
||||
|
||||
|
||||
void PWR_Loop(void)
|
||||
{
|
||||
if(BAT_State){
|
||||
if(!gpio_get_level(PWR_KEY_Input_PIN)){
|
||||
if(BAT_State == 2){
|
||||
Long_Press ++;
|
||||
if(Long_Press >= Device_Sleep_Time){
|
||||
if(Long_Press >= Device_Sleep_Time && Long_Press < Device_Restart_Time)
|
||||
Device_State = 1;
|
||||
else if(Long_Press >= Device_Restart_Time && Long_Press < Device_Shutdown_Time)
|
||||
Device_State = 2;
|
||||
else if(Long_Press >= Device_Shutdown_Time)
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(BAT_State == 1)
|
||||
BAT_State = 2;
|
||||
Long_Press = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void Fall_Asleep(void)
|
||||
{
|
||||
|
||||
}
|
||||
void Restart(void)
|
||||
{
|
||||
|
||||
}
|
||||
void Shutdown(void)
|
||||
{
|
||||
gpio_set_level(PWR_Control_PIN, false);
|
||||
LCD_Backlight = 0;
|
||||
}
|
||||
void configure_GPIO(int pin, gpio_mode_t Mode)
|
||||
{
|
||||
gpio_reset_pin(pin);
|
||||
gpio_set_direction(pin, Mode);
|
||||
}
|
||||
void PWR_Init(void) {
|
||||
configure_GPIO(PWR_KEY_Input_PIN, GPIO_MODE_INPUT);
|
||||
configure_GPIO(PWR_Control_PIN, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(PWR_Control_PIN, false);
|
||||
vTaskDelay(100);
|
||||
if(!gpio_get_level(PWR_KEY_Input_PIN)) {
|
||||
BAT_State = 1;
|
||||
gpio_set_level(PWR_Control_PIN, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user