-
Notifications
You must be signed in to change notification settings - Fork 0
/
rf_controller.rb
40 lines (33 loc) · 950 Bytes
/
rf_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require "yaml"
require "pi_piper"
include PiPiper
class RFController
def initialize
@ledOut = PiPiper::Pin.new(pin: 4, direction: :out)
@signals = YAML.load_file("signals.yml")
@outlets = {}
@signals.each do |a, b|
@outlets[a] = {}
b.each { |c, d| @outlets[a][c] = "off" }
end
end
def flashLED
@ledOut.on
sleep 0.25
@ledOut.off
end
def sigOut(area, name)
return if @outlets[area].nil? || @outlets[area][name].nil?
which = @outlets[area][name] == "on" ?
@signals[area][name]["off"] :
@signals[area][name]["on"]
system("./codesend #{which} 0 175")
code = $?.exitstatus
if code == 0
self.flashLED
@outlets[area][name] == "on" ?
@outlets[area][name] = "off" :
@outlets[area][name] = "on"
end
end
end