Module: Z4box
- Defined in:
- lib/z4box.rb,
lib/z4box/version.rb
Defined Under Namespace
Modules: BT Classes: Box, Error, Iot
Constant Summary collapse
- IOT_DEFAULTS =
default led theme.
{ :fg=>"purple", :bg=>"green", :gl=>"gold", :fps=>60, :fade=>10, :glitter=>0, :rainbow=>1, :fwd=>1, :rev=>0, :mono=>0, :mirror=>1, :rpt=>0 }
- DEV =
lambda { |*i| Dir['/dev/ttyUSB*'].each { |e| [i].flatten.each { |ee| Iot.new(e) << ERB.new(%[#{ee}]).result(binding) } } }
- VERSION =
"0.1.2"
- COMMIT =
`git log --format="%H" -n 1`.strip
- @@BOX =
Hash.new { |h,k| h[k] = Box.new(k) }
- @@TUNNEL =
NgrokAPI::Client.new(api_key: ENV['Z4_NGROK_KEY'])
- @@VLC =
VLC::Client.new('127.0.0.1', 9595)
Class Method Summary collapse
-
.<<(i) ⇒ Object
push input to all connected devices.
-
.box ⇒ Object
ssh to other z4 instances.
-
.leds(h = {}) ⇒ Object
push led theme to all connected devices.
-
.ok! ⇒ Object
push soft reset to all connected devices.
-
.tunnel ⇒ Object
inbounnd access.
-
.vlc(*p) ⇒ Object
add items to playlist.
Class Method Details
.<<(i) ⇒ Object
push input to all connected devices.
130 131 132 |
# File 'lib/z4box.rb', line 130 def self.<< i DEV.call(i) end |
.box ⇒ Object
ssh to other z4 instances.
74 75 76 |
# File 'lib/z4box.rb', line 74 def self.box @@BOX end |
.leds(h = {}) ⇒ Object
push led theme to all connected devices.
118 119 120 121 122 123 124 125 126 |
# File 'lib/z4box.rb', line 118 def self.leds h={} hh = IOT_DEFAULTS.merge(h) i = [ %[theme(#{hh[:fg]},#{hh[:bg]},#{hh[:gl]});], %[leds(#{hh[:fps].to_i},#{hh[:fade].to_i},#{hh[:glitter].to_i},#{hh[:rainbow].to_i});], %[pattern(#{hh[:fwd].to_i},#{hh[:rev].to_i},#{hh[:mono].to_i},#{hh[:mirror].to_i},#{hh[:rpt].to_i});] ].join(" ") DEV.call(i) end |
.ok! ⇒ Object
push soft reset to all connected devices.
112 113 114 |
# File 'lib/z4box.rb', line 112 def self.ok! DEV.call(%[ok();]) end |
.tunnel ⇒ Object
inbounnd access
82 83 84 |
# File 'lib/z4box.rb', line 82 def self.tunnel @@TUNNEL end |
.vlc(*p) ⇒ Object
add items to playlist.
170 171 172 173 174 175 |
# File 'lib/z4box.rb', line 170 def self.vlc *p if p.length > 0 [p].flatten.each { |e| @@VLC.add_to_playlist(e) } end @@VLC end |