|
|
@ -10,8 +10,8 @@ |
|
|
|
#include "zes8p5066lib/systicket.h" |
|
|
|
#include "zes8p5066lib/uart0.h" |
|
|
|
// |
|
|
|
#include "service/device_state.h" |
|
|
|
#include "service/light_control_service.h" |
|
|
|
#include "service/thisdevice.h" |
|
|
|
#include "test.h" |
|
|
|
#include "zsimple_timer/zsimple_timer.h" |
|
|
|
|
|
|
@ -61,6 +61,14 @@ static void increase_and_assign_countdonwnum() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void set_countdown(int countdownnum) { |
|
|
|
thisDevice.countdonwnum = countdownnum; |
|
|
|
thisDevice.countdonwnum_s = thisDevice.countdonwnum * kconst_countdown_step_s; |
|
|
|
|
|
|
|
thisDevice.countdonw_s_setting_num = thisDevice.countdonwnum_s; |
|
|
|
thisDevice.countdonw_start_ticket = systicket_get_now_ms(); |
|
|
|
} |
|
|
|
|
|
|
|
static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
|
if /* */ (strcmp(key->name, "powerkey") == 0 && zks_rising_edge == key_state) { |
|
|
|
printf("on %s \n", key->name); |
|
|
@ -80,7 +88,9 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
|
} |
|
|
|
// levelkey |
|
|
|
if (strcmp(key->name, "levelkey") == 0 && zks_rising_edge == key_state) { |
|
|
|
if (!thisDevice.poweron) return; |
|
|
|
printf("on %s \n", key->name); |
|
|
|
|
|
|
|
/** |
|
|
|
* @brief 当前在不在修改状态,不在,则进入修改状态 |
|
|
|
*/ |
|
|
@ -103,15 +113,13 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
|
} |
|
|
|
// timerkey |
|
|
|
if (strcmp(key->name, "timerkey") == 0 && zks_rising_edge == key_state) { |
|
|
|
if (!thisDevice.poweron) return; |
|
|
|
printf("on %s \n", key->name); |
|
|
|
if (!lcs_input_is_active(kchange_countdonw_time_input)) { |
|
|
|
lcs_active_input(kchange_countdonw_time_input); |
|
|
|
|
|
|
|
if (thisDevice.mode != ktimingMode || thisDevice.countdonwnum_s == 0) { |
|
|
|
thisDevice.countdonwnum_s = kconst_countdown_step_s; |
|
|
|
thisDevice.countdonwnum = 1; |
|
|
|
thisDevice.countdonw_s_setting_num = thisDevice.countdonwnum_s; |
|
|
|
thisDevice.countdonw_start_ticket = systicket_get_now_ms(); |
|
|
|
set_countdown(1); |
|
|
|
thisDevice.mode = ktimingMode; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
@ -120,16 +128,14 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
|
increase_and_assign_countdonwnum(); |
|
|
|
} |
|
|
|
if (strcmp(key->name, "intervalkey") == 0 && zks_rising_edge == key_state) { |
|
|
|
if (!thisDevice.poweron) return; |
|
|
|
printf("on %s \n", key->name); |
|
|
|
|
|
|
|
if (!lcs_input_is_active(kchange_intermittentmode_time_input)) { |
|
|
|
lcs_active_input(kchange_intermittentmode_time_input); |
|
|
|
|
|
|
|
if (thisDevice.mode != kintermittentMode || thisDevice.countdonwnum_s == 0) { |
|
|
|
thisDevice.countdonwnum_s = kconst_countdown_step_s; |
|
|
|
thisDevice.countdonwnum = 1; |
|
|
|
thisDevice.countdonw_s_setting_num = thisDevice.countdonwnum_s; |
|
|
|
thisDevice.countdonw_start_ticket = systicket_get_now_ms(); |
|
|
|
set_countdown(1); |
|
|
|
thisDevice.mode = kintermittentMode; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
@ -172,11 +178,7 @@ void process_countdwonevent() { |
|
|
|
} else { |
|
|
|
if (systicket_haspassedms(thisDevice.countdonw_start_ticket) / 1000 > INTERMITTENTMODE_PERIOD_S) { |
|
|
|
thisDevice.intermittentMode_idle = false; |
|
|
|
// |
|
|
|
thisDevice.countdonw_start_ticket = systicket_get_now_ms(); |
|
|
|
thisDevice.countdonwnum_s = thisDevice.countdonw_s_setting_num; |
|
|
|
thisDevice.countdonwnum = compute_countdown_num(thisDevice.countdonwnum_s); |
|
|
|
|
|
|
|
set_countdown(thisDevice.countdonw_s_setting_num); |
|
|
|
//启动设备 |
|
|
|
} |
|
|
|
} |
|
|
@ -219,15 +221,14 @@ int main(void) { |
|
|
|
zsimple_timer_module_init(zsimple_timer_mem, ZARR_SIZE(zsimple_timer_mem), systicket_get_now_ms); //定时器模块初始化 |
|
|
|
zkey_init(&key_module); //按键初始化 |
|
|
|
|
|
|
|
port_fan_set(true); |
|
|
|
port_ozone_pwm_set_duty(30000, 10 * 1000); |
|
|
|
port_ozone_pwm_start(); |
|
|
|
// port_fan_set(true); |
|
|
|
// port_ozone_pwm_set_duty(30000, 10 * 1000); |
|
|
|
// port_ozone_pwm_start(); |
|
|
|
|
|
|
|
debuglighttimer = zsimple_timer_alloc(); |
|
|
|
zsimple_timer_trigger_static(debuglighttimer, 300, INFINITE_TIMES /*触发次数:*/, true, do_debug_light_state); |
|
|
|
|
|
|
|
lcs_count_donwload_light__set_count_num(3); |
|
|
|
lcs_status_light__set_color(/*r:*/ true, /*g:*/ false, /*b:*/ false); |
|
|
|
// lcs_status_light__set_color(/*r:*/ true, /*g:*/ false, /*b:*/ false); |
|
|
|
|
|
|
|
while (true) { |
|
|
|
//按键扫描逻辑 |
|
|
@ -236,6 +237,7 @@ int main(void) { |
|
|
|
|
|
|
|
zsimple_timer_schedule(); |
|
|
|
lcs_shcedule(); |
|
|
|
process_countdwonevent(); |
|
|
|
// test_all_light(); |
|
|
|
} |
|
|
|
} |