tinkerforge 2.1.23 → 2.1.28
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 +156 -75
- data/lib/tinkerforge/brick_hat.rb +109 -30
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +191 -86
- data/lib/tinkerforge/brick_imu_v2.rb +219 -118
- data/lib/tinkerforge/brick_master.rb +495 -195
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
- data/lib/tinkerforge/brick_stepper.rb +212 -100
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
- 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 +75 -47
- data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
- data/lib/tinkerforge/bricklet_compass.rb +81 -40
- 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 +68 -33
- 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 +81 -40
- 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 +99 -51
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -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 +76 -39
- 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 +75 -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_performance_dc.rb +676 -0
- 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 +57 -26
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +250 -164
- 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_servo_v2.rb +565 -0
- 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 +61 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
- 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 +92 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
- data/lib/tinkerforge/device_display_names.rb +167 -0
- data/lib/tinkerforge/ip_connection.rb +156 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +8 -3
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2021-01-15. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
|
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
|
|
15
17
|
DEVICE_IDENTIFIER = 111 # :nodoc:
|
|
16
18
|
DEVICE_DISPLAY_NAME = 'HAT Brick' # :nodoc:
|
|
17
19
|
|
|
20
|
+
# This callback is triggered periodically according to the configuration set by
|
|
21
|
+
# BrickHAT#set_voltages_callback_configuration.
|
|
22
|
+
#
|
|
23
|
+
# The parameters are the same as BrickHAT#get_voltages.
|
|
24
|
+
#
|
|
25
|
+
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
|
26
|
+
CALLBACK_VOLTAGES = 8
|
|
27
|
+
|
|
18
28
|
FUNCTION_SET_SLEEP_MODE = 1 # :nodoc:
|
|
19
29
|
FUNCTION_GET_SLEEP_MODE = 2 # :nodoc:
|
|
20
30
|
FUNCTION_SET_BRICKLET_POWER = 3 # :nodoc:
|
|
21
31
|
FUNCTION_GET_BRICKLET_POWER = 4 # :nodoc:
|
|
22
32
|
FUNCTION_GET_VOLTAGES = 5 # :nodoc:
|
|
33
|
+
FUNCTION_SET_VOLTAGES_CALLBACK_CONFIGURATION = 6 # :nodoc:
|
|
34
|
+
FUNCTION_GET_VOLTAGES_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
|
23
35
|
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
24
36
|
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
25
37
|
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
@@ -52,15 +64,17 @@ module Tinkerforge
|
|
|
52
64
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
53
65
|
# the IP Connection <tt>ipcon</tt>.
|
|
54
66
|
def initialize(uid, ipcon)
|
|
55
|
-
super uid, ipcon
|
|
67
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
56
68
|
|
|
57
|
-
@api_version = [2, 0,
|
|
69
|
+
@api_version = [2, 0, 1]
|
|
58
70
|
|
|
59
71
|
@response_expected[FUNCTION_SET_SLEEP_MODE] = RESPONSE_EXPECTED_FALSE
|
|
60
72
|
@response_expected[FUNCTION_GET_SLEEP_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
61
73
|
@response_expected[FUNCTION_SET_BRICKLET_POWER] = RESPONSE_EXPECTED_FALSE
|
|
62
74
|
@response_expected[FUNCTION_GET_BRICKLET_POWER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
63
75
|
@response_expected[FUNCTION_GET_VOLTAGES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
76
|
+
@response_expected[FUNCTION_SET_VOLTAGES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
77
|
+
@response_expected[FUNCTION_GET_VOLTAGES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
64
78
|
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
65
79
|
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
66
80
|
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -74,19 +88,21 @@ module Tinkerforge
|
|
|
74
88
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
75
89
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
76
90
|
|
|
91
|
+
@callback_formats[CALLBACK_VOLTAGES] = [12, 'S S']
|
|
77
92
|
|
|
93
|
+
@ipcon.add_device self
|
|
78
94
|
end
|
|
79
95
|
|
|
80
96
|
# Sets the sleep mode.
|
|
81
97
|
#
|
|
82
98
|
# .. note::
|
|
83
99
|
# Calling this function will cut the Raspberry Pi's power after Power Off Delay seconds.
|
|
84
|
-
# You have to shut down the
|
|
100
|
+
# You have to shut down the operating system yourself, e.g. by calling 'sudo shutdown -h now'.
|
|
85
101
|
#
|
|
86
102
|
# Parameters:
|
|
87
103
|
#
|
|
88
|
-
# * Power Off Delay: Time
|
|
89
|
-
# * 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.
|
|
90
106
|
# * Raspberry Pi Off: RPi is powered off if set to true.
|
|
91
107
|
# * Bricklets Off: Bricklets are powered off if set to true.
|
|
92
108
|
# * Enable Sleep Indicator: If set to true, the status LED will blink in a 1s interval
|
|
@@ -100,27 +116,33 @@ module Tinkerforge
|
|
|
100
116
|
# (10, 2, true, false, false). If the RPi crashes or gets stuck
|
|
101
117
|
# the HAT will reset the RPi after 10 seconds.
|
|
102
118
|
def set_sleep_mode(power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator)
|
|
103
|
-
|
|
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, ''
|
|
104
122
|
end
|
|
105
123
|
|
|
106
124
|
# Returns the sleep mode settings as set by BrickHAT#set_sleep_mode.
|
|
107
125
|
def get_sleep_mode
|
|
108
|
-
|
|
126
|
+
check_validity
|
|
127
|
+
|
|
128
|
+
send_request FUNCTION_GET_SLEEP_MODE, [], '', 19, 'L L ? ? ?'
|
|
109
129
|
end
|
|
110
130
|
|
|
111
131
|
# Set to true/false to turn the power supply of the connected Bricklets on/off.
|
|
112
|
-
#
|
|
113
|
-
# By default the Bricklets are on.
|
|
114
132
|
def set_bricklet_power(bricklet_power)
|
|
115
|
-
|
|
133
|
+
check_validity
|
|
134
|
+
|
|
135
|
+
send_request FUNCTION_SET_BRICKLET_POWER, [bricklet_power], '?', 8, ''
|
|
116
136
|
end
|
|
117
137
|
|
|
118
138
|
# Returns the power status of the connected Bricklets as set by BrickHAT#set_bricklet_power.
|
|
119
139
|
def get_bricklet_power
|
|
120
|
-
|
|
140
|
+
check_validity
|
|
141
|
+
|
|
142
|
+
send_request FUNCTION_GET_BRICKLET_POWER, [], '', 9, '?'
|
|
121
143
|
end
|
|
122
144
|
|
|
123
|
-
# Returns the USB supply voltage and the DC input supply voltage
|
|
145
|
+
# Returns the USB supply voltage and the DC input supply voltage.
|
|
124
146
|
#
|
|
125
147
|
# There are three possible combinations:
|
|
126
148
|
#
|
|
@@ -135,7 +157,36 @@ module Tinkerforge
|
|
|
135
157
|
# disconnect the DC input (or if the DC input voltage falls below the
|
|
136
158
|
# USB voltage).
|
|
137
159
|
def get_voltages
|
|
138
|
-
|
|
160
|
+
check_validity
|
|
161
|
+
|
|
162
|
+
send_request FUNCTION_GET_VOLTAGES, [], '', 12, 'S S'
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# The period is the period with which the CALLBACK_VOLTAGES
|
|
166
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
167
|
+
#
|
|
168
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
169
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
170
|
+
# period, the callback is triggered immediately on change.
|
|
171
|
+
#
|
|
172
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
173
|
+
# independent of the value.
|
|
174
|
+
#
|
|
175
|
+
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
|
176
|
+
def set_voltages_callback_configuration(period, value_has_to_change)
|
|
177
|
+
check_validity
|
|
178
|
+
|
|
179
|
+
send_request FUNCTION_SET_VOLTAGES_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Returns the callback configuration as set by
|
|
183
|
+
# BrickHAT#set_voltages_callback_configuration.
|
|
184
|
+
#
|
|
185
|
+
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
|
186
|
+
def get_voltages_callback_configuration
|
|
187
|
+
check_validity
|
|
188
|
+
|
|
189
|
+
send_request FUNCTION_GET_VOLTAGES_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
139
190
|
end
|
|
140
191
|
|
|
141
192
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -150,7 +201,9 @@ module Tinkerforge
|
|
|
150
201
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
151
202
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
152
203
|
def get_spitfp_error_count
|
|
153
|
-
|
|
204
|
+
check_validity
|
|
205
|
+
|
|
206
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
154
207
|
end
|
|
155
208
|
|
|
156
209
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -163,12 +216,16 @@ module Tinkerforge
|
|
|
163
216
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
164
217
|
# necessary to call it in a normal user program.
|
|
165
218
|
def set_bootloader_mode(mode)
|
|
166
|
-
|
|
219
|
+
check_validity
|
|
220
|
+
|
|
221
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
167
222
|
end
|
|
168
223
|
|
|
169
224
|
# Returns the current bootloader mode, see BrickHAT#set_bootloader_mode.
|
|
170
225
|
def get_bootloader_mode
|
|
171
|
-
|
|
226
|
+
check_validity
|
|
227
|
+
|
|
228
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
172
229
|
end
|
|
173
230
|
|
|
174
231
|
# Sets the firmware pointer for BrickHAT#write_firmware. The pointer has
|
|
@@ -178,7 +235,9 @@ module Tinkerforge
|
|
|
178
235
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
179
236
|
# necessary to call it in a normal user program.
|
|
180
237
|
def set_write_firmware_pointer(pointer)
|
|
181
|
-
|
|
238
|
+
check_validity
|
|
239
|
+
|
|
240
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
182
241
|
end
|
|
183
242
|
|
|
184
243
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -190,7 +249,9 @@ module Tinkerforge
|
|
|
190
249
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
191
250
|
# necessary to call it in a normal user program.
|
|
192
251
|
def write_firmware(data)
|
|
193
|
-
|
|
252
|
+
check_validity
|
|
253
|
+
|
|
254
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
194
255
|
end
|
|
195
256
|
|
|
196
257
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -201,22 +262,28 @@ module Tinkerforge
|
|
|
201
262
|
#
|
|
202
263
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
203
264
|
def set_status_led_config(config)
|
|
204
|
-
|
|
265
|
+
check_validity
|
|
266
|
+
|
|
267
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
205
268
|
end
|
|
206
269
|
|
|
207
270
|
# Returns the configuration as set by BrickHAT#set_status_led_config
|
|
208
271
|
def get_status_led_config
|
|
209
|
-
|
|
272
|
+
check_validity
|
|
273
|
+
|
|
274
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
210
275
|
end
|
|
211
276
|
|
|
212
|
-
# Returns the temperature
|
|
277
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
213
278
|
# value returned is not the ambient temperature!
|
|
214
279
|
#
|
|
215
280
|
# The temperature is only proportional to the real temperature and it has bad
|
|
216
281
|
# accuracy. Practically it is only useful as an indicator for
|
|
217
282
|
# temperature changes.
|
|
218
283
|
def get_chip_temperature
|
|
219
|
-
|
|
284
|
+
check_validity
|
|
285
|
+
|
|
286
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
220
287
|
end
|
|
221
288
|
|
|
222
289
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -226,7 +293,9 @@ module Tinkerforge
|
|
|
226
293
|
# calling functions on the existing ones will result in
|
|
227
294
|
# undefined behavior!
|
|
228
295
|
def reset
|
|
229
|
-
|
|
296
|
+
check_validity
|
|
297
|
+
|
|
298
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
230
299
|
end
|
|
231
300
|
|
|
232
301
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -235,26 +304,36 @@ module Tinkerforge
|
|
|
235
304
|
#
|
|
236
305
|
# We recommend that you use Brick Viewer to change the UID.
|
|
237
306
|
def write_uid(uid)
|
|
238
|
-
|
|
307
|
+
check_validity
|
|
308
|
+
|
|
309
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
239
310
|
end
|
|
240
311
|
|
|
241
312
|
# Returns the current UID as an integer. Encode as
|
|
242
313
|
# Base58 to get the usual string version.
|
|
243
314
|
def read_uid
|
|
244
|
-
|
|
315
|
+
check_validity
|
|
316
|
+
|
|
317
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
245
318
|
end
|
|
246
319
|
|
|
247
|
-
# Returns the UID, the UID where the
|
|
320
|
+
# Returns the UID, the UID where the HAT is connected to
|
|
321
|
+
# (typically '0' as the HAT is the root device in the topology),
|
|
248
322
|
# the position, the hardware and firmware version as well as the
|
|
249
323
|
# device identifier.
|
|
250
324
|
#
|
|
251
|
-
# The
|
|
325
|
+
# The HAT (Zero) Brick is always at position 'i'.
|
|
252
326
|
#
|
|
253
327
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
254
328
|
# |device_identifier_constant|
|
|
255
329
|
def get_identity
|
|
256
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
330
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
257
331
|
end
|
|
258
332
|
|
|
333
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
334
|
+
def register_callback(id, &block)
|
|
335
|
+
callback = block
|
|
336
|
+
@registered_callbacks[id] = callback
|
|
337
|
+
end
|
|
259
338
|
end
|
|
260
339
|
end
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2021-01-15. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
|
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
|
|
15
17
|
DEVICE_IDENTIFIER = 112 # :nodoc:
|
|
16
18
|
DEVICE_DISPLAY_NAME = 'HAT Zero Brick' # :nodoc:
|
|
17
19
|
|
|
20
|
+
# This callback is triggered periodically according to the configuration set by
|
|
21
|
+
# BrickHATZero#set_usb_voltage_callback_configuration.
|
|
22
|
+
#
|
|
23
|
+
# The parameter is the same as BrickHATZero#get_usb_voltage.
|
|
24
|
+
#
|
|
25
|
+
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
|
26
|
+
CALLBACK_USB_VOLTAGE = 4
|
|
27
|
+
|
|
18
28
|
FUNCTION_GET_USB_VOLTAGE = 1 # :nodoc:
|
|
29
|
+
FUNCTION_SET_USB_VOLTAGE_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
30
|
+
FUNCTION_GET_USB_VOLTAGE_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
19
31
|
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
20
32
|
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
21
33
|
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
@@ -29,6 +41,11 @@ module Tinkerforge
|
|
|
29
41
|
FUNCTION_READ_UID = 249 # :nodoc:
|
|
30
42
|
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
31
43
|
|
|
44
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
45
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
46
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
47
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
48
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
32
49
|
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
33
50
|
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
34
51
|
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
@@ -48,11 +65,13 @@ module Tinkerforge
|
|
|
48
65
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
49
66
|
# the IP Connection <tt>ipcon</tt>.
|
|
50
67
|
def initialize(uid, ipcon)
|
|
51
|
-
super uid, ipcon
|
|
68
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
52
69
|
|
|
53
|
-
@api_version = [2, 0,
|
|
70
|
+
@api_version = [2, 0, 1]
|
|
54
71
|
|
|
55
72
|
@response_expected[FUNCTION_GET_USB_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
73
|
+
@response_expected[FUNCTION_SET_USB_VOLTAGE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
74
|
+
@response_expected[FUNCTION_GET_USB_VOLTAGE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
56
75
|
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
57
76
|
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
58
77
|
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -66,12 +85,63 @@ module Tinkerforge
|
|
|
66
85
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
67
86
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
68
87
|
|
|
88
|
+
@callback_formats[CALLBACK_USB_VOLTAGE] = [10, 'S']
|
|
69
89
|
|
|
90
|
+
@ipcon.add_device self
|
|
70
91
|
end
|
|
71
92
|
|
|
72
|
-
# Returns the USB supply voltage of the Raspberry Pi
|
|
93
|
+
# Returns the USB supply voltage of the Raspberry Pi.
|
|
94
|
+
#
|
|
95
|
+
#
|
|
96
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
97
|
+
# CALLBACK_USB_VOLTAGE callback. You can set the callback configuration
|
|
98
|
+
# with BrickHATZero#set_usb_voltage_callback_configuration.
|
|
73
99
|
def get_usb_voltage
|
|
74
|
-
|
|
100
|
+
check_validity
|
|
101
|
+
|
|
102
|
+
send_request FUNCTION_GET_USB_VOLTAGE, [], '', 10, 'S'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# The period is the period with which the CALLBACK_USB_VOLTAGE callback is triggered
|
|
106
|
+
# periodically. A value of 0 turns the callback off.
|
|
107
|
+
#
|
|
108
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
109
|
+
# triggered after the value has changed. If the value didn't change
|
|
110
|
+
# within the period, the callback is triggered immediately on change.
|
|
111
|
+
#
|
|
112
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
113
|
+
# independent of the value.
|
|
114
|
+
#
|
|
115
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
116
|
+
#
|
|
117
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_USB_VOLTAGE callback.
|
|
118
|
+
#
|
|
119
|
+
# The following options are possible:
|
|
120
|
+
#
|
|
121
|
+
# "Option", "Description"
|
|
122
|
+
#
|
|
123
|
+
# "'x'", "Threshold is turned off"
|
|
124
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
125
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
126
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
127
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
128
|
+
#
|
|
129
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
130
|
+
#
|
|
131
|
+
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
|
132
|
+
def set_usb_voltage_callback_configuration(period, value_has_to_change, option, min, max)
|
|
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, ''
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Returns the callback configuration as set by BrickHATZero#set_usb_voltage_callback_configuration.
|
|
139
|
+
#
|
|
140
|
+
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
|
141
|
+
def get_usb_voltage_callback_configuration
|
|
142
|
+
check_validity
|
|
143
|
+
|
|
144
|
+
send_request FUNCTION_GET_USB_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
|
|
75
145
|
end
|
|
76
146
|
|
|
77
147
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -86,7 +156,9 @@ module Tinkerforge
|
|
|
86
156
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
87
157
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
88
158
|
def get_spitfp_error_count
|
|
89
|
-
|
|
159
|
+
check_validity
|
|
160
|
+
|
|
161
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
90
162
|
end
|
|
91
163
|
|
|
92
164
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -99,12 +171,16 @@ module Tinkerforge
|
|
|
99
171
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
100
172
|
# necessary to call it in a normal user program.
|
|
101
173
|
def set_bootloader_mode(mode)
|
|
102
|
-
|
|
174
|
+
check_validity
|
|
175
|
+
|
|
176
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
103
177
|
end
|
|
104
178
|
|
|
105
179
|
# Returns the current bootloader mode, see BrickHATZero#set_bootloader_mode.
|
|
106
180
|
def get_bootloader_mode
|
|
107
|
-
|
|
181
|
+
check_validity
|
|
182
|
+
|
|
183
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
108
184
|
end
|
|
109
185
|
|
|
110
186
|
# Sets the firmware pointer for BrickHATZero#write_firmware. The pointer has
|
|
@@ -114,7 +190,9 @@ module Tinkerforge
|
|
|
114
190
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
115
191
|
# necessary to call it in a normal user program.
|
|
116
192
|
def set_write_firmware_pointer(pointer)
|
|
117
|
-
|
|
193
|
+
check_validity
|
|
194
|
+
|
|
195
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
118
196
|
end
|
|
119
197
|
|
|
120
198
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -126,7 +204,9 @@ module Tinkerforge
|
|
|
126
204
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
127
205
|
# necessary to call it in a normal user program.
|
|
128
206
|
def write_firmware(data)
|
|
129
|
-
|
|
207
|
+
check_validity
|
|
208
|
+
|
|
209
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
130
210
|
end
|
|
131
211
|
|
|
132
212
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -137,22 +217,28 @@ module Tinkerforge
|
|
|
137
217
|
#
|
|
138
218
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
139
219
|
def set_status_led_config(config)
|
|
140
|
-
|
|
220
|
+
check_validity
|
|
221
|
+
|
|
222
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
141
223
|
end
|
|
142
224
|
|
|
143
225
|
# Returns the configuration as set by BrickHATZero#set_status_led_config
|
|
144
226
|
def get_status_led_config
|
|
145
|
-
|
|
227
|
+
check_validity
|
|
228
|
+
|
|
229
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
146
230
|
end
|
|
147
231
|
|
|
148
|
-
# Returns the temperature
|
|
232
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
149
233
|
# value returned is not the ambient temperature!
|
|
150
234
|
#
|
|
151
235
|
# The temperature is only proportional to the real temperature and it has bad
|
|
152
236
|
# accuracy. Practically it is only useful as an indicator for
|
|
153
237
|
# temperature changes.
|
|
154
238
|
def get_chip_temperature
|
|
155
|
-
|
|
239
|
+
check_validity
|
|
240
|
+
|
|
241
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
156
242
|
end
|
|
157
243
|
|
|
158
244
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -162,7 +248,9 @@ module Tinkerforge
|
|
|
162
248
|
# calling functions on the existing ones will result in
|
|
163
249
|
# undefined behavior!
|
|
164
250
|
def reset
|
|
165
|
-
|
|
251
|
+
check_validity
|
|
252
|
+
|
|
253
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
166
254
|
end
|
|
167
255
|
|
|
168
256
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -171,26 +259,36 @@ module Tinkerforge
|
|
|
171
259
|
#
|
|
172
260
|
# We recommend that you use Brick Viewer to change the UID.
|
|
173
261
|
def write_uid(uid)
|
|
174
|
-
|
|
262
|
+
check_validity
|
|
263
|
+
|
|
264
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
175
265
|
end
|
|
176
266
|
|
|
177
267
|
# Returns the current UID as an integer. Encode as
|
|
178
268
|
# Base58 to get the usual string version.
|
|
179
269
|
def read_uid
|
|
180
|
-
|
|
270
|
+
check_validity
|
|
271
|
+
|
|
272
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
181
273
|
end
|
|
182
274
|
|
|
183
|
-
# Returns the UID, the UID where the
|
|
275
|
+
# Returns the UID, the UID where the HAT is connected to
|
|
276
|
+
# (typically '0' as the HAT is the root device in the topology),
|
|
184
277
|
# the position, the hardware and firmware version as well as the
|
|
185
278
|
# device identifier.
|
|
186
279
|
#
|
|
187
|
-
# The
|
|
280
|
+
# The HAT (Zero) Brick is always at position 'i'.
|
|
188
281
|
#
|
|
189
282
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
190
283
|
# |device_identifier_constant|
|
|
191
284
|
def get_identity
|
|
192
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
285
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
193
286
|
end
|
|
194
287
|
|
|
288
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
289
|
+
def register_callback(id, &block)
|
|
290
|
+
callback = block
|
|
291
|
+
@registered_callbacks[id] = callback
|
|
292
|
+
end
|
|
195
293
|
end
|
|
196
294
|
end
|