tinkerforge 2.1.24 → 2.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinkerforge/brick_dc.rb +155 -74
- data/lib/tinkerforge/brick_hat.rb +70 -30
- data/lib/tinkerforge/brick_hat_zero.rb +56 -22
- data/lib/tinkerforge/brick_imu.rb +184 -77
- data/lib/tinkerforge/brick_imu_v2.rb +208 -105
- data/lib/tinkerforge/brick_master.rb +484 -182
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +185 -101
- data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
- data/lib/tinkerforge/brick_stepper.rb +210 -98
- data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
- data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
- data/lib/tinkerforge/bricklet_barometer.rb +66 -26
- data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -18
- data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
- data/lib/tinkerforge/bricklet_co2.rb +34 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
- data/lib/tinkerforge/bricklet_color.rb +69 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
- data/lib/tinkerforge/bricklet_compass.rb +78 -30
- data/lib/tinkerforge/bricklet_current12.rb +58 -24
- data/lib/tinkerforge/bricklet_current25.rb +58 -24
- data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_dmx.rb +88 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
- data/lib/tinkerforge/bricklet_gps.rb +64 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_humidity.rb +51 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_io16.rb +55 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
- data/lib/tinkerforge/bricklet_io4.rb +55 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -28
- data/lib/tinkerforge/bricklet_joystick.rb +59 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
- data/lib/tinkerforge/bricklet_line.rb +34 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
- data/lib/tinkerforge/bricklet_moisture.rb +40 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
- data/lib/tinkerforge/bricklet_nfc.rb +123 -58
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
- data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
- data/lib/tinkerforge/bricklet_ptc.rb +74 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_rs232.rb +90 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
- data/lib/tinkerforge/bricklet_rs485.rb +223 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
- data/lib/tinkerforge/bricklet_temperature.rb +40 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
- data/lib/tinkerforge/bricklet_tilt.rb +24 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
- data/lib/tinkerforge/bricklet_voltage.rb +52 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
- data/lib/tinkerforge/device_display_names.rb +163 -0
- data/lib/tinkerforge/ip_connection.rb +151 -32
- data/lib/tinkerforge/version.rb +1 -1
- metadata +3 -2
@@ -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-04-07. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
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 Voltage, Current, Energy, Real/Apparent/Reactive Power, Power Factor and Frequency
|
14
16
|
class BrickletEnergyMonitor < Device
|
@@ -62,7 +64,7 @@ module Tinkerforge
|
|
62
64
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
63
65
|
# the IP Connection <tt>ipcon</tt>.
|
64
66
|
def initialize(uid, ipcon)
|
65
|
-
super uid, ipcon
|
67
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
66
68
|
|
67
69
|
@api_version = [2, 0, 0]
|
68
70
|
|
@@ -88,8 +90,9 @@ module Tinkerforge
|
|
88
90
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
89
91
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
90
92
|
|
91
|
-
@callback_formats[CALLBACK_ENERGY_DATA] = 'l l l l l l S S'
|
93
|
+
@callback_formats[CALLBACK_ENERGY_DATA] = [36, 'l l l l l l S S']
|
92
94
|
|
95
|
+
@ipcon.add_device self
|
93
96
|
end
|
94
97
|
|
95
98
|
# Returns all of the measurements that are done by the Energy Monitor Bricklet.
|
@@ -113,12 +116,16 @@ module Tinkerforge
|
|
113
116
|
# to calculate the frequency and it will use an integration time of
|
114
117
|
# 10 zero-crossings of the current waveform.
|
115
118
|
def get_energy_data
|
116
|
-
|
119
|
+
check_validity
|
120
|
+
|
121
|
+
send_request FUNCTION_GET_ENERGY_DATA, [], '', 36, 'l l l l l l S S'
|
117
122
|
end
|
118
123
|
|
119
124
|
# Sets the energy value (see BrickletEnergyMonitor#get_energy_data) back to 0Wh.
|
120
125
|
def reset_energy
|
121
|
-
|
126
|
+
check_validity
|
127
|
+
|
128
|
+
send_request FUNCTION_RESET_ENERGY, [], '', 8, ''
|
122
129
|
end
|
123
130
|
|
124
131
|
# Returns a snapshot of the voltage and current waveform. The values
|
@@ -132,12 +139,16 @@ module Tinkerforge
|
|
132
139
|
# This data is meant to be used for a non-realtime graphical representation of
|
133
140
|
# the voltage and current waveforms.
|
134
141
|
def get_waveform_low_level
|
135
|
-
|
142
|
+
check_validity
|
143
|
+
|
144
|
+
send_request FUNCTION_GET_WAVEFORM_LOW_LEVEL, [], '', 70, 'S s30'
|
136
145
|
end
|
137
146
|
|
138
147
|
# Returns *true* if a voltage/current transformer is connected to the Bricklet.
|
139
148
|
def get_transformer_status
|
140
|
-
|
149
|
+
check_validity
|
150
|
+
|
151
|
+
send_request FUNCTION_GET_TRANSFORMER_STATUS, [], '', 10, '? ?'
|
141
152
|
end
|
142
153
|
|
143
154
|
# Sets the transformer ratio for the voltage and current transformer in 1/100 form.
|
@@ -153,12 +164,16 @@ module Tinkerforge
|
|
153
164
|
#
|
154
165
|
# Set the phase shift to 0. It is for future use and currently not supported by the Bricklet.
|
155
166
|
def set_transformer_calibration(voltage_ratio, current_ratio, phase_shift)
|
156
|
-
|
167
|
+
check_validity
|
168
|
+
|
169
|
+
send_request FUNCTION_SET_TRANSFORMER_CALIBRATION, [voltage_ratio, current_ratio, phase_shift], 'S S s', 8, ''
|
157
170
|
end
|
158
171
|
|
159
172
|
# Returns the transformer calibration as set by BrickletEnergyMonitor#set_transformer_calibration.
|
160
173
|
def get_transformer_calibration
|
161
|
-
|
174
|
+
check_validity
|
175
|
+
|
176
|
+
send_request FUNCTION_GET_TRANSFORMER_CALIBRATION, [], '', 14, 'S S s'
|
162
177
|
end
|
163
178
|
|
164
179
|
# Calling this function will start an offset calibration. The offset calibration will
|
@@ -174,7 +189,9 @@ module Tinkerforge
|
|
174
189
|
#
|
175
190
|
# The calibration is saved in non-volatile memory, you only have to set it once.
|
176
191
|
def calibrate_offset
|
177
|
-
|
192
|
+
check_validity
|
193
|
+
|
194
|
+
send_request FUNCTION_CALIBRATE_OFFSET, [], '', 8, ''
|
178
195
|
end
|
179
196
|
|
180
197
|
# The period is the period with which the CALLBACK_ENERGY_DATA
|
@@ -187,13 +204,17 @@ module Tinkerforge
|
|
187
204
|
# If it is set to false, the callback is continuously triggered with the period,
|
188
205
|
# independent of the value.
|
189
206
|
def set_energy_data_callback_configuration(period, value_has_to_change)
|
190
|
-
|
207
|
+
check_validity
|
208
|
+
|
209
|
+
send_request FUNCTION_SET_ENERGY_DATA_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
191
210
|
end
|
192
211
|
|
193
212
|
# Returns the callback configuration as set by
|
194
213
|
# BrickletEnergyMonitor#set_energy_data_callback_configuration.
|
195
214
|
def get_energy_data_callback_configuration
|
196
|
-
|
215
|
+
check_validity
|
216
|
+
|
217
|
+
send_request FUNCTION_GET_ENERGY_DATA_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
197
218
|
end
|
198
219
|
|
199
220
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -208,7 +229,9 @@ module Tinkerforge
|
|
208
229
|
# The errors counts are for errors that occur on the Bricklet side. All
|
209
230
|
# Bricks have a similar function that returns the errors on the Brick side.
|
210
231
|
def get_spitfp_error_count
|
211
|
-
|
232
|
+
check_validity
|
233
|
+
|
234
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
212
235
|
end
|
213
236
|
|
214
237
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -221,12 +244,16 @@ module Tinkerforge
|
|
221
244
|
# This function is used by Brick Viewer during flashing. It should not be
|
222
245
|
# necessary to call it in a normal user program.
|
223
246
|
def set_bootloader_mode(mode)
|
224
|
-
|
247
|
+
check_validity
|
248
|
+
|
249
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
225
250
|
end
|
226
251
|
|
227
252
|
# Returns the current bootloader mode, see BrickletEnergyMonitor#set_bootloader_mode.
|
228
253
|
def get_bootloader_mode
|
229
|
-
|
254
|
+
check_validity
|
255
|
+
|
256
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
230
257
|
end
|
231
258
|
|
232
259
|
# Sets the firmware pointer for BrickletEnergyMonitor#write_firmware. The pointer has
|
@@ -236,7 +263,9 @@ module Tinkerforge
|
|
236
263
|
# This function is used by Brick Viewer during flashing. It should not be
|
237
264
|
# necessary to call it in a normal user program.
|
238
265
|
def set_write_firmware_pointer(pointer)
|
239
|
-
|
266
|
+
check_validity
|
267
|
+
|
268
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
240
269
|
end
|
241
270
|
|
242
271
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -248,7 +277,9 @@ module Tinkerforge
|
|
248
277
|
# This function is used by Brick Viewer during flashing. It should not be
|
249
278
|
# necessary to call it in a normal user program.
|
250
279
|
def write_firmware(data)
|
251
|
-
|
280
|
+
check_validity
|
281
|
+
|
282
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
252
283
|
end
|
253
284
|
|
254
285
|
# Sets the status LED configuration. By default the LED shows
|
@@ -259,22 +290,28 @@ module Tinkerforge
|
|
259
290
|
#
|
260
291
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
261
292
|
def set_status_led_config(config)
|
262
|
-
|
293
|
+
check_validity
|
294
|
+
|
295
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
263
296
|
end
|
264
297
|
|
265
298
|
# Returns the configuration as set by BrickletEnergyMonitor#set_status_led_config
|
266
299
|
def get_status_led_config
|
267
|
-
|
300
|
+
check_validity
|
301
|
+
|
302
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
268
303
|
end
|
269
304
|
|
270
|
-
# Returns the temperature
|
305
|
+
# Returns the temperature as measured inside the microcontroller. The
|
271
306
|
# value returned is not the ambient temperature!
|
272
307
|
#
|
273
308
|
# The temperature is only proportional to the real temperature and it has bad
|
274
309
|
# accuracy. Practically it is only useful as an indicator for
|
275
310
|
# temperature changes.
|
276
311
|
def get_chip_temperature
|
277
|
-
|
312
|
+
check_validity
|
313
|
+
|
314
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
278
315
|
end
|
279
316
|
|
280
317
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -284,7 +321,9 @@ module Tinkerforge
|
|
284
321
|
# calling functions on the existing ones will result in
|
285
322
|
# undefined behavior!
|
286
323
|
def reset
|
287
|
-
|
324
|
+
check_validity
|
325
|
+
|
326
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
288
327
|
end
|
289
328
|
|
290
329
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -293,25 +332,32 @@ module Tinkerforge
|
|
293
332
|
#
|
294
333
|
# We recommend that you use Brick Viewer to change the UID.
|
295
334
|
def write_uid(uid)
|
296
|
-
|
335
|
+
check_validity
|
336
|
+
|
337
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
297
338
|
end
|
298
339
|
|
299
340
|
# Returns the current UID as an integer. Encode as
|
300
341
|
# Base58 to get the usual string version.
|
301
342
|
def read_uid
|
302
|
-
|
343
|
+
check_validity
|
344
|
+
|
345
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
303
346
|
end
|
304
347
|
|
305
348
|
# Returns the UID, the UID where the Bricklet is connected to,
|
306
349
|
# the position, the hardware and firmware version as well as the
|
307
350
|
# device identifier.
|
308
351
|
#
|
309
|
-
# The position can be 'a', 'b', 'c' or '
|
352
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
353
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
354
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
355
|
+
# position 'z'.
|
310
356
|
#
|
311
357
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
312
358
|
# |device_identifier_constant|
|
313
359
|
def get_identity
|
314
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
360
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
315
361
|
end
|
316
362
|
|
317
363
|
# Returns a snapshot of the voltage and current waveform. The values
|
@@ -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-04-07. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
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
|
# Determine position, velocity and altitude using GPS
|
14
16
|
class BrickletGPS < Device
|
@@ -87,7 +89,7 @@ module Tinkerforge
|
|
87
89
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
88
90
|
# the IP Connection <tt>ipcon</tt>.
|
89
91
|
def initialize(uid, ipcon)
|
90
|
-
super uid, ipcon
|
92
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
91
93
|
|
92
94
|
@api_version = [2, 0, 1]
|
93
95
|
|
@@ -109,12 +111,13 @@ module Tinkerforge
|
|
109
111
|
@response_expected[FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
110
112
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
111
113
|
|
112
|
-
@callback_formats[CALLBACK_COORDINATES] = 'L k L k S S S S'
|
113
|
-
@callback_formats[CALLBACK_STATUS] = 'C C C'
|
114
|
-
@callback_formats[CALLBACK_ALTITUDE] = 'l l'
|
115
|
-
@callback_formats[CALLBACK_MOTION] = 'L L'
|
116
|
-
@callback_formats[CALLBACK_DATE_TIME] = 'L L'
|
114
|
+
@callback_formats[CALLBACK_COORDINATES] = [26, 'L k L k S S S S']
|
115
|
+
@callback_formats[CALLBACK_STATUS] = [11, 'C C C']
|
116
|
+
@callback_formats[CALLBACK_ALTITUDE] = [16, 'l l']
|
117
|
+
@callback_formats[CALLBACK_MOTION] = [16, 'L L']
|
118
|
+
@callback_formats[CALLBACK_DATE_TIME] = [16, 'L L']
|
117
119
|
|
120
|
+
@ipcon.add_device self
|
118
121
|
end
|
119
122
|
|
120
123
|
# Returns the GPS coordinates. Latitude and longitude are given in the
|
@@ -136,7 +139,9 @@ module Tinkerforge
|
|
136
139
|
# This data is only valid if there is currently a fix as indicated by
|
137
140
|
# BrickletGPS#get_status.
|
138
141
|
def get_coordinates
|
139
|
-
|
142
|
+
check_validity
|
143
|
+
|
144
|
+
send_request FUNCTION_GET_COORDINATES, [], '', 26, 'L k L k S S S S'
|
140
145
|
end
|
141
146
|
|
142
147
|
# Returns the current fix status, the number of satellites that are in view and
|
@@ -153,7 +158,9 @@ module Tinkerforge
|
|
153
158
|
# There is also a :ref:`blue LED <gps_bricklet_fix_led>` on the Bricklet that
|
154
159
|
# indicates the fix status.
|
155
160
|
def get_status
|
156
|
-
|
161
|
+
check_validity
|
162
|
+
|
163
|
+
send_request FUNCTION_GET_STATUS, [], '', 11, 'C C C'
|
157
164
|
end
|
158
165
|
|
159
166
|
# Returns the current altitude and corresponding geoidal separation.
|
@@ -161,7 +168,9 @@ module Tinkerforge
|
|
161
168
|
# This data is only valid if there is currently a fix as indicated by
|
162
169
|
# BrickletGPS#get_status.
|
163
170
|
def get_altitude
|
164
|
-
|
171
|
+
check_validity
|
172
|
+
|
173
|
+
send_request FUNCTION_GET_ALTITUDE, [], '', 16, 'l l'
|
165
174
|
end
|
166
175
|
|
167
176
|
# Returns the current course and speed. A course of 0° means the Bricklet is
|
@@ -173,7 +182,9 @@ module Tinkerforge
|
|
173
182
|
# This data is only valid if there is currently a fix as indicated by
|
174
183
|
# BrickletGPS#get_status.
|
175
184
|
def get_motion
|
176
|
-
|
185
|
+
check_validity
|
186
|
+
|
187
|
+
send_request FUNCTION_GET_MOTION, [], '', 16, 'L L'
|
177
188
|
end
|
178
189
|
|
179
190
|
# Returns the current date and time. The date is
|
@@ -181,7 +192,9 @@ module Tinkerforge
|
|
181
192
|
# in the format ``hhmmss.sss``. For example, 140713 means
|
182
193
|
# 14.07.13 as date and 195923568 means 19:59:23.568 as time.
|
183
194
|
def get_date_time
|
184
|
-
|
195
|
+
check_validity
|
196
|
+
|
197
|
+
send_request FUNCTION_GET_DATE_TIME, [], '', 16, 'L L'
|
185
198
|
end
|
186
199
|
|
187
200
|
# Restarts the GPS Bricklet, the following restart types are available:
|
@@ -193,7 +206,9 @@ module Tinkerforge
|
|
193
206
|
# "2", "Cold start (don't use time, position, almanacs and ephemeris at restart)"
|
194
207
|
# "3", "Factory reset (clear all system/user configurations at restart)"
|
195
208
|
def restart(restart_type)
|
196
|
-
|
209
|
+
check_validity
|
210
|
+
|
211
|
+
send_request FUNCTION_RESTART, [restart_type], 'C', 8, ''
|
197
212
|
end
|
198
213
|
|
199
214
|
# Sets the period with which the CALLBACK_COORDINATES callback is triggered
|
@@ -202,12 +217,16 @@ module Tinkerforge
|
|
202
217
|
# The CALLBACK_COORDINATES callback is only triggered if the coordinates changed
|
203
218
|
# since the last triggering.
|
204
219
|
def set_coordinates_callback_period(period)
|
205
|
-
|
220
|
+
check_validity
|
221
|
+
|
222
|
+
send_request FUNCTION_SET_COORDINATES_CALLBACK_PERIOD, [period], 'L', 8, ''
|
206
223
|
end
|
207
224
|
|
208
225
|
# Returns the period as set by BrickletGPS#set_coordinates_callback_period.
|
209
226
|
def get_coordinates_callback_period
|
210
|
-
|
227
|
+
check_validity
|
228
|
+
|
229
|
+
send_request FUNCTION_GET_COORDINATES_CALLBACK_PERIOD, [], '', 12, 'L'
|
211
230
|
end
|
212
231
|
|
213
232
|
# Sets the period with which the CALLBACK_STATUS callback is triggered
|
@@ -216,12 +235,16 @@ module Tinkerforge
|
|
216
235
|
# The CALLBACK_STATUS callback is only triggered if the status changed since the
|
217
236
|
# last triggering.
|
218
237
|
def set_status_callback_period(period)
|
219
|
-
|
238
|
+
check_validity
|
239
|
+
|
240
|
+
send_request FUNCTION_SET_STATUS_CALLBACK_PERIOD, [period], 'L', 8, ''
|
220
241
|
end
|
221
242
|
|
222
243
|
# Returns the period as set by BrickletGPS#set_status_callback_period.
|
223
244
|
def get_status_callback_period
|
224
|
-
|
245
|
+
check_validity
|
246
|
+
|
247
|
+
send_request FUNCTION_GET_STATUS_CALLBACK_PERIOD, [], '', 12, 'L'
|
225
248
|
end
|
226
249
|
|
227
250
|
# Sets the period with which the CALLBACK_ALTITUDE callback is triggered
|
@@ -230,12 +253,16 @@ module Tinkerforge
|
|
230
253
|
# The CALLBACK_ALTITUDE callback is only triggered if the altitude changed since
|
231
254
|
# the last triggering.
|
232
255
|
def set_altitude_callback_period(period)
|
233
|
-
|
256
|
+
check_validity
|
257
|
+
|
258
|
+
send_request FUNCTION_SET_ALTITUDE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
234
259
|
end
|
235
260
|
|
236
261
|
# Returns the period as set by BrickletGPS#set_altitude_callback_period.
|
237
262
|
def get_altitude_callback_period
|
238
|
-
|
263
|
+
check_validity
|
264
|
+
|
265
|
+
send_request FUNCTION_GET_ALTITUDE_CALLBACK_PERIOD, [], '', 12, 'L'
|
239
266
|
end
|
240
267
|
|
241
268
|
# Sets the period with which the CALLBACK_MOTION callback is triggered
|
@@ -244,12 +271,16 @@ module Tinkerforge
|
|
244
271
|
# The CALLBACK_MOTION callback is only triggered if the motion changed since the
|
245
272
|
# last triggering.
|
246
273
|
def set_motion_callback_period(period)
|
247
|
-
|
274
|
+
check_validity
|
275
|
+
|
276
|
+
send_request FUNCTION_SET_MOTION_CALLBACK_PERIOD, [period], 'L', 8, ''
|
248
277
|
end
|
249
278
|
|
250
279
|
# Returns the period as set by BrickletGPS#set_motion_callback_period.
|
251
280
|
def get_motion_callback_period
|
252
|
-
|
281
|
+
check_validity
|
282
|
+
|
283
|
+
send_request FUNCTION_GET_MOTION_CALLBACK_PERIOD, [], '', 12, 'L'
|
253
284
|
end
|
254
285
|
|
255
286
|
# Sets the period with which the CALLBACK_DATE_TIME callback is triggered
|
@@ -258,24 +289,31 @@ module Tinkerforge
|
|
258
289
|
# The CALLBACK_DATE_TIME callback is only triggered if the date or time changed
|
259
290
|
# since the last triggering.
|
260
291
|
def set_date_time_callback_period(period)
|
261
|
-
|
292
|
+
check_validity
|
293
|
+
|
294
|
+
send_request FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD, [period], 'L', 8, ''
|
262
295
|
end
|
263
296
|
|
264
297
|
# Returns the period as set by BrickletGPS#set_date_time_callback_period.
|
265
298
|
def get_date_time_callback_period
|
266
|
-
|
299
|
+
check_validity
|
300
|
+
|
301
|
+
send_request FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD, [], '', 12, 'L'
|
267
302
|
end
|
268
303
|
|
269
304
|
# Returns the UID, the UID where the Bricklet is connected to,
|
270
305
|
# the position, the hardware and firmware version as well as the
|
271
306
|
# device identifier.
|
272
307
|
#
|
273
|
-
# The position can be 'a', 'b', 'c' or '
|
308
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
309
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
310
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
311
|
+
# position 'z'.
|
274
312
|
#
|
275
313
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
276
314
|
# |device_identifier_constant|
|
277
315
|
def get_identity
|
278
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
316
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
279
317
|
end
|
280
318
|
|
281
319
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|