mirror of
https://github.com/andreili/klipper.git
synced 2025-08-24 03:44:06 +02:00
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>
This commit is contained in:
parent
7aec52dfb3
commit
06ef60011e
@ -68,6 +68,21 @@ command_schedule_digital_out(uint32_t *args)
|
|||||||
DECL_COMMAND(command_schedule_digital_out,
|
DECL_COMMAND(command_schedule_digital_out,
|
||||||
"schedule_digital_out oid=%c clock=%u value=%c");
|
"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
|
void
|
||||||
digital_out_shutdown(void)
|
digital_out_shutdown(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user