|
@ -10,7 +10,7 @@ |
|
|
#include "zes8p5066lib/systicket.h" |
|
|
#include "zes8p5066lib/systicket.h" |
|
|
#include "zes8p5066lib/uart0.h" |
|
|
#include "zes8p5066lib/uart0.h" |
|
|
// |
|
|
// |
|
|
#include "service/light_control_service.h" |
|
|
|
|
|
|
|
|
#include "service/human_computer_interaction_service.h" |
|
|
#include "service/ozone_control_service.h" |
|
|
#include "service/ozone_control_service.h" |
|
|
#include "service/thisdevice.h" |
|
|
#include "service/thisdevice.h" |
|
|
#include "test.h" |
|
|
#include "test.h" |
|
@ -39,12 +39,21 @@ static uint32_t compute_countdown_num(int countdowns) { |
|
|
if (countdowns) return countdowns / kconst_countdown_step_s + !!(countdowns % kconst_countdown_step_s); |
|
|
if (countdowns) return countdowns / kconst_countdown_step_s + !!(countdowns % kconst_countdown_step_s); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void startwork() { |
|
|
|
|
|
port_fan_set(true); |
|
|
|
|
|
ozone_control_start(); |
|
|
|
|
|
thisDevice.working = true; |
|
|
|
|
|
} |
|
|
|
|
|
static void stopwork() { |
|
|
|
|
|
ozone_control_stop(); |
|
|
|
|
|
port_fan_set(false); |
|
|
|
|
|
thisDevice.working = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static void shutdwon() { |
|
|
static void shutdwon() { |
|
|
printf("power off\n"); |
|
|
printf("power off\n"); |
|
|
thisDevice.poweron = false; |
|
|
thisDevice.poweron = false; |
|
|
port_fan_set(false); |
|
|
|
|
|
//@TODO:关闭臭氧 |
|
|
|
|
|
port_ozone_pwm_stop(); |
|
|
|
|
|
|
|
|
stopwork(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void increase_and_assign_countdonwnum() { |
|
|
static void increase_and_assign_countdonwnum() { |
|
@ -52,7 +61,7 @@ static void increase_and_assign_countdonwnum() { |
|
|
thisDevice.countdonwnum = 0; |
|
|
thisDevice.countdonwnum = 0; |
|
|
thisDevice.countdonwnum_s = 0; |
|
|
thisDevice.countdonwnum_s = 0; |
|
|
thisDevice.countdonw_setting_num = 0; |
|
|
thisDevice.countdonw_setting_num = 0; |
|
|
lcs_active_input(knone_active); |
|
|
|
|
|
|
|
|
hcis_active_input(knone_active); |
|
|
thisDevice.mode = knormal; |
|
|
thisDevice.mode = knormal; |
|
|
} else { |
|
|
} else { |
|
|
thisDevice.countdonwnum_s = (thisDevice.countdonwnum + 1) * kconst_countdown_step_s; |
|
|
thisDevice.countdonwnum_s = (thisDevice.countdonwnum + 1) * kconst_countdown_step_s; |
|
@ -77,10 +86,7 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
thisDevice.poweron = true; |
|
|
thisDevice.poweron = true; |
|
|
thisDevice.level = klevel1; |
|
|
thisDevice.level = klevel1; |
|
|
thisDevice.mode = knormal; |
|
|
thisDevice.mode = knormal; |
|
|
|
|
|
|
|
|
//设置灯光效果 |
|
|
|
|
|
port_fan_set(true); |
|
|
|
|
|
//@TODO:启动臭氧 |
|
|
|
|
|
|
|
|
startwork(); |
|
|
} else { |
|
|
} else { |
|
|
shutdwon(); |
|
|
shutdwon(); |
|
|
} |
|
|
} |
|
@ -94,8 +100,8 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
/** |
|
|
/** |
|
|
* @brief 当前在不在修改状态,不在,则进入修改状态 |
|
|
* @brief 当前在不在修改状态,不在,则进入修改状态 |
|
|
*/ |
|
|
*/ |
|
|
if (!lcs_input_is_active(kchange_level_input)) { |
|
|
|
|
|
lcs_active_input(kchange_level_input); |
|
|
|
|
|
|
|
|
if (!hcis_input_is_active(kchange_level_input)) { |
|
|
|
|
|
hcis_active_input(kchange_level_input); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -108,7 +114,7 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
thisDevice.level = klevel1; |
|
|
thisDevice.level = klevel1; |
|
|
//更改臭氧状态 |
|
|
//更改臭氧状态 |
|
|
} |
|
|
} |
|
|
lcs_active_input(kchange_level_input); |
|
|
|
|
|
|
|
|
hcis_active_input(kchange_level_input); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// timerkey |
|
|
// timerkey |
|
@ -117,8 +123,8 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
printf("on %s \n", key->name); |
|
|
printf("on %s \n", key->name); |
|
|
port_fan_set(true); |
|
|
port_fan_set(true); |
|
|
// TODO:启动臭氧 |
|
|
// TODO:启动臭氧 |
|
|
if (!lcs_input_is_active(kchange_countdonw_time_input)) { |
|
|
|
|
|
lcs_active_input(kchange_countdonw_time_input); |
|
|
|
|
|
|
|
|
if (!hcis_input_is_active(kchange_countdonw_time_input)) { |
|
|
|
|
|
hcis_active_input(kchange_countdonw_time_input); |
|
|
if (thisDevice.mode != ktimingMode || thisDevice.countdonwnum_s == 0) { |
|
|
if (thisDevice.mode != ktimingMode || thisDevice.countdonwnum_s == 0) { |
|
|
set_countdown(1); |
|
|
set_countdown(1); |
|
|
thisDevice.mode = ktimingMode; |
|
|
thisDevice.mode = ktimingMode; |
|
@ -126,7 +132,7 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
lcs_active_input(kchange_countdonw_time_input); |
|
|
|
|
|
|
|
|
hcis_active_input(kchange_countdonw_time_input); |
|
|
increase_and_assign_countdonwnum(); |
|
|
increase_and_assign_countdonwnum(); |
|
|
} |
|
|
} |
|
|
if (strcmp(key->name, "intervalkey") == 0 && zks_rising_edge == key_state) { |
|
|
if (strcmp(key->name, "intervalkey") == 0 && zks_rising_edge == key_state) { |
|
@ -136,8 +142,8 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
|
|
|
|
|
|
port_fan_set(true); |
|
|
port_fan_set(true); |
|
|
|
|
|
|
|
|
if (!lcs_input_is_active(kchange_intermittentmode_time_input)) { |
|
|
|
|
|
lcs_active_input(kchange_intermittentmode_time_input); |
|
|
|
|
|
|
|
|
if (!hcis_input_is_active(kchange_intermittentmode_time_input)) { |
|
|
|
|
|
hcis_active_input(kchange_intermittentmode_time_input); |
|
|
if (thisDevice.mode != kintermittentMode || thisDevice.countdonwnum_s == 0) { |
|
|
if (thisDevice.mode != kintermittentMode || thisDevice.countdonwnum_s == 0) { |
|
|
set_countdown(1); |
|
|
set_countdown(1); |
|
|
thisDevice.mode = kintermittentMode; |
|
|
thisDevice.mode = kintermittentMode; |
|
@ -145,12 +151,12 @@ static void onkey(zkey_t* key, zkey_state_t key_state) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
lcs_active_input(kchange_intermittentmode_time_input); |
|
|
|
|
|
|
|
|
hcis_active_input(kchange_intermittentmode_time_input); |
|
|
increase_and_assign_countdonwnum(); |
|
|
increase_and_assign_countdonwnum(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void compute_countdown() { |
|
|
|
|
|
|
|
|
void update_countdown() { |
|
|
if /* */ (thisDevice.mode == knormal) { |
|
|
if /* */ (thisDevice.mode == knormal) { |
|
|
thisDevice.countdonwnum = 0; |
|
|
thisDevice.countdonwnum = 0; |
|
|
thisDevice.countdonwnum_s = 0; |
|
|
thisDevice.countdonwnum_s = 0; |
|
@ -164,8 +170,8 @@ void compute_countdown() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void process_countdwonevent() { |
|
|
void process_countdwonevent() { |
|
|
//计算countdown |
|
|
|
|
|
compute_countdown(); |
|
|
|
|
|
|
|
|
//更新倒计时计数 |
|
|
|
|
|
update_countdown(); |
|
|
/** |
|
|
/** |
|
|
* @brief 处理倒计时事件发生时的事件 |
|
|
* @brief 处理倒计时事件发生时的事件 |
|
|
*/ |
|
|
*/ |
|
@ -181,20 +187,14 @@ void process_countdwonevent() { |
|
|
* @brief 如果当前处于间歇模式下 |
|
|
* @brief 如果当前处于间歇模式下 |
|
|
* 定时时间到,关闭风扇,关闭臭氧,等待大周期过去后,开启风扇,开启臭氧,并重新计时 |
|
|
* 定时时间到,关闭风扇,关闭臭氧,等待大周期过去后,开启风扇,开启臭氧,并重新计时 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
if (!thisDevice.intermittentMode_idle) { |
|
|
|
|
|
if (thisDevice.countdonwnum_s == 0) { |
|
|
|
|
|
//切换状态到待机状态 |
|
|
|
|
|
// TODO:关闭臭氧 |
|
|
|
|
|
thisDevice.intermittentMode_idle = true; |
|
|
|
|
|
port_fan_set(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (thisDevice.working) { |
|
|
|
|
|
//间歇模式下,定时到达定时时间,停止工作 |
|
|
|
|
|
if (thisDevice.countdonwnum_s == 0) stopwork(); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
//间歇模式下,再次到达工作时间,再次工作 |
|
|
if (systicket_haspassedms(thisDevice.countdonw_start_ticket) / 1000 > INTERMITTENTMODE_PERIOD_S) { |
|
|
if (systicket_haspassedms(thisDevice.countdonw_start_ticket) / 1000 > INTERMITTENTMODE_PERIOD_S) { |
|
|
thisDevice.intermittentMode_idle = false; |
|
|
|
|
|
set_countdown(thisDevice.countdonw_setting_num); |
|
|
set_countdown(thisDevice.countdonw_setting_num); |
|
|
//启动设备 |
|
|
|
|
|
port_fan_set(true); |
|
|
|
|
|
|
|
|
startwork(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -253,7 +253,7 @@ int main(void) { |
|
|
DO_IT_EACH_MS(150) { do_debug_light_state(); } |
|
|
DO_IT_EACH_MS(150) { do_debug_light_state(); } |
|
|
END(); |
|
|
END(); |
|
|
ozone_control_schedule(); |
|
|
ozone_control_schedule(); |
|
|
lcs_shcedule(); |
|
|
|
|
|
|
|
|
hcis_shcedule(); |
|
|
process_countdwonevent(); |
|
|
process_countdwonevent(); |
|
|
// printf("countddonw %d\n", thisDevice.countdonwnum_s); |
|
|
// printf("countddonw %d\n", thisDevice.countdonwnum_s); |
|
|
} |
|
|
} |