tinkerforge 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tinkerforge/brick_dc.rb +42 -4
- data/lib/tinkerforge/brick_imu.rb +49 -11
- data/lib/tinkerforge/brick_imu_v2.rb +506 -0
- data/lib/tinkerforge/brick_master.rb +86 -46
- data/lib/tinkerforge/brick_red.rb +36 -5
- data/lib/tinkerforge/brick_servo.rb +53 -15
- data/lib/tinkerforge/brick_stepper.rb +43 -14
- data/lib/tinkerforge/bricklet_accelerometer.rb +229 -0
- data/lib/tinkerforge/bricklet_ambient_light.rb +10 -9
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +216 -0
- data/lib/tinkerforge/bricklet_analog_in.rb +13 -12
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +259 -0
- data/lib/tinkerforge/bricklet_analog_out.rb +5 -4
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +66 -0
- data/lib/tinkerforge/bricklet_barometer.rb +11 -9
- data/lib/tinkerforge/bricklet_color.rb +11 -9
- data/lib/tinkerforge/bricklet_current12.rb +5 -4
- data/lib/tinkerforge/bricklet_current25.rb +5 -4
- data/lib/tinkerforge/bricklet_distance_ir.rb +8 -7
- data/lib/tinkerforge/bricklet_distance_us.rb +9 -8
- data/lib/tinkerforge/bricklet_dual_button.rb +5 -4
- data/lib/tinkerforge/bricklet_dual_relay.rb +5 -4
- data/lib/tinkerforge/bricklet_dust_detector.rb +178 -0
- data/lib/tinkerforge/bricklet_gps.rb +6 -5
- data/lib/tinkerforge/bricklet_hall_effect.rb +5 -4
- data/lib/tinkerforge/bricklet_humidity.rb +8 -7
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +137 -0
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +8 -7
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +5 -4
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +6 -5
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +209 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +5 -4
- data/lib/tinkerforge/bricklet_io16.rb +8 -7
- data/lib/tinkerforge/bricklet_io4.rb +8 -7
- data/lib/tinkerforge/bricklet_joystick.rb +5 -4
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +324 -0
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +7 -6
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +11 -10
- data/lib/tinkerforge/bricklet_led_strip.rb +12 -10
- data/lib/tinkerforge/bricklet_line.rb +5 -4
- data/lib/tinkerforge/bricklet_linear_poti.rb +8 -7
- data/lib/tinkerforge/bricklet_load_cell.rb +261 -0
- data/lib/tinkerforge/bricklet_moisture.rb +6 -5
- data/lib/tinkerforge/bricklet_motion_detector.rb +5 -4
- data/lib/tinkerforge/bricklet_multi_touch.rb +5 -4
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +38 -46
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +5 -4
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +6 -5
- data/lib/tinkerforge/bricklet_ptc.rb +5 -4
- data/lib/tinkerforge/bricklet_remote_switch.rb +9 -8
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +5 -4
- data/lib/tinkerforge/bricklet_rotary_poti.rb +5 -4
- data/lib/tinkerforge/bricklet_rs232.rb +183 -0
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +8 -5
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +5 -4
- data/lib/tinkerforge/bricklet_sound_intensity.rb +6 -5
- data/lib/tinkerforge/bricklet_temperature.rb +7 -6
- data/lib/tinkerforge/bricklet_temperature_ir.rb +7 -6
- data/lib/tinkerforge/bricklet_tilt.rb +5 -4
- data/lib/tinkerforge/bricklet_voltage.rb +8 -7
- data/lib/tinkerforge/bricklet_voltage_current.rb +5 -4
- data/lib/tinkerforge/version.rb +1 -1
- metadata +13 -2
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.6 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
|
-
# to the
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
12
|
module Tinkerforge
|
13
|
-
#
|
13
|
+
# Determine position, velocity and altitude using GPS
|
14
14
|
class BrickletGPS < Device
|
15
15
|
DEVICE_IDENTIFIER = 222 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'GPS Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered periodically with the period that is set by
|
18
19
|
# BrickletGPS#set_coordinates_callback_period. The parameters are the same
|
@@ -129,7 +130,7 @@ module Tinkerforge
|
|
129
130
|
# PDOP, HDOP and VDOP are the dilution of precision (DOP) values. They specify
|
130
131
|
# the additional multiplicative effect of GPS satellite geometry on GPS
|
131
132
|
# precision. See
|
132
|
-
# `here <
|
133
|
+
# `here <https://en.wikipedia.org/wiki/Dilution_of_precision_(GPS)>`__
|
133
134
|
# for more information. The values are give in hundredths.
|
134
135
|
#
|
135
136
|
# EPE is the "Estimated Position Error". The EPE is given in cm. This is not the
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.6 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
|
-
# to the
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
12
|
module Tinkerforge
|
13
|
-
#
|
13
|
+
# Detects presence of magnetic field
|
14
14
|
class BrickletHallEffect < Device
|
15
15
|
DEVICE_IDENTIFIER = 240 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Hall Effect Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered periodically with the period that is set by
|
18
19
|
# BrickletHallEffect#set_edge_count_callback_period. The parameters are the
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.6 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
|
-
# to the
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
12
|
module Tinkerforge
|
13
|
-
#
|
13
|
+
# Measures relative humidity
|
14
14
|
class BrickletHumidity < Device
|
15
15
|
DEVICE_IDENTIFIER = 27 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Humidity Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered periodically with the period that is set by
|
18
19
|
# BrickletHumidity#set_humidity_callback_period. The parameter is the humidity of the
|
@@ -71,7 +72,7 @@ module Tinkerforge
|
|
71
72
|
def initialize(uid, ipcon)
|
72
73
|
super uid, ipcon
|
73
74
|
|
74
|
-
@api_version = [2, 0,
|
75
|
+
@api_version = [2, 0, 1]
|
75
76
|
|
76
77
|
@response_expected[FUNCTION_GET_HUMIDITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
77
78
|
@response_expected[FUNCTION_GET_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -173,12 +174,12 @@ module Tinkerforge
|
|
173
174
|
#
|
174
175
|
# The default value is ('x', 0, 0).
|
175
176
|
def set_humidity_callback_threshold(option, min, max)
|
176
|
-
send_request(FUNCTION_SET_HUMIDITY_CALLBACK_THRESHOLD, [option, min, max], 'k
|
177
|
+
send_request(FUNCTION_SET_HUMIDITY_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
177
178
|
end
|
178
179
|
|
179
180
|
# Returns the threshold as set by BrickletHumidity#set_humidity_callback_threshold.
|
180
181
|
def get_humidity_callback_threshold
|
181
|
-
send_request(FUNCTION_GET_HUMIDITY_CALLBACK_THRESHOLD, [], '', 5, 'k
|
182
|
+
send_request(FUNCTION_GET_HUMIDITY_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
182
183
|
end
|
183
184
|
|
184
185
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.1.6 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Generates configurable DC voltage and current, 0V to 10V and 4mA to 20mA
|
14
|
+
class BrickletIndustrialAnalogOut < Device
|
15
|
+
DEVICE_IDENTIFIER = 258 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Analog Out Bricklet' # :nodoc:
|
17
|
+
|
18
|
+
FUNCTION_ENABLE = 1 # :nodoc:
|
19
|
+
FUNCTION_DISABLE = 2 # :nodoc:
|
20
|
+
FUNCTION_IS_ENABLED = 3 # :nodoc:
|
21
|
+
FUNCTION_SET_VOLTAGE = 4 # :nodoc:
|
22
|
+
FUNCTION_GET_VOLTAGE = 5 # :nodoc:
|
23
|
+
FUNCTION_SET_CURRENT = 6 # :nodoc:
|
24
|
+
FUNCTION_GET_CURRENT = 7 # :nodoc:
|
25
|
+
FUNCTION_SET_CONFIGURATION = 8 # :nodoc:
|
26
|
+
FUNCTION_GET_CONFIGURATION = 9 # :nodoc:
|
27
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
28
|
+
|
29
|
+
VOLTAGE_RANGE_0_TO_5V = 0 # :nodoc:
|
30
|
+
VOLTAGE_RANGE_0_TO_10V = 1 # :nodoc:
|
31
|
+
CURRENT_RANGE_4_TO_20MA = 0 # :nodoc:
|
32
|
+
CURRENT_RANGE_0_TO_20MA = 1 # :nodoc:
|
33
|
+
CURRENT_RANGE_0_TO_24MA = 2 # :nodoc:
|
34
|
+
|
35
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
36
|
+
# the IP Connection <tt>ipcon</tt>.
|
37
|
+
def initialize(uid, ipcon)
|
38
|
+
super uid, ipcon
|
39
|
+
|
40
|
+
@api_version = [2, 0, 0]
|
41
|
+
|
42
|
+
@response_expected[FUNCTION_ENABLE] = RESPONSE_EXPECTED_FALSE
|
43
|
+
@response_expected[FUNCTION_DISABLE] = RESPONSE_EXPECTED_FALSE
|
44
|
+
@response_expected[FUNCTION_IS_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
45
|
+
@response_expected[FUNCTION_SET_VOLTAGE] = RESPONSE_EXPECTED_FALSE
|
46
|
+
@response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
47
|
+
@response_expected[FUNCTION_SET_CURRENT] = RESPONSE_EXPECTED_FALSE
|
48
|
+
@response_expected[FUNCTION_GET_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
49
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
50
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
51
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# Enables the output of voltage and current.
|
56
|
+
#
|
57
|
+
# The default is disabled.
|
58
|
+
def enable
|
59
|
+
send_request(FUNCTION_ENABLE, [], '', 0, '')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Disables the output of voltage and current.
|
63
|
+
#
|
64
|
+
# The default is disabled.
|
65
|
+
def disable
|
66
|
+
send_request(FUNCTION_DISABLE, [], '', 0, '')
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns *true* if output of voltage and current is enabled, *false* otherwise.
|
70
|
+
def is_enabled
|
71
|
+
send_request(FUNCTION_IS_ENABLED, [], '', 1, '?')
|
72
|
+
end
|
73
|
+
|
74
|
+
# Sets the output voltage in mV.
|
75
|
+
#
|
76
|
+
# The output voltage and output current are linked. Changing the output voltage
|
77
|
+
# also changes the output current.
|
78
|
+
def set_voltage(voltage)
|
79
|
+
send_request(FUNCTION_SET_VOLTAGE, [voltage], 'S', 0, '')
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns the voltage as set by BrickletIndustrialAnalogOut#set_voltage.
|
83
|
+
def get_voltage
|
84
|
+
send_request(FUNCTION_GET_VOLTAGE, [], '', 2, 'S')
|
85
|
+
end
|
86
|
+
|
87
|
+
# Sets the output current in µA.
|
88
|
+
#
|
89
|
+
# The output current and output voltage are linked. Changing the output current
|
90
|
+
# also changes the output voltage.
|
91
|
+
def set_current(current)
|
92
|
+
send_request(FUNCTION_SET_CURRENT, [current], 'S', 0, '')
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns the current as set by BrickletIndustrialAnalogOut#set_current.
|
96
|
+
def get_current
|
97
|
+
send_request(FUNCTION_GET_CURRENT, [], '', 2, 'S')
|
98
|
+
end
|
99
|
+
|
100
|
+
# Configures the voltage and current range.
|
101
|
+
#
|
102
|
+
# Possible voltage ranges are:
|
103
|
+
#
|
104
|
+
# * 0V to 5V
|
105
|
+
# * 0V to 10V (default)
|
106
|
+
#
|
107
|
+
# Possible current ranges are:
|
108
|
+
#
|
109
|
+
# * 4mA to 20mA (default)
|
110
|
+
# * 0mA to 20mA
|
111
|
+
# * 0mA to 24mA
|
112
|
+
#
|
113
|
+
# The resolution will always be 12 bit. This means, that the
|
114
|
+
# precision is higher with a smaller range.
|
115
|
+
def set_configuration(voltage_range, current_range)
|
116
|
+
send_request(FUNCTION_SET_CONFIGURATION, [voltage_range, current_range], 'C C', 0, '')
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns the configuration as set by BrickletIndustrialAnalogOut#set_configuration.
|
120
|
+
def get_configuration
|
121
|
+
send_request(FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C')
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
125
|
+
# the position, the hardware and firmware version as well as the
|
126
|
+
# device identifier.
|
127
|
+
#
|
128
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
129
|
+
#
|
130
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
131
|
+
# |device_identifier_constant|
|
132
|
+
def get_identity
|
133
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.6 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
|
-
# to the
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
12
|
module Tinkerforge
|
13
|
-
#
|
13
|
+
# 4 galvanically isolated digital inputs
|
14
14
|
class BrickletIndustrialDigitalIn4 < Device
|
15
15
|
DEVICE_IDENTIFIER = 223 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Digital In 4 Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered whenever a change of the voltage level is detected
|
18
19
|
# on pins where the interrupt was activated with BrickletIndustrialDigitalIn4#set_interrupt.
|
@@ -160,7 +161,7 @@ module Tinkerforge
|
|
160
161
|
# If you set the reset counter to *true*, the count is set back to 0
|
161
162
|
# directly after it is read.
|
162
163
|
#
|
163
|
-
# .. versionadded:: 2.0.1
|
164
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
164
165
|
def get_edge_count(pin, reset_counter)
|
165
166
|
send_request(FUNCTION_GET_EDGE_COUNT, [pin, reset_counter], 'C ?', 4, 'L')
|
166
167
|
end
|
@@ -184,7 +185,7 @@ module Tinkerforge
|
|
184
185
|
#
|
185
186
|
# Default values: 0 (edge type) and 100ms (debounce time)
|
186
187
|
#
|
187
|
-
# .. versionadded:: 2.0.1
|
188
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
188
189
|
def set_edge_count_config(selection_mask, edge_type, debounce)
|
189
190
|
send_request(FUNCTION_SET_EDGE_COUNT_CONFIG, [selection_mask, edge_type, debounce], 'S C C', 0, '')
|
190
191
|
end
|
@@ -192,7 +193,7 @@ module Tinkerforge
|
|
192
193
|
# Returns the edge type and debounce time for the selected pin as set by
|
193
194
|
# BrickletIndustrialDigitalIn4#set_edge_count_config.
|
194
195
|
#
|
195
|
-
# .. versionadded:: 2.0.1
|
196
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
196
197
|
def get_edge_count_config(pin)
|
197
198
|
send_request(FUNCTION_GET_EDGE_COUNT_CONFIG, [pin], 'C', 2, 'C C')
|
198
199
|
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.6 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
|
-
# to the
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
12
|
module Tinkerforge
|
13
|
-
#
|
13
|
+
# 4 galvanically isolated digital outputs
|
14
14
|
class BrickletIndustrialDigitalOut4 < Device
|
15
15
|
DEVICE_IDENTIFIER = 224 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Digital Out 4 Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered whenever a monoflop timer reaches 0. The
|
18
19
|
# parameters contain the involved pins and the current value of the pins
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.6 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
|
-
# to the
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
12
|
module Tinkerforge
|
13
|
-
#
|
13
|
+
# Measures two DC currents between 0mA and 20mA (IEC 60381-1)
|
14
14
|
class BrickletIndustrialDual020mA < Device
|
15
15
|
DEVICE_IDENTIFIER = 228 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Dual 0-20mA Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered periodically with the period that is set by
|
18
19
|
# BrickletIndustrialDual020mA#set_current_callback_period. The parameter is the current of the
|
@@ -161,7 +162,7 @@ module Tinkerforge
|
|
161
162
|
# "2", "15 samples per second, 16 bit resolution"
|
162
163
|
# "3", "4 samples per second, 18 bit resolution"
|
163
164
|
#
|
164
|
-
# The default value is 3
|
165
|
+
# The default value is 3 (4 samples per second with 18 bit resolution).
|
165
166
|
def set_sample_rate(rate)
|
166
167
|
send_request(FUNCTION_SET_SAMPLE_RATE, [rate], 'C', 0, '')
|
167
168
|
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2015-11-17. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.1.6 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Measures two DC voltages between -35V and +35V with 24bit resolution each
|
14
|
+
class BrickletIndustrialDualAnalogIn < Device
|
15
|
+
DEVICE_IDENTIFIER = 249 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Dual Analog In Bricklet' # :nodoc:
|
17
|
+
|
18
|
+
# This callback is triggered periodically with the period that is set by
|
19
|
+
# BrickletIndustrialDualAnalogIn#set_voltage_callback_period. The parameter is the voltage of the
|
20
|
+
# channel.
|
21
|
+
#
|
22
|
+
# CALLBACK_VOLTAGE is only triggered if the voltage has changed since the
|
23
|
+
# last triggering.
|
24
|
+
CALLBACK_VOLTAGE = 13
|
25
|
+
|
26
|
+
# This callback is triggered when the threshold as set by
|
27
|
+
# BrickletIndustrialDualAnalogIn#set_voltage_callback_threshold is reached.
|
28
|
+
# The parameter is the voltage of the channel.
|
29
|
+
#
|
30
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
31
|
+
# with the period as set by BrickletIndustrialDualAnalogIn#set_debounce_period.
|
32
|
+
CALLBACK_VOLTAGE_REACHED = 14
|
33
|
+
|
34
|
+
FUNCTION_GET_VOLTAGE = 1 # :nodoc:
|
35
|
+
FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD = 2 # :nodoc:
|
36
|
+
FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD = 3 # :nodoc:
|
37
|
+
FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD = 4 # :nodoc:
|
38
|
+
FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD = 5 # :nodoc:
|
39
|
+
FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
|
40
|
+
FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
|
41
|
+
FUNCTION_SET_SAMPLE_RATE = 8 # :nodoc:
|
42
|
+
FUNCTION_GET_SAMPLE_RATE = 9 # :nodoc:
|
43
|
+
FUNCTION_SET_CALIBRATION = 10 # :nodoc:
|
44
|
+
FUNCTION_GET_CALIBRATION = 11 # :nodoc:
|
45
|
+
FUNCTION_GET_ADC_VALUES = 12 # :nodoc:
|
46
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
47
|
+
|
48
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
49
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
50
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
51
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
52
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
53
|
+
SAMPLE_RATE_976_SPS = 0 # :nodoc:
|
54
|
+
SAMPLE_RATE_488_SPS = 1 # :nodoc:
|
55
|
+
SAMPLE_RATE_244_SPS = 2 # :nodoc:
|
56
|
+
SAMPLE_RATE_122_SPS = 3 # :nodoc:
|
57
|
+
SAMPLE_RATE_61_SPS = 4 # :nodoc:
|
58
|
+
SAMPLE_RATE_4_SPS = 5 # :nodoc:
|
59
|
+
SAMPLE_RATE_2_SPS = 6 # :nodoc:
|
60
|
+
SAMPLE_RATE_1_SPS = 7 # :nodoc:
|
61
|
+
|
62
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
63
|
+
# the IP Connection <tt>ipcon</tt>.
|
64
|
+
def initialize(uid, ipcon)
|
65
|
+
super uid, ipcon
|
66
|
+
|
67
|
+
@api_version = [2, 0, 0]
|
68
|
+
|
69
|
+
@response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
70
|
+
@response_expected[FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
71
|
+
@response_expected[FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
72
|
+
@response_expected[FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
73
|
+
@response_expected[FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
74
|
+
@response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
|
75
|
+
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
76
|
+
@response_expected[FUNCTION_SET_SAMPLE_RATE] = RESPONSE_EXPECTED_FALSE
|
77
|
+
@response_expected[FUNCTION_GET_SAMPLE_RATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
78
|
+
@response_expected[FUNCTION_SET_CALIBRATION] = RESPONSE_EXPECTED_FALSE
|
79
|
+
@response_expected[FUNCTION_GET_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
80
|
+
@response_expected[FUNCTION_GET_ADC_VALUES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
81
|
+
@response_expected[CALLBACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
82
|
+
@response_expected[CALLBACK_VOLTAGE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
83
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
84
|
+
|
85
|
+
@callback_formats[CALLBACK_VOLTAGE] = 'C l'
|
86
|
+
@callback_formats[CALLBACK_VOLTAGE_REACHED] = 'C l'
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns the voltage for the given channel in mV.
|
90
|
+
#
|
91
|
+
# If you want to get the voltage periodically, it is recommended to use the
|
92
|
+
# callback CALLBACK_VOLTAGE and set the period with
|
93
|
+
# BrickletIndustrialDualAnalogIn#set_voltage_callback_period.
|
94
|
+
def get_voltage(channel)
|
95
|
+
send_request(FUNCTION_GET_VOLTAGE, [channel], 'C', 4, 'l')
|
96
|
+
end
|
97
|
+
|
98
|
+
# Sets the period in ms with which the CALLBACK_VOLTAGE callback is triggered
|
99
|
+
# periodically for the given channel. A value of 0 turns the callback off.
|
100
|
+
#
|
101
|
+
# CALLBACK_VOLTAGE is only triggered if the voltage has changed since the
|
102
|
+
# last triggering.
|
103
|
+
#
|
104
|
+
# The default value is 0.
|
105
|
+
def set_voltage_callback_period(channel, period)
|
106
|
+
send_request(FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [channel, period], 'C L', 0, '')
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns the period as set by BrickletIndustrialDualAnalogIn#set_voltage_callback_period.
|
110
|
+
def get_voltage_callback_period(channel)
|
111
|
+
send_request(FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [channel], 'C', 4, 'L')
|
112
|
+
end
|
113
|
+
|
114
|
+
# Sets the thresholds for the CALLBACK_VOLTAGE_REACHED callback for the given
|
115
|
+
# channel.
|
116
|
+
#
|
117
|
+
# The following options are possible:
|
118
|
+
#
|
119
|
+
# "Option", "Description"
|
120
|
+
#
|
121
|
+
# "'x'", "Callback is turned off"
|
122
|
+
# "'o'", "Callback is triggered when the voltage is *outside* the min and max values"
|
123
|
+
# "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
|
124
|
+
# "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
|
125
|
+
# "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
|
126
|
+
#
|
127
|
+
# The default value is ('x', 0, 0).
|
128
|
+
def set_voltage_callback_threshold(channel, option, min, max)
|
129
|
+
send_request(FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [channel, option, min, max], 'C k l l', 0, '')
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns the threshold as set by BrickletIndustrialDualAnalogIn#set_voltage_callback_threshold.
|
133
|
+
def get_voltage_callback_threshold(channel)
|
134
|
+
send_request(FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [channel], 'C', 9, 'k l l')
|
135
|
+
end
|
136
|
+
|
137
|
+
# Sets the period in ms with which the threshold callback
|
138
|
+
#
|
139
|
+
# * CALLBACK_VOLTAGE_REACHED
|
140
|
+
#
|
141
|
+
# is triggered, if the threshold
|
142
|
+
#
|
143
|
+
# * BrickletIndustrialDualAnalogIn#set_voltage_callback_threshold
|
144
|
+
#
|
145
|
+
# keeps being reached.
|
146
|
+
#
|
147
|
+
# The default value is 100.
|
148
|
+
def set_debounce_period(debounce)
|
149
|
+
send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns the debounce period as set by BrickletIndustrialDualAnalogIn#set_debounce_period.
|
153
|
+
def get_debounce_period
|
154
|
+
send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
|
155
|
+
end
|
156
|
+
|
157
|
+
# Sets the sample rate. The sample rate can be between 1 sample per second
|
158
|
+
# and 976 samples per second. Decreasing the sample rate will also decrease the
|
159
|
+
# noise on the data.
|
160
|
+
#
|
161
|
+
# The default value is 6 (2 samples per second).
|
162
|
+
def set_sample_rate(rate)
|
163
|
+
send_request(FUNCTION_SET_SAMPLE_RATE, [rate], 'C', 0, '')
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns the sample rate as set by BrickletIndustrialDualAnalogIn#set_sample_rate.
|
167
|
+
def get_sample_rate
|
168
|
+
send_request(FUNCTION_GET_SAMPLE_RATE, [], '', 1, 'C')
|
169
|
+
end
|
170
|
+
|
171
|
+
# Sets offset and gain of MCP3911 internal calibration registers.
|
172
|
+
#
|
173
|
+
# See MCP3911 datasheet 7.7 and 7.8. The Industrial Dual Analog In Bricklet
|
174
|
+
# is already factory calibrated by Tinkerforge. It should not be necessary
|
175
|
+
# for you to use this function
|
176
|
+
def set_calibration(offset, gain)
|
177
|
+
send_request(FUNCTION_SET_CALIBRATION, [offset, gain], 'l2 l2', 0, '')
|
178
|
+
end
|
179
|
+
|
180
|
+
# Returns the calibration as set by BrickletIndustrialDualAnalogIn#set_calibration.
|
181
|
+
def get_calibration
|
182
|
+
send_request(FUNCTION_GET_CALIBRATION, [], '', 16, 'l2 l2')
|
183
|
+
end
|
184
|
+
|
185
|
+
# Returns the ADC values as given by the MCP3911 IC. This function
|
186
|
+
# is needed for proper calibration, see BrickletIndustrialDualAnalogIn#set_calibration.
|
187
|
+
def get_adc_values
|
188
|
+
send_request(FUNCTION_GET_ADC_VALUES, [], '', 8, 'l2')
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
192
|
+
# the position, the hardware and firmware version as well as the
|
193
|
+
# device identifier.
|
194
|
+
#
|
195
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
196
|
+
#
|
197
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
198
|
+
# |device_identifier_constant|
|
199
|
+
def get_identity
|
200
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
201
|
+
end
|
202
|
+
|
203
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
204
|
+
def register_callback(id, &block)
|
205
|
+
callback = block
|
206
|
+
@registered_callbacks[id] = callback
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|