Fix compilation errors and minor tweaks

This commit is contained in:
Mega Mind 2020-10-13 00:09:57 +08:00
parent 4adcb396ff
commit 2e649b7fd4
3 changed files with 7 additions and 5 deletions

View file

@ -3,7 +3,7 @@
ext_power: behavior_ext_power { ext_power: behavior_ext_power {
compatible = "zmk,behavior-ext-power"; compatible = "zmk,behavior-ext-power";
label = "EXT_POWER_BEHAVIOR"; label = "EXT_POWER_BEHAVIOR";
#binding-cells = <2>; #binding-cells = <1>;
}; };
}; };
}; };

View file

@ -7,4 +7,4 @@ description: External power control Behavior
compatible: "zmk,behavior-ext-power" compatible: "zmk,behavior-ext-power"
include: two_param.yaml include: one_param.yaml

View file

@ -11,14 +11,16 @@
#include <drivers/behavior.h> #include <drivers/behavior.h>
#include <drivers/ext_power.h> #include <drivers/ext_power.h>
#include <dt-bindings/zmk/ext_power.h>
#include <logging/log.h> #include <logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) { struct zmk_behavior_binding_event event) {
const struct device *ext_power = device_get_binding("EXT_POWER"); struct device *ext_power = device_get_binding("EXT_POWER");
if (ext_power == NULL) { if (ext_power == NULL) {
LOG_ERR("Unable to retrieve ext_power device: %d", command); LOG_ERR("Unable to retrieve ext_power device: %d", binding->param1);
return -EIO; return -EIO;
} }
@ -33,7 +35,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
else else
return ext_power_enable(ext_power); return ext_power_enable(ext_power);
default: default:
LOG_ERR("Unknown ext_power command: %d", command); LOG_ERR("Unknown ext_power command: %d", binding->param1);
} }
return -ENOTSUP; return -ENOTSUP;