#include "human_computer_interaction_service.h" #include "port.h" #include "zes8p5066lib/systicket.h" #include "zsimple_timer/zsimple_timer.h" void hcis_active_input(active_input_t input) { thisDevice.active_start_ticket = systicket_get_now_ms(); thisDevice.active_input = input; } bool hcis_input_is_active(active_input_t input) { return (thisDevice.active_input == input); } /*********************************************************************************************************************** * =====================================================schedule====================================================== * ***********************************************************************************************************************/ void mf_set_status_light_state(bool r, bool g, bool b) { port_led_r_set(r); port_led_g_set(g); port_led_b_set(b); } static void mf_set_status_light_by_level(level_t level) { if (level == klevel1) { mf_set_status_light_state(/*rgb:*/ 0, 0, 1); } else if (level == klevel2) { mf_set_status_light_state(/*rgb:*/ 1, 0, 0); } } void do_countdown_flash_light_effect() { //所有定时指示灯闪烁效果 static uint32_t lastticket = 0; static bool statenow; if (systicket_haspassedms(lastticket) > kconst_active_input_light_flick_interval_ms) { lastticket = systicket_get_now_ms(); statenow = !statenow; port_led0_set(statenow && thisDevice.countdonwnum > 0); port_led1_set(statenow && thisDevice.countdonwnum > 1); port_led2_set(statenow && thisDevice.countdonwnum > 2); port_led3_set(statenow && thisDevice.countdonwnum > 3); } } void close_all_light() { port_led0_set(0); port_led1_set(0); port_led2_set(0); port_led3_set(0); mf_set_status_light_state(0, 0, 0); } void process_countdonwlight() { /** * @brief 定时指示灯的控制 * * 配置模型下,指示灯闪烁 * 非配置模式下,指示灯常亮 * */ if (thisDevice.active_input == kchange_countdonw_time_input || // thisDevice.active_input == kchange_intermittentmode_time_input) { do_countdown_flash_light_effect(); } else { port_led0_set(thisDevice.countdonwnum > 0); port_led1_set(thisDevice.countdonwnum > 1); port_led2_set(thisDevice.countdonwnum > 2); port_led3_set(thisDevice.countdonwnum > 3); } } void process_level_light() { /** * @brief 等级指示灯的控制 * * 配置模式下 指示灯根据当前工作等级闪烁 * 非配置模式下 如果设备处于间歇空闲状态,则亮绿灯,否则亮相应的等级指示灯 * */ if (thisDevice.active_input == kchange_level_input) { /** * @brief 配置时,等级指示灯闪烁 */ static uint32_t lastticket = 0; static bool statenow; if (systicket_haspassedms(lastticket) > kconst_active_input_light_flick_interval_ms) { lastticket = systicket_get_now_ms(); statenow = !statenow; if (statenow) { mf_set_status_light_by_level(thisDevice.level); } else { mf_set_status_light_state(/*rgb:*/ 0, 0, 0); } } } else { if (thisDevice.mode == kintermittentMode && thisDevice.working) { mf_set_status_light_state(/*rgb:*/ 0, 1, 0); } else { mf_set_status_light_by_level(thisDevice.level); } } } void lcs_schedule_process() { if (!thisDevice.poweron) { close_all_light(); return; } //自动失能active_input if (thisDevice.active_input != knone_active && systicket_haspassedms(thisDevice.active_start_ticket) >= kconst_flash_auto_close_time) { thisDevice.active_input = knone_active; } //控制定时指示灯 process_countdonwlight(); //控制等级指示灯 process_level_light(); } void hcis_shcedule() { static uint32_t ticket = 0; if (systicket_haspassedms(ticket) > 30) { ticket = systicket_get_now_ms(); lcs_schedule_process(); } }