Added toggle and removed a param
This commit is contained in:
parent
b5e1c8a7ad
commit
5d1c083959
2 changed files with 9 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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…
Reference in a new issue