tinkerforge 2.1.24 → 2.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +69 -31
  4. data/lib/tinkerforge/brick_hat_zero.rb +55 -23
  5. data/lib/tinkerforge/brick_imu.rb +185 -78
  6. data/lib/tinkerforge/brick_imu_v2.rb +209 -106
  7. data/lib/tinkerforge/brick_master.rb +491 -183
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
  11. data/lib/tinkerforge/brick_stepper.rb +211 -99
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
  18. data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +100 -27
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -19
  27. data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +33 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
  30. data/lib/tinkerforge/bricklet_color.rb +68 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +77 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +57 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +57 -24
  35. data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
  36. data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
  37. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
  38. data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
  39. data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
  40. data/lib/tinkerforge/bricklet_dmx.rb +87 -34
  41. data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
  42. data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
  43. data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
  44. data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
  45. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
  46. data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
  47. data/lib/tinkerforge/bricklet_gps.rb +63 -26
  48. data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
  49. data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
  50. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
  51. data/lib/tinkerforge/bricklet_humidity.rb +50 -21
  52. data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
  53. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  54. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
  55. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
  56. data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
  58. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
  60. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
  62. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
  65. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
  66. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
  67. data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
  68. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
  69. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
  70. data/lib/tinkerforge/bricklet_io16.rb +54 -21
  71. data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
  72. data/lib/tinkerforge/bricklet_io4.rb +54 -23
  73. data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
  74. data/lib/tinkerforge/bricklet_isolator.rb +72 -29
  75. data/lib/tinkerforge/bricklet_joystick.rb +58 -25
  76. data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
  77. data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
  78. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
  79. data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
  80. data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
  81. data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
  82. data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
  83. data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
  84. data/lib/tinkerforge/bricklet_line.rb +33 -14
  85. data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
  86. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
  87. data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
  88. data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
  89. data/lib/tinkerforge/bricklet_moisture.rb +39 -16
  90. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  91. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
  92. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
  93. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
  94. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
  95. data/lib/tinkerforge/bricklet_nfc.rb +126 -62
  96. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  97. data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
  98. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
  99. data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
  100. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  101. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
  102. data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
  103. data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
  104. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
  105. data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
  106. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
  107. data/lib/tinkerforge/bricklet_ptc.rb +73 -42
  108. data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
  109. data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
  110. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
  111. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  112. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  113. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  114. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  115. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  116. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  117. data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
  118. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
  119. data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
  120. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
  121. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  122. data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
  123. data/lib/tinkerforge/bricklet_rs485.rb +222 -95
  124. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  125. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
  126. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  127. data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
  128. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  129. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  130. data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
  131. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
  132. data/lib/tinkerforge/bricklet_temperature.rb +39 -16
  133. data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
  134. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
  135. data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
  136. data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
  137. data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
  138. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
  139. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  140. data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
  141. data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
  142. data/lib/tinkerforge/bricklet_voltage.rb +51 -28
  143. data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
  144. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
  145. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
  146. data/lib/tinkerforge/device_display_names.rb +170 -0
  147. data/lib/tinkerforge/ip_connection.rb +153 -33
  148. data/lib/tinkerforge/version.rb +1 -1
  149. metadata +11 -3
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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 distance up to 150cm with infrared light
14
16
  class BrickletDistanceIR < Device
@@ -72,7 +74,7 @@ module Tinkerforge
72
74
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
73
75
  # the IP Connection <tt>ipcon</tt>.
74
76
  def initialize(uid, ipcon)
75
- super uid, ipcon
77
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
76
78
 
77
79
  @api_version = [2, 0, 1]
78
80
 
@@ -92,11 +94,12 @@ module Tinkerforge
92
94
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
93
95
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
94
96
 
