aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-06-27 11:54:45 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-06-27 12:10:39 -0400
commit06ef60011e548f9734a83244f1038e90f353c50d (patch)
treefafdd638114169c8b0844fe1b8c5685b0305dd58
parent7aec52dfb3743850935d1080e045339c4a766231 (diff)
downloadkutter-06ef60011e548f9734a83244f1038e90f353c50d.tar.gz
kutter-06ef60011e548f9734a83244f1038e90f353c50d.tar.xz
kutter-06ef60011e548f9734a83244f1038e90f353c50d.zip
gpiocmds: Add update_digital_out command
Add a command that can immediately set the value of a digital output pin created with config_digital_out. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/gpiocmds.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gpiocmds.c b/src/gpiocmds.c
index cc221fc3..105d9d88 100644
--- a/src/gpiocmds.c
+++ b/src/gpiocmds.c
@@ -69,6 +69,21 @@ DECL_COMMAND(command_schedule_digital_out,
"schedule_digital_out oid=%c clock=%u value=%c");
void
+command_update_digital_out(uint32_t *args)
+{
+ struct digital_out_s *d = oid_lookup(args[0], command_config_digital_out);
+ sched_del_timer(&d->timer);
+ uint8_t value = args[1];
+ gpio_out_write(d->pin, value);
+ if (value != d->default_value && d->max_duration) {
+ d->timer.waketime = timer_read_time() + d->max_duration;
+ d->timer.func = digital_end_event;
+ sched_add_timer(&d->timer);
+ }
+}
+DECL_COMMAND(command_update_digital_out, "update_digital_out oid=%c value=%c");
+
+void
digital_out_shutdown(void)
{
uint8_t i;