tinkerforge 2.1.4 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
|
+
# Measures ambient light up to 900lux
|
14
14
|
class BrickletAmbientLight < Device
|
15
15
|
DEVICE_IDENTIFIER = 21 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Ambient Light Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered periodically with the period that is set by
|
18
19
|
# BrickletAmbientLight#set_illuminance_callback_period. The parameter is the illuminance 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_ILLUMINANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
77
78
|
@response_expected[FUNCTION_GET_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -98,8 +99,8 @@ module Tinkerforge
|
|
98
99
|
end
|
99
100
|
|
100
101
|
# Returns the illuminance of the ambient light sensor. The value
|
101
|
-
# has a range of 0 to 9000 and is given in
|
102
|
-
# of 4500 means that an illuminance of
|
102
|
+
# has a range of 0 to 9000 and is given in lux/10, i.e. a value
|
103
|
+
# of 4500 means that an illuminance of 450lux is measured.
|
103
104
|
#
|
104
105
|
# If you want to get the illuminance periodically, it is recommended to use the
|
105
106
|
# callback CALLBACK_ILLUMINANCE and set the period with
|
@@ -174,12 +175,12 @@ module Tinkerforge
|
|
174
175
|
#
|
175
176
|
# The default value is ('x', 0, 0).
|
176
177
|
def set_illuminance_callback_threshold(option, min, max)
|
177
|
-
send_request(FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD, [option, min, max], 'k
|
178
|
+
send_request(FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
178
179
|
end
|
179
180
|
|
180
181
|
# Returns the threshold as set by BrickletAmbientLight#set_illuminance_callback_threshold.
|
181
182
|
def get_illuminance_callback_threshold
|
182
|
-
send_request(FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD, [], '', 5, 'k
|
183
|
+
send_request(FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
183
184
|
end
|
184
185
|
|
185
186
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
@@ -0,0 +1,216 @@
|
|
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 ambient light up to 64000lux
|
14
|
+
class BrickletAmbientLightV2 < Device
|
15
|
+
DEVICE_IDENTIFIER = 259 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Ambient Light Bricklet 2.0' # :nodoc:
|
17
|
+
|
18
|
+
# This callback is triggered periodically with the period that is set by
|
19
|
+
# BrickletAmbientLightV2#set_illuminance_callback_period. The parameter is the illuminance of the
|
20
|
+
# ambient light sensor.
|
21
|
+
#
|
22
|
+
# CALLBACK_ILLUMINANCE is only triggered if the illuminance has changed since the
|
23
|
+
# last triggering.
|
24
|
+
CALLBACK_ILLUMINANCE = 10
|
25
|
+
|
26
|
+
# This callback is triggered when the threshold as set by
|
27
|
+
# BrickletAmbientLightV2#set_illuminance_callback_threshold is reached.
|
28
|
+
# The parameter is the illuminance of the ambient light sensor.
|
29
|
+
#
|
30
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
31
|
+
# with the period as set by BrickletAmbientLightV2#set_debounce_period.
|
32
|
+
CALLBACK_ILLUMINANCE_REACHED = 11
|
33
|
+
|
34
|
+
FUNCTION_GET_ILLUMINANCE = 1 # :nodoc:
|
35
|
+
FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD = 2 # :nodoc:
|
36
|
+
FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD = 3 # :nodoc:
|
37
|
+
FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD = 4 # :nodoc:
|
38
|
+
FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD = 5 # :nodoc:
|
39
|
+
FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
|
40
|
+
FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
|
41
|
+
FUNCTION_SET_CONFIGURATION = 8 # :nodoc:
|
42
|
+
FUNCTION_GET_CONFIGURATION = 9 # :nodoc:
|
43
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
44
|
+
|
45
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
46
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
47
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
48
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
49
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
50
|
+
ILLUMINANCE_RANGE_UNLIMITED = 6 # :nodoc:
|
51
|
+
ILLUMINANCE_RANGE_64000LUX = 0 # :nodoc:
|
52
|
+
ILLUMINANCE_RANGE_32000LUX = 1 # :nodoc:
|
53
|
+
ILLUMINANCE_RANGE_16000LUX = 2 # :nodoc:
|
54
|
+
ILLUMINANCE_RANGE_8000LUX = 3 # :nodoc:
|
55
|
+
ILLUMINANCE_RANGE_1300LUX = 4 # :nodoc:
|
56
|
+
ILLUMINANCE_RANGE_600LUX = 5 # :nodoc:
|
57
|
+
INTEGRATION_TIME_50MS = 0 # :nodoc:
|
58
|
+
INTEGRATION_TIME_100MS = 1 # :nodoc:
|
59
|
+
INTEGRATION_TIME_150MS = 2 # :nodoc:
|
60
|
+
INTEGRATION_TIME_200MS = 3 # :nodoc:
|
61
|
+
INTEGRATION_TIME_250MS = 4 # :nodoc:
|
62
|
+
INTEGRATION_TIME_300MS = 5 # :nodoc:
|
63
|
+
INTEGRATION_TIME_350MS = 6 # :nodoc:
|
64
|
+
INTEGRATION_TIME_400MS = 7 # :nodoc:
|
65
|
+
|
66
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
67
|
+
# the IP Connection <tt>ipcon</tt>.
|
68
|
+
def initialize(uid, ipcon)
|
69
|
+
super uid, ipcon
|
70
|
+
|
71
|
+
@api_version = [2, 0, 1]
|
72
|
+
|
73
|
+
@response_expected[FUNCTION_GET_ILLUMINANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
74
|
+
@response_expected[FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
75
|
+
@response_expected[FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
76
|
+
@response_expected[FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
77
|
+
@response_expected[FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
78
|
+
@response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
|
79
|
+
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
80
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
81
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
82
|
+
@response_expected[CALLBACK_ILLUMINANCE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
83
|
+
@response_expected[CALLBACK_ILLUMINANCE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
84
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
85
|
+
|
86
|
+
@callback_formats[CALLBACK_ILLUMINANCE] = 'L'
|
87
|
+
@callback_formats[CALLBACK_ILLUMINANCE_REACHED] = 'L'
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns the illuminance of the ambient light sensor. The measurement range goes
|
91
|
+
# up to about 100000lux, but above 64000lux the precision starts to drop.
|
92
|
+
# The illuminance is given in lux/100, i.e. a value of 450000 means that an
|
93
|
+
# illuminance of 4500lux is measured.
|
94
|
+
#
|
95
|
+
# .. versionchanged:: 2.0.2$nbsp;(Plugin)
|
96
|
+
# An illuminance of 0lux indicates that the sensor is saturated and the
|
97
|
+
# configuration should be modified, see BrickletAmbientLightV2#set_configuration.
|
98
|
+
#
|
99
|
+
# If you want to get the illuminance periodically, it is recommended to use the
|
100
|
+
# callback CALLBACK_ILLUMINANCE and set the period with
|
101
|
+
# BrickletAmbientLightV2#set_illuminance_callback_period.
|
102
|
+
def get_illuminance
|
103
|
+
send_request(FUNCTION_GET_ILLUMINANCE, [], '', 4, 'L')
|
104
|
+
end
|
105
|
+
|
106
|
+
# Sets the period in ms with which the CALLBACK_ILLUMINANCE callback is triggered
|
107
|
+
# periodically. A value of 0 turns the callback off.
|
108
|
+
#
|
109
|
+
# CALLBACK_ILLUMINANCE is only triggered if the illuminance has changed since the
|
110
|
+
# last triggering.
|
111
|
+
#
|
112
|
+
# The default value is 0.
|
113
|
+
def set_illuminance_callback_period(period)
|
114
|
+
send_request(FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD, [period], 'L', 0, '')
|
115
|
+
end
|
116
|
+
|
117
|
+
# Returns the period as set by BrickletAmbientLightV2#set_illuminance_callback_period.
|
118
|
+
def get_illuminance_callback_period
|
119
|
+
send_request(FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD, [], '', 4, 'L')
|
120
|
+
end
|
121
|
+
|
122
|
+
# Sets the thresholds for the CALLBACK_ILLUMINANCE_REACHED callback.
|
123
|
+
#
|
124
|
+
# The following options are possible:
|
125
|
+
#
|
126
|
+
# "Option", "Description"
|
127
|
+
#
|
128
|
+
# "'x'", "Callback is turned off"
|
129
|
+
# "'o'", "Callback is triggered when the illuminance is *outside* the min and max values"
|
130
|
+
# "'i'", "Callback is triggered when the illuminance is *inside* the min and max values"
|
131
|
+
# "'<'", "Callback is triggered when the illuminance is smaller than the min value (max is ignored)"
|
132
|
+
# "'>'", "Callback is triggered when the illuminance is greater than the min value (max is ignored)"
|
133
|
+
#
|
134
|
+
# The default value is ('x', 0, 0).
|
135
|
+
def set_illuminance_callback_threshold(option, min, max)
|
136
|
+
send_request(FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD, [option, min, max], 'k L L', 0, '')
|
137
|
+
end
|
138
|
+
|
139
|
+
# Returns the threshold as set by BrickletAmbientLightV2#set_illuminance_callback_threshold.
|
140
|
+
def get_illuminance_callback_threshold
|
141
|
+
send_request(FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD, [], '', 9, 'k L L')
|
142
|
+
end
|
143
|
+
|
144
|
+
# Sets the period in ms with which the threshold callbacks
|
145
|
+
#
|
146
|
+
# * CALLBACK_ILLUMINANCE_REACHED,
|
147
|
+
#
|
148
|
+
# are triggered, if the thresholds
|
149
|
+
#
|
150
|
+
# * BrickletAmbientLightV2#set_illuminance_callback_threshold,
|
151
|
+
#
|
152
|
+
# keep being reached.
|
153
|
+
#
|
154
|
+
# The default value is 100.
|
155
|
+
def set_debounce_period(debounce)
|
156
|
+
send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
|
157
|
+
end
|
158
|
+
|
159
|
+
# Returns the debounce period as set by BrickletAmbientLightV2#set_debounce_period.
|
160
|
+
def get_debounce_period
|
161
|
+
send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
|
162
|
+
end
|
163
|
+
|
164
|
+
# Sets the configuration. It is possible to configure an illuminance range
|
165
|
+
# between 0-600lux and 0-64000lux and an integration time between 50ms and 400ms.
|
166
|
+
#
|
167
|
+
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
168
|
+
# The unlimited illuminance range allows to measure up to about 100000lux, but
|
169
|
+
# above 64000lux the precision starts to drop.
|
170
|
+
#
|
171
|
+
# A smaller illuminance range increases the resolution of the data. A longer
|
172
|
+
# integration time will result in less noise on the data.
|
173
|
+
#
|
174
|
+
# .. versionchanged:: 2.0.2$nbsp;(Plugin)
|
175
|
+
# If the actual measure illuminance is out-of-range then the current illuminance
|
176
|
+
# range maximum +0.01lux is reported by BrickletAmbientLightV2#get_illuminance and the
|
177
|
+
# CALLBACK_ILLUMINANCE callback. For example, 800001 for the 0-8000lux range.
|
178
|
+
#
|
179
|
+
# .. versionchanged:: 2.0.2$nbsp;(Plugin)
|
180
|
+
# With a long integration time the sensor might be saturated before the measured
|
181
|
+
# value reaches the maximum of the selected illuminance range. In this case 0lux
|
182
|
+
# is reported by BrickletAmbientLightV2#get_illuminance and the CALLBACK_ILLUMINANCE callback.
|
183
|
+
#
|
184
|
+
# If the measurement is out-of-range or the sensor is saturated then you should
|
185
|
+
# configure the next higher illuminance range. If the highest range is already
|
186
|
+
# in use, then start to reduce the integration time.
|
187
|
+
#
|
188
|
+
# The default values are 0-8000lux illuminance range and 200ms integration time.
|
189
|
+
def set_configuration(illuminance_range, integration_time)
|
190
|
+
send_request(FUNCTION_SET_CONFIGURATION, [illuminance_range, integration_time], 'C C', 0, '')
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns the configuration as set by BrickletAmbientLightV2#set_configuration.
|
194
|
+
def get_configuration
|
195
|
+
send_request(FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C')
|
196
|
+
end
|
197
|
+
|
198
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
199
|
+
# the position, the hardware and firmware version as well as the
|
200
|
+
# device identifier.
|
201
|
+
#
|
202
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
203
|
+
#
|
204
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
205
|
+
# |device_identifier_constant|
|
206
|
+
def get_identity
|
207
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
208
|
+
end
|
209
|
+
|
210
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
211
|
+
def register_callback(id, &block)
|
212
|
+
callback = block
|
213
|
+
@registered_callbacks[id] = callback
|
214
|
+
end
|
215
|
+
end
|
216
|
+
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
|
+
# Measures DC voltage between 0V and 45V
|
14
14
|
class BrickletAnalogIn < Device
|
15
15
|
DEVICE_IDENTIFIER = 219 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Analog In Bricklet' # :nodoc:
|
16
17
|
|
17
18
|
# This callback is triggered periodically with the period that is set by
|
18
19
|
# BrickletAnalogIn#set_voltage_callback_period. The parameter is the voltage of the
|
@@ -81,7 +82,7 @@ module Tinkerforge
|
|
81
82
|
def initialize(uid, ipcon)
|
82
83
|
super uid, ipcon
|
83
84
|
|
84
|
-
@api_version = [2, 0,
|
85
|
+
@api_version = [2, 0, 3]
|
85
86
|
|
86
87
|
@response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
87
88
|
@response_expected[FUNCTION_GET_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -184,12 +185,12 @@ module Tinkerforge
|
|
184
185
|
#
|
185
186
|
# The default value is ('x', 0, 0).
|
186
187
|
def set_voltage_callback_threshold(option, min, max)
|
187
|
-
send_request(FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k
|
188
|
+
send_request(FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
188
189
|
end
|
189
190
|
|
190
191
|
# Returns the threshold as set by BrickletAnalogIn#set_voltage_callback_threshold.
|
191
192
|
def get_voltage_callback_threshold
|
192
|
-
send_request(FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k
|
193
|
+
send_request(FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
193
194
|
end
|
194
195
|
|
195
196
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
@@ -243,18 +244,18 @@ module Tinkerforge
|
|
243
244
|
# * 2: 0V - 10.32V, ~2.52mV resolution
|
244
245
|
# * 3: 0V - 36.30V, ~8.86mV resolution
|
245
246
|
# * 4: 0V - 45.00V, ~11.25mV resolution
|
246
|
-
# * 5: 0V - 3.3V, ~0.81mV resolution, new in version 2.0.3
|
247
|
+
# * 5: 0V - 3.3V, ~0.81mV resolution, new in version 2.0.3$nbsp;(Plugin)
|
247
248
|
#
|
248
249
|
# The default measurement range is 0.
|
249
250
|
#
|
250
|
-
# .. versionadded:: 2.0.1
|
251
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
251
252
|
def set_range(range)
|
252
253
|
send_request(FUNCTION_SET_RANGE, [range], 'C', 0, '')
|
253
254
|
end
|
254
255
|
|
255
256
|
# Returns the measurement range as set by BrickletAnalogIn#set_range.
|
256
257
|
#
|
257
|
-
# .. versionadded:: 2.0.1
|
258
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
258
259
|
def get_range
|
259
260
|
send_request(FUNCTION_GET_RANGE, [], '', 1, 'C')
|
260
261
|
end
|
@@ -267,14 +268,14 @@ module Tinkerforge
|
|
267
268
|
#
|
268
269
|
# The default value is 50.
|
269
270
|
#
|
270
|
-
# .. versionadded:: 2.0.3
|
271
|
+
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
271
272
|
def set_averaging(average)
|
272
273
|
send_request(FUNCTION_SET_AVERAGING, [average], 'C', 0, '')
|
273
274
|
end
|
274
275
|
|
275
276
|
# Returns the averaging configuration as set by BrickletAnalogIn#set_averaging.
|
276
277
|
#
|
277
|
-
# .. versionadded:: 2.0.3
|
278
|
+
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
278
279
|
def get_averaging
|
279
280
|
send_request(FUNCTION_GET_AVERAGING, [], '', 1, 'C')
|
280
281
|
end
|
@@ -0,0 +1,259 @@
|
|
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 DC voltage between 0V and 42V
|
14
|
+
class BrickletAnalogInV2 < Device
|
15
|
+
DEVICE_IDENTIFIER = 251 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'Analog In Bricklet 2.0' # :nodoc:
|
17
|
+
|
18
|
+
# This callback is triggered periodically with the period that is set by
|
19
|
+
# BrickletAnalogInV2#set_voltage_callback_period. The parameter is the voltage of the
|
20
|
+
# sensor.
|
21
|
+
#
|
22
|
+
# CALLBACK_VOLTAGE is only triggered if the voltage has changed since the
|
23
|
+
# last triggering.
|
24
|
+
CALLBACK_VOLTAGE = 15
|
25
|
+
|
26
|
+
# This callback is triggered periodically with the period that is set by
|
27
|
+
# BrickletAnalogInV2#set_analog_value_callback_period. The parameter is the analog value of the
|
28
|
+
# sensor.
|
29
|
+
#
|
30
|
+
# CALLBACK_ANALOG_VALUE is only triggered if the voltage has changed since the
|
31
|
+
# last triggering.
|
32
|
+
CALLBACK_ANALOG_VALUE = 16
|
33
|
+
|
34
|
+
# This callback is triggered when the threshold as set by
|
35
|
+
# BrickletAnalogInV2#set_voltage_callback_threshold is reached.
|
36
|
+
# The parameter is the voltage of the sensor.
|
37
|
+
#
|
38
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
39
|
+
# with the period as set by BrickletAnalogInV2#set_debounce_period.
|
40
|
+
CALLBACK_VOLTAGE_REACHED = 17
|
41
|
+
|
42
|
+
# This callback is triggered when the threshold as set by
|
43
|
+
# BrickletAnalogInV2#set_analog_value_callback_threshold is reached.
|
44
|
+
# The parameter is the analog value of the sensor.
|
45
|
+
#
|
46
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
47
|
+
# with the period as set by BrickletAnalogInV2#set_debounce_period.
|
48
|
+
CALLBACK_ANALOG_VALUE_REACHED = 18
|
49
|
+
|
50
|
+
FUNCTION_GET_VOLTAGE = 1 # :nodoc:
|
51
|
+
FUNCTION_GET_ANALOG_VALUE = 2 # :nodoc:
|
52
|
+
FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD = 3 # :nodoc:
|
53
|
+
FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD = 4 # :nodoc:
|
54
|
+
FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD = 5 # :nodoc:
|
55
|
+
FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD = 6 # :nodoc:
|
56
|
+
FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD = 7 # :nodoc:
|
57
|
+
FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD = 8 # :nodoc:
|
58
|
+
FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD = 9 # :nodoc:
|
59
|
+
FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD = 10 # :nodoc:
|
60
|
+
FUNCTION_SET_DEBOUNCE_PERIOD = 11 # :nodoc:
|
61
|
+
FUNCTION_GET_DEBOUNCE_PERIOD = 12 # :nodoc:
|
62
|
+
FUNCTION_SET_MOVING_AVERAGE = 13 # :nodoc:
|
63
|
+
FUNCTION_GET_MOVING_AVERAGE = 14 # :nodoc:
|
64
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
65
|
+
|
66
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
67
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
68
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
69
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
70
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
71
|
+
|
72
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
73
|
+
# the IP Connection <tt>ipcon</tt>.
|
74
|
+
def initialize(uid, ipcon)
|
75
|
+
super uid, ipcon
|
76
|
+
|
77
|
+
@api_version = [2, 0, 1]
|
78
|
+
|
79
|
+
@response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
80
|
+
@response_expected[FUNCTION_GET_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
81
|
+
@response_expected[FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
82
|
+
@response_expected[FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
83
|
+
@response_expected[FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
84
|
+
@response_expected[FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
85
|
+
@response_expected[FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
86
|
+
@response_expected[FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
87
|
+
@response_expected[FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
88
|
+
@response_expected[FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
89
|
+
@response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
|
90
|
+
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
91
|
+
@response_expected[FUNCTION_SET_MOVING_AVERAGE] = RESPONSE_EXPECTED_FALSE
|
92
|
+
@response_expected[FUNCTION_GET_MOVING_AVERAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
93
|
+
@response_expected[CALLBACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
94
|
+
@response_expected[CALLBACK_ANALOG_VALUE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
95
|
+
@response_expected[CALLBACK_VOLTAGE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
96
|
+
@response_expected[CALLBACK_ANALOG_VALUE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
97
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
98
|
+
|
99
|
+
@callback_formats[CALLBACK_VOLTAGE] = 'S'
|
100
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
101
|
+
@callback_formats[CALLBACK_VOLTAGE_REACHED] = 'S'
|
102
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns the measured voltage. The value is in mV and
|
106
|
+
# between 0V and 42V. The resolution is approximately 10mV.
|
107
|
+
#
|
108
|
+
# If you want to get the voltage periodically, it is recommended to use the
|
109
|
+
# callback CALLBACK_VOLTAGE and set the period with
|
110
|
+
# BrickletAnalogInV2#set_voltage_callback_period.
|
111
|
+
def get_voltage
|
112
|
+
send_request(FUNCTION_GET_VOLTAGE, [], '', 2, 'S')
|
113
|
+
end
|
114
|
+
|
115
|
+
# Returns the value as read by a 12-bit analog-to-digital converter.
|
116
|
+
# The value is between 0 and 4095.
|
117
|
+
#
|
118
|
+
# If you want the analog value periodically, it is recommended to use the
|
119
|
+
# callback CALLBACK_ANALOG_VALUE and set the period with
|
120
|
+
# BrickletAnalogInV2#set_analog_value_callback_period.
|
121
|
+
def get_analog_value
|
122
|
+
send_request(FUNCTION_GET_ANALOG_VALUE, [], '', 2, 'S')
|
123
|
+
end
|
124
|
+
|
125
|
+
# Sets the period in ms with which the CALLBACK_VOLTAGE callback is triggered
|
126
|
+
# periodically. A value of 0 turns the callback off.
|
127
|
+
#
|
128
|
+
# CALLBACK_VOLTAGE is only triggered if the voltage has changed since the
|
129
|
+
# last triggering.
|
130
|
+
#
|
131
|
+
# The default value is 0.
|
132
|
+
def set_voltage_callback_period(period)
|
133
|
+
send_request(FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, '')
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns the period as set by BrickletAnalogInV2#set_voltage_callback_period.
|
137
|
+
def get_voltage_callback_period
|
138
|
+
send_request(FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L')
|
139
|
+
end
|
140
|
+
|
141
|
+
# Sets the period in ms with which the CALLBACK_ANALOG_VALUE callback is triggered
|
142
|
+
# periodically. A value of 0 turns the callback off.
|
143
|
+
#
|
144
|
+
# CALLBACK_ANALOG_VALUE is only triggered if the analog value has changed since the
|
145
|
+
# last triggering.
|
146
|
+
#
|
147
|
+
# The default value is 0.
|
148
|
+
def set_analog_value_callback_period(period)
|
149
|
+
send_request(FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 0, '')
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns the period as set by BrickletAnalogInV2#set_analog_value_callback_period.
|
153
|
+
def get_analog_value_callback_period
|
154
|
+
send_request(FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 4, 'L')
|
155
|
+
end
|
156
|
+
|
157
|
+
# Sets the thresholds for the CALLBACK_VOLTAGE_REACHED callback.
|
158
|
+
#
|
159
|
+
# The following options are possible:
|
160
|
+
#
|
161
|
+
# "Option", "Description"
|
162
|
+
#
|
163
|
+
# "'x'", "Callback is turned off"
|
164
|
+
# "'o'", "Callback is triggered when the voltage is *outside* the min and max values"
|
165
|
+
# "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
|
166
|
+
# "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
|
167
|
+
# "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
|
168
|
+
#
|
169
|
+
# The default value is ('x', 0, 0).
|
170
|
+
def set_voltage_callback_threshold(option, min, max)
|
171
|
+
send_request(FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the threshold as set by BrickletAnalogInV2#set_voltage_callback_threshold.
|
175
|
+
def get_voltage_callback_threshold
|
176
|
+
send_request(FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
177
|
+
end
|
178
|
+
|
179
|
+
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
180
|
+
#
|
181
|
+
# The following options are possible:
|
182
|
+
#
|
183
|
+
# "Option", "Description"
|
184
|
+
#
|
185
|
+
# "'x'", "Callback is turned off"
|
186
|
+
# "'o'", "Callback is triggered when the analog value is *outside* the min and max values"
|
187
|
+
# "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
|
188
|
+
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
189
|
+
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
190
|
+
#
|
191
|
+
# The default value is ('x', 0, 0).
|
192
|
+
def set_analog_value_callback_threshold(option, min, max)
|
193
|
+
send_request(FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the threshold as set by BrickletAnalogInV2#set_analog_value_callback_threshold.
|
197
|
+
def get_analog_value_callback_threshold
|
198
|
+
send_request(FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
199
|
+
end
|
200
|
+
|
201
|
+
# Sets the period in ms with which the threshold callbacks
|
202
|
+
#
|
203
|
+
# * CALLBACK_VOLTAGE_REACHED,
|
204
|
+
# * CALLBACK_ANALOG_VALUE_REACHED
|
205
|
+
#
|
206
|
+
# are triggered, if the thresholds
|
207
|
+
#
|
208
|
+
# * BrickletAnalogInV2#set_voltage_callback_threshold,
|
209
|
+
# * BrickletAnalogInV2#set_analog_value_callback_threshold
|
210
|
+
#
|
211
|
+
# keep being reached.
|
212
|
+
#
|
213
|
+
# The default value is 100.
|
214
|
+
def set_debounce_period(debounce)
|
215
|
+
send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns the debounce period as set by BrickletAnalogInV2#set_debounce_period.
|
219
|
+
def get_debounce_period
|
220
|
+
send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
|
221
|
+
end
|
222
|
+
|
223
|
+
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
224
|
+
# for the moisture value.
|
225
|
+
#
|
226
|
+
# Setting the length to 1 will turn the averaging off. With less
|
227
|
+
# averaging, there is more noise on the data.
|
228
|
+
#
|
229
|
+
# The range for the averaging is 1-50.
|
230
|
+
#
|
231
|
+
# The default value is 50.
|
232
|
+
def set_moving_average(average)
|
233
|
+
send_request(FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 0, '')
|
234
|
+
end
|
235
|
+
|
236
|
+
# Returns the length of the moving average as set by BrickletAnalogInV2#set_moving_average.
|
237
|
+
def get_moving_average
|
238
|
+
send_request(FUNCTION_GET_MOVING_AVERAGE, [], '', 1, 'C')
|
239
|
+
end
|
240
|
+
|
241
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
242
|
+
# the position, the hardware and firmware version as well as the
|
243
|
+
# device identifier.
|
244
|
+
#
|
245
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
246
|
+
#
|
247
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
248
|
+
# |device_identifier_constant|
|
249
|
+
def get_identity
|
250
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
251
|
+
end
|
252
|
+
|
253
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
254
|
+
def register_callback(id, &block)
|
255
|
+
callback = block
|
256
|
+
@registered_callbacks[id] = callback
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|