Class: Tinkerforge::BrickletRGBLED
- Defined in:
- lib/tinkerforge/bricklet_rgb_led.rb
Overview
Controls one RGB LED
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
271
- DEVICE_DISPLAY_NAME =
:nodoc:
'RGB LED Bricklet'
- FUNCTION_SET_RGB_VALUE =
:nodoc:
1
- FUNCTION_GET_RGB_VALUE =
:nodoc:
2
- FUNCTION_GET_IDENTITY =
:nodoc:
255
Constants inherited from Device
Device::DEVICE_IDENTIFIER_CHECK_MATCH, Device::DEVICE_IDENTIFIER_CHECK_MISMATCH, Device::DEVICE_IDENTIFIER_CHECK_PENDING, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #high_level_callbacks, #registered_callbacks, #replaced, #uid
Instance Method Summary collapse
-
#get_identity ⇒ Object
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
-
#get_rgb_value ⇒ Object
Returns the r, g and b values of the LED as set by BrickletRGBLED#set_rgb_value.
-
#initialize(uid, ipcon) ⇒ BrickletRGBLED
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. -
#set_rgb_value(r, g, b) ⇒ Object
Sets the r, g and b values for the LED.
Methods inherited from Device
#check_validity, #dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickletRGBLED
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tinkerforge/bricklet_rgb_led.rb', line 27 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 |
Instance Method Details
#get_identity ⇒ Object
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|
64 65 66 |
# File 'lib/tinkerforge/bricklet_rgb_led.rb', line 64 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_rgb_value ⇒ Object
Returns the r, g and b values of the LED as set by BrickletRGBLED#set_rgb_value.
48 49 50 51 52 |
# File 'lib/tinkerforge/bricklet_rgb_led.rb', line 48 def get_rgb_value check_validity send_request FUNCTION_GET_RGB_VALUE, [], '', 11, 'C C C' end |
#set_rgb_value(r, g, b) ⇒ Object
Sets the r, g and b values for the LED.
41 42 43 44 45 |
# File 'lib/tinkerforge/bricklet_rgb_led.rb', line 41 def set_rgb_value(r, g, b) check_validity send_request FUNCTION_SET_RGB_VALUE, [r, g, b], 'C C C', 8, '' end |