Browse Source

Added toggle and removed a param

xmkb
Mega Mind 4 years ago
parent
commit
5d1c083959
  1. 11
      app/include/dt-bindings/zmk/ext_power.h
  2. 5
      app/src/behaviors/behavior_ext_power.c

11
app/include/dt-bindings/zmk/ext_power.h

@ -6,11 +6,8 @@ @@ -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

5
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 @@ -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);
}

Loading…
Cancel
Save