Class: Tinkerforge::BrickletRGBLEDButton

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

Instance Method Summary collapse

Instance Method Details

#blackoutObject

Switches off the button’s LED.



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

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

#rgbObject

Returns the button’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_button/bricklet_rgb_led_button.rb', line 6

def rgb
  get_color
end

#rgb=(*rgb) ⇒ Object

Sets the button’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_button/bricklet_rgb_led_button.rb', line 13

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

#stateObject

Returns the device’s state.



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

def state
  super.merge(
    'color_rgb'         => get_color,
    'color_calibration' => get_color_calibration,
    'pressed'           => get_button_state == 0,
  )
end