Class: Tinkerforge::BrickletAnalogOutV2
- Defined in:
- lib/tinkerforge/bricklet_analog_out_v2.rb
Overview
Generates configurable DC voltage between 0V and 12V
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
256
- DEVICE_DISPLAY_NAME =
:nodoc:
'Analog Out Bricklet 2.0'
- FUNCTION_SET_OUTPUT_VOLTAGE =
:nodoc:
1
- FUNCTION_GET_OUTPUT_VOLTAGE =
:nodoc:
2
- FUNCTION_GET_INPUT_VOLTAGE =
:nodoc:
3
- 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_input_voltage ⇒ Object
Returns the input voltage.
-
#get_output_voltage ⇒ Object
Returns the voltage as set by BrickletAnalogOutV2#set_output_voltage.
-
#initialize(uid, ipcon) ⇒ BrickletAnalogOutV2
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. -
#set_output_voltage(voltage) ⇒ Object
Sets the voltage.
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) ⇒ BrickletAnalogOutV2
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tinkerforge/bricklet_analog_out_v2.rb', line 28 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 0] @response_expected[FUNCTION_SET_OUTPUT_VOLTAGE] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_OUTPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_INPUT_VOLTAGE] = 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|
73 74 75 |
# File 'lib/tinkerforge/bricklet_analog_out_v2.rb', line 73 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_input_voltage ⇒ Object
Returns the input voltage.
57 58 59 60 61 |
# File 'lib/tinkerforge/bricklet_analog_out_v2.rb', line 57 def get_input_voltage check_validity send_request FUNCTION_GET_INPUT_VOLTAGE, [], '', 10, 'S' end |
#get_output_voltage ⇒ Object
Returns the voltage as set by BrickletAnalogOutV2#set_output_voltage.
50 51 52 53 54 |
# File 'lib/tinkerforge/bricklet_analog_out_v2.rb', line 50 def get_output_voltage check_validity send_request FUNCTION_GET_OUTPUT_VOLTAGE, [], '', 10, 'S' end |
#set_output_voltage(voltage) ⇒ Object
Sets the voltage.
43 44 45 46 47 |
# File 'lib/tinkerforge/bricklet_analog_out_v2.rb', line 43 def set_output_voltage(voltage) check_validity send_request FUNCTION_SET_OUTPUT_VOLTAGE, [voltage], 'S', 8, '' end |