diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-10-11 22:50:29 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-10-12 11:59:27 -0400 |
commit | db97f3663168a138461d5b693aa285b67a0193d5 (patch) | |
tree | eb50cf6fce088c73518b97090e0b955bfb84cddc /src/gpiocmds.c | |
parent | d03cf2b83f9df6b802af72860d8d3b56df89956f (diff) | |
download | kutter-db97f3663168a138461d5b693aa285b67a0193d5.tar.gz kutter-db97f3663168a138461d5b693aa285b67a0193d5.tar.xz kutter-db97f3663168a138461d5b693aa285b67a0193d5.zip |
gpiocmds: Allow the start value for a pin to differ from the default_value
Allow the start value to be different from the default/shutdown value
for the pin. This will be useful for "heater fans" that should
startup in the off state, and transition to full on in a shutdown
state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/gpiocmds.c')
-rw-r--r-- | src/gpiocmds.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gpiocmds.c b/src/gpiocmds.c index 69f60f97..52e3d8d5 100644 --- a/src/gpiocmds.c +++ b/src/gpiocmds.c @@ -44,14 +44,15 @@ digital_out_event(struct timer *timer) void command_config_digital_out(uint32_t *args) { + struct gpio_out pin = gpio_out_setup(args[1], args[2]); struct digital_out_s *d = oid_alloc(args[0], command_config_digital_out , sizeof(*d)); - d->default_value = args[2]; - d->pin = gpio_out_setup(args[1], d->default_value); - d->max_duration = args[3]; + d->pin = pin; + d->default_value = args[3]; + d->max_duration = args[4]; } DECL_COMMAND(command_config_digital_out, - "config_digital_out oid=%c pin=%u default_value=%c" + "config_digital_out oid=%c pin=%u value=%c default_value=%c" " max_duration=%u"); void @@ -159,17 +160,18 @@ soft_pwm_load_event(struct timer *timer) void command_config_soft_pwm_out(uint32_t *args) { + struct gpio_out pin = gpio_out_setup(args[1], !!args[3]); struct soft_pwm_s *s = oid_alloc(args[0], command_config_soft_pwm_out , sizeof(*s)); + s->pin = pin; s->cycle_time = args[2]; - s->default_value = !!args[3]; - s->max_duration = args[4]; + s->default_value = !!args[4]; + s->max_duration = args[5]; s->flags = s->default_value ? SPF_ON : 0; - s->pin = gpio_out_setup(args[1], s->default_value); } DECL_COMMAND(command_config_soft_pwm_out, - "config_soft_pwm_out oid=%c pin=%u cycle_ticks=%u default_value=%c" - " max_duration=%u"); + "config_soft_pwm_out oid=%c pin=%u cycle_ticks=%u value=%c" + " default_value=%c max_duration=%u"); void command_schedule_soft_pwm_out(uint32_t *args) |