tinkerforge 2.1.22 → 2.1.27
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.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
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
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# Measures weight with a load cell
|
|
14
16
|
class BrickletLoadCellV2 < Device
|
|
@@ -77,7 +79,7 @@ module Tinkerforge
|
|
|
77
79
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
78
80
|
# the IP Connection <tt>ipcon</tt>.
|
|
79
81
|
def initialize(uid, ipcon)
|
|
80
|
-
super uid, ipcon
|
|
82
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
81
83
|
|
|
82
84
|
@api_version = [2, 0, 0]
|
|
83
85
|
|
|
@@ -105,21 +107,24 @@ module Tinkerforge
|
|
|
105
107
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
106
108
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
107
109
|
|
|
108
|
-
@callback_formats[CALLBACK_WEIGHT] = 'l'
|
|
110
|
+
@callback_formats[CALLBACK_WEIGHT] = [12, 'l']
|
|
109
111
|
|
|
112
|
+
@ipcon.add_device self
|
|
110
113
|
end
|
|
111
114
|
|
|
112
|
-
# Returns the currently measured weight
|
|
115
|
+
# Returns the currently measured weight.
|
|
113
116
|
#
|
|
114
117
|
#
|
|
115
118
|
# If you want to get the value periodically, it is recommended to use the
|
|
116
119
|
# CALLBACK_WEIGHT callback. You can set the callback configuration
|
|
117
120
|
# with BrickletLoadCellV2#set_weight_callback_configuration.
|
|
118
121
|
def get_weight
|
|
119
|
-
|
|
122
|
+
check_validity
|
|
123
|
+
|
|
124
|
+
send_request FUNCTION_GET_WEIGHT, [], '', 12, 'l'
|
|
120
125
|
end
|
|
121
126
|
|
|
122
|
-
# The period
|
|
127
|
+
# The period is the period with which the CALLBACK_WEIGHT callback is triggered
|
|
123
128
|
# periodically. A value of 0 turns the callback off.
|
|
124
129
|
#
|
|
125
130
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -144,15 +149,17 @@ module Tinkerforge
|
|
|
144
149
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
145
150
|
#
|
|
146
151
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
147
|
-
#
|
|
148
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
149
152
|
def set_weight_callback_configuration(period, value_has_to_change, option, min, max)
|
|
150
|
-
|
|
153
|
+
check_validity
|
|
154
|
+
|
|
155
|
+
send_request FUNCTION_SET_WEIGHT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
|
151
156
|
end
|
|
152
157
|
|
|
153
158
|
# Returns the callback configuration as set by BrickletLoadCellV2#set_weight_callback_configuration.
|
|
154
159
|
def get_weight_callback_configuration
|
|
155
|
-
|
|
160
|
+
check_validity
|
|
161
|
+
|
|
162
|
+
send_request FUNCTION_GET_WEIGHT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
|
156
163
|
end
|
|
157
164
|
|
|
158
165
|
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
|
@@ -160,35 +167,38 @@ module Tinkerforge
|
|
|
160
167
|
#
|
|
161
168
|
# Setting the length to 1 will turn the averaging off. With less
|
|
162
169
|
# averaging, there is more noise on the data.
|
|
163
|
-
#
|
|
164
|
-
# The range for the averaging is 1-100.
|
|
165
|
-
#
|
|
166
|
-
# The default value is 4.
|
|
167
170
|
def set_moving_average(average)
|
|
168
|
-
|
|
171
|
+
check_validity
|
|
172
|
+
|
|
173
|
+
send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'S', 8, ''
|
|
169
174
|
end
|
|
170
175
|
|
|
171
176
|
# Returns the length moving average as set by BrickletLoadCellV2#set_moving_average.
|
|
172
177
|
def get_moving_average
|
|
173
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 10, 'S'
|
|
174
181
|
end
|
|
175
182
|
|
|
176
183
|
# Configures the info LED to be either turned off, turned on, or blink in
|
|
177
184
|
# heartbeat mode.
|
|
178
185
|
def set_info_led_config(config)
|
|
179
|
-
|
|
186
|
+
check_validity
|
|
187
|
+
|
|
188
|
+
send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 8, ''
|
|
180
189
|
end
|
|
181
190
|
|
|
182
191
|
# Returns the LED configuration as set by BrickletLoadCellV2#set_info_led_config
|
|
183
192
|
def get_info_led_config
|
|
184
|
-
|
|
193
|
+
check_validity
|
|
194
|
+
|
|
195
|
+
send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 9, 'C'
|
|
185
196
|
end
|
|
186
197
|
|
|
187
198
|
# To calibrate your Load Cell Bricklet 2.0 you have to
|
|
188
199
|
#
|
|
189
200
|
# * empty the scale and call this function with 0 and
|
|
190
|
-
# * add a known weight to the scale and call this function with the weight
|
|
191
|
-
# grams.
|
|
201
|
+
# * add a known weight to the scale and call this function with the weight.
|
|
192
202
|
#
|
|
193
203
|
# The calibration is saved in the flash of the Bricklet and only
|
|
194
204
|
# needs to be done once.
|
|
@@ -196,12 +206,16 @@ module Tinkerforge
|
|
|
196
206
|
# We recommend to use the Brick Viewer for calibration, you don't need
|
|
197
207
|
# to call this function in your source code.
|
|
198
208
|
def calibrate(weight)
|
|
199
|
-
|
|
209
|
+
check_validity
|
|
210
|
+
|
|
211
|
+
send_request FUNCTION_CALIBRATE, [weight], 'L', 8, ''
|
|
200
212
|
end
|
|
201
213
|
|
|
202
214
|
# Sets the currently measured weight as tare weight.
|
|
203
215
|
def tare
|
|
204
|
-
|
|
216
|
+
check_validity
|
|
217
|
+
|
|
218
|
+
send_request FUNCTION_TARE, [], '', 8, ''
|
|
205
219
|
end
|
|
206
220
|
|
|
207
221
|
# The measurement rate and gain are configurable.
|
|
@@ -216,15 +230,17 @@ module Tinkerforge
|
|
|
216
230
|
# means the voltage range is ±15mV for most load cells (i.e. gain of 128x
|
|
217
231
|
# is best). If you don't know what all of this means you should keep it at
|
|
218
232
|
# 128x, it will most likely be correct.
|
|
219
|
-
#
|
|
220
|
-
# The default rate is 10Hz and the default gain is 128x.
|
|
221
233
|
def set_configuration(rate, gain)
|
|
222
|
-
|
|
234
|
+
check_validity
|
|
235
|
+
|
|
236
|
+
send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 8, ''
|
|
223
237
|
end
|
|
224
238
|
|
|
225
239
|
# Returns the configuration as set by BrickletLoadCellV2#set_configuration.
|
|
226
240
|
def get_configuration
|
|
227
|
-
|
|
241
|
+
check_validity
|
|
242
|
+
|
|
243
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
|
|
228
244
|
end
|
|
229
245
|
|
|
230
246
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -239,7 +255,9 @@ module Tinkerforge
|
|
|
239
255
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
240
256
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
241
257
|
def get_spitfp_error_count
|
|
242
|
-
|
|
258
|
+
check_validity
|
|
259
|
+
|
|
260
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
243
261
|
end
|
|
244
262
|
|
|
245
263
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -252,12 +270,16 @@ module Tinkerforge
|
|
|
252
270
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
253
271
|
# necessary to call it in a normal user program.
|
|
254
272
|
def set_bootloader_mode(mode)
|
|
255
|
-
|
|
273
|
+
check_validity
|
|
274
|
+
|
|
275
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
256
276
|
end
|
|
257
277
|
|
|
258
278
|
# Returns the current bootloader mode, see BrickletLoadCellV2#set_bootloader_mode.
|
|
259
279
|
def get_bootloader_mode
|
|
260
|
-
|
|
280
|
+
check_validity
|
|
281
|
+
|
|
282
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
261
283
|
end
|
|
262
284
|
|
|
263
285
|
# Sets the firmware pointer for BrickletLoadCellV2#write_firmware. The pointer has
|
|
@@ -267,7 +289,9 @@ module Tinkerforge
|
|
|
267
289
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
268
290
|
# necessary to call it in a normal user program.
|
|
269
291
|
def set_write_firmware_pointer(pointer)
|
|
270
|
-
|
|
292
|
+
check_validity
|
|
293
|
+
|
|
294
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
271
295
|
end
|
|
272
296
|
|
|
273
297
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -279,7 +303,9 @@ module Tinkerforge
|
|
|
279
303
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
280
304
|
# necessary to call it in a normal user program.
|
|
281
305
|
def write_firmware(data)
|
|
282
|
-
|
|
306
|
+
check_validity
|
|
307
|
+
|
|
308
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
283
309
|
end
|
|
284
310
|
|
|
285
311
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -290,22 +316,28 @@ module Tinkerforge
|
|
|
290
316
|
#
|
|
291
317
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
292
318
|
def set_status_led_config(config)
|
|
293
|
-
|
|
319
|
+
check_validity
|
|
320
|
+
|
|
321
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
294
322
|
end
|
|
295
323
|
|
|
296
324
|
# Returns the configuration as set by BrickletLoadCellV2#set_status_led_config
|
|
297
325
|
def get_status_led_config
|
|
298
|
-
|
|
326
|
+
check_validity
|
|
327
|
+
|
|
328
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
299
329
|
end
|
|
300
330
|
|
|
301
|
-
# Returns the temperature
|
|
331
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
302
332
|
# value returned is not the ambient temperature!
|
|
303
333
|
#
|
|
304
334
|
# The temperature is only proportional to the real temperature and it has bad
|
|
305
335
|
# accuracy. Practically it is only useful as an indicator for
|
|
306
336
|
# temperature changes.
|
|
307
337
|
def get_chip_temperature
|
|
308
|
-
|
|
338
|
+
check_validity
|
|
339
|
+
|
|
340
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
309
341
|
end
|
|
310
342
|
|
|
311
343
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -315,7 +347,9 @@ module Tinkerforge
|
|
|
315
347
|
# calling functions on the existing ones will result in
|
|
316
348
|
# undefined behavior!
|
|
317
349
|
def reset
|
|
318
|
-
|
|
350
|
+
check_validity
|
|
351
|
+
|
|
352
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
319
353
|
end
|
|
320
354
|
|
|
321
355
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -324,25 +358,31 @@ module Tinkerforge
|
|
|
324
358
|
#
|
|
325
359
|
# We recommend that you use Brick Viewer to change the UID.
|
|
326
360
|
def write_uid(uid)
|
|
327
|
-
|
|
361
|
+
check_validity
|
|
362
|
+
|
|
363
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
328
364
|
end
|
|
329
365
|
|
|
330
366
|
# Returns the current UID as an integer. Encode as
|
|
331
367
|
# Base58 to get the usual string version.
|
|
332
368
|
def read_uid
|
|
333
|
-
|
|
369
|
+
check_validity
|
|
370
|
+
|
|
371
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
334
372
|
end
|
|
335
373
|
|
|
336
374
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
337
375
|
# the position, the hardware and firmware version as well as the
|
|
338
376
|
# device identifier.
|
|
339
377
|
#
|
|
340
|
-
# The position can be 'a', 'b', 'c' or '
|
|
378
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
379
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
380
|
+
# position 'z'.
|
|
341
381
|
#
|
|
342
382
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
343
383
|
# |device_identifier_constant|
|
|
344
384
|
def get_identity
|
|
345
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
385
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
346
386
|
end
|
|
347
387
|
|
|
348
388
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
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
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# Measures soil moisture
|
|
14
16
|
class BrickletMoisture < Device
|
|
@@ -51,7 +53,7 @@ module Tinkerforge
|
|
|
51
53
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
52
54
|
# the IP Connection <tt>ipcon</tt>.
|
|
53
55
|
def initialize(uid, ipcon)
|
|
54
|
-
super uid, ipcon
|
|
56
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
55
57
|
|
|
56
58
|
@api_version = [2, 0, 0]
|
|
57
59
|
|
|
@@ -66,36 +68,41 @@ module Tinkerforge
|
|
|
66
68
|
@response_expected[FUNCTION_GET_MOVING_AVERAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
67
69
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
68
70
|
|
|
69
|
-
@callback_formats[CALLBACK_MOISTURE] = 'S'
|
|
70
|
-
@callback_formats[CALLBACK_MOISTURE_REACHED] = 'S'
|
|
71
|
+
@callback_formats[CALLBACK_MOISTURE] = [10, 'S']
|
|
72
|
+
@callback_formats[CALLBACK_MOISTURE_REACHED] = [10, 'S']
|
|
71
73
|
|
|
74
|
+
@ipcon.add_device self
|
|
72
75
|
end
|
|
73
76
|
|
|
74
|
-
# Returns the current moisture value.
|
|
75
|
-
#
|
|
77
|
+
# Returns the current moisture value.
|
|
78
|
+
# A small value corresponds to little moisture, a big
|
|
76
79
|
# value corresponds to much moisture.
|
|
77
80
|
#
|
|
78
81
|
# If you want to get the moisture value periodically, it is recommended
|
|
79
82
|
# to use the CALLBACK_MOISTURE callback and set the period with
|
|
80
83
|
# BrickletMoisture#set_moisture_callback_period.
|
|
81
84
|
def get_moisture_value
|
|
82
|
-
|
|
85
|
+
check_validity
|
|
86
|
+
|
|
87
|
+
send_request FUNCTION_GET_MOISTURE_VALUE, [], '', 10, 'S'
|
|
83
88
|
end
|
|
84
89
|
|
|
85
|
-
# Sets the period
|
|
90
|
+
# Sets the period with which the CALLBACK_MOISTURE callback is triggered
|
|
86
91
|
# periodically. A value of 0 turns the callback off.
|
|
87
92
|
#
|
|
88
93
|
# The CALLBACK_MOISTURE callback is only triggered if the moisture value has changed
|
|
89
94
|
# since the last triggering.
|
|
90
|
-
#
|
|
91
|
-
# The default value is 0.
|
|
92
95
|
def set_moisture_callback_period(period)
|
|
93
|
-
|
|
96
|
+
check_validity
|
|
97
|
+
|
|
98
|
+
send_request FUNCTION_SET_MOISTURE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
94
99
|
end
|
|
95
100
|
|
|
96
101
|
# Returns the period as set by BrickletMoisture#set_moisture_callback_period.
|
|
97
102
|
def get_moisture_callback_period
|
|
98
|
-
|
|
103
|
+
check_validity
|
|
104
|
+
|
|
105
|
+
send_request FUNCTION_GET_MOISTURE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
99
106
|
end
|
|
100
107
|
|
|
101
108
|
# Sets the thresholds for the CALLBACK_MOISTURE_REACHED callback.
|
|
@@ -109,18 +116,20 @@ module Tinkerforge
|
|
|
109
116
|
# "'i'", "Callback is triggered when the moisture value is *inside* the min and max values"
|
|
110
117
|
# "'<'", "Callback is triggered when the moisture value is smaller than the min value (max is ignored)"
|
|
111
118
|
# "'>'", "Callback is triggered when the moisture value is greater than the min value (max is ignored)"
|
|
112
|
-
#
|
|
113
|
-
# The default value is ('x', 0, 0).
|
|
114
119
|
def set_moisture_callback_threshold(option, min, max)
|
|
115
|
-
|
|
120
|
+
check_validity
|
|
121
|
+
|
|
122
|
+
send_request FUNCTION_SET_MOISTURE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
116
123
|
end
|
|
117
124
|
|
|
118
125
|
# Returns the threshold as set by BrickletMoisture#set_moisture_callback_threshold.
|
|
119
126
|
def get_moisture_callback_threshold
|
|
120
|
-
|
|
127
|
+
check_validity
|
|
128
|
+
|
|
129
|
+
send_request FUNCTION_GET_MOISTURE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
121
130
|
end
|
|
122
131
|
|
|
123
|
-
# Sets the period
|
|
132
|
+
# Sets the period with which the threshold callback
|
|
124
133
|
#
|
|
125
134
|
# * CALLBACK_MOISTURE_REACHED
|
|
126
135
|
#
|
|
@@ -129,15 +138,17 @@ module Tinkerforge
|
|
|
129
138
|
# * BrickletMoisture#set_moisture_callback_threshold
|
|
130
139
|
#
|
|
131
140
|
# keeps being reached.
|
|
132
|
-
#
|
|
133
|
-
# The default value is 100.
|
|
134
141
|
def set_debounce_period(debounce)
|
|
135
|
-
|
|
142
|
+
check_validity
|
|
143
|
+
|
|
144
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
136
145
|
end
|
|
137
146
|
|
|
138
147
|
# Returns the debounce period as set by BrickletMoisture#set_debounce_period.
|
|
139
148
|
def get_debounce_period
|
|
140
|
-
|
|
149
|
+
check_validity
|
|
150
|
+
|
|
151
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
141
152
|
end
|
|
142
153
|
|
|
143
154
|
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
|
@@ -145,29 +156,31 @@ module Tinkerforge
|
|
|
145
156
|
#
|
|
146
157
|
# Setting the length to 0 will turn the averaging completely off. With less
|
|
147
158
|
# averaging, there is more noise on the data.
|
|
148
|
-
#
|
|
149
|
-
# The range for the averaging is 0-100.
|
|
150
|
-
#
|
|
151
|
-
# The default value is 100.
|
|
152
159
|
def set_moving_average(average)
|
|
153
|
-
|
|
160
|
+
check_validity
|
|
161
|
+
|
|
162
|
+
send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 8, ''
|
|
154
163
|
end
|
|
155
164
|
|
|
156
165
|
# Returns the length moving average as set by BrickletMoisture#set_moving_average.
|
|
157
166
|
def get_moving_average
|
|
158
|
-
|
|
167
|
+
check_validity
|
|
168
|
+
|
|
169
|
+
send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 9, 'C'
|
|
159
170
|
end
|
|
160
171
|
|
|
161
172
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
162
173
|
# the position, the hardware and firmware version as well as the
|
|
163
174
|
# device identifier.
|
|
164
175
|
#
|
|
165
|
-
# The position can be 'a', 'b', 'c' or '
|
|
176
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
177
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
178
|
+
# position 'z'.
|
|
166
179
|
#
|
|
167
180
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
168
181
|
# |device_identifier_constant|
|
|
169
182
|
def get_identity
|
|
170
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
183
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
171
184
|
end
|
|
172
185
|
|
|
173
186
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|