95
- @callback_formats[CALLBACK_DISTANCE] = 'S'
96
- @callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
97
- @callback_formats[CALLBACK_DISTANCE_REACHED] = 'S'
98
- @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
97
+ @callback_formats[CALLBACK_DISTANCE] = [10, 'S']
98
+ @callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
99
+ @callback_formats[CALLBACK_DISTANCE_REACHED] = [10, 'S']
100
+ @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
99
101
 
102
+ @ipcon.add_device self
100
103
  end
101
104
 
102
105
  # Returns the distance measured by the sensor. Possible
@@ -107,7 +110,9 @@ module Tinkerforge
107
110
  # CALLBACK_DISTANCE callback and set the period with
108
111
  # BrickletDistanceIR#set_distance_callback_period.
109
112
  def get_distance
110
- send_request FUNCTION_GET_DISTANCE, [], '', 2, 'S'
113
+ check_validity
114
+
115
+ send_request FUNCTION_GET_DISTANCE, [], '', 10, 'S'
111
116
  end
112
117
 
113
118
  # Returns the value as read by a 12-bit analog-to-digital converter.
@@ -122,7 +127,9 @@ module Tinkerforge
122
127
  # CALLBACK_ANALOG_VALUE callback and set the period with
123
128
  # BrickletDistanceIR#set_analog_value_callback_period.
124
129
  def get_analog_value
125
- send_request FUNCTION_GET_ANALOG_VALUE, [], '', 2, 'S'
130
+ check_validity
131
+
132
+ send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
126
133
  end
127
134
 
128
135
  # Sets a sampling point value to a specific position of the lookup table.
@@ -144,13 +151,17 @@ module Tinkerforge
144
151
  # implemented in the Brick Viewer. If you want to calibrate your Bricklet it is
145
152
  # highly recommended to use this implementation.
146
153
  def set_sampling_point(position, distance)
147
- send_request FUNCTION_SET_SAMPLING_POINT, [position, distance], 'C S', 0, ''
154
+ check_validity
155
+
156
+ send_request FUNCTION_SET_SAMPLING_POINT, [position, distance], 'C S', 8, ''
148
157
  end
149
158
 
150
159
  # Returns the distance to a sampling point position as set by
151
160
  # BrickletDistanceIR#set_sampling_point.
152
161
  def get_sampling_point(position)
153
- send_request FUNCTION_GET_SAMPLING_POINT, [position], 'C', 2, 'S'
162
+ check_validity
163
+
164
+ send_request FUNCTION_GET_SAMPLING_POINT, [position], 'C', 10, 'S'
154
165
  end
155
166
 
156
167
  # Sets the period with which the CALLBACK_DISTANCE callback is triggered
@@ -159,12 +170,16 @@ module Tinkerforge
159
170
  # The CALLBACK_DISTANCE callback is only triggered if the distance has changed since the
160
171
  # last triggering.
161
172
  def set_distance_callback_period(period)
162
- send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 0, ''
173
+ check_validity
174
+
175
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
163
176
  end
164
177
 
165
178
  # Returns the period as set by BrickletDistanceIR#set_distance_callback_period.
166
179
  def get_distance_callback_period
167
- send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 4, 'L'
180
+ check_validity
181
+
182
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 12, 'L'
168
183
  end
169
184
 
170
185
  # Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
@@ -173,12 +188,16 @@ module Tinkerforge
173
188
  # The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
174
189
  # changed since the last triggering.
175
190
  def set_analog_value_callback_period(period)
176
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 0, ''
191
+ check_validity
192
+
193
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
177
194
  end
178
195
 
179
196
  # Returns the period as set by BrickletDistanceIR#set_analog_value_callback_period.
180
197
  def get_analog_value_callback_period
181
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 4, 'L'
198
+ check_validity
199
+
200
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
182
201
  end
183
202
 
184
203
  # Sets the thresholds for the CALLBACK_DISTANCE_REACHED callback.
@@ -193,12 +212,16 @@ module Tinkerforge
193
212
  # "'<'", "Callback is triggered when the distance is smaller than the min value (max is ignored)"
