Added toggle and removed a param

This commit is contained in:
Mega Mind 2020-10-12 00:30:51 +08:00
parent b5e1c8a7ad
commit 5d1c083959
2 changed files with 9 additions and 7 deletions

View file

@ -6,11 +6,8 @@
#define EXT_POWER_OFF_CMD 0 #define EXT_POWER_OFF_CMD 0
#define EXT_POWER_ON_CMD 1 #define EXT_POWER_ON_CMD 1
#define EXT_POWER_TOGGLE_CMD 2
/* #define EP_ON EXT_POWER_ON_CMD
* Note: Some future commands might include additional parameters, so we #define EP_OFF EXT_POWER_OFF_CMD
* defines these aliases up front. #define EP_TOG EXT_POWER_TOGGLE_CMD
*/
#define EP_ON EXT_POWER_ON_CMD 0
#define EP_OFF EXT_POWER_OFF_CMD 0

View file

@ -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); return ext_power_api->disable(ext_power);
case EXT_POWER_ON_CMD: case EXT_POWER_ON_CMD:
return ext_power_api->enable(ext_power); 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: default:
LOG_ERR("Unknown ext_power command: %d", command); LOG_ERR("Unknown ext_power command: %d", command);
} }