Class: Pixo::Renderer

Inherits:
Pixo::Rpc::Service show all
Defined in:
lib/pixo/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Pixo::Rpc::Service

#live_request_count, #request, #run, #shutdown

Constructor Details

#initialize(fullscreen = false) ⇒ Renderer



5
6
7
8
9
# File 'lib/pixo/renderer.rb', line 5

def initialize(fullscreen = false)
  i, o, t = Open3.popen2("bundle exec pixo #{'--fullscreen' if fullscreen}")
  super(o, i)
  @service_thread = Thread.new { self.run }
end

Instance Attribute Details

#service_threadObject (readonly)

Returns the value of attribute service_thread.



3
4
5
# File 'lib/pixo/renderer.rb', line 3

def service_thread
  @service_thread
end

Instance Method Details

#add_fadecandy(hostname, count) ⇒ Object



51
52
53
# File 'lib/pixo/renderer.rb', line 51

def add_fadecandy(hostname, count)
  request(Pixo::Rpc::AddFadecandy.new(hostname, count))
end

#add_pattern(name, code) ⇒ Object



47
48
49
# File 'lib/pixo/renderer.rb', line 47

def add_pattern(name, code)
  request(Pixo::Rpc::AddPattern.new(name, code))
end

#brightnessObject



35
36
37
# File 'lib/pixo/renderer.rb', line 35

def brightness
  request(Pixo::Rpc::GetBrightness.new())
end

#brightness=(brightness) ⇒ Object



31
32
33
# File 'lib/pixo/renderer.rb', line 31

def brightness=(brightness)
  request(Pixo::Rpc::SetBrightness.new(brightness))
end

#leds_onObject



43
44
45
# File 'lib/pixo/renderer.rb', line 43

def leds_on
  request(Pixo::Rpc::GetLedsOn.new())
end

#leds_on=(leds_on) ⇒ Object



39
40
41
# File 'lib/pixo/renderer.rb', line 39

def leds_on=(leds_on)
  request(Pixo::Rpc::SetLedsOn.new(leds_on))
end

#list_patternsObject



19
20
21
# File 'lib/pixo/renderer.rb', line 19

def list_patterns
  request(Pixo::Rpc::ListPatterns.new)
end

#on_key(key, scancode, action, mods) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/pixo/renderer.rb', line 11

def on_key(key, scancode, action, mods)
  if (action == 0)
    self.pattern = self.list_patterns.sample
    return true
  end
  return false
end

#patternObject



23
24
25
# File 'lib/pixo/renderer.rb', line 23

def pattern
  request(Pixo::Rpc::GetPattern.new)
end

#pattern=(name) ⇒ Object



27
28
29
# File 'lib/pixo/renderer.rb', line 27

def pattern=(name)
  request(Pixo::Rpc::SetPattern.new(name))
end