Class: Tinkerforge::BrickletRGBLEDV2

Inherits:
Object
  • Object
show all
Defined in:
lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb

Instance Method Summary collapse

Instance Method Details

#blackoutObject

Switches off the LED.



18
19
20
21
# File 'lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb', line 18

def blackout
  self.rgb = 0, 0, 0
  true
end

#rgbObject

Returns the LED’s current color as three values for red, green, and blue (integers in the range 0..255).



6
7
8
# File 'lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb', line 6

def rgb
  get_rgb_value
end

#rgb=(*rgb) ⇒ Object

Sets the LED’s color using three values for red, green, and blue (integers in the range 0..255).

Values can be supplied as an array or as three separate values.



13
14
15
# File 'lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb', line 13

def rgb=(*rgb)
  set_rgb_value *rgb.flatten
end

#stateObject

Returns the device’s state.



24
25
26
27
28
# File 'lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb', line 24

def state
  super.merge(
    'color_rgb' => get_rgb_value,
  )
end