diff --git a/app/include/dt-bindings/zmk/ext_power.h b/app/include/dt-bindings/zmk/ext_power.h index a72b6571..2a3e8460 100644 --- a/app/include/dt-bindings/zmk/ext_power.h +++ b/app/include/dt-bindings/zmk/ext_power.h @@ -6,11 +6,8 @@ #define EXT_POWER_OFF_CMD 0 #define EXT_POWER_ON_CMD 1 +#define EXT_POWER_TOGGLE_CMD 2 -/* - * Note: Some future commands might include additional parameters, so we - * defines these aliases up front. - */ - -#define EP_ON EXT_POWER_ON_CMD 0 -#define EP_OFF EXT_POWER_OFF_CMD 0 +#define EP_ON EXT_POWER_ON_CMD +#define EP_OFF EXT_POWER_OFF_CMD +#define EP_TOG EXT_POWER_TOGGLE_CMD diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index 2bd93ee0..7f06e1dd 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -30,6 +30,11 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c return ext_power_api->disable(ext_power); case EXT_POWER_ON_CMD: return ext_power_api->enable(ext_power); + case EXT_POWER_TOGGLE_CMD: + if(ext_power_api->get(ext_power) > 0) + return ext_power_api->disable(ext_power); + else + return ext_power_api->enable(ext_power); default: LOG_ERR("Unknown ext_power command: %d", command); }