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
  # Measures color (RGB value), illuminance and color temperature
14
16
  class BrickletColor < Device
@@ -42,7 +44,7 @@ module Tinkerforge
42
44
 
43
45
  # This callback is triggered periodically with the period that is set by
44
46
  # BrickletColor#set_color_temperature_callback_period. The parameter is the
45
- # color temperature in Kelvin.
47
+ # color temperature.
46
48
  #
47
49
  # The CALLBACK_COLOR_TEMPERATURE callback is only triggered if the color temperature
48
50
  # has changed since the last triggering.
@@ -88,7 +90,7 @@ module Tinkerforge
88
90
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
89
91
  # the IP Connection <tt>ipcon</tt>.
90
92
  def initialize(uid, ipcon)
91
- super uid, ipcon
93
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
92
94
 
93
95
  @api_version = [2, 0, 0]
94
96
 
@@ -112,15 +114,15 @@ module Tinkerforge
112
114
  @response_expected[FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
115
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
116
 
115
- @callback_formats[CALLBACK_COLOR] = 'S S S S'
116
- @callback_formats[CALLBACK_COLOR_REACHED] = 'S S S S'
117
- @callback_formats[CALLBACK_ILLUMINANCE] = 'L'
118
- @callback_formats[CALLBACK_COLOR_TEMPERATURE] = 'S'
117
+ @callback_formats[CALLBACK_COLOR] = [16, 'S S S S']
118
+ @callback_formats[CALLBACK_COLOR_REACHED] = [16, 'S S S S']
119
+ @callback_formats[CALLBACK_ILLUMINANCE] = [12, 'L']
120
+ @callback_formats[CALLBACK_COLOR_TEMPERATURE] = [10, 'S']
119
121
 
122
+ @ipcon.add_device self
120
123
  end
121
124
 
122
- # Returns the measured color of the sensor. The values
123
- # have a range of 0 to 65535.
125
+ # Returns the measured color of the sensor.
124
126
  #
125
127
  # The red (r), green (g), blue (b) and clear (c) colors are measured
126
128
  # with four different photodiodes that are responsive at different
@@ -136,23 +138,27 @@ module Tinkerforge
136
138
  # to use the CALLBACK_COLOR callback and set the period with
137
139
  # BrickletColor#set_color_callback_period.
138
140
  def get_color
139
- send_request FUNCTION_GET_COLOR, [], '', 8, 'S S S S'
141
+ check_validity
142
+
143
+ send_request FUNCTION_GET_COLOR, [], '', 16, 'S S S S'
140
144
  end
141
145
 
142
- # Sets the period in ms with which the CALLBACK_COLOR callback is triggered
146
+ # Sets the period with which the CALLBACK_COLOR callback is triggered
143
147
  # periodically. A value of 0 turns the callback off.
144
148
  #
145
149
  # The CALLBACK_COLOR callback is only triggered if the color has changed since the
146
150
  # last triggering.
147
- #
148
- # The default value is 0.
149
151
  def set_color_callback_period(period)
150
- send_request FUNCTION_SET_COLOR_CALLBACK_PERIOD, [period], 'L', 0, ''
152
+ check_validity
153
+
154
+ send_request FUNCTION_SET_COLOR_CALLBACK_PERIOD, [period], 'L', 8, ''
151
155
  end
152
156
 
153
157
  # Returns the period as set by BrickletColor#set_color_callback_period.
154
158
  def get_color_callback_period
155
- send_request FUNCTION_GET_COLOR_CALLBACK_PERIOD, [], '', 4, 'L'
159
+ check_validity
160
+
161
+ send_request FUNCTION_GET_COLOR_CALLBACK_PERIOD, [], '', 12, 'L'
156
162
  end
157
163
 
158
164
  # Sets the thresholds for the CALLBACK_COLOR_REACHED callback.
@@ -166,18 +172,20 @@ module Tinkerforge
166
172
  # "'i'", "Callback is triggered when the temperature is *inside* the min and max values"
167
173
  # "'<'", "Callback is triggered when the temperature is smaller than the min value (max is ignored)"
168
174
  # "'>'", "Callback is triggered when the temperature is greater than the min value (max is ignored)"
169
- #
170
- # The default value is ('x', 0, 0, 0, 0, 0, 0, 0, 0).
171
175
  def set_color_callback_threshold(option, min_r, max_r, min_g, max_g, min_b, max_b, min_c, max_c)
172
- send_request FUNCTION_SET_COLOR_CALLBACK_THRESHOLD, [option, min_r, max_r, min_g, max_g, min_b, max_b, min_c, max_c], 'k S S S S S S S S', 0, ''
176
+ check_validity
177
+
178
+ send_request FUNCTION_SET_COLOR_CALLBACK_THRESHOLD, [option, min_r, max_r, min_g, max_g, min_b, max_b, min_c, max_c], 'k S S S S S S S S', 8, ''
173
179
  end
174
180
 
175
181
  # Returns the threshold as set by BrickletColor#set_color_callback_threshold.
176
182
  def get_color_callback_threshold
177
- send_request FUNCTION_GET_COLOR_CALLBACK_THRESHOLD, [], '', 17, 'k S S S S S S S S'
183
+ check_validity
184
+
185
+ send_request FUNCTION_GET_COLOR_CALLBACK_THRESHOLD, [], '', 25, 'k S S S S S S S S'
178
186
  end
179
187
 
180
- # Sets the period in ms with which the threshold callback
188
+ # Sets the period with which the threshold callback
181
189
  #
182
190
  # * CALLBACK_COLOR_REACHED
183
191
  #
@@ -186,25 +194,31 @@ module Tinkerforge
186
194
  # * BrickletColor#set_color_callback_threshold
187
195
  #
188
196
  # keeps being reached.
189
- #
190
- # The default value is 100.
191
197
  def set_debounce_period(debounce)
192
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
198
+ check_validity
199
+
200
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
193
201
  end
194
202
 
195
203
  # Returns the debounce period as set by BrickletColor#set_debounce_period.
196
204
  def get_debounce_period
197
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
205
+ check_validity
206
+
207
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
198
208
  end
199
209
 
200
210
  # Turns the LED on.
201
211
  def light_on
202
- send_request FUNCTION_LIGHT_ON, [], '', 0, ''
212
+ check_validity
213
+
214
+ send_request FUNCTION_LIGHT_ON, [], '', 8, ''
203
215
  end
204
216
 
205
217
  # Turns the LED off.
206
218
  def light_off
207
- send_request FUNCTION_LIGHT_OFF, [], '', 0, ''
219
+ check_validity
220
+
221
+ send_request FUNCTION_LIGHT_OFF, [], '', 8, ''
208
222
  end
209
223
 
210
224
  # Returns the state of the LED. Possible values are:
@@ -212,7 +226,9 @@ module Tinkerforge
212
226
  # * 0: On
213
227
  # * 1: Off
214
228
  def is_light_on
215
- send_request FUNCTION_IS_LIGHT_ON, [], '', 1, 'C'
229
+ check_validity
230
+
231
+ send_request FUNCTION_IS_LIGHT_ON, [], '', 9, 'C'
216
232
  end
217
233
 
218
234
  # Sets the configuration of the sensor. Gain and integration time
@@ -240,15 +256,17 @@ module Tinkerforge
240
256
  # and accuracy. With a longer integration time the values read will
241
257
  # be more accurate but it will take longer time to get the conversion
242
258
  # results.
243
- #
244
- # The default values are 60x gain and 154ms integration time.
245
259
  def set_config(gain, integration_time)
246
- send_request FUNCTION_SET_CONFIG, [gain, integration_time], 'C C', 0, ''
260
+ check_validity
261
+
262
+ send_request FUNCTION_SET_CONFIG, [gain, integration_time], 'C C', 8, ''
247
263
  end
248
264
 
249
265
  # Returns the configuration as set by BrickletColor#set_config.
250
266
  def get_config
251
- send_request FUNCTION_GET_CONFIG, [], '', 2, 'C C'
267
+ check_validity
268
+
269
+ send_request FUNCTION_GET_CONFIG, [], '', 10, 'C C'
252
270
  end
253
271
 
254
272
  # Returns the illuminance affected by the gain and integration time as
@@ -261,61 +279,71 @@ module Tinkerforge
261
279
  # is saturated if it is equal to the maximum value of 65535.
262
280
  # In that case you have to reduce the gain, see BrickletColor#set_config.
263
281
  def get_illuminance
264
- send_request FUNCTION_GET_ILLUMINANCE, [], '', 4, 'L'
282
+ check_validity
283
+
284
+ send_request FUNCTION_GET_ILLUMINANCE, [], '', 12, 'L'
265
285
  end
266
286
 
267
- # Returns the color temperature in Kelvin.
287
+ # Returns the color temperature.
268
288
  #
269
289
  # To get a correct color temperature measurement make sure that the color
270
290
  # values themselves are not saturated. The color value (R, G or B)
271
291
  # is saturated if it is equal to the maximum value of 65535.
272
292
  # In that case you have to reduce the gain, see BrickletColor#set_config.
273
293
  def get_color_temperature
274
- send_request FUNCTION_GET_COLOR_TEMPERATURE, [], '', 2, 'S'
294
+ check_validity
295
+
296
+ send_request FUNCTION_GET_COLOR_TEMPERATURE, [], '', 10, 'S'
275
297
  end
276
298
 
277
- # Sets the period in ms with which the CALLBACK_ILLUMINANCE callback is triggered
299
+ # Sets the period with which the CALLBACK_ILLUMINANCE callback is triggered
278
300
  # periodically. A value of 0 turns the callback off.
279
301
  #
280
302
  # The CALLBACK_ILLUMINANCE callback is only triggered if the illuminance has changed
281
303
  # since the last triggering.
282
- #
283
- # The default value is 0.
284
304
  def set_illuminance_callback_period(period)
285
- send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD, [period], 'L', 0, ''
305
+ check_validity
306
+
307
+ send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
286
308
  end
287
309
 
288
310
  # Returns the period as set by BrickletColor#set_illuminance_callback_period.
289
311
  def get_illuminance_callback_period
290
- send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD, [], '', 4, 'L'
312
+ check_validity
313
+
314
+ send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD, [], '', 12, 'L'
291
315
  end
292
316
 
293
- # Sets the period in ms with which the CALLBACK_COLOR_TEMPERATURE callback is
317
+ # Sets the period with which the CALLBACK_COLOR_TEMPERATURE callback is
294
318
  # triggered periodically. A value of 0 turns the callback off.
295
319
  #
296
320
  # The CALLBACK_COLOR_TEMPERATURE callback is only triggered if the color temperature
297
321
  # has changed since the last triggering.
298
- #
299
- # The default value is 0.
300
322
  def set_color_temperature_callback_period(period)
301
- send_request FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 0, ''
323
+ check_validity
324
+
325
+ send_request FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_PERIOD, [period], 'L', 8, ''
302
326
  end
303
327
 
304
328
  # Returns the period as set by BrickletColor#set_color_temperature_callback_period.
305
329
  def get_color_temperature_callback_period
306
- send_request FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_PERIOD, [], '', 4, 'L'
330
+ check_validity
331
+
332
+ send_request FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_PERIOD, [], '', 12, 'L'
307
333
  end
308
334
 
309
335
  # Returns the UID, the UID where the Bricklet is connected to,
310
336
  # the position, the hardware and firmware version as well as the
311
337
  # device identifier.
312
338
  #
313
- # The position can be 'a', 'b', 'c' or 'd'.
339
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
340
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
341
+ # position 'z'.
314
342
  #
315
343
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
316
344
  # |device_identifier_constant|
317
345
  def get_identity
318
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
346
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
319
347
  end
320
348
 
321
349
  # 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
  # Measures color (RGB value), illuminance and color temperature
14
16
  class BrickletColorV2 < Device
@@ -94,7 +96,7 @@ module Tinkerforge
94
96
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
95
97
  # the IP Connection <tt>ipcon</tt>.
96
98
  def initialize(uid, ipcon)
97
- super uid, ipcon
99
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
98
100
 
99
101
  @api_version = [2, 0, 0]
100
102
 
@@ -124,14 +126,14 @@ module Tinkerforge
124
126
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
125
127
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
126
128
 
127
- @callback_formats[CALLBACK_COLOR] = 'S S S S'
128
- @callback_formats[CALLBACK_ILLUMINANCE] = 'L'
129
- @callback_formats[CALLBACK_COLOR_TEMPERATURE] = 'S'
129
+ @callback_formats[CALLBACK_COLOR] = [16, 'S S S S']
130
+ @callback_formats[CALLBACK_ILLUMINANCE] = [12, 'L']
131
+ @callback_formats[CALLBACK_COLOR_TEMPERATURE] = [10, 'S']
130
132
 
133
+ @ipcon.add_device self
131
134
  end
132
135
 
133
- # Returns the measured color of the sensor. The values
134
- # have a range of 0 to 65535.
136
+ # Returns the measured color of the sensor.
135
137
  #
136
138
  # The red (r), green (g), blue (b) and clear (c) colors are measured
137
139
  # with four different photodiodes that are responsive at different
@@ -147,10 +149,12 @@ module Tinkerforge
147
149
  # to use the CALLBACK_COLOR callback and set the period with
148
150
  # BrickletColorV2#set_color_callback_configuration.
149
151
  def get_color
150
- send_request FUNCTION_GET_COLOR, [], '', 8, 'S S S S'
152
+ check_validity
153
+
154
+ send_request FUNCTION_GET_COLOR, [], '', 16, 'S S S S'
151
155
  end
152
156
 
153
- # The period in ms is the period with which the CALLBACK_COLOR
157
+ # The period is the period with which the CALLBACK_COLOR
154
158
  # callback is triggered periodically. A value of 0 turns the callback off.
155
159
  #
156
160
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -159,16 +163,18 @@ module Tinkerforge
159
163
  #
160
164
  # If it is set to false, the callback is continuously triggered with the period,
161
165
  # independent of the value.
162
- #
163
- # The default value is (0, false).
164
166
  def set_color_callback_configuration(period, value_has_to_change)
165
- send_request FUNCTION_SET_COLOR_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
167
+ check_validity
168
+
169
+ send_request FUNCTION_SET_COLOR_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
166
170
  end
167
171
 
168
172
  # Returns the callback configuration as set by
169
173
  # BrickletColorV2#set_color_callback_configuration.
170
174
  def get_color_callback_configuration
171
- send_request FUNCTION_GET_COLOR_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
175
+ check_validity
176
+
177
+ send_request FUNCTION_GET_COLOR_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
172
178
  end
173
179
 
174
180
  # Returns the illuminance affected by the gain and integration time as
@@ -186,10 +192,12 @@ module Tinkerforge
186
192
  # CALLBACK_ILLUMINANCE callback. You can set the callback configuration
187
193
  # with BrickletColorV2#set_illuminance_callback_configuration.
188
194
  def get_illuminance
189
- send_request FUNCTION_GET_ILLUMINANCE, [], '', 4, 'L'
195
+ check_validity
196
+
197
+ send_request FUNCTION_GET_ILLUMINANCE, [], '', 12, 'L'
190
198
  end
191
199
 
192
- # The period in ms is the period with which the CALLBACK_ILLUMINANCE callback is triggered
200
+ # The period is the period with which the CALLBACK_ILLUMINANCE callback is triggered
193
201
  # periodically. A value of 0 turns the callback off.
194
202
  #
195
203
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -214,18 +222,20 @@ module Tinkerforge
214
222
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
215
223
  #
216
224
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
217
- #
218
- # The default value is (0, false, 'x', 0, 0).
219
225
  def set_illuminance_callback_configuration(period, value_has_to_change, option, min, max)
220
- send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 0, ''
226
+ check_validity
227
+
228
+ send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 8, ''
221
229
  end
222
230
 
223
231
  # Returns the callback configuration as set by BrickletColorV2#set_illuminance_callback_configuration.
224
232
  def get_illuminance_callback_configuration
225
- send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k L L'
233
+ check_validity
234
+
235
+ send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k L L'
226
236
  end
227
237
 
228
- # Returns the color temperature in Kelvin.
238
+ # Returns the color temperature.
229
239
  #
230
240
  # To get a correct color temperature measurement make sure that the color
231
241
  # values themselves are not saturated. The color value (R, G or B)
@@ -237,10 +247,12 @@ module Tinkerforge
237
247
  # CALLBACK_COLOR_TEMPERATURE callback. You can set the callback configuration
238
248
  # with BrickletColorV2#set_color_temperature_callback_configuration.
239
249
  def get_color_temperature
240
- send_request FUNCTION_GET_COLOR_TEMPERATURE, [], '', 2, 'S'
250
+ check_validity
251
+
252
+ send_request FUNCTION_GET_COLOR_TEMPERATURE, [], '', 10, 'S'
241
253
  end
242
254
 
243
- # The period in ms is the period with which the CALLBACK_COLOR_TEMPERATURE callback is triggered
255
+ # The period is the period with which the CALLBACK_COLOR_TEMPERATURE callback is triggered
244
256
  # periodically. A value of 0 turns the callback off.
245
257
  #
246
258
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -265,25 +277,31 @@ module Tinkerforge
265
277
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
266
278
  #
267
279
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
268
- #
269
- # The default value is (0, false, 'x', 0, 0).
270
280
  def set_color_temperature_callback_configuration(period, value_has_to_change, option, min, max)
271
- send_request FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
281
+ check_validity
282
+
283
+ send_request FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
272
284
  end
273
285
 
274
286
  # Returns the callback configuration as set by BrickletColorV2#set_color_temperature_callback_configuration.
275
287
  def get_color_temperature_callback_configuration
276
- send_request FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
288
+ check_validity
289
+
290
+ send_request FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
277
291
  end
278
292
 
279
293
  # Turns the white LED on the Bricklet on/off.
280
294
  def set_light(enable)
281
- send_request FUNCTION_SET_LIGHT, [enable], '?', 0, ''
295
+ check_validity
296
+
297
+ send_request FUNCTION_SET_LIGHT, [enable], '?', 8, ''
282
298
  end
283
299
 
284
300
  # Returns the value as set by BrickletColorV2#set_light.
285
301
  def get_light
286
- send_request FUNCTION_GET_LIGHT, [], '', 1, '?'
302
+ check_validity
303
+
304
+ send_request FUNCTION_GET_LIGHT, [], '', 9, '?'
287
305
  end
288
306
 
289
307
  # Sets the configuration of the sensor. Gain and integration time
@@ -311,15 +329,17 @@ module Tinkerforge
311
329
  # and accuracy. With a longer integration time the values read will
312
330
  # be more accurate but it will take longer to get the conversion
313
331
  # results.
314
- #
315
- # The default values are 60x gain and 154ms integration time.
316
332
  def set_configuration(gain, integration_time)
317
- send_request FUNCTION_SET_CONFIGURATION, [gain, integration_time], 'C C', 0, ''
333
+ check_validity
334
+
335
+ send_request FUNCTION_SET_CONFIGURATION, [gain, integration_time], 'C C', 8, ''
318
336
  end
319
337
 
320
338
  # Returns the configuration as set by BrickletColorV2#set_configuration.
321
339
  def get_configuration
322
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
340
+ check_validity
341
+
342
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
323
343
  end
324
344
 
325
345
  # Returns the error count for the communication between Brick and Bricklet.
@@ -334,7 +354,9 @@ module Tinkerforge
334
354
  # The errors counts are for errors that occur on the Bricklet side. All
335
355
  # Bricks have a similar function that returns the errors on the Brick side.
336
356
  def get_spitfp_error_count
337
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
357
+ check_validity
358
+
359
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
338
360
  end
339
361
 
340
362
  # Sets the bootloader mode and returns the status after the requested
@@ -347,12 +369,16 @@ module Tinkerforge
347
369
  # This function is used by Brick Viewer during flashing. It should not be
348
370
  # necessary to call it in a normal user program.
349
371
  def set_bootloader_mode(mode)
350
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
372
+ check_validity
373
+
374
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
351
375
  end
352
376
 
353
377
  # Returns the current bootloader mode, see BrickletColorV2#set_bootloader_mode.
354
378
  def get_bootloader_mode
355
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
379
+ check_validity
380
+
381
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
356
382
  end
357
383
 
358
384
  # Sets the firmware pointer for BrickletColorV2#write_firmware. The pointer has
@@ -362,7 +388,9 @@ module Tinkerforge
362
388
  # This function is used by Brick Viewer during flashing. It should not be
363
389
  # necessary to call it in a normal user program.
364
390
  def set_write_firmware_pointer(pointer)
365
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
391
+ check_validity
392
+
393
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
366
394
  end
367
395
 
368
396
  # Writes 64 Bytes of firmware at the position as written by
@@ -374,7 +402,9 @@ module Tinkerforge
374
402
  # This function is used by Brick Viewer during flashing. It should not be
375
403
  # necessary to call it in a normal user program.
376
404
  def write_firmware(data)
377
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
405
+ check_validity
406
+
407
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
378
408
  end
379
409
 
380
410
  # Sets the status LED configuration. By default the LED shows
@@ -385,22 +415,28 @@ module Tinkerforge
385
415
  #
386
416
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
387
417
  def set_status_led_config(config)
388
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
418
+ check_validity
419
+
420
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
389
421
  end
390
422
 
391
423
  # Returns the configuration as set by BrickletColorV2#set_status_led_config
392
424
  def get_status_led_config
393
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
425
+ check_validity
426
+
427
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
394
428
  end
395
429
 
396
- # Returns the temperature in °C as measured inside the microcontroller. The
430
+ # Returns the temperature as measured inside the microcontroller. The
397
431
  # value returned is not the ambient temperature!
398
432
  #
399
433
  # The temperature is only proportional to the real temperature and it has bad
400
434
  # accuracy. Practically it is only useful as an indicator for
401
435
  # temperature changes.
402
436
  def get_chip_temperature
403
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
437
+ check_validity
438
+
439
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
404
440
  end
405
441
 
406
442
  # Calling this function will reset the Bricklet. All configurations
@@ -410,7 +446,9 @@ module Tinkerforge
410
446
  # calling functions on the existing ones will result in
411
447
  # undefined behavior!
412
448
  def reset
413
- send_request FUNCTION_RESET, [], '', 0, ''
449
+ check_validity
450
+
451
+ send_request FUNCTION_RESET, [], '', 8, ''
414
452
  end
415
453
 
416
454
  # Writes a new UID into flash. If you want to set a new UID
@@ -419,25 +457,31 @@ module Tinkerforge
419
457
  #
420
458
  # We recommend that you use Brick Viewer to change the UID.
421
459
  def write_uid(uid)
422
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
460
+ check_validity
461
+
462
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
423
463
  end
424
464
 
425
465
  # Returns the current UID as an integer. Encode as
426
466
  # Base58 to get the usual string version.
427
467
  def read_uid
428
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
468
+ check_validity
469
+
470
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
429
471
  end
430
472
 
431
473
  # Returns the UID, the UID where the Bricklet is connected to,
432
474
  # the position, the hardware and firmware version as well as the
433
475
  # device identifier.
434
476
  #
435
- # The position can be 'a', 'b', 'c' or 'd'.
477
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
478
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
479
+ # position 'z'.
436
480
  #
437
481
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
438
482
  # |device_identifier_constant|
439
483
  def get_identity
440
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
484
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
441
485
  end
442
486
 
443
487
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.