Browse Source

update

master
zhaohe 3 years ago
parent
commit
ee4c09d6f6
  1. 202
      APP/main.c
  2. 2
      APP/service/frequency_sweep_service.c
  3. 2
      APP/service/human_computer_interaction_service.c
  4. 2
      CMSIS
  5. 1027
      project_ozone/Listings/project_o.map
  6. 26
      project_ozone/project_o.uvgui.zel
  7. 4
      project_ozone/project_o.uvopt
  8. 2
      zes8p5066lib

202
APP/main.c

@ -35,34 +35,18 @@ zkey_module_t key_module = ZMODULE_INIT(s_keys, onkey);
* =============================================================================================================== * * =============================================================================================================== *
***********************************************************************************************************************/ ***********************************************************************************************************************/
/***********************************************************************************************************************
* ===================================================COUNT_COMPUTE=================================================== *
***********************************************************************************************************************/
static uint32_t compute_countdown_num(int countdowns) { 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() {
printf("power off\n");
thisDevice.poweron = false;
stopwork();
}
static void increase_and_assign_countdonwnum() { static void increase_and_assign_countdonwnum() {
if (thisDevice.countdonwnum == 4) { if (thisDevice.countdonwnum == 4) {
thisDevice.countdonwnum = 0; thisDevice.countdonwnum = 0;
thisDevice.countdonwnum_s = 0; thisDevice.countdonwnum_s = 0;
thisDevice.countdonw_setting_num = 0; thisDevice.countdonw_setting_num = 0;
hcis_active_input(knone_active);
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;
thisDevice.countdonwnum = thisDevice.countdonwnum + 1; thisDevice.countdonwnum = thisDevice.countdonwnum + 1;
@ -71,40 +55,63 @@ static void increase_and_assign_countdonwnum() {
} }
} }
static void set_countdown(int countdownnum) {
static void mf_set_countdown(int countdownnum) {
thisDevice.countdonwnum = countdownnum; thisDevice.countdonwnum = countdownnum;
thisDevice.countdonwnum_s = thisDevice.countdonwnum * kconst_countdown_step_s; thisDevice.countdonwnum_s = thisDevice.countdonwnum * kconst_countdown_step_s;
thisDevice.countdonw_setting_num = thisDevice.countdonwnum; thisDevice.countdonw_setting_num = thisDevice.countdonwnum;
thisDevice.countdonw_start_ticket = systicket_get_now_ms(); 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);
if (!thisDevice.poweron) {
/***********************************************************************************************************************
* ===================================================POWER_CONTROL=================================================== *
***********************************************************************************************************************/
//
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() {
printf("power off\n");
thisDevice.poweron = false;
stopwork();
}
//
static void poweron() {
printf("power on\n"); printf("power on\n");
thisDevice.poweron = true; thisDevice.poweron = true;
thisDevice.level = klevel1; thisDevice.level = klevel1;
thisDevice.mode = knormal; thisDevice.mode = knormal;
startwork(); startwork();
}
/***********************************************************************************************************************
* =================================================KEY_EVENT_PROCESS================================================= *
***********************************************************************************************************************/
//
static void mf_process_poweron_key(zkey_t* key) {
printf("on %s \n", key->name);
if (!thisDevice.poweron) {
poweron();
} else { } else {
shutdwon(); shutdwon();
} }
return; return;
} }
// levelkey
if (strcmp(key->name, "levelkey") == 0 && zks_rising_edge == key_state) {
//
static void mf_process_level_key(zkey_t* key) {
if (!thisDevice.poweron) return; if (!thisDevice.poweron) return;
printf("on %s \n", key->name); printf("on %s \n", key->name);
/** /**
* @brief * @brief
*/ */
if (!hcis_input_is_active(kchange_level_input)) {
hcis_active_input(kchange_level_input);
return;
}
if (thisDevice.level == klevel1) { if (thisDevice.level == klevel1) {
printf("changet level to level2\n"); printf("changet level to level2\n");
thisDevice.level = klevel2; thisDevice.level = klevel2;
@ -117,46 +124,75 @@ static void onkey(zkey_t* key, zkey_state_t key_state) {
hcis_active_input(kchange_level_input); hcis_active_input(kchange_level_input);
return; return;
} }
// timerkey
if (strcmp(key->name, "timerkey") == 0 && zks_rising_edge == key_state) {
//
static void mf_process_timer_key(zkey_t* key) {
if (!thisDevice.poweron) return; if (!thisDevice.poweron) return;
printf("on %s \n", key->name); printf("on %s \n", key->name);
port_fan_set(true);
// TODO:
if (!hcis_input_is_active(kchange_countdonw_time_input)) {
if (!thisDevice.working) {
startwork();
}
increase_and_assign_countdonwnum();
if (thisDevice.countdonwnum_s == 0) {
hcis_active_input(knone_active);
thisDevice.mode = knormal;
} else {
hcis_active_input(kchange_countdonw_time_input); hcis_active_input(kchange_countdonw_time_input);
if (thisDevice.mode != ktimingMode || thisDevice.countdonwnum_s == 0) {
set_countdown(1);
thisDevice.mode = ktimingMode; thisDevice.mode = ktimingMode;
} }
return;
}
hcis_active_input(kchange_countdonw_time_input);
increase_and_assign_countdonwnum();
} }
if (strcmp(key->name, "intervalkey") == 0 && zks_rising_edge == key_state) {
//
static void mf_process_interval_key(zkey_t* key) {
if (!thisDevice.poweron) return; if (!thisDevice.poweron) return;
printf("on %s \n", key->name); printf("on %s \n", key->name);
// TODO:
port_fan_set(true);
if (!hcis_input_is_active(kchange_intermittentmode_time_input)) {
hcis_active_input(kchange_intermittentmode_time_input);
if (thisDevice.mode != kintermittentMode || thisDevice.countdonwnum_s == 0) {
set_countdown(1);
if (!thisDevice.working) {
startwork();
}
increase_and_assign_countdonwnum();
if (thisDevice.countdonwnum_s == 0) {
hcis_active_input(knone_active);
thisDevice.mode = knormal;
} else {
hcis_active_input(kchange_countdonw_time_input);
thisDevice.mode = kintermittentMode; thisDevice.mode = kintermittentMode;
} }
return;
} }
hcis_active_input(kchange_intermittentmode_time_input);
increase_and_assign_countdonwnum();
static void onkey(zkey_t* key, zkey_state_t key_state) {
if /* */ (strcmp(key->name, "powerkey") == 0 && zks_rising_edge == key_state) {
mf_process_poweron_key(key);
} else if (strcmp(key->name, "levelkey") == 0 && zks_rising_edge == key_state) {
mf_process_level_key(key);
} else if (strcmp(key->name, "timerkey") == 0 && zks_rising_edge == key_state) {
mf_process_timer_key(key);
} else if (strcmp(key->name, "intervalkey") == 0 && zks_rising_edge == key_state) {
mf_process_interval_key(key);
}
}
/***********************************************************************************************************************
* ===============================================THIS_MODULE_SCHEDULE================================================ *
***********************************************************************************************************************/
static void mf_try_autoshutdown() {
if (thisDevice.poweron) {
if (thisDevice.countdonwnum_s == 0) {
shutdwon();
}
}
}
static void mf_try_autostop() {
//,
if (thisDevice.countdonwnum_s == 0) stopwork();
}
static void mf_try_auto_restart() {
//,
if (systicket_haspassedms(thisDevice.countdonw_start_ticket) / 1000 > INTERMITTENTMODE_PERIOD_S) {
mf_set_countdown(thisDevice.countdonw_setting_num);
startwork();
} }
} }
void update_countdown() {
static void mf_update_countdown() {
if /* */ (thisDevice.mode == knormal) { if /* */ (thisDevice.mode == knormal) {
thisDevice.countdonwnum = 0; thisDevice.countdonwnum = 0;
thisDevice.countdonwnum_s = 0; thisDevice.countdonwnum_s = 0;
@ -169,48 +205,39 @@ void update_countdown() {
} }
} }
void process_countdwonevent() {
//
update_countdown();
void this_module_schedule() {
/** /**
* @brief
* @brief
*/ */
if (thisDevice.mode == ktimingMode) { if (thisDevice.mode == ktimingMode) {
// //
if (thisDevice.poweron) {
if (thisDevice.countdonwnum_s == 0) {
shutdwon();
}
mf_update_countdown();
mf_try_autoshutdown();
} }
} else if (thisDevice.mode == kintermittentMode) {
/** /**
* @brief
* ,,,,,
* @brief ,
*/ */
if (thisDevice.mode == kintermittentMode) {
mf_update_countdown();
if (thisDevice.working) { if (thisDevice.working) {
//,
if (thisDevice.countdonwnum_s == 0) stopwork();
mf_try_autostop();
} else { } else {
//,
if (systicket_haspassedms(thisDevice.countdonw_start_ticket) / 1000 > INTERMITTENTMODE_PERIOD_S) {
set_countdown(thisDevice.countdonw_setting_num);
startwork();
}
mf_try_auto_restart();
} }
} }
}; };
void ozone_control_start();
void ozone_control_stop();
void ozone_control_schedule();
void do_debug_light_state() {
/***********************************************************************************************************************
* =======================================================MAIN======================================================== *
***********************************************************************************************************************/
static void mf_do_debug_light_state() {
static uint8_t debug_led_state = 1; static uint8_t debug_led_state = 1;
debug_led_state = !debug_led_state; debug_led_state = !debug_led_state;
port_debug_set(debug_led_state); port_debug_set(debug_led_state);
} }
void init_all_subdevice_state() {
static void mf_init_all_subdevice_state() {
port_debug_set(false); port_debug_set(false);
port_fan_set(false); port_fan_set(false);
port_led0_set(false); port_led0_set(false);
@ -230,7 +257,7 @@ int main(void) {
/*系统初始化*/ /*系统初始化*/
zgpio_init_all_gpio(); // zgpio_init_all_gpio(); //
port_init(); // port_init(); //
init_all_subdevice_state(); //
mf_init_all_subdevice_state(); //
printf("==========OZONE_GENERATOR==========\n"); // printf("==========OZONE_GENERATOR==========\n"); //
printf("= manufactor: iflytop\n"); // printf("= manufactor: iflytop\n"); //
printf("= version : %s\n", VERSION); // printf("= version : %s\n", VERSION); //
@ -244,17 +271,18 @@ int main(void) {
* @brief * @brief
* 20k起步50hz100ms计算功率 * 20k起步50hz100ms计算功率
*/ */
// printf_ozone_freq_and_power_table();
// ozone_control_init();
while (true) { while (true) {
// //
DO_IT_EACH_MS(KEY_PERIOD) { zkey_do_loop_in_each_period(NULL); } DO_IT_EACH_MS(KEY_PERIOD) { zkey_do_loop_in_each_period(NULL); }
END(); END();
DO_IT_EACH_MS(150) { do_debug_light_state(); }
//
DO_IT_EACH_MS(150) { mf_do_debug_light_state(); }
END(); END();
//Schedule
ozone_control_schedule(); ozone_control_schedule();
//Schedule
hcis_shcedule(); hcis_shcedule();
process_countdwonevent();
// printf("countddonw %d\n", thisDevice.countdonwnum_s);
//Schedule
this_module_schedule();
} }
} }

2
APP/service/frequency_sweep_service.c

@ -10,7 +10,7 @@
***********************************************************************************************************************/ ***********************************************************************************************************************/
struct { struct {
float power_table[350];
float power_table[200];
uint16_t startfreq; uint16_t startfreq;
uint16_t endfreq; uint16_t endfreq;
uint16_t step; uint16_t step;

2
APP/service/human_computer_interaction_service.c

@ -90,7 +90,7 @@ void process_level_light() {
} }
} }
} else { } else {
if (thisDevice.mode == kintermittentMode && thisDevice.working) {
if (thisDevice.mode == kintermittentMode && !thisDevice.working) {
mf_set_status_light_state(/*rgb:*/ 0, 1, 0); mf_set_status_light_state(/*rgb:*/ 0, 1, 0);
} else { } else {
mf_set_status_light_by_level(thisDevice.level); mf_set_status_light_by_level(thisDevice.level);

2
CMSIS

@ -1 +1 @@
Subproject commit 97fbccc0525041fe1ccfb714cfca2548495cc3a6
Subproject commit 7a042b9cf42c5c74e9a09dfd8928d8c2fa654928

1027
project_ozone/Listings/project_o.map
File diff suppressed because it is too large
View File

26
project_ozone/project_o.uvgui.zel
File diff suppressed because it is too large
View File

4
project_ozone/project_o.uvopt

@ -379,7 +379,7 @@
<Group> <Group>
<GroupName>CMSIS</GroupName> <GroupName>CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -411,7 +411,7 @@
<Group> <Group>
<GroupName>Library</GroupName> <GroupName>Library</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>

2
zes8p5066lib

@ -1 +1 @@
Subproject commit d42b02a3055c9ab99c917608797208790712524f
Subproject commit 55af3285a5274efafc730b5b3b994c940b81322d
Loading…
Cancel
Save