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 power, DC voltage and DC current up to 720W/36V/20A
|
|
14
16
|
class BrickletVoltageCurrentV2 < Device
|
|
@@ -72,6 +74,14 @@ module Tinkerforge
|
|
|
72
74
|
AVERAGING_256 = 5 # :nodoc:
|
|
73
75
|
AVERAGING_512 = 6 # :nodoc:
|
|
74
76
|
AVERAGING_1024 = 7 # :nodoc:
|
|
77
|
+
CONVERSION_TIME_140US = 0 # :nodoc:
|
|
78
|
+
CONVERSION_TIME_204US = 1 # :nodoc:
|
|
79
|
+
CONVERSION_TIME_332US = 2 # :nodoc:
|
|
80
|
+
CONVERSION_TIME_588US = 3 # :nodoc:
|
|
81
|
+
CONVERSION_TIME_1_1MS = 4 # :nodoc:
|
|
82
|
+
CONVERSION_TIME_2_116MS = 5 # :nodoc:
|
|
83
|
+
CONVERSION_TIME_4_156MS = 6 # :nodoc:
|
|
84
|
+
CONVERSION_TIME_8_244MS = 7 # :nodoc:
|
|
75
85
|
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
76
86
|
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
77
87
|
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
@@ -91,7 +101,7 @@ module Tinkerforge
|
|
|
91
101
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
92
102
|
# the IP Connection <tt>ipcon</tt>.
|
|
93
103
|
def initialize(uid, ipcon)
|
|
94
|
-
super uid, ipcon
|
|
104
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
95
105
|
|
|
96
106
|
@api_version = [2, 0, 0]
|
|
97
107
|
|
|
@@ -121,24 +131,26 @@ module Tinkerforge
|
|
|
121
131
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
122
132
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
123
133
|
|
|
124
|
-
@callback_formats[CALLBACK_CURRENT] = 'l'
|
|
125
|
-
@callback_formats[CALLBACK_VOLTAGE] = 'l'
|
|
126
|
-
@callback_formats[CALLBACK_POWER] = 'l'
|
|
134
|
+
@callback_formats[CALLBACK_CURRENT] = [12, 'l']
|
|
135
|
+
@callback_formats[CALLBACK_VOLTAGE] = [12, 'l']
|
|
136
|
+
@callback_formats[CALLBACK_POWER] = [12, 'l']
|
|
127
137
|
|
|
138
|
+
@ipcon.add_device self
|
|
128
139
|
end
|
|
129
140
|
|
|
130
|
-
# Returns the current.
|
|
131
|
-
# and between -20000mA and 20000mA.
|
|
141
|
+
# Returns the current.
|
|
132
142
|
#
|
|
133
143
|
#
|
|
134
144
|
# If you want to get the value periodically, it is recommended to use the
|
|
135
145
|
# CALLBACK_CURRENT callback. You can set the callback configuration
|
|
136
146
|
# with BrickletVoltageCurrentV2#set_current_callback_configuration.
|
|
137
147
|
def get_current
|
|
138
|
-
|
|
148
|
+
check_validity
|
|
149
|
+
|
|
150
|
+
send_request FUNCTION_GET_CURRENT, [], '', 12, 'l'
|
|
139
151
|
end
|
|
140
152
|
|
|
141
|
-
# The period
|
|
153
|
+
# The period is the period with which the CALLBACK_CURRENT callback is triggered
|
|
142
154
|
# periodically. A value of 0 turns the callback off.
|
|
143
155
|
#
|
|
144
156
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -163,29 +175,32 @@ module Tinkerforge
|
|
|
163
175
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
164
176
|
#
|
|
165
177
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
166
|
-
#
|
|
167
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
168
178
|
def set_current_callback_configuration(period, value_has_to_change, option, min, max)
|
|
169
|
-
|
|
179
|
+
check_validity
|
|
180
|
+
|
|
181
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
|
170
182
|
end
|
|
171
183
|
|
|
172
184
|
# Returns the callback configuration as set by BrickletVoltageCurrentV2#set_current_callback_configuration.
|
|
173
185
|
def get_current_callback_configuration
|
|
174
|
-
|
|
186
|
+
check_validity
|
|
187
|
+
|
|
188
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
|
175
189
|
end
|
|
176
190
|
|
|
177
|
-
# Returns the voltage.
|
|
178
|
-
# and between 0mV and 36000mV.
|
|
191
|
+
# Returns the voltage.
|
|
179
192
|
#
|
|
180
193
|
#
|
|
181
194
|
# If you want to get the value periodically, it is recommended to use the
|
|
182
195
|
# CALLBACK_VOLTAGE callback. You can set the callback configuration
|
|
183
196
|
# with BrickletVoltageCurrentV2#set_voltage_callback_configuration.
|
|
184
197
|
def get_voltage
|
|
185
|
-
|
|
198
|
+
check_validity
|
|
199
|
+
|
|
200
|
+
send_request FUNCTION_GET_VOLTAGE, [], '', 12, 'l'
|
|
186
201
|
end
|
|
187
202
|
|
|
188
|
-
# The period
|
|
203
|
+
# The period is the period with which the CALLBACK_VOLTAGE callback is triggered
|
|
189
204
|
# periodically. A value of 0 turns the callback off.
|
|
190
205
|
#
|
|
191
206
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -210,29 +225,32 @@ module Tinkerforge
|
|
|
210
225
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
211
226
|
#
|
|
212
227
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
213
|
-
#
|
|
214
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
215
228
|
def set_voltage_callback_configuration(period, value_has_to_change, option, min, max)
|
|
216
|
-
|
|
229
|
+
check_validity
|
|
230
|
+
|
|
231
|
+
send_request FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
|
217
232
|
end
|
|
218
233
|
|
|
219
234
|
# Returns the callback configuration as set by BrickletVoltageCurrentV2#set_voltage_callback_configuration.
|
|
220
235
|
def get_voltage_callback_configuration
|
|
221
|
-
|
|
236
|
+
check_validity
|
|
237
|
+
|
|
238
|
+
send_request FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
|
222
239
|
end
|
|
223
240
|
|
|
224
|
-
# Returns the power.
|
|
225
|
-
# and between 0mV and 720000mW.
|
|
241
|
+
# Returns the power.
|
|
226
242
|
#
|
|
227
243
|
#
|
|
228
244
|
# If you want to get the value periodically, it is recommended to use the
|
|
229
245
|
# CALLBACK_POWER callback. You can set the callback configuration
|
|
230
246
|
# with BrickletVoltageCurrentV2#set_power_callback_configuration.
|
|
231
247
|
def get_power
|
|
232
|
-
|
|
248
|
+
check_validity
|
|
249
|
+
|
|
250
|
+
send_request FUNCTION_GET_POWER, [], '', 12, 'l'
|
|
233
251
|
end
|
|
234
252
|
|
|
235
|
-
# The period
|
|
253
|
+
# The period is the period with which the CALLBACK_POWER callback is triggered
|
|
236
254
|
# periodically. A value of 0 turns the callback off.
|
|
237
255
|
#
|
|
238
256
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -257,56 +275,33 @@ module Tinkerforge
|
|
|
257
275
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
258
276
|
#
|
|
259
277
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
260
|
-
#
|
|
261
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
262
278
|
def set_power_callback_configuration(period, value_has_to_change, option, min, max)
|
|
263
|
-
|
|
279
|
+
check_validity
|
|
280
|
+
|
|
281
|
+
send_request FUNCTION_SET_POWER_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
|
264
282
|
end
|
|
265
283
|
|
|
266
284
|
# Returns the callback configuration as set by BrickletVoltageCurrentV2#set_power_callback_configuration.
|
|
267
285
|
def get_power_callback_configuration
|
|
268
|
-
|
|
286
|
+
check_validity
|
|
287
|
+
|
|
288
|
+
send_request FUNCTION_GET_POWER_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
|
269
289
|
end
|
|
270
290
|
|
|
271
291
|
# Sets the configuration of the Voltage/Current Bricklet 2.0. It is
|
|
272
292
|
# possible to configure number of averages as well as
|
|
273
293
|
# voltage and current conversion time.
|
|
274
|
-
#
|
|
275
|
-
# Averaging:
|
|
276
|
-
#
|
|
277
|
-
# "Value", "Number of Averages"
|
|
278
|
-
#
|
|
279
|
-
# "0", "1"
|
|
280
|
-
# "1", "4"
|
|
281
|
-
# "2", "16"
|
|
282
|
-
# "3", "64"
|
|
283
|
-
# "4", "128"
|
|
284
|
-
# "5", "256"
|
|
285
|
-
# "6", "512"
|
|
286
|
-
# ">=7", "1024"
|
|
287
|
-
#
|
|
288
|
-
# Voltage/Current conversion:
|
|
289
|
-
#
|
|
290
|
-
# "Value", "Conversion time"
|
|
291
|
-
#
|
|
292
|
-
# "0", "140µs"
|
|
293
|
-
# "1", "204µs"
|
|
294
|
-
# "2", "332µs"
|
|
295
|
-
# "3", "588µs"
|
|
296
|
-
# "4", "1.1ms"
|
|
297
|
-
# "5", "2.116ms"
|
|
298
|
-
# "6", "4.156ms"
|
|
299
|
-
# ">=7", "8.244ms"
|
|
300
|
-
#
|
|
301
|
-
# The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage
|
|
302
|
-
# conversion and current conversion.
|
|
303
294
|
def set_configuration(averaging, voltage_conversion_time, current_conversion_time)
|
|
304
|
-
|
|
295
|
+
check_validity
|
|
296
|
+
|
|
297
|
+
send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 8, ''
|
|
305
298
|
end
|
|
306
299
|
|
|
307
300
|
# Returns the configuration as set by BrickletVoltageCurrentV2#set_configuration.
|
|
308
301
|
def get_configuration
|
|
309
|
-
|
|
302
|
+
check_validity
|
|
303
|
+
|
|
304
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 11, 'C C C'
|
|
310
305
|
end
|
|
311
306
|
|
|
312
307
|
# Since the ADC and the shunt resistor used for the measurements
|
|
@@ -317,13 +312,20 @@ module Tinkerforge
|
|
|
317
312
|
# are measuring 1023mA, you can calibrate the Voltage/Current Bricklet
|
|
318
313
|
# by setting the current multiplier to 1000 and the divisor to 1023.
|
|
319
314
|
# The same applies for the voltage.
|
|
315
|
+
#
|
|
316
|
+
# The calibration will be saved on the EEPROM of the Voltage/Current
|
|
317
|
+
# Bricklet and only needs to be done once.
|
|
320
318
|
def set_calibration(voltage_multiplier, voltage_divisor, current_multiplier, current_divisor)
|
|
321
|
-
|
|
319
|
+
check_validity
|
|
320
|
+
|
|
321
|
+
send_request FUNCTION_SET_CALIBRATION, [voltage_multiplier, voltage_divisor, current_multiplier, current_divisor], 'S S S S', 8, ''
|
|
322
322
|
end
|
|
323
323
|
|
|
324
324
|
# Returns the calibration as set by BrickletVoltageCurrentV2#set_calibration.
|
|
325
325
|
def get_calibration
|
|
326
|
-
|
|
326
|
+
check_validity
|
|
327
|
+
|
|
328
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 16, 'S S S S'
|
|
327
329
|
end
|
|
328
330
|
|
|
329
331
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -338,7 +340,9 @@ module Tinkerforge
|
|
|
338
340
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
339
341
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
340
342
|
def get_spitfp_error_count
|
|
341
|
-
|
|
343
|
+
check_validity
|
|
344
|
+
|
|
345
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
342
346
|
end
|
|
343
347
|
|
|
344
348
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -351,12 +355,16 @@ module Tinkerforge
|
|
|
351
355
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
352
356
|
# necessary to call it in a normal user program.
|
|
353
357
|
def set_bootloader_mode(mode)
|
|
354
|
-
|
|
358
|
+
check_validity
|
|
359
|
+
|
|
360
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
355
361
|
end
|
|
356
362
|
|
|
357
363
|
# Returns the current bootloader mode, see BrickletVoltageCurrentV2#set_bootloader_mode.
|
|
358
364
|
def get_bootloader_mode
|
|
359
|
-
|
|
365
|
+
check_validity
|
|
366
|
+
|
|
367
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
360
368
|
end
|
|
361
369
|
|
|
362
370
|
# Sets the firmware pointer for BrickletVoltageCurrentV2#write_firmware. The pointer has
|
|
@@ -366,7 +374,9 @@ module Tinkerforge
|
|
|
366
374
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
367
375
|
# necessary to call it in a normal user program.
|
|
368
376
|
def set_write_firmware_pointer(pointer)
|
|
369
|
-
|
|
377
|
+
check_validity
|
|
378
|
+
|
|
379
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
370
380
|
end
|
|
371
381
|
|
|
372
382
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -378,7 +388,9 @@ module Tinkerforge
|
|
|
378
388
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
379
389
|
# necessary to call it in a normal user program.
|
|
380
390
|
def write_firmware(data)
|
|
381
|
-
|
|
391
|
+
check_validity
|
|
392
|
+
|
|
393
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
382
394
|
end
|
|
383
395
|
|
|
384
396
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -389,22 +401,28 @@ module Tinkerforge
|
|
|
389
401
|
#
|
|
390
402
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
391
403
|
def set_status_led_config(config)
|
|
392
|
-
|
|
404
|
+
check_validity
|
|
405
|
+
|
|
406
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
393
407
|
end
|
|
394
408
|
|
|
395
409
|
# Returns the configuration as set by BrickletVoltageCurrentV2#set_status_led_config
|
|
396
410
|
def get_status_led_config
|
|
397
|
-
|
|
411
|
+
check_validity
|
|
412
|
+
|
|
413
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
398
414
|
end
|
|
399
415
|
|
|
400
|
-
# Returns the temperature
|
|
416
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
401
417
|
# value returned is not the ambient temperature!
|
|
402
418
|
#
|
|
403
419
|
# The temperature is only proportional to the real temperature and it has bad
|
|
404
420
|
# accuracy. Practically it is only useful as an indicator for
|
|
405
421
|
# temperature changes.
|
|
406
422
|
def get_chip_temperature
|
|
407
|
-
|
|
423
|
+
check_validity
|
|
424
|
+
|
|
425
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
408
426
|
end
|
|
409
427
|
|
|
410
428
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -414,7 +432,9 @@ module Tinkerforge
|
|
|
414
432
|
# calling functions on the existing ones will result in
|
|
415
433
|
# undefined behavior!
|
|
416
434
|
def reset
|
|
417
|
-
|
|
435
|
+
check_validity
|
|
436
|
+
|
|
437
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
418
438
|
end
|
|
419
439
|
|
|
420
440
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -423,25 +443,31 @@ module Tinkerforge
|
|
|
423
443
|
#
|
|
424
444
|
# We recommend that you use Brick Viewer to change the UID.
|
|
425
445
|
def write_uid(uid)
|
|
426
|
-
|
|
446
|
+
check_validity
|
|
447
|
+
|
|
448
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
427
449
|
end
|
|
428
450
|
|
|
429
451
|
# Returns the current UID as an integer. Encode as
|
|
430
452
|
# Base58 to get the usual string version.
|
|
431
453
|
def read_uid
|
|
432
|
-
|
|
454
|
+
check_validity
|
|
455
|
+
|
|
456
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
433
457
|
end
|
|
434
458
|
|
|
435
459
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
436
460
|
# the position, the hardware and firmware version as well as the
|
|
437
461
|
# device identifier.
|
|
438
462
|
#
|
|
439
|
-
# The position can be 'a', 'b', 'c' or '
|
|
463
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
464
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
465
|
+
# position 'z'.
|
|
440
466
|
#
|
|
441
467
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
442
468
|
# |device_identifier_constant|
|
|
443
469
|
def get_identity
|
|
444
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
470
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
445
471
|
end
|
|
446
472
|
|
|
447
473
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
6
|
+
# #
|
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
|
10
|
+
#############################################################
|
|
11
|
+
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
14
|
+
module Tinkerforge
|
|
15
|
+
# Breakout for Infineon XMC1400 microcontroller
|
|
16
|
+
class BrickletXMC1400Breakout < Device
|
|
17
|
+
DEVICE_IDENTIFIER = 279 # :nodoc:
|
|
18
|
+
DEVICE_DISPLAY_NAME = 'XMC1400 Breakout Bricklet' # :nodoc:
|
|
19
|
+
|
|
20
|
+
# This callback is triggered periodically according to the configuration set by
|
|
21
|
+
# BrickletXMC1400Breakout#set_adc_values_callback_configuration.
|
|
22
|
+
#
|
|
23
|
+
# The parameters are the same as BrickletXMC1400Breakout#get_adc_values.
|
|
24
|
+
CALLBACK_ADC_VALUES = 9
|
|
25
|
+
|
|
26
|
+
# This callback is triggered periodically according to the configuration set by
|
|
27
|
+
# BrickletXMC1400Breakout#set_count_callback_configuration.
|
|
28
|
+
#
|
|
29
|
+
# The parameter is the same as BrickletXMC1400Breakout#get_count.
|
|
30
|
+
CALLBACK_COUNT = 13
|
|
31
|
+
|
|
32
|
+
FUNCTION_SET_GPIO_CONFIG = 1 # :nodoc:
|
|
33
|
+
FUNCTION_GET_GPIO_INPUT = 2 # :nodoc:
|
|
34
|
+
FUNCTION_SET_ADC_CHANNEL_CONFIG = 3 # :nodoc:
|
|
35
|
+
FUNCTION_GET_ADC_CHANNEL_CONFIG = 4 # :nodoc:
|
|
36
|
+
FUNCTION_GET_ADC_CHANNEL_VALUE = 5 # :nodoc:
|
|
37
|
+
FUNCTION_GET_ADC_VALUES = 6 # :nodoc:
|
|
38
|
+
FUNCTION_SET_ADC_VALUES_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
|
39
|
+
FUNCTION_GET_ADC_VALUES_CALLBACK_CONFIGURATION = 8 # :nodoc:
|
|
40
|
+
FUNCTION_GET_COUNT = 10 # :nodoc:
|
|
41
|
+
FUNCTION_SET_COUNT_CALLBACK_CONFIGURATION = 11 # :nodoc:
|
|
42
|
+
FUNCTION_GET_COUNT_CALLBACK_CONFIGURATION = 12 # :nodoc:
|
|
43
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
44
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
45
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
46
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
47
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
48
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
49
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
50
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
51
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
52
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
53
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
54
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
55
|
+
|
|
56
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
57
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
58
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
59
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
60
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
61
|
+
GPIO_MODE_INPUT_TRISTATE = 0 # :nodoc:
|
|
62
|
+
GPIO_MODE_INPUT_PULL_DOWN = 1 # :nodoc:
|
|
63
|
+
GPIO_MODE_INPUT_PULL_UP = 2 # :nodoc:
|
|
64
|
+
GPIO_MODE_INPUT_SAMPLING = 3 # :nodoc:
|
|
65
|
+
GPIO_MODE_INPUT_INVERTED_TRISTATE = 4 # :nodoc:
|
|
66
|
+
GPIO_MODE_INPUT_INVERTED_PULL_DOWN = 5 # :nodoc:
|
|
67
|
+
GPIO_MODE_INPUT_INVERTED_PULL_UP = 6 # :nodoc:
|
|
68
|
+
GPIO_MODE_INPUT_INVERTED_SAMPLING = 7 # :nodoc:
|
|
69
|
+
GPIO_MODE_OUTPUT_PUSH_PULL = 8 # :nodoc:
|
|
70
|
+
GPIO_MODE_OUTPUT_OPEN_DRAIN = 9 # :nodoc:
|
|
71
|
+
GPIO_INPUT_HYSTERESIS_STANDARD = 0 # :nodoc:
|
|
72
|
+
GPIO_INPUT_HYSTERESIS_LARGE = 4 # :nodoc:
|
|
73
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
74
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
75
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
76
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
77
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
78
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
79
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
80
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
81
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
82
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
83
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
84
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
85
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
86
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
87
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
88
|
+
|
|
89
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
90
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
91
|
+
def initialize(uid, ipcon)
|
|
92
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
93
|
+
|
|
94
|
+
@api_version = [2, 0, 0]
|
|
95
|
+
|
|
96
|
+
@response_expected[FUNCTION_SET_GPIO_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
97
|
+
@response_expected[FUNCTION_GET_GPIO_INPUT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
98
|
+
@response_expected[FUNCTION_SET_ADC_CHANNEL_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
99
|
+
@response_expected[FUNCTION_GET_ADC_CHANNEL_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
100
|
+
@response_expected[FUNCTION_GET_ADC_CHANNEL_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
|
+
@response_expected[FUNCTION_GET_ADC_VALUES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
|
+
@response_expected[FUNCTION_SET_ADC_VALUES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
103
|
+
@response_expected[FUNCTION_GET_ADC_VALUES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
104
|
+
@response_expected[FUNCTION_GET_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
105
|
+
@response_expected[FUNCTION_SET_COUNT_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
106
|
+
@response_expected[FUNCTION_GET_COUNT_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
107
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
108
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
109
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
110
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
111
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
112
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
113
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
115
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
116
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
117
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
118
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
119
|
+
|
|
120
|
+
@callback_formats[CALLBACK_ADC_VALUES] = [24, 'S8']
|
|
121
|
+
@callback_formats[CALLBACK_COUNT] = [12, 'L']
|
|
122
|
+
|
|
123
|
+
@ipcon.add_device self
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Example for a setter function. The values are the values that can be given to
|
|
127
|
+
# the XMC_GPIO_Init function. See communication.c in the firmware.
|
|
128
|
+
def set_gpio_config(port, pin, mode, input_hysteresis, output_level)
|
|
129
|
+
check_validity
|
|
130
|
+
|
|
131
|
+
send_request FUNCTION_SET_GPIO_CONFIG, [port, pin, mode, input_hysteresis, output_level], 'C C C C ?', 8, ''
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Example for a getter function. Returns the result of a
|
|
135
|
+
# XMC_GPIO_GetInput call for the given port/pin.
|
|
136
|
+
def get_gpio_input(port, pin)
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_GET_GPIO_INPUT, [port, pin], 'C C', 9, '?'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Enables a ADC channel for the ADC driver example (adc.c/adc.h).
|
|
143
|
+
#
|
|
144
|
+
# There are 8 ADC channels and they correspond to the following pins:
|
|
145
|
+
#
|
|
146
|
+
# * Channel 0: P2_6
|
|
147
|
+
# * Channel 1: P2_8
|
|
148
|
+
# * Channel 2: P2_9
|
|
149
|
+
# * Channel 3: P2_10
|
|
150
|
+
# * Channel 4: P2_11
|
|
151
|
+
# * Channel 5: P2_0
|
|
152
|
+
# * Channel 6: P2_1
|
|
153
|
+
# * Channel 7: P2_2
|
|
154
|
+
def set_adc_channel_config(channel, enable)
|
|
155
|
+
check_validity
|
|
156
|
+
|
|
157
|
+
send_request FUNCTION_SET_ADC_CHANNEL_CONFIG, [channel, enable], 'C ?', 8, ''
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Returns the config for the given channel as set by BrickletXMC1400Breakout#set_adc_channel_config.
|
|
161
|
+
def get_adc_channel_config(channel)
|
|
162
|
+
check_validity
|
|
163
|
+
|
|
164
|
+
send_request FUNCTION_GET_ADC_CHANNEL_CONFIG, [channel], 'C', 9, '?'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Returns the 12-bit value of the given ADC channel of the ADC driver example.
|
|
168
|
+
def get_adc_channel_value(channel)
|
|
169
|
+
check_validity
|
|
170
|
+
|
|
171
|
+
send_request FUNCTION_GET_ADC_CHANNEL_VALUE, [channel], 'C', 10, 'S'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns the values for all 8 ADC channels of the adc driver example.
|
|
175
|
+
#
|
|
176
|
+
# This example function also has a corresponding callback.
|
|
177
|
+
#
|
|
178
|
+
# See BrickletXMC1400Breakout#set_adc_values_callback_configuration and CALLBACK_ADC_VALUES callback.
|
|
179
|
+
def get_adc_values
|
|
180
|
+
check_validity
|
|
181
|
+
|
|
182
|
+
send_request FUNCTION_GET_ADC_VALUES, [], '', 24, 'S8'
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# The period is the period with which the CALLBACK_ADC_VALUES
|
|
186
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
187
|
+
#
|
|
188
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
189
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
190
|
+
# period, the callback is triggered immediately on change.
|
|
191
|
+
#
|
|
192
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
193
|
+
# independent of the value.
|
|
194
|
+
def set_adc_values_callback_configuration(period, value_has_to_change)
|
|
195
|
+
check_validity
|
|
196
|
+
|
|
197
|
+
send_request FUNCTION_SET_ADC_VALUES_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Returns the callback configuration as set by
|
|
201
|
+
# BrickletXMC1400Breakout#set_adc_values_callback_configuration.
|
|
202
|
+
def get_adc_values_callback_configuration
|
|
203
|
+
check_validity
|
|
204
|
+
|
|
205
|
+
send_request FUNCTION_GET_ADC_VALUES_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Returns the value of the example count (see example.c).
|
|
209
|
+
#
|
|
210
|
+
# This example function uses the "add_callback_value_function"-helper in the
|
|
211
|
+
# generator. The getter as well as the callback and callback configuration
|
|
212
|
+
# functions are auto-generated for the API as well as the firmware.
|
|
213
|
+
#
|
|
214
|
+
#
|
|
215
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
216
|
+
# CALLBACK_COUNT callback. You can set the callback configuration
|
|
217
|
+
# with BrickletXMC1400Breakout#set_count_callback_configuration.
|
|
218
|
+
def get_count
|
|
219
|
+
check_validity
|
|
220
|
+
|
|
221
|
+
send_request FUNCTION_GET_COUNT, [], '', 12, 'L'
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# The period is the period with which the CALLBACK_COUNT callback is triggered
|
|
225
|
+
# periodically. A value of 0 turns the callback off.
|
|
226
|
+
#
|
|
227
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
228
|
+
# triggered after the value has changed. If the value didn't change
|
|
229
|
+
# within the period, the callback is triggered immediately on change.
|
|
230
|
+
#
|
|
231
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
232
|
+
# independent of the value.
|
|
233
|
+
#
|
|
234
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
235
|
+
#
|
|
236
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_COUNT callback.
|
|
237
|
+
#
|
|
238
|
+
# The following options are possible:
|
|
239
|
+
#
|
|
240
|
+
# "Option", "Description"
|
|
241
|
+
#
|
|
242
|
+
# "'x'", "Threshold is turned off"
|
|
243
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
244
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
245
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
246
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
247
|
+
#
|
|
248
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
249
|
+
def set_count_callback_configuration(period, value_has_to_change, option, min, max)
|
|
250
|
+
check_validity
|
|
251
|
+
|
|
252
|
+
send_request FUNCTION_SET_COUNT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 8, ''
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Returns the callback configuration as set by BrickletXMC1400Breakout#set_count_callback_configuration.
|
|
256
|
+
def get_count_callback_configuration
|
|
257
|
+
check_validity
|
|
258
|
+
|
|
259
|
+
send_request FUNCTION_GET_COUNT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k L L'
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
263
|
+
#
|
|
264
|
+
# The errors are divided into
|
|
265
|
+
#
|
|
266
|
+
# * ACK checksum errors,
|
|
267
|
+
# * message checksum errors,
|
|
268
|
+
# * framing errors and
|
|
269
|
+
# * overflow errors.
|
|
270
|
+
#
|
|
271
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
272
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
273
|
+
def get_spitfp_error_count
|
|
274
|
+
check_validity
|
|
275
|
+
|
|
276
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
280
|
+
# mode change was instigated.
|
|
281
|
+
#
|
|
282
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
283
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
284
|
+
# device identifier and CRC are present and correct.
|
|
285
|
+
#
|
|
286
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
287
|
+
# necessary to call it in a normal user program.
|
|
288
|
+
def set_bootloader_mode(mode)
|
|
289
|
+
check_validity
|
|
290
|
+
|
|
291
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Returns the current bootloader mode, see BrickletXMC1400Breakout#set_bootloader_mode.
|
|
295
|
+
def get_bootloader_mode
|
|
296
|
+
check_validity
|
|
297
|
+
|
|
298
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# Sets the firmware pointer for BrickletXMC1400Breakout#write_firmware. The pointer has
|
|
302
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
303
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
304
|
+
#
|
|
305
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
306
|
+
# necessary to call it in a normal user program.
|
|
307
|
+
def set_write_firmware_pointer(pointer)
|
|
308
|
+
check_validity
|
|
309
|
+
|
|
310
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
314
|
+
# BrickletXMC1400Breakout#set_write_firmware_pointer before. The firmware is written
|
|
315
|
+
# to flash every 4 chunks.
|
|
316
|
+
#
|
|
317
|
+
# You can only write firmware in bootloader mode.
|
|
318
|
+
#
|
|
319
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
320
|
+
# necessary to call it in a normal user program.
|
|
321
|
+
def write_firmware(data)
|
|
322
|
+
check_validity
|
|
323
|
+
|
|
324
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
# Sets the status LED configuration. By default the LED shows
|
|
328
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
329
|
+
# for every 10 received data packets.
|
|
330
|
+
#
|
|
331
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
332
|
+
#
|
|
333
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
334
|
+
def set_status_led_config(config)
|
|
335
|
+
check_validity
|
|
336
|
+
|
|
337
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Returns the configuration as set by BrickletXMC1400Breakout#set_status_led_config
|
|
341
|
+
def get_status_led_config
|
|
342
|
+
check_validity
|
|
343
|
+
|
|
344
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
348
|
+
# value returned is not the ambient temperature!
|
|
349
|
+
#
|
|
350
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
351
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
352
|
+
# temperature changes.
|
|
353
|
+
def get_chip_temperature
|
|
354
|
+
check_validity
|
|
355
|
+
|
|
356
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
360
|
+
# will be lost.
|
|
361
|
+
#
|
|
362
|
+
# After a reset you have to create new device objects,
|
|
363
|
+
# calling functions on the existing ones will result in
|
|
364
|
+
# undefined behavior!
|
|
365
|
+
def reset
|
|
366
|
+
check_validity
|
|
367
|
+
|
|
368
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
372
|
+
# you have to decode the Base58 encoded UID string into an
|
|
373
|
+
# integer first.
|
|
374
|
+
#
|
|
375
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
376
|
+
def write_uid(uid)
|
|
377
|
+
check_validity
|
|
378
|
+
|
|
379
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
# Returns the current UID as an integer. Encode as
|
|
383
|
+
# Base58 to get the usual string version.
|
|
384
|
+
def read_uid
|
|
385
|
+
check_validity
|
|
386
|
+
|
|
387
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
391
|
+
# the position, the hardware and firmware version as well as the
|
|
392
|
+
# device identifier.
|
|
393
|
+
#
|
|
394
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
395
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
396
|
+
# position 'z'.
|
|
397
|
+
#
|
|
398
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
399
|
+
# |device_identifier_constant|
|
|
400
|
+
def get_identity
|
|
401
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
405
|
+
def register_callback(id, &block)
|
|
406
|
+
callback = block
|
|
407
|
+
@registered_callbacks[id] = callback
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
end
|