You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "light_control_service.h"
#include "../../zes8p5066lib/systicket.h"
#include "../port.h"
static Page_t s_nowpage;
typedef struct { Page_t nowpage; union { struct { // rgb状态指示灯
bool status_light_r; bool status_light_g; bool status_light_b;
//倒计时指示灯
int countdown_num; //当前灯的数量
int one_light_time; //
uint32_t countdown_ms; //当前灯代表的时间
uint32_t flash_triggerTicket; //倒计时指示灯闪烁效果触发时间
bool flash_triggered; //是否触发闪烁指示灯
uint32_t flash_autoCloseTimeMs; //倒计时闪烁指示灯自动关闭时间
int count_light_flash_ticket;
} p1; struct { int errorNum; } p2; } p; } ModuleState_t;
ModuleState_t m;
void lcs_change_page(Page_t page) { m.nowpage = page; if (m.nowpage == kworkPage) { port_led_r_set(m.p.p1.status_light_r); port_led_g_set(m.p.p1.status_light_g); port_led_b_set(m.p.p1.status_light_b); } }
void lcs_count_donwload_light__set_one_light_time_min(int min) {} void lcs_count_donwload_light__set_count_num(int num) {} void lcs_count_donwload_light__trigger_flash(int lastfortime, bool retrigger) { /**
* @brief 触发倒计时指示灯闪烁效果 */ m.p.p1.flash_triggerTicket = systicket_get_now_ms(); m.p.p1.flash_triggered = true; m.p.p1.flash_autoCloseTimeMs = lastfortime; } void lcs_status_light__set_color(bool r, bool g, bool b) { m.p.p1.status_light_r = r; m.p.p1.status_light_g = g; m.p.p1.status_light_b = b; }
void lcs_error_light__set_error(int errorNum) {} void lcs_error_light__clear_error(int errorNum) {}
/***********************************************************************************************************************
* =====================================================schedule====================================================== * ***********************************************************************************************************************/ void lcs_schedule_process() { /**
* @brief */
if (m.nowpage == kworkPage) { if (m.p.p1.flash_triggered) { } } }
void lcs_shcedule() { static uint32_t ticket = 0; if (systicket_haspassedms(ticket) > 30) { ticket = systicket_get_now_ms(); lcs_schedule_process(); } }
#if 0
#include "light.h"
static bool s_interval_working_mode; static rgb_light_mode_t s_rgb_now_state; static rgb_light_mode_t s_rgb_light_mode_config; static int s_errornum = 0; static bool s_errorlight_display_state; static bool s_autoshutdown_light_state; /**
* @brief 设置灯的模式,高低中分别亮不同颜色的灯 * 高档红色,中档蓝色,低档绿色 */ static void prv_light_module_set_rgb_mode(rgb_light_mode_t mode) { if (mode == krgb_color_red) { port_led_r_set(true); port_led_g_set(false); port_led_b_set(false); } else if (mode == krgb_color_blue) { port_led_r_set(false); port_led_g_set(false); port_led_b_set(true); } else if (mode == krgb_color_green) { port_led_r_set(false); port_led_b_set(false); port_led_g_set(true); } else if (mode == krgb_close) { port_led_r_set(false); port_led_g_set(false); port_led_b_set(false); } s_rgb_now_state = mode; }
static void prv_set_timing_light_mode(int mode) { if (mode == 1) { port_led0_set(true); port_led1_set(false); port_led2_set(false); port_led3_set(false); } else if (mode == 2) { port_led0_set(true); port_led1_set(true); port_led2_set(false); port_led3_set(false); } else if (mode == 3) { port_led0_set(true); port_led1_set(true); port_led2_set(true); port_led3_set(false); } else if (mode == 4) { port_led0_set(true); port_led1_set(true); port_led2_set(true); port_led3_set(true); } else if (mode == 0) { port_led0_set(false); port_led1_set(false); port_led2_set(false); port_led3_set(false); } }
void prv_light_module_rgb_light_control_schedule() { if (s_rgb_light_mode_config == krgb_close) { prv_light_module_set_rgb_mode(krgb_close); return; } if (!s_interval_working_mode) { prv_light_module_set_rgb_mode(s_rgb_light_mode_config); return; }
/**
* @brief 是否处于间歇模式 */ if (s_interval_working_mode) { if (hook_get_ozone_generator_working_flag()) { static uint32_t rgb_flicker_ticket = 0; static uint8_t rgb_ticket_count = 0; if (port_haspassedms(rgb_flicker_ticket) > 1000) { rgb_flicker_ticket = get_sys_ticket(); if (s_rgb_now_state == krgb_close) { prv_light_module_set_rgb_mode(s_rgb_light_mode_config); } else { prv_light_module_set_rgb_mode(krgb_close); } } } else { prv_light_module_set_rgb_mode(krgb_color_green); } } }
/**
* @brief 倒计时指示灯状态控制 */ static void prv_time_light_control_schedule() { if (s_autoshutdown_light_state) { /**
* @brief 显示自动关机倒计时指示灯 */ int lightnum = hook_get_autoshutdown_timecount() / AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S; int lightnum_remainder = hook_get_autoshutdown_timecount() % AUTO_SHUTDOWN_ONE_LIGHT_EQ_TIME_S; if (lightnum_remainder != 0) { lightnum += 1; }
prv_set_timing_light_mode(lightnum); } else if (s_errorlight_display_state) { /**
* @brief 显示异常指示灯 */ static uint32_t ticket = 0; static bool state; if (port_haspassedms(ticket) > 300) { ticket = get_sys_ticket(); state = !state; if (state) { prv_set_timing_light_mode(s_errornum); } else { prv_set_timing_light_mode(0); } } } else { prv_set_timing_light_mode(0); } }
/***********************************************************************************************************************
* ======================================================Extern======================================================= * ***********************************************************************************************************************/
void light_module_set_rgb_mode(rgb_light_mode_t mode) { printf("light_module_set_rgb_mode %d\n", mode); s_rgb_light_mode_config = mode; prv_light_module_set_rgb_mode(mode); }
void light_module_set_rgb_in_interval_working_mode(bool state) { printf("light_module_set_rgb_in_interval_working_mode %d\n", state); s_interval_working_mode = state; } void light_module_set_autoshutdown_indicator_light(bool open) { s_autoshutdown_light_state = open; } void light_module_set_error_light_mode(bool open, uint8_t error_mode) { printf("light_module_set_error_light_mode %d\n", error_mode); s_errorlight_display_state = open; s_errornum = error_mode; } void light_module_close_all_light(void) { printf("light_module_close_all_light\n"); light_module_set_rgb_mode(krgb_close); light_module_set_autoshutdown_indicator_light(false); light_module_set_rgb_in_interval_working_mode(false); prv_set_timing_light_mode(0); s_errornum = 0; s_interval_working_mode = false; s_autoshutdown_light_state = false; s_errorlight_display_state = false; } void light_module_schedule(void) { prv_light_module_rgb_light_control_schedule(); prv_time_light_control_schedule(); } #endif
|