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.
164 lines
5.0 KiB
164 lines
5.0 KiB
#include "light.h"
|
|
#if 0
|
|
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
|