194
213
  # "'>'", "Callback is triggered when the distance is greater than the min value (max is ignored)"
195
214
  def set_distance_callback_threshold(option, min, max)
196
- send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
215
+ check_validity
216
+
217
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
197
218
  end
198
219
 
199
220
  # Returns the threshold as set by BrickletDistanceIR#set_distance_callback_threshold.
200
221
  def get_distance_callback_threshold
201
- send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
222
+ check_validity
223
+
224
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
202
225
  end
203
226
 
204
227
  # Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
@@ -213,12 +236,16 @@ module Tinkerforge
213
236
  # "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
214
237
  # "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
215
238
  def set_analog_value_callback_threshold(option, min, max)
216
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
239
+ check_validity
240
+
241
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
217
242
  end
218
243
 
219
244
  # Returns the threshold as set by BrickletDistanceIR#set_analog_value_callback_threshold.
220
245
  def get_analog_value_callback_threshold
221
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
246
+ check_validity
247
+
248
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
222
249
  end
223
250
 
224
251
  # Sets the period with which the threshold callbacks
@@ -233,24 +260,30 @@ module Tinkerforge
233
260
  #
234
261
  # keep being reached.
235
262
  def set_debounce_period(debounce)
236
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
263
+ check_validity
264
+
265
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
237
266
  end
238
267
 
239
268
  # Returns the debounce period as set by BrickletDistanceIR#set_debounce_period.
240
269
  def get_debounce_period
241
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
270
+ check_validity
271
+
272
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 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 'd'.
279
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
280
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
281
+ # position 'z'.
249
282
  #
250
283
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
251
284
  # |device_identifier_constant|
252
285
  def get_identity
253
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
286
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
254
287
  end
255
288
 
256
289
  # 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 2019-11-25. #
3
+ # This file was automatically generated on 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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 distance up to 150cm with infrared light
14
16
  class BrickletDistanceIRV2 < Device
@@ -83,7 +85,7 @@ module Tinkerforge
83
85
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
84
86
  # the IP Connection <tt>ipcon</tt>.
85
87
  def initialize(uid, ipcon)
86
- super uid, ipcon
88
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
87
89
 
88
90
  @api_version = [2, 0, 1]
89
91
 
@@ -112,9 +114,10 @@ module Tinkerforge
112
114
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
115
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
116
 
115
- @callback_formats[CALLBACK_DISTANCE] = 'S'
116
- @callback_formats[CALLBACK_ANALOG_VALUE] = 'L'
117
+ @callback_formats[CALLBACK_DISTANCE] = [10, 'S']
118
+ @callback_formats[CALLBACK_ANALOG_VALUE] = [12, 'L']
117
119
 
120
+ @ipcon.add_device self
118
121
  end
119
122
 
120
123
  # Returns the distance measured by the sensor. Possible
@@ -126,7 +129,9 @@ module Tinkerforge
126
129
  # CALLBACK_DISTANCE callback. You can set the callback configuration
127
130
  # with BrickletDistanceIRV2#set_distance_callback_configuration.
128
131
  def get_distance
129
- send_request FUNCTION_GET_DISTANCE, [], '', 2, 'S'
132
+ check_validity
133
+
134
+ send_request FUNCTION_GET_DISTANCE, [], '', 10, 'S'
130
135
  end
131
136
 
132
137
  # The period is the period with which the CALLBACK_DISTANCE callback is triggered
@@ -155,12 +160,16 @@ module Tinkerforge
155
160
  #
156
161
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
157
162
  def set_distance_callback_configuration(period, value_has_to_change, option, min, max)
158
- send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
163
+ check_validity
164
+
165
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
159
166
  end
160
167
 
161
168
  # Returns the callback configuration as set by BrickletDistanceIRV2#set_distance_callback_configuration.
162
169
  def get_distance_callback_configuration
163
- send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
170
+ check_validity
171
+
172
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
164
173
  end
165
174
 
