Browse Source

update

master
zhaohe 3 years ago
parent
commit
a7fb33b0b0
  1. 44
      APP/main.c
  2. 3
      APP/service/device_state.c
  3. 61
      APP/service/light_control_service.c
  4. 2
      APP/service/light_control_service.h
  5. 3
      APP/service/thisdevice.c
  6. 7
      APP/service/thisdevice.h
  7. 1188
      project_ozone/Listings/project_o.map
  8. 68
      project_ozone/project_o.uvgui.zel
  9. 50
      project_ozone/project_o.uvopt
  10. 5
      project_ozone/project_o.uvproj

44
APP/main.c

@ -10,8 +10,8 @@
#include "zes8p5066lib/systicket.h" #include "zes8p5066lib/systicket.h"
#include "zes8p5066lib/uart0.h" #include "zes8p5066lib/uart0.h"
// //
#include "service/device_state.h"
#include "service/light_control_service.h" #include "service/light_control_service.h"
#include "service/thisdevice.h"
#include "test.h" #include "test.h"
#include "zsimple_timer/zsimple_timer.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) { static void onkey(zkey_t* key, zkey_state_t key_state) {
if /* */ (strcmp(key->name, "powerkey") == 0 && zks_rising_edge == key_state) { if /* */ (strcmp(key->name, "powerkey") == 0 && zks_rising_edge == key_state) {
printf("on %s \n", key->name); printf("on %s \n", key->name);
@ -80,7 +88,9 @@ static void onkey(zkey_t* key, zkey_state_t key_state) {
} }
// levelkey // levelkey
if (strcmp(key->name, "levelkey") == 0 && zks_rising_edge == key_state) { if (strcmp(key->name, "levelkey") == 0 && zks_rising_edge == key_state) {
if (!thisDevice.poweron) return;
printf("on %s \n", key->name); printf("on %s \n", key->name);
/** /**
* @brief * @brief
*/ */
@ -103,15 +113,13 @@ static void onkey(zkey_t* key, zkey_state_t key_state) {
} }
// timerkey // timerkey
if (strcmp(key->name, "timerkey") == 0 && zks_rising_edge == key_state) { if (strcmp(key->name, "timerkey") == 0 && zks_rising_edge == key_state) {
if (!thisDevice.poweron) return;
printf("on %s \n", key->name); printf("on %s \n", key->name);
if (!lcs_input_is_active(kchange_countdonw_time_input)) { if (!lcs_input_is_active(kchange_countdonw_time_input)) {
lcs_active_input(kchange_countdonw_time_input); lcs_active_input(kchange_countdonw_time_input);
if (thisDevice.mode != ktimingMode || thisDevice.countdonwnum_s == 0) { 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; return;
} }
@ -120,16 +128,14 @@ static void onkey(zkey_t* key, zkey_state_t key_state) {
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) {
if (!thisDevice.poweron) return;
printf("on %s \n", key->name); printf("on %s \n", key->name);
if (!lcs_input_is_active(kchange_intermittentmode_time_input)) { if (!lcs_input_is_active(kchange_intermittentmode_time_input)) {
lcs_active_input(kchange_intermittentmode_time_input); lcs_active_input(kchange_intermittentmode_time_input);
if (thisDevice.mode != kintermittentMode || thisDevice.countdonwnum_s == 0) { 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; return;
} }
@ -172,11 +178,7 @@ void process_countdwonevent() {
} 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; 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); // zsimple_timer_module_init(zsimple_timer_mem, ZARR_SIZE(zsimple_timer_mem), systicket_get_now_ms); //
zkey_init(&key_module); // 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(); debuglighttimer = zsimple_timer_alloc();
zsimple_timer_trigger_static(debuglighttimer, 300, INFINITE_TIMES /*触发次数:*/, true, do_debug_light_state); 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) { while (true) {
// //
@ -236,6 +237,7 @@ int main(void) {
zsimple_timer_schedule(); zsimple_timer_schedule();
lcs_shcedule(); lcs_shcedule();
process_countdwonevent();
// test_all_light(); // test_all_light();
} }
} }

3
APP/service/device_state.c

@ -1,3 +0,0 @@
#include "device_state.h"
device_state_t thisDevice;

61
APP/service/light_control_service.c

@ -29,7 +29,7 @@ void do_countdown_flash_light_effect() {
// //
static uint32_t lastticket = 0; static uint32_t lastticket = 0;
static bool statenow; static bool statenow;
if (systicket_haspassedms(lastticket) > 300) {
if (systicket_haspassedms(lastticket) > kconst_active_input_light_flick_interval_ms) {
lastticket = systicket_get_now_ms(); lastticket = systicket_get_now_ms();
statenow = !statenow; statenow = !statenow;
port_led0_set(statenow && thisDevice.countdonwnum > 0); port_led0_set(statenow && thisDevice.countdonwnum > 0);
@ -38,28 +38,16 @@ void do_countdown_flash_light_effect() {
port_led3_set(statenow && thisDevice.countdonwnum > 3); port_led3_set(statenow && thisDevice.countdonwnum > 3);
} }
} }
void do_level_light_flash() {
//
static uint32_t lastticket = 0;
static bool statenow;
if (systicket_haspassedms(lastticket) > 300) {
lastticket = systicket_get_now_ms();
statenow = !statenow;
if (statenow) {
mf_set_status_light_by_level(thisDevice.level);
} else {
mf_set_status_light_state(/*rgb:*/ 0, 0, 0);
}
}
void close_all_light() {
port_led0_set(0);
port_led1_set(0);
port_led2_set(0);
port_led3_set(0);
mf_set_status_light_state(0, 0, 0);
} }
void lcs_schedule_process() {
/**
* @brief
*/
if (thisDevice.active_input != knone_active && systicket_haspassedms(thisDevice.active_start_ticket) >= 3000) {
thisDevice.active_input = knone_active;
}
void process_countdonwlight() {
/** /**
* @brief * @brief
* *
@ -76,7 +64,9 @@ void lcs_schedule_process() {
port_led2_set(thisDevice.countdonwnum > 2); port_led2_set(thisDevice.countdonwnum > 2);
port_led3_set(thisDevice.countdonwnum > 3); port_led3_set(thisDevice.countdonwnum > 3);
} }
}
void process_level_light() {
/** /**
* @brief * @brief
* *
@ -85,6 +75,20 @@ void lcs_schedule_process() {
* *
*/ */
if (thisDevice.active_input == kchange_level_input) { if (thisDevice.active_input == kchange_level_input) {
/**
* @brief
*/
static uint32_t lastticket = 0;
static bool statenow;
if (systicket_haspassedms(lastticket) > kconst_active_input_light_flick_interval_ms) {
lastticket = systicket_get_now_ms();
statenow = !statenow;
if (statenow) {
mf_set_status_light_by_level(thisDevice.level);
} else {
mf_set_status_light_state(/*rgb:*/ 0, 0, 0);
}
}
} else { } else {
if (thisDevice.mode == kintermittentMode && thisDevice.intermittentMode_idle) { if (thisDevice.mode == kintermittentMode && thisDevice.intermittentMode_idle) {
mf_set_status_light_state(/*rgb:*/ 0, 1, 0); mf_set_status_light_state(/*rgb:*/ 0, 1, 0);
@ -93,6 +97,21 @@ void lcs_schedule_process() {
} }
} }
} }
void lcs_schedule_process() {
if (!thisDevice.poweron) {
close_all_light();
return;
}
//active_input
if (thisDevice.active_input != knone_active && systicket_haspassedms(thisDevice.active_start_ticket) >= 1500) {
thisDevice.active_input = knone_active;
}
//
process_countdonwlight();
//
process_level_light();
}
void lcs_shcedule() { void lcs_shcedule() {
static uint32_t ticket = 0; static uint32_t ticket = 0;
if (systicket_haspassedms(ticket) > 30) { if (systicket_haspassedms(ticket) > 30) {

2
APP/service/light_control_service.h

@ -3,7 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "service/device_state.h"
#include "service/thisdevice.h"
void lcs_active_input(active_input_t input); void lcs_active_input(active_input_t input);
bool lcs_input_is_active(active_input_t input); bool lcs_input_is_active(active_input_t input);

3
APP/service/thisdevice.c

@ -0,0 +1,3 @@
#include "thisdevice.h"
ThisDevice_t thisDevice;

7
APP/service/device_state.h → APP/service/thisdevice.h

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
typedef enum { typedef enum {
klevel1 = 0, klevel1 = 0,
@ -34,10 +35,12 @@ typedef struct {
bool intermittentMode_idle; bool intermittentMode_idle;
} device_state_t;
} ThisDevice_t;
#define kconst_flash_auto_close_time (3000) #define kconst_flash_auto_close_time (3000)
// #define kconst_countdown_step_s (15 * 60) // #define kconst_countdown_step_s (15 * 60)
#define kconst_countdown_step_s (10) #define kconst_countdown_step_s (10)
extern device_state_t thisDevice;
#define kconst_active_input_light_flick_interval_ms (150)
extern ThisDevice_t thisDevice;

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

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

50
project_ozone/project_o.uvopt

@ -294,6 +294,18 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\APP\service\thisdevice.c</PathWithFileName>
<FilenameWithoutPath>thisdevice.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group> </Group>
<Group> <Group>
@ -304,7 +316,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -316,7 +328,7 @@
</File> </File>
<File> <File>
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>8</FileNumber>
<FileNumber>9</FileNumber>
<FileType>2</FileType> <FileType>2</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -336,7 +348,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>9</FileNumber>
<FileNumber>10</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -348,7 +360,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>10</FileNumber>
<FileNumber>11</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -360,7 +372,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>11</FileNumber>
<FileNumber>12</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -372,7 +384,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>12</FileNumber>
<FileNumber>13</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -384,7 +396,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>13</FileNumber>
<FileNumber>14</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -396,7 +408,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>14</FileNumber>
<FileNumber>15</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -408,7 +420,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>15</FileNumber>
<FileNumber>16</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -420,7 +432,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>16</FileNumber>
<FileNumber>17</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -432,7 +444,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>17</FileNumber>
<FileNumber>18</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -444,7 +456,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>18</FileNumber>
<FileNumber>19</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -456,7 +468,7 @@
</File> </File>
<File> <File>
<GroupNumber>3</GroupNumber> <GroupNumber>3</GroupNumber>
<FileNumber>19</FileNumber>
<FileNumber>20</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -476,7 +488,7 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>20</FileNumber>
<FileNumber>21</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -488,7 +500,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>21</FileNumber>
<FileNumber>22</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -500,7 +512,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>22</FileNumber>
<FileNumber>23</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -512,7 +524,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>23</FileNumber>
<FileNumber>24</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -524,7 +536,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>24</FileNumber>
<FileNumber>25</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -536,7 +548,7 @@
</File> </File>
<File> <File>
<GroupNumber>4</GroupNumber> <GroupNumber>4</GroupNumber>
<FileNumber>25</FileNumber>
<FileNumber>26</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>

5
project_ozone/project_o.uvproj

@ -452,6 +452,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\dep\zsimple_timer\zsimple_timer.c</FilePath> <FilePath>..\dep\zsimple_timer\zsimple_timer.c</FilePath>
</File> </File>
<File>
<FileName>thisdevice.c</FileName>
<FileType>1</FileType>
<FilePath>..\APP\service\thisdevice.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>

Loading…
Cancel
Save