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
|
# HAT for Raspberry Pi with 8 Bricklets ports and real-time clock
|
14
16
|
class BrickHAT < 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, 1]
|
68
70
|
|
@@ -86,8 +88,9 @@ module Tinkerforge
|
|
86
88
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
87
89
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
88
90
|
|
89
|
-
@callback_formats[CALLBACK_VOLTAGES] = 'S S'
|
91
|
+
@callback_formats[CALLBACK_VOLTAGES] = [12, 'S S']
|
90
92
|
|
93
|
+
@ipcon.add_device self
|
91
94
|
end
|
92
95
|
|
93
96
|
# Sets the sleep mode.
|
@@ -98,8 +101,8 @@ module Tinkerforge
|
|
98
101
|
#
|
99
102
|
# Parameters:
|
100
103
|
#
|
101
|
-
# * Power Off Delay: Time
|
102
|
-
# * Power Off Duration: Duration
|
104
|
+
# * Power Off Delay: Time before the RPi/Bricklets are powered off.
|
105
|
+
# * Power Off Duration: Duration that the RPi/Bricklets stay powered off.
|
103
106
|
# * Raspberry Pi Off: RPi is powered off if set to true.
|
104
107
|
# * Bricklets Off: Bricklets are powered off if set to true.
|
105
108
|
# * Enable Sleep Indicator: If set to true, the status LED will blink in a 1s interval
|
@@ -113,27 +116,33 @@ module Tinkerforge
|
|
113
116
|
# (10, 2, true, false, false). If the RPi crashes or gets stuck
|
114
117
|
# the HAT will reset the RPi after 10 seconds.
|
115
118
|
def set_sleep_mode(power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator)
|
116
|
-
|
119
|
+
check_validity
|
120
|
+
|
121
|
+
send_request FUNCTION_SET_SLEEP_MODE, [power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator], 'L L ? ? ?', 8, ''
|
117
122
|
end
|
118
123
|
|
119
124
|
# Returns the sleep mode settings as set by BrickHAT#set_sleep_mode.
|
120
125
|
def get_sleep_mode
|
121
|
-
|
126
|
+
check_validity
|
127
|
+
|
128
|
+
send_request FUNCTION_GET_SLEEP_MODE, [], '', 19, 'L L ? ? ?'
|
122
129
|
end
|
123
130
|
|
124
131
|
# Set to true/false to turn the power supply of the connected Bricklets on/off.
|
125
|
-
#
|
126
|
-
# By default the Bricklets are on.
|
127
132
|
def set_bricklet_power(bricklet_power)
|
128
|
-
|
133
|
+
check_validity
|
134
|
+
|
135
|
+
send_request FUNCTION_SET_BRICKLET_POWER, [bricklet_power], '?', 8, ''
|
129
136
|
end
|
130
137
|
|
131
138
|
# Returns the power status of the connected Bricklets as set by BrickHAT#set_bricklet_power.
|
132
139
|
def get_bricklet_power
|
133
|
-
|
140
|
+
check_validity
|
141
|
+
|
142
|
+
send_request FUNCTION_GET_BRICKLET_POWER, [], '', 9, '?'
|
134
143
|
end
|
135
144
|
|
136
|
-
# Returns the USB supply voltage and the DC input supply voltage
|
145
|
+
# Returns the USB supply voltage and the DC input supply voltage.
|
137
146
|
#
|
138
147
|
# There are three possible combinations:
|
139
148
|
#
|
@@ -148,7 +157,9 @@ module Tinkerforge
|
|
148
157
|
# disconnect the DC input (or if the DC input voltage falls below the
|
149
158
|
# USB voltage).
|
150
159
|
def get_voltages
|
151
|
-
|
160
|
+
check_validity
|
161
|
+
|
162
|
+
send_request FUNCTION_GET_VOLTAGES, [], '', 12, 'S S'
|
152
163
|
end
|
153
164
|
|
154
165
|
# The period is the period with which the CALLBACK_VOLTAGES
|
@@ -163,7 +174,9 @@ module Tinkerforge
|
|
163
174
|
#
|
164
175
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
165
176
|
def set_voltages_callback_configuration(period, value_has_to_change)
|
166
|
-
|
177
|
+
check_validity
|
178
|
+
|
179
|
+
send_request FUNCTION_SET_VOLTAGES_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
167
180
|
end
|
168
181
|
|
169
182
|
# Returns the callback configuration as set by
|
@@ -171,7 +184,9 @@ module Tinkerforge
|
|
171
184
|
#
|
172
185
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
173
186
|
def get_voltages_callback_configuration
|
174
|
-
|
187
|
+
check_validity
|
188
|
+
|
189
|
+
send_request FUNCTION_GET_VOLTAGES_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
175
190
|
end
|
176
191
|
|
177
192
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -186,7 +201,9 @@ module Tinkerforge
|
|
186
201
|
# The errors counts are for errors that occur on the Bricklet side. All
|
187
202
|
# Bricks have a similar function that returns the errors on the Brick side.
|
188
203
|
def get_spitfp_error_count
|
189
|
-
|
204
|
+
check_validity
|
205
|
+
|
206
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
190
207
|
end
|
191
208
|
|
192
209
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -199,12 +216,16 @@ module Tinkerforge
|
|
199
216
|
# This function is used by Brick Viewer during flashing. It should not be
|
200
217
|
# necessary to call it in a normal user program.
|
201
218
|
def set_bootloader_mode(mode)
|
202
|
-
|
219
|
+
check_validity
|
220
|
+
|
221
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
203
222
|
end
|
204
223
|
|
205
224
|
# Returns the current bootloader mode, see BrickHAT#set_bootloader_mode.
|
206
225
|
def get_bootloader_mode
|
207
|
-
|
226
|
+
check_validity
|
227
|
+
|
228
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
208
229
|
end
|
209
230
|
|
210
231
|
# Sets the firmware pointer for BrickHAT#write_firmware. The pointer has
|
@@ -214,7 +235,9 @@ module Tinkerforge
|
|
214
235
|
# This function is used by Brick Viewer during flashing. It should not be
|
215
236
|
# necessary to call it in a normal user program.
|
216
237
|
def set_write_firmware_pointer(pointer)
|
217
|
-
|
238
|
+
check_validity
|
239
|
+
|
240
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
218
241
|
end
|
219
242
|
|
220
243
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -226,7 +249,9 @@ module Tinkerforge
|
|
226
249
|
# This function is used by Brick Viewer during flashing. It should not be
|
227
250
|
# necessary to call it in a normal user program.
|
228
251
|
def write_firmware(data)
|
229
|
-
|
252
|
+
check_validity
|
253
|
+
|
254
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
230
255
|
end
|
231
256
|
|
232
257
|
# Sets the status LED configuration. By default the LED shows
|
@@ -237,22 +262,28 @@ module Tinkerforge
|
|
237
262
|
#
|
238
263
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
239
264
|
def set_status_led_config(config)
|
240
|
-
|
265
|
+
check_validity
|
266
|
+
|
267
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
241
268
|
end
|
242
269
|
|
243
270
|
# Returns the configuration as set by BrickHAT#set_status_led_config
|
244
271
|
def get_status_led_config
|
245
|
-
|
272
|
+
check_validity
|
273
|
+
|
274
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
246
275
|
end
|
247
276
|
|
248
|
-
# Returns the temperature
|
277
|
+
# Returns the temperature as measured inside the microcontroller. The
|
249
278
|
# value returned is not the ambient temperature!
|
250
279
|
#
|
251
280
|
# The temperature is only proportional to the real temperature and it has bad
|
252
281
|
# accuracy. Practically it is only useful as an indicator for
|
253
282
|
# temperature changes.
|
254
283
|
def get_chip_temperature
|
255
|
-
|
284
|
+
check_validity
|
285
|
+
|
286
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
256
287
|
end
|
257
288
|
|
258
289
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -262,7 +293,9 @@ module Tinkerforge
|
|
262
293
|
# calling functions on the existing ones will result in
|
263
294
|
# undefined behavior!
|
264
295
|
def reset
|
265
|
-
|
296
|
+
check_validity
|
297
|
+
|
298
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
266
299
|
end
|
267
300
|
|
268
301
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -271,25 +304,32 @@ module Tinkerforge
|
|
271
304
|
#
|
272
305
|
# We recommend that you use Brick Viewer to change the UID.
|
273
306
|
def write_uid(uid)
|
274
|
-
|
307
|
+
check_validity
|
308
|
+
|
309
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
275
310
|
end
|
276
311
|
|
277
312
|
# Returns the current UID as an integer. Encode as
|
278
313
|
# Base58 to get the usual string version.
|
279
314
|
def read_uid
|
280
|
-
|
315
|
+
check_validity
|
316
|
+
|
317
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
281
318
|
end
|
282
319
|
|
283
320
|
# Returns the UID, the UID where the Bricklet is connected to,
|
284
321
|
# the position, the hardware and firmware version as well as the
|
285
322
|
# device identifier.
|
286
323
|
#
|
287
|
-
# The position can be 'a', 'b', 'c' or '
|
324
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
325
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
326
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
327
|
+
# position 'z'.
|
288
328
|
#
|
289
329
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
290
330
|
# |device_identifier_constant|
|
291
331
|
def get_identity
|
292
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
332
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
293
333
|
end
|
294
334
|
|
295
335
|
# 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-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
|
# HAT for Raspberry Pi Zero with 4 Bricklets ports
|
14
16
|
class BrickHATZero < Device
|
@@ -63,7 +65,7 @@ module Tinkerforge
|
|
63
65
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
64
66
|
# the IP Connection <tt>ipcon</tt>.
|
65
67
|
def initialize(uid, ipcon)
|
66
|
-
super uid, ipcon
|
68
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
67
69
|
|
68
70
|
@api_version = [2, 0, 1]
|
69
71
|
|
@@ -83,18 +85,21 @@ module Tinkerforge
|
|
83
85
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
84
86
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
85
87
|
|
86
|
-
@callback_formats[CALLBACK_USB_VOLTAGE] = 'S'
|
88
|
+
@callback_formats[CALLBACK_USB_VOLTAGE] = [10, 'S']
|
87
89
|
|
90
|
+
@ipcon.add_device self
|
88
91
|
end
|
89
92
|
|
90
|
-
# Returns the USB supply voltage of the Raspberry Pi
|
93
|
+
# Returns the USB supply voltage of the Raspberry Pi.
|
91
94
|
#
|
92
95
|
#
|
93
96
|
# If you want to get the value periodically, it is recommended to use the
|
94
97
|
# CALLBACK_USB_VOLTAGE callback. You can set the callback configuration
|
95
98
|
# with BrickHATZero#set_usb_voltage_callback_configuration.
|
96
99
|
def get_usb_voltage
|
97
|
-
|
100
|
+
check_validity
|
101
|
+
|
102
|
+
send_request FUNCTION_GET_USB_VOLTAGE, [], '', 10, 'S'
|
98
103
|
end
|
99
104
|
|
100
105
|
# The period is the period with which the CALLBACK_USB_VOLTAGE callback is triggered
|
@@ -125,14 +130,18 @@ module Tinkerforge
|
|
125
130
|
#
|
126
131
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
127
132
|
def set_usb_voltage_callback_configuration(period, value_has_to_change, option, min, max)
|
128
|
-
|
133
|
+
check_validity
|
134
|
+
|
135
|
+
send_request FUNCTION_SET_USB_VOLTAGE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
|
129
136
|
end
|
130
137
|
|
131
138
|
# Returns the callback configuration as set by BrickHATZero#set_usb_voltage_callback_configuration.
|
132
139
|
#
|
133
140
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
134
141
|
def get_usb_voltage_callback_configuration
|
135
|
-
|
142
|
+
check_validity
|
143
|
+
|
144
|
+
send_request FUNCTION_GET_USB_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
|
136
145
|
end
|
137
146
|
|
138
147
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -147,7 +156,9 @@ module Tinkerforge
|
|
147
156
|
# The errors counts are for errors that occur on the Bricklet side. All
|
148
157
|
# Bricks have a similar function that returns the errors on the Brick side.
|
149
158
|
def get_spitfp_error_count
|
150
|
-
|
159
|
+
check_validity
|
160
|
+
|
161
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
151
162
|
end
|
152
163
|
|
153
164
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -160,12 +171,16 @@ module Tinkerforge
|
|
160
171
|
# This function is used by Brick Viewer during flashing. It should not be
|
161
172
|
# necessary to call it in a normal user program.
|
162
173
|
def set_bootloader_mode(mode)
|
163
|
-
|
174
|
+
check_validity
|
175
|
+
|
176
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
164
177
|
end
|
165
178
|
|
166
179
|
# Returns the current bootloader mode, see BrickHATZero#set_bootloader_mode.
|
167
180
|
def get_bootloader_mode
|
168
|
-
|
181
|
+
check_validity
|
182
|
+
|
183
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
169
184
|
end
|
170
185
|
|
171
186
|
# Sets the firmware pointer for BrickHATZero#write_firmware. The pointer has
|
@@ -175,7 +190,9 @@ module Tinkerforge
|
|
175
190
|
# This function is used by Brick Viewer during flashing. It should not be
|
176
191
|
# necessary to call it in a normal user program.
|
177
192
|
def set_write_firmware_pointer(pointer)
|
178
|
-
|
193
|
+
check_validity
|
194
|
+
|
195
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
179
196
|
end
|
180
197
|
|
181
198
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -187,7 +204,9 @@ module Tinkerforge
|
|
187
204
|
# This function is used by Brick Viewer during flashing. It should not be
|
188
205
|
# necessary to call it in a normal user program.
|
189
206
|
def write_firmware(data)
|
190
|
-
|
207
|
+
check_validity
|
208
|
+
|
209
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
191
210
|
end
|
192
211
|
|
193
212
|
# Sets the status LED configuration. By default the LED shows
|
@@ -198,22 +217,28 @@ module Tinkerforge
|
|
198
217
|
#
|
199
218
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
200
219
|
def set_status_led_config(config)
|
201
|
-
|
220
|
+
check_validity
|
221
|
+
|
222
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
202
223
|
end
|
203
224
|
|
204
225
|
# Returns the configuration as set by BrickHATZero#set_status_led_config
|
205
226
|
def get_status_led_config
|
206
|
-
|
227
|
+
check_validity
|
228
|
+
|
229
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
207
230
|
end
|
208
231
|
|
209
|
-
# Returns the temperature
|
232
|
+
# Returns the temperature as measured inside the microcontroller. The
|
210
233
|
# value returned is not the ambient temperature!
|
211
234
|
#
|
212
235
|
# The temperature is only proportional to the real temperature and it has bad
|
213
236
|
# accuracy. Practically it is only useful as an indicator for
|
214
237
|
# temperature changes.
|
215
238
|
def get_chip_temperature
|
216
|
-
|
239
|
+
check_validity
|
240
|
+
|
241
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
217
242
|
end
|
218
243
|
|
219
244
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -223,7 +248,9 @@ module Tinkerforge
|
|
223
248
|
# calling functions on the existing ones will result in
|
224
249
|
# undefined behavior!
|
225
250
|
def reset
|
226
|
-
|
251
|
+
check_validity
|
252
|
+
|
253
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
227
254
|
end
|
228
255
|
|
229
256
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -232,25 +259,32 @@ module Tinkerforge
|
|
232
259
|
#
|
233
260
|
# We recommend that you use Brick Viewer to change the UID.
|
234
261
|
def write_uid(uid)
|
235
|
-
|
262
|
+
check_validity
|
263
|
+
|
264
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
236
265
|
end
|
237
266
|
|
238
267
|
# Returns the current UID as an integer. Encode as
|
239
268
|
# Base58 to get the usual string version.
|
240
269
|
def read_uid
|
241
|
-
|
270
|
+
check_validity
|
271
|
+
|
272
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
242
273
|
end
|
243
274
|
|
244
275
|
# Returns the UID, the UID where the Bricklet is connected to,
|
245
276
|
# the position, the hardware and firmware version as well as the
|
246
277
|
# device identifier.
|
247
278
|
#
|
248
|
-
# The position can be 'a', 'b', 'c' or '
|
279
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
280
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
281
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
282
|
+
# position 'z'.
|
249
283
|
#
|
250
284
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
251
285
|
# |device_identifier_constant|
|
252
286
|
def get_identity
|
253
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
287
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
254
288
|
end
|
255
289
|
|
256
290
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|