Browse Source

update

master
zwsd 3 years ago
parent
commit
fd0eff307b
  1. 24
      APP/main.c
  2. 14
      APP/this_device.h

24
APP/main.c

@ -14,7 +14,7 @@ static key_t s_keys[] = {
s_key_init("intervalkey", port_gpio_get_interval_key_state), s_key_init("intervalkey", port_gpio_get_interval_key_state),
}; };
static ThisDevice_t this_device = {.power = false};
static ThisDevice_t this_device;
static void mf_init_all_subdevice_state() { static void mf_init_all_subdevice_state() {
port_debug_set(false); port_debug_set(false);
@ -28,14 +28,23 @@ static void mf_init_all_subdevice_state() {
port_led_b_set(false); port_led_b_set(false);
} }
//
static void startwork() { port_fan_set(true); }
//
static void stopwork() { port_fan_set(false); }
static void poweron() { static void poweron() {
this_device.power = true; this_device.power = true;
port_fan_set(true);
this_device.ozone_level = level_low;
this_device.ozone_module = normal;
startwork();
return; return;
} }
static void powerdown() { static void powerdown() {
this_device.power = false; this_device.power = false;
port_fan_set(false);
stopwork();
return; return;
} }
@ -52,14 +61,23 @@ static void mf_process_poweron_key(key_t *key) {
return; return;
} }
static void mf_process_level_key(key_t *key) { static void mf_process_level_key(key_t *key) {
if (!this_device.power) {
return;
}
printf("key name:%s\n", key->name); printf("key name:%s\n", key->name);
return; return;
} }
static void mf_process_timer_key(key_t *key) { static void mf_process_timer_key(key_t *key) {
if (!this_device.power) {
return;
}
printf("key name:%s\n", key->name); printf("key name:%s\n", key->name);
return; return;
} }
static void mf_process_interval_key(key_t *key) { static void mf_process_interval_key(key_t *key) {
if (!this_device.power) {
return;
}
printf("key name:%s\n", key->name); printf("key name:%s\n", key->name);
return; return;
} }

14
APP/this_device.h

@ -2,7 +2,19 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
typedef enum {
level_low,
level_high,
} ozone_level_t;
typedef enum {
normal,
timingMode,
intermittentMode,
} ozone_module_t;
typedef struct { typedef struct {
/* data */
bool power; bool power;
ozone_level_t ozone_level;
ozone_module_t ozone_module;
} ThisDevice_t; } ThisDevice_t;
Loading…
Cancel
Save