166
175
  # Returns the analog value as read by a analog-to-digital converter.
@@ -177,7 +186,9 @@ module Tinkerforge
177
186
  # CALLBACK_ANALOG_VALUE callback. You can set the callback configuration
178
187
  # with BrickletDistanceIRV2#set_analog_value_callback_configuration.
179
188
  def get_analog_value
180
- send_request FUNCTION_GET_ANALOG_VALUE, [], '', 4, 'L'
189
+ check_validity
190
+
191
+ send_request FUNCTION_GET_ANALOG_VALUE, [], '', 12, 'L'
181
192
  end
182
193
 
183
194
  # The period is the period with which the CALLBACK_ANALOG_VALUE callback is triggered
@@ -206,12 +217,16 @@ module Tinkerforge
206
217
  #
207
218
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
208
219
  def set_analog_value_callback_configuration(period, value_has_to_change, option, min, max)
209
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 0, ''
220
+ check_validity
221
+
222
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 8, ''
210
223
  end
211
224
 
212
225
  # Returns the callback configuration as set by BrickletDistanceIRV2#set_analog_value_callback_configuration.
213
226
  def get_analog_value_callback_configuration
214
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k L L'
227
+ check_validity
228
+
229
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k L L'
215
230
  end
216
231
 
217
232
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -224,23 +239,31 @@ module Tinkerforge
224
239
  # resulting averaging window has a length of approximately 10s. If you want to do
225
240
  # long term measurements the longest moving average will give the cleanest results.
226
241
  def set_moving_average_configuration(moving_average_length)
227
- send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length], 'S', 0, ''
242
+ check_validity
243
+
244
+ send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length], 'S', 8, ''
228
245
  end
229
246
 
230
247
  # Returns the moving average configuration as set by BrickletDistanceIRV2#set_moving_average_configuration.
231
248
  def get_moving_average_configuration
232
- send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 2, 'S'
249
+ check_validity
250
+
251
+ send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 10, 'S'
233
252
  end
234
253
 
235
254
  # Configures the distance LED to be either turned off, turned on, blink in
236
255
  # heartbeat mode or show the distance (brighter = object is nearer).
237
256
  def set_distance_led_config(config)
238
- send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 0, ''
257
+ check_validity
258
+
259
+ send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 8, ''
239
260
  end
240
261
 
241
262
  # Returns the LED configuration as set by BrickletDistanceIRV2#set_distance_led_config
242
263
  def get_distance_led_config
243
- send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 1, 'C'
264
+ check_validity
265
+
266
+ send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 9, 'C'
244
267
  end
245
268
 
246
269
  # Sets the sensor type.
@@ -252,12 +275,16 @@ module Tinkerforge
252
275
  # If you want to change the sensor you can set the type in Brick Viewer,
253
276
  # you will likely never need to call this function from your program.
254
277
  def set_sensor_type(sensor)
255
- send_request FUNCTION_SET_SENSOR_TYPE, [sensor], 'C', 0, ''
278
+ check_validity
279
+
280
+ send_request FUNCTION_SET_SENSOR_TYPE, [sensor], 'C', 8, ''
256
281
  end
257
282
 
258
283
  # Returns the sensor type as set by BrickletDistanceIRV2#set_sensor_type.
259
284
  def get_sensor_type
260
- send_request FUNCTION_GET_SENSOR_TYPE, [], '', 1, 'C'
285
+ check_validity
286
+
287
+ send_request FUNCTION_GET_SENSOR_TYPE, [], '', 9, 'C'
261
288
  end
262
289
 
263
290
  # Returns the error count for the communication between Brick and Bricklet.
@@ -272,7 +299,9 @@ module Tinkerforge
272
299
  # The errors counts are for errors that occur on the Bricklet side. All
273
300
  # Bricks have a similar function that returns the errors on the Brick side.
274
301
  def get_spitfp_error_count
275
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
302
+ check_validity
303
+
304
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
276
305
  end
277
306
 
278
307
  # Sets the bootloader mode and returns the status after the requested
@@ -285,12 +314,16 @@ module Tinkerforge
285
314
  # This function is used by Brick Viewer during flashing. It should not be
286
315
  # necessary to call it in a normal user program.
287
316
  def set_bootloader_mode(mode)
288
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
317
+ check_validity
318
+
319
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
289
320
  end
290
321
 
291
322
  # Returns the current bootloader mode, see BrickletDistanceIRV2#set_bootloader_mode.
292
323
  def get_bootloader_mode
293
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
324
+ check_validity
325
+
326
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
294
327
  end
295
328
 
296
329
  # Sets the firmware pointer for BrickletDistanceIRV2#write_firmware. The pointer has
@@ -300,7 +333,9 @@ module Tinkerforge
300
333
  # This function is used by Brick Viewer during flashing. It should not be
301
334
  # necessary to call it in a normal user program.
302
335
  def set_write_firmware_pointer(pointer)
303
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
336
+ check_validity
337
+
338
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
304
339
  end
305
340
 
306
341
  # Writes 64 Bytes of firmware at the position as written by
@@ -312,7 +347,9 @@ module Tinkerforge
312
347
  # This function is used by Brick Viewer during flashing. It should not be
313
348
  # necessary to call it in a normal user program.
314
349
  def write_firmware(data)
315
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
350
+ check_validity
351
+
352
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
316
353
  end
317
354
 
318
355
  # Sets the status LED configuration. By default the LED shows
@@ -323,22 +360,28 @@ module Tinkerforge
323
360
  #
324
361
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
325
362
  def set_status_led_config(config)
326
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
363
+ check_validity
364
+
365
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
327
366
  end
328
367
 
329
368
  # Returns the configuration as set by BrickletDistanceIRV2#set_status_led_config
330
369
  def get_status_led_config
331
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
370
+ check_validity
371
+
372
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
332
373
  end
333
374
 
334
- # Returns the temperature in °C as measured inside the microcontroller. The
375
+ # Returns the temperature as measured inside the microcontroller. The
335
376
  # value returned is not the ambient temperature!
336
377
  #
337
378
  # The temperature is only proportional to the real temperature and it has bad
338
379
  # accuracy. Practically it is only useful as an indicator for
339
380
  # temperature changes.
340
381
  def get_chip_temperature
341
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
382
+ check_validity
383
+
384
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
342
385
  end
343
386
 
344
387
  # Calling this function will reset the Bricklet. All configurations
@@ -348,7 +391,9 @@ module Tinkerforge
348
391
  # calling functions on the existing ones will result in
349
392
  # undefined behavior!
350
393
  def reset
351
- send_request FUNCTION_RESET, [], '', 0, ''
394
+ check_validity
395
+
396
+ send_request FUNCTION_RESET, [], '', 8, ''
352
397
  end
353
398
 
354
399
  # Writes a new UID into flash. If you want to set a new UID
@@ -357,25 +402,31 @@ module Tinkerforge
357
402
  #
358
403
  # We recommend that you use Brick Viewer to change the UID.
359
404
  def write_uid(uid)
360
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
405
+ check_validity
406
+
407
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
361
408
  end
362
409
 
363
410
  # Returns the current UID as an integer. Encode as
364
411
  # Base58 to get the usual string version.
365
412
  def read_uid
366
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
413
+ check_validity
414
+
415
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
367
416
  end
368
417
 
369
418
  # Returns the UID, the UID where the Bricklet is connected to,
370
419
  # the position, the hardware and firmware version as well as the
371
420
  # device identifier.
372
421
  #
373
- # The position can be 'a', 'b', 'c' or 'd'.
422
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
423
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
424
+ # position 'z'.
374
425
  #
375
426
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
376
427
  # |device_identifier_constant|
377
428
  def get_identity
378
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
429
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
379
430
  end
380
431
 
381
432
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.