Skip to content

Commit

Permalink
fix(interface electrical relay): changes requested from review
Browse files Browse the repository at this point in the history
sorry @kimburgess merged accidentally
  • Loading branch information
stakach committed Apr 26, 2021
1 parent 63b80bc commit 82d85d0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/placeos-driver/interface/electrical_relay.cr
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
abstract class PlaceOS::Driver; end

module PlaceOS::Driver::Interface::ElectricalRelay
# `**options` here should be passed to the `task` to allow for different priorities
abstract def relay(state : Bool, index : Int32 = 0, **options)

def pulse(period : Float64 = 1.0, index : Int32 = 0, times : Int32 = 1, initial_state = false)
def pulse(period : Int32 = 1000, index : Int32 = 0, times : Int32 = 1, initial_state = false)
queue(name: "pulse_#{index}") do |task|
# higher pririty so these commands run next once added to the queue
priority = queue.priority + 25
period = pause_for.seconds
pause_for = period.milliseconds

times.times do
relay(!initial_state, index, delay: period, priority: priority)
relay(initial_state, index, delay: period, priority: priority)
relay(!initial_state, index, delay: pause_for, priority: priority)
relay(initial_state, index, delay: pause_for, priority: priority)
end
task.success
end
Expand Down

0 comments on commit 82d85d0

Please sign in to comment.