Skip to content

Commit

Permalink
[MGR] HW2 Power off on Button double press
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Apr 8, 2024
1 parent b3ba50c commit 1475031
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions main/system/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#define LED_P3_PIN 12
#define LED_P4_PIN 15

#define INHIBIT_CNT 200

typedef void (*sys_mgr_cmd_t)(void);

enum {
Expand Down Expand Up @@ -353,6 +355,7 @@ static void wired_port_hdl(void) {
}

static void boot_btn_hdl(void) {
uint32_t inhibit_cnt = 0;
uint32_t hold_cnt = 0;
uint32_t state = 0;

Expand Down Expand Up @@ -402,8 +405,16 @@ static void boot_btn_hdl(void) {
}

set_leds_as_btn_status(0);
/* Inhibit SW press for 2 seconds */
vTaskDelay(2000 / portTICK_PERIOD_MS);
while (inhibit_cnt++ < INHIBIT_CNT) {
/* Power off on quick double press */
if (sys_mgr_get_boot_btn()) {
sys_mgr_power_off();
/* Inhibit SW press for 2 seconds */
vTaskDelay(2000 / portTICK_PERIOD_MS);
return;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
};
}
}

Expand Down

0 comments on commit 1475031

Please sign in to comment.