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.
Files changed (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +109 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +191 -86
  6. data/lib/tinkerforge/brick_imu_v2.rb +219 -118
  7. data/lib/tinkerforge/brick_master.rb +495 -195
  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 +248 -168
  11. data/lib/tinkerforge/brick_stepper.rb +212 -100
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +75 -47
  31. data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
  32. data/lib/tinkerforge/bricklet_compass.rb +81 -40
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +68 -33
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +81 -40
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +99 -51
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -39
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +75 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_performance_dc.rb +676 -0
  102. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  103. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  104. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  105. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  106. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  107. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  108. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  109. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  110. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  111. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  112. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  113. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  114. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  115. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  116. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  117. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  118. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -26
  119. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  120. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  121. data/lib/tinkerforge/bricklet_rs485.rb +250 -164
  122. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  123. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  124. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  125. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  126. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  127. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  128. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  129. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  130. data/lib/tinkerforge/bricklet_temperature_ir.rb +61 -47
  131. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
  132. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  133. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  134. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  135. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  136. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  137. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  138. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  139. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  140. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  141. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +92 -77
  142. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
  143. data/lib/tinkerforge/device_display_names.rb +167 -0
  144. data/lib/tinkerforge/ip_connection.rb +156 -33
  145. data/lib/tinkerforge/version.rb +1 -1
  146. metadata +8 -3
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
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
  # 360° rotary encoder with push-button
14
16
  class BrickletRotaryEncoderV2 < Device
@@ -68,7 +70,7 @@ module Tinkerforge
68
70
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
69
71
  # the IP Connection <tt>ipcon</tt>.
70
72
  def initialize(uid, ipcon)
71
- super uid, ipcon
73
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
72
74
 
73
75
  @api_version = [2, 0, 1]
74
76
 
@@ -89,10 +91,11 @@ module Tinkerforge
89
91
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
92
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
91
93
 
92
- @callback_formats[CALLBACK_COUNT] = 'l'
93
- @callback_formats[CALLBACK_PRESSED] = ''
94
- @callback_formats[CALLBACK_RELEASED] = ''
94
+ @callback_formats[CALLBACK_COUNT] = [12, 'l']
95
+ @callback_formats[CALLBACK_PRESSED] = [8, '']
96
+ @callback_formats[CALLBACK_RELEASED] = [8, '']
95
97
 
98
+ @ipcon.add_device self
96
99
  end
97
100
 
98
101
  # Returns the current count of the encoder. If you set reset
@@ -109,10 +112,12 @@ module Tinkerforge
109
112
  # CALLBACK_COUNT callback. You can set the callback configuration
110
113
  # with BrickletRotaryEncoderV2#set_count_callback_configuration.
111
114
  def get_count(reset)
112
- send_request FUNCTION_GET_COUNT, [reset], '?', 4, 'l'
115
+ check_validity
116
+
117
+ send_request FUNCTION_GET_COUNT, [reset], '?', 12, 'l'
113
118
  end
114
119
 
115
- # The period in ms is the period with which the CALLBACK_COUNT callback is triggered
120
+ # The period is the period with which the CALLBACK_COUNT callback is triggered
116
121
  # periodically. A value of 0 turns the callback off.
117
122
  #
118
123
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -137,15 +142,17 @@ module Tinkerforge
137
142
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
138
143
  #
139
144
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
140
- #
141
- # The default value is (0, false, 'x', 0, 0).
142
145
  def set_count_callback_configuration(period, value_has_to_change, option, min, max)
143
- send_request FUNCTION_SET_COUNT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
146
+ check_validity
147
+
148
+ send_request FUNCTION_SET_COUNT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
144
149
  end
145
150
 
146
151
  # Returns the callback configuration as set by BrickletRotaryEncoderV2#set_count_callback_configuration.
147
152
  def get_count_callback_configuration
148
- send_request FUNCTION_GET_COUNT_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
153
+ check_validity
154
+
155
+ send_request FUNCTION_GET_COUNT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
149
156
  end
150
157
 
151
158
  # Returns *true* if the button is pressed and *false* otherwise.
@@ -153,7 +160,9 @@ module Tinkerforge
153
160
  # It is recommended to use the CALLBACK_PRESSED and CALLBACK_RELEASED callbacks
154
161
  # to handle the button.
155
162
  def is_pressed
156
- send_request FUNCTION_IS_PRESSED, [], '', 1, '?'
163
+ check_validity
164
+
165
+ send_request FUNCTION_IS_PRESSED, [], '', 9, '?'
157
166
  end
158
167
 
159
168
  # Returns the error count for the communication between Brick and Bricklet.
@@ -168,7 +177,9 @@ module Tinkerforge
168
177
  # The errors counts are for errors that occur on the Bricklet side. All
169
178
  # Bricks have a similar function that returns the errors on the Brick side.
170
179
  def get_spitfp_error_count
171
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
180
+ check_validity
181
+
182
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
172
183
  end
173
184
 
174
185
  # Sets the bootloader mode and returns the status after the requested
@@ -181,12 +192,16 @@ module Tinkerforge
181
192
  # This function is used by Brick Viewer during flashing. It should not be
182
193
  # necessary to call it in a normal user program.
183
194
  def set_bootloader_mode(mode)
184
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
195
+ check_validity
196
+
197
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
185
198
  end
186
199
 
187
200
  # Returns the current bootloader mode, see BrickletRotaryEncoderV2#set_bootloader_mode.
188
201
  def get_bootloader_mode
189
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
202
+ check_validity
203
+
204
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
190
205
  end
191
206
 
192
207
  # Sets the firmware pointer for BrickletRotaryEncoderV2#write_firmware. The pointer has
@@ -196,7 +211,9 @@ module Tinkerforge
196
211
  # This function is used by Brick Viewer during flashing. It should not be
197
212
  # necessary to call it in a normal user program.
198
213
  def set_write_firmware_pointer(pointer)
199
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
214
+ check_validity
215
+
216
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
200
217
  end
201
218
 
202
219
  # Writes 64 Bytes of firmware at the position as written by
@@ -208,7 +225,9 @@ module Tinkerforge
208
225
  # This function is used by Brick Viewer during flashing. It should not be
209
226
  # necessary to call it in a normal user program.
210
227
  def write_firmware(data)
211
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
228
+ check_validity
229
+
230
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
212
231
  end
213
232
 
214
233
  # Sets the status LED configuration. By default the LED shows
@@ -219,22 +238,28 @@ module Tinkerforge
219
238
  #
220
239
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
221
240
  def set_status_led_config(config)
222
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
241
+ check_validity
242
+
243
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
223
244
  end
224
245
 
225
246
  # Returns the configuration as set by BrickletRotaryEncoderV2#set_status_led_config
226
247
  def get_status_led_config
227
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
248
+ check_validity
249
+
250
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
228
251
  end
229
252
 
230
- # Returns the temperature in °C as measured inside the microcontroller. The
253
+ # Returns the temperature as measured inside the microcontroller. The
231
254
  # value returned is not the ambient temperature!
232
255
  #
233
256
  # The temperature is only proportional to the real temperature and it has bad
234
257
  # accuracy. Practically it is only useful as an indicator for
235
258
  # temperature changes.
236
259
  def get_chip_temperature
237
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
260
+ check_validity
261
+
262
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
238
263
  end
239
264
 
240
265
  # Calling this function will reset the Bricklet. All configurations
@@ -244,7 +269,9 @@ module Tinkerforge
244
269
  # calling functions on the existing ones will result in
245
270
  # undefined behavior!
246
271
  def reset
247
- send_request FUNCTION_RESET, [], '', 0, ''
272
+ check_validity
273
+
274
+ send_request FUNCTION_RESET, [], '', 8, ''
248
275
  end
249
276
 
250
277
  # Writes a new UID into flash. If you want to set a new UID
@@ -253,25 +280,31 @@ module Tinkerforge
253
280
  #
254
281
  # We recommend that you use Brick Viewer to change the UID.
255
282
  def write_uid(uid)
256
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
283
+ check_validity
284
+
285
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
257
286
  end
258
287
 
259
288
  # Returns the current UID as an integer. Encode as
260
289
  # Base58 to get the usual string version.
261
290
  def read_uid
262
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
291
+ check_validity
292
+
293
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
263
294
  end
264
295
 
265
296
  # Returns the UID, the UID where the Bricklet is connected to,
266
297
  # the position, the hardware and firmware version as well as the
267
298
  # device identifier.
268
299
  #
269
- # The position can be 'a', 'b', 'c' or 'd'.
300
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
301
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
302
+ # position 'z'.
270
303
  #
271
304
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
272
305
  # |device_identifier_constant|
273
306
  def get_identity
274
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
307
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
275
308
  end
276
309
 
277
310
  # 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-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
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
  # 300° rotary potentiometer
14
16
  class BrickletRotaryPoti < Device
@@ -70,7 +72,7 @@ module Tinkerforge
70
72
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
71
73
  # the IP Connection <tt>ipcon</tt>.
72
74
  def initialize(uid, ipcon)
73
- super uid, ipcon
75
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
74
76
 
75
77
  @api_version = [2, 0, 0]
76
78
 
@@ -88,25 +90,27 @@ module Tinkerforge
88
90
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
91
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
92
 
91
- @callback_formats[CALLBACK_POSITION] = 's'
92
- @callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
93
- @callback_formats[CALLBACK_POSITION_REACHED] = 's'
94
- @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
93
+ @callback_formats[CALLBACK_POSITION] = [10, 's']
94
+ @callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
95
+ @callback_formats[CALLBACK_POSITION_REACHED] = [10, 's']
96
+ @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
95
97
 
98
+ @ipcon.add_device self
96
99
  end
97
100
 
98
- # Returns the position of the rotary potentiometer. The value is in degree
99
- # and between -150° (turned left) and 150° (turned right).
101
+ # Returns the position of the rotary potentiometer. The value is
102
+ # between -150° (turned left) and 150° (turned right).
100
103
  #
101
104
  # If you want to get the position periodically, it is recommended to use the
102
105
  # CALLBACK_POSITION callback and set the period with
103
106
  # BrickletRotaryPoti#set_position_callback_period.
104
107
  def get_position
105
- send_request FUNCTION_GET_POSITION, [], '', 2, 's'
108
+ check_validity
109
+
110
+ send_request FUNCTION_GET_POSITION, [], '', 10, 's'
106
111
  end
107
112
 
108
113
  # Returns the value as read by a 12-bit analog-to-digital converter.
109
- # The value is between 0 and 4095.
110
114
  #
111
115
  # .. note::
112
116
  # The value returned by BrickletRotaryPoti#get_position is averaged over several samples
@@ -118,39 +122,45 @@ module Tinkerforge
118
122
  # CALLBACK_ANALOG_VALUE callback and set the period with
119
123
  # BrickletRotaryPoti#set_analog_value_callback_period.
120
124
  def get_analog_value
121
- send_request FUNCTION_GET_ANALOG_VALUE, [], '', 2, 'S'
125
+ check_validity
126
+
127
+ send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
122
128
  end
123
129
 
124
- # Sets the period in ms with which the CALLBACK_POSITION callback is triggered
130
+ # Sets the period with which the CALLBACK_POSITION callback is triggered
125
131
  # periodically. A value of 0 turns the callback off.
126
132
  #
127
133
  # The CALLBACK_POSITION callback is only triggered if the position has changed since
128
134
  # the last triggering.
129
- #
130
- # The default value is 0.
131
135
  def set_position_callback_period(period)
132
- send_request FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 0, ''
136
+ check_validity
137
+
138
+ send_request FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 8, ''
133
139
  end
134
140
 
135
141
  # Returns the period as set by BrickletRotaryPoti#set_position_callback_period.
136
142
  def get_position_callback_period
137
- send_request FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 4, 'L'
143
+ check_validity
144
+
145
+ send_request FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 12, 'L'
138
146
  end
139
147
 
140
- # Sets the period in ms with which the CALLBACK_ANALOG_VALUE callback is triggered
148
+ # Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
141
149
  # periodically. A value of 0 turns the callback off.
142
150
  #
143
151
  # The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
144
152
  # changed since the last triggering.
145
- #
146
- # The default value is 0.
147
153
  def set_analog_value_callback_period(period)
148
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 0, ''
154
+ check_validity
155
+
156
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
149
157
  end
150
158
 
151
159
  # Returns the period as set by BrickletRotaryPoti#set_analog_value_callback_period.
152
160
  def get_analog_value_callback_period
153
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 4, 'L'
161
+ check_validity
162
+
163
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
154
164
  end
155
165
 
156
166
  # Sets the thresholds for the CALLBACK_POSITION_REACHED callback.
@@ -164,15 +174,17 @@ module Tinkerforge
164
174
  # "'i'", "Callback is triggered when the position is *inside* the min and max values"
165
175
  # "'<'", "Callback is triggered when the position is smaller than the min value (max is ignored)"
166
176
  # "'>'", "Callback is triggered when the position is greater than the min value (max is ignored)"
167
- #
168
- # The default value is ('x', 0, 0).
169
177
  def set_position_callback_threshold(option, min, max)
170
- send_request FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, ''
178
+ check_validity
179
+
180
+ send_request FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
171
181
  end
172
182
 
173
183
  # Returns the threshold as set by BrickletRotaryPoti#set_position_callback_threshold.
174
184
  def get_position_callback_threshold
175
- send_request FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 5, 'k s s'
185
+ check_validity
186
+
187
+ send_request FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
176
188
  end
177
189
 
178
190
  # Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
@@ -186,18 +198,20 @@ module Tinkerforge
186
198
  # "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
187
199
  # "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
188
200
  # "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
189
- #
190
- # The default value is ('x', 0, 0).
191
201
  def set_analog_value_callback_threshold(option, min, max)
192
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
202
+ check_validity
203
+
204
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
193
205
  end
194
206
 
195
207
  # Returns the threshold as set by BrickletRotaryPoti#set_analog_value_callback_threshold.
196
208
  def get_analog_value_callback_threshold
197
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
209
+ check_validity
210
+
211
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
198
212
  end
199
213
 
200
- # Sets the period in ms with which the threshold callbacks
214
+ # Sets the period with which the threshold callbacks
201
215
  #
202
216
  # * CALLBACK_POSITION_REACHED,
203
217
  # * CALLBACK_ANALOG_VALUE_REACHED
@@ -208,27 +222,31 @@ module Tinkerforge
208
222
  # * BrickletRotaryPoti#set_analog_value_callback_threshold
209
223
  #
210
224
  # keep being reached.
211
- #
212
- # The default value is 100.
213
225
  def set_debounce_period(debounce)
214
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
226
+ check_validity
227
+
228
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
215
229
  end
216
230
 
217
231
  # Returns the debounce period as set by BrickletRotaryPoti#set_debounce_period.
218
232
  def get_debounce_period
219
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
233
+ check_validity
234
+
235
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
220
236
  end
221
237
 
222
238
  # Returns the UID, the UID where the Bricklet is connected to,
223
239
  # the position, the hardware and firmware version as well as the
224
240
  # device identifier.
225
241
  #
226
- # The position can be 'a', 'b', 'c' or 'd'.
242
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
243
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
244
+ # position 'z'.
227
245
  #
228
246
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
229
247
  # |device_identifier_constant|
230
248
  def get_identity
231
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
249
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
232
250
  end
233
251
 
234
252
  # 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-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
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
  # 300° rotary potentiometer
14
16
  class BrickletRotaryPotiV2 < Device
@@ -61,7 +63,7 @@ module Tinkerforge
61
63
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
62
64
  # the IP Connection <tt>ipcon</tt>.
63
65
  def initialize(uid, ipcon)
64
- super uid, ipcon
66
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
65
67
 
66
68
  @api_version = [2, 0, 0]
67
69
 
@@ -81,22 +83,25 @@ module Tinkerforge
81
83
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
84
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
85
 
84
- @callback_formats[CALLBACK_POSITION] = 's'
86
+ @callback_formats[CALLBACK_POSITION] = [10, 's']
85
87
 
88
+ @ipcon.add_device self
86
89
  end
87
90
 
88
- # Returns the position of the rotary potentiometer. The value is in degree
89
- # and between -150° (turned left) and 150° (turned right).
91
+ # Returns the position of the rotary potentiometer. The value is
92
+ # between -150° (turned left) and 150° (turned right).
90
93
  #
91
94
  #
92
95
  # If you want to get the value periodically, it is recommended to use the
93
96
  # CALLBACK_POSITION callback. You can set the callback configuration
94
97
  # with BrickletRotaryPotiV2#set_position_callback_configuration.
95
98
  def get_position
96
- send_request FUNCTION_GET_POSITION, [], '', 2, 's'
99
+ check_validity
100
+
101
+ send_request FUNCTION_GET_POSITION, [], '', 10, 's'
97
102
  end
98
103
 
99
- # The period in ms is the period with which the CALLBACK_POSITION callback is triggered
104
+ # The period is the period with which the CALLBACK_POSITION callback is triggered
100
105
  # periodically. A value of 0 turns the callback off.
101
106
  #
102
107
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -121,15 +126,17 @@ module Tinkerforge
121
126
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
122
127
  #
123
128
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
124
- #
125
- # The default value is (0, false, 'x', 0, 0).
126
129
  def set_position_callback_configuration(period, value_has_to_change, option, min, max)
127
- send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
130
+ check_validity
131
+
132
+ send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
128
133
  end
129
134
 
130
135
  # Returns the callback configuration as set by BrickletRotaryPotiV2#set_position_callback_configuration.
131
136
  def get_position_callback_configuration
132
- send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
137
+ check_validity
138
+
139
+ send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
133
140
  end
134
141
 
135
142
  # Returns the error count for the communication between Brick and Bricklet.
@@ -144,7 +151,9 @@ module Tinkerforge
144
151
  # The errors counts are for errors that occur on the Bricklet side. All
145
152
  # Bricks have a similar function that returns the errors on the Brick side.
146
153
  def get_spitfp_error_count
147
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
154
+ check_validity
155
+
156
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
148
157
  end
149
158
 
150
159
  # Sets the bootloader mode and returns the status after the requested
@@ -157,12 +166,16 @@ module Tinkerforge
157
166
  # This function is used by Brick Viewer during flashing. It should not be
158
167
  # necessary to call it in a normal user program.
159
168
  def set_bootloader_mode(mode)
160
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
169
+ check_validity
170
+
171
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
161
172
  end
162
173
 
163
174
  # Returns the current bootloader mode, see BrickletRotaryPotiV2#set_bootloader_mode.
164
175
  def get_bootloader_mode
165
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
176
+ check_validity
177
+
178
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
166
179
  end
167
180
 
168
181
  # Sets the firmware pointer for BrickletRotaryPotiV2#write_firmware. The pointer has
@@ -172,7 +185,9 @@ module Tinkerforge
172
185
  # This function is used by Brick Viewer during flashing. It should not be
173
186
  # necessary to call it in a normal user program.
174
187
  def set_write_firmware_pointer(pointer)
175
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
188
+ check_validity
189
+
190
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
176
191
  end
177
192
 
178
193
  # Writes 64 Bytes of firmware at the position as written by
@@ -184,7 +199,9 @@ module Tinkerforge
184
199
  # This function is used by Brick Viewer during flashing. It should not be
185
200
  # necessary to call it in a normal user program.
186
201
  def write_firmware(data)
187
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
202
+ check_validity
203
+
204
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
188
205
  end
189
206
 
190
207
  # Sets the status LED configuration. By default the LED shows
@@ -195,22 +212,28 @@ module Tinkerforge
195
212
  #
196
213
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
197
214
  def set_status_led_config(config)
198
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
215
+ check_validity
216
+
217
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
199
218
  end
200
219
 
201
220
  # Returns the configuration as set by BrickletRotaryPotiV2#set_status_led_config
202
221
  def get_status_led_config
203
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
222
+ check_validity
223
+
224
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
204
225
  end
205
226
 
206
- # Returns the temperature in °C as measured inside the microcontroller. The
227
+ # Returns the temperature as measured inside the microcontroller. The
207
228
  # value returned is not the ambient temperature!
208
229
  #
209
230
  # The temperature is only proportional to the real temperature and it has bad
210
231
  # accuracy. Practically it is only useful as an indicator for
211
232
  # temperature changes.
212
233
  def get_chip_temperature
213
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
234
+ check_validity
235
+
236
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
214
237
  end
215
238
 
216
239
  # Calling this function will reset the Bricklet. All configurations
@@ -220,7 +243,9 @@ module Tinkerforge
220
243
  # calling functions on the existing ones will result in
221
244
  # undefined behavior!
222
245
  def reset
223
- send_request FUNCTION_RESET, [], '', 0, ''
246
+ check_validity
247
+
248
+ send_request FUNCTION_RESET, [], '', 8, ''
224
249
  end
225
250
 
226
251
  # Writes a new UID into flash. If you want to set a new UID
@@ -229,25 +254,31 @@ module Tinkerforge
229
254
  #
230
255
  # We recommend that you use Brick Viewer to change the UID.
231
256
  def write_uid(uid)
232
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
257
+ check_validity
258
+
259
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
233
260
  end
234
261
 
235
262
  # Returns the current UID as an integer. Encode as
236
263
  # Base58 to get the usual string version.
237
264
  def read_uid
238
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
265
+ check_validity
266
+
267
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
239
268
  end
240
269
 
241
270
  # Returns the UID, the UID where the Bricklet is connected to,
242
271
  # the position, the hardware and firmware version as well as the
243
272
  # device identifier.
244
273
  #
245
- # The position can be 'a', 'b', 'c' or 'd'.
274
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
275
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
276
+ # position 'z'.
246
277
  #
247
278
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
248
279
  # |device_identifier_constant|
249
280
  def get_identity
250
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
281
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
251
282
  end
252
283
 
253
284
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.