class Tinkerforge::BrickletRGBLED
Controls one RGB LED
Public Class Methods
new(uid, ipcon)
click to toggle source
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
Calls superclass method
# File lib/tinkerforge/bricklet_rgb_led.rb, line 26 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 0] @response_expected[FUNCTION_SET_RGB_VALUE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_RGB_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @ipcon.add_device self end
Public Instance Methods
get_identity()
click to toggle source
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
# File lib/tinkerforge/bricklet_rgb_led.rb, line 63 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end
get_rgb_value()
click to toggle source
Returns the r, g and b values of the LED as set by BrickletRGBLED#set_rgb_value
.
# File lib/tinkerforge/bricklet_rgb_led.rb, line 47 def get_rgb_value check_validity send_request FUNCTION_GET_RGB_VALUE, [], '', 11, 'C C C' end
set_rgb_value(r, g, b)
click to toggle source
Sets the r, g and b values for the LED.
# File lib/tinkerforge/bricklet_rgb_led.rb, line 40 def set_rgb_value(r, g, b) check_validity send_request FUNCTION_SET_RGB_VALUE, [r, g, b], 'C C C', 8, '' end