Class: Milight::RgbwAll

Inherits:
Object
  • Object
show all
Defined in:
lib/milight/rgbw_all.rb

Constant Summary collapse

ALL_OFF =
0x41
ALL_ON =
0x42
WHITE =
0xC2
COLOUR =
0x40
BRIGHTNESS =
0x4E

Instance Method Summary collapse

Constructor Details

#initialize(commander, colour_helper: Milight::Colour) ⇒ RgbwAll

Returns a new instance of RgbwAll.



12
13
14
15
# File 'lib/milight/rgbw_all.rb', line 12

def initialize(commander, colour_helper: Milight::Colour)
  @commander = commander
  @colour_helper = colour_helper
end

Instance Method Details

#brightness(value) ⇒ Object



38
39
40
41
42
# File 'lib/milight/rgbw_all.rb', line 38

def brightness(value)
  brightness = Milight::Brightness.new(value)
  send_brightness_cmd brightness
  self
end

#colour(colour) ⇒ Object



44
45
46
47
48
49
# File 'lib/milight/rgbw_all.rb', line 44

def colour(colour)
  colour_value = @colour_helper.new(colour)
  colour_value.greyscale? ? send_white_cmd : send_colour_cmd(colour_value)
  send_brightness_cmd colour_value
  self
end

#hue(hue) ⇒ Object



32
33
34
35
36
# File 'lib/milight/rgbw_all.rb', line 32

def hue(hue)
  colour = @colour_helper.new(hue)
  send_colour_cmd colour
  self
end

#offObject



22
23
24
25
# File 'lib/milight/rgbw_all.rb', line 22

def off
  @commander.send_command ALL_OFF
  self
end

#onObject



17
18
19
20
# File 'lib/milight/rgbw_all.rb', line 17

def on
  @commander.send_command ALL_ON
  self
end

#whiteObject



27
28
29
30
# File 'lib/milight/rgbw_all.rb', line 27

def white
  send_white_cmd
  self
end