diff --git a/src/fs/phy.c b/src/fs/phy.c index 35fc591..159951c 100644 --- a/src/fs/phy.c +++ b/src/fs/phy.c @@ -45,6 +45,11 @@ int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len) { *p++ = PHY_OPTS; *p++ = phy->opts >> 8; *p++ = phy->opts & 0xff; + if (phy->up_btn_present) { + *p++ = PHY_UP_BTN; + *p++ = phy->up_btn; + } + *len = p - data; return PICOKEY_OK; } @@ -77,6 +82,10 @@ int phy_unserialize_data(const uint8_t *data, uint16_t len, phy_data_t *phy) { phy->opts = (*p << 8) | *(p + 1); p += 2; break; + case PHY_UP_BTN: + phy->up_btn = *p++; + phy->up_btn_present = true; + break; } } return PICOKEY_OK; diff --git a/src/fs/phy.h b/src/fs/phy.h index 531d916..95d4c99 100644 --- a/src/fs/phy.h +++ b/src/fs/phy.h @@ -24,6 +24,7 @@ #define PHY_LED_GPIO 0x4 #define PHY_LED_BTNESS 0x5 #define PHY_OPTS 0x6 +#define PHY_UP_BTN 0x8 #define PHY_OPT_WCID 0x1 #define PHY_OPT_DIMM 0x2 @@ -42,14 +43,16 @@ typedef struct phy_data { uint8_t led_gpio; uint8_t led_brightness; uint16_t opts; + uint8_t up_btn; bool vidpid_present; bool led_gpio_present; bool led_brightness_present; + bool up_btn_present; } phy_data_t; -#define PHY_OPT_MASK (PHY_OPT_SECURE_LOCK | PHY_OPT_SECURE_BOOT | PHY_OPT_DIMM | PHY_OPT_WCID) +#define PHY_OPT_MASK (PHY_UP_BTN | PHY_OPT_SECURE_LOCK | PHY_OPT_SECURE_BOOT | PHY_OPT_DIMM | PHY_OPT_WCID) -#define PHY_MAX_SIZE 8 +#define PHY_MAX_SIZE 9 #ifndef ENABLE_EMULATION extern int phy_serialize_data(const phy_data_t *phy, uint8_t *data, uint16_t *len); diff --git a/src/main.c b/src/main.c index 541dbeb..47f0de6 100644 --- a/src/main.c +++ b/src/main.c @@ -99,7 +99,6 @@ bool is_req_button_pending() { return req_button_pending; } -uint32_t button_timeout = 15000; bool cancel_button = false; #ifdef ENABLE_EMULATION @@ -182,6 +181,13 @@ bool button_pressed_state = false; uint32_t button_pressed_time = 0; uint8_t button_press = 0; bool wait_button() { + uint32_t button_timeout = 15000; + if (phy_data.up_btn_present) { + button_timeout = phy_data.up_btn * 1000; + if (button_timeout == 0) { + return false; + } + } uint32_t start_button = board_millis(); bool timeout = false; cancel_button = false;