tinkerforge 2.1.22 → 2.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +157 -76
  3. data/lib/tinkerforge/brick_hat.rb +115 -32
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +192 -87
  6. data/lib/tinkerforge/brick_imu_v2.rb +220 -119
  7. data/lib/tinkerforge/brick_master.rb +498 -198
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +187 -103
  10. data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
  11. data/lib/tinkerforge/brick_stepper.rb +214 -102
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
  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 +77 -49
  31. data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +397 -0
  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 +335 -0
  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 +416 -0
  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 +101 -53
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -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 +371 -0
  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 +97 -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_piezo_buzzer.rb +19 -13
  102. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  103. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  104. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  105. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  106. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  107. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  108. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  109. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  110. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  111. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  112. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  113. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  114. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  115. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  116. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  117. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
  118. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  119. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  120. data/lib/tinkerforge/bricklet_rs485.rb +303 -207
  121. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  122. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  123. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  124. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  125. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  126. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  127. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  128. data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
  129. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
  130. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  131. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  132. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  133. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  134. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  135. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  136. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  137. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  138. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  139. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
  140. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
  141. data/lib/tinkerforge/device_display_names.rb +165 -0
  142. data/lib/tinkerforge/ip_connection.rb +155 -33
  143. data/lib/tinkerforge/version.rb +1 -1
  144. metadata +14 -4
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Measures 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
@@ -257,65 +275,75 @@ module Tinkerforge
257
275
  # lux = illuminance * 700 / gain / integration_time
258
276
  #
259
277
  # To get a correct illuminance measurement make sure that the color
260
- # values themself are not saturated. The color value (R, G or B)
278
+ # values themselves are not saturated. The color value (R, G or B)
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
- # values themself are not saturated. The color value (R, G or B)
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>.
@@ -0,0 +1,493 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2020-11-02. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.27 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ require_relative './ip_connection'
13
+
14
+ module Tinkerforge
15
+ # Measures color (RGB value), illuminance and color temperature
16
+ class BrickletColorV2 < Device
17
+ DEVICE_IDENTIFIER = 2128 # :nodoc:
18
+ DEVICE_DISPLAY_NAME = 'Color Bricklet 2.0' # :nodoc:
19
+
20
+ # This callback is triggered periodically with the period that is set by
21
+ # BrickletColorV2#set_color_callback_configuration. The parameter is the color
22
+ # of the sensor as RGBC.
23
+ #
24
+ # The CALLBACK_COLOR callback is only triggered if the color has changed since the
25
+ # last triggering.
26
+ CALLBACK_COLOR = 4
27
+
28
+ # This callback is triggered periodically according to the configuration set by
29
+ # BrickletColorV2#set_illuminance_callback_configuration.
30
+ #
31
+ # The parameter is the same as BrickletColorV2#get_illuminance.
32
+ CALLBACK_ILLUMINANCE = 8
33
+
34
+ # This callback is triggered periodically according to the configuration set by
35
+ # BrickletColorV2#set_color_temperature_callback_configuration.
36
+ #
37
+ # The parameter is the same as BrickletColorV2#get_color_temperature.
38
+ CALLBACK_COLOR_TEMPERATURE = 12
39
+
40
+ FUNCTION_GET_COLOR = 1 # :nodoc:
41
+ FUNCTION_SET_COLOR_CALLBACK_CONFIGURATION = 2 # :nodoc:
42
+ FUNCTION_GET_COLOR_CALLBACK_CONFIGURATION = 3 # :nodoc:
43
+ FUNCTION_GET_ILLUMINANCE = 5 # :nodoc:
44
+ FUNCTION_SET_ILLUMINANCE_CALLBACK_CONFIGURATION = 6 # :nodoc:
45
+ FUNCTION_GET_ILLUMINANCE_CALLBACK_CONFIGURATION = 7 # :nodoc:
46
+ FUNCTION_GET_COLOR_TEMPERATURE = 9 # :nodoc:
47
+ FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION = 10 # :nodoc:
48
+ FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION = 11 # :nodoc:
49
+ FUNCTION_SET_LIGHT = 13 # :nodoc:
50
+ FUNCTION_GET_LIGHT = 14 # :nodoc:
51
+ FUNCTION_SET_CONFIGURATION = 15 # :nodoc:
52
+ FUNCTION_GET_CONFIGURATION = 16 # :nodoc:
53
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
54
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
55
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
56
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
57
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
58
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
59
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
60
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
61
+ FUNCTION_RESET = 243 # :nodoc:
62
+ FUNCTION_WRITE_UID = 248 # :nodoc:
63
+ FUNCTION_READ_UID = 249 # :nodoc:
64
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
65
+
66
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
67
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
68
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
69
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
70
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
71
+ GAIN_1X = 0 # :nodoc:
72
+ GAIN_4X = 1 # :nodoc:
73
+ GAIN_16X = 2 # :nodoc:
74
+ GAIN_60X = 3 # :nodoc:
75
+ INTEGRATION_TIME_2MS = 0 # :nodoc:
76
+ INTEGRATION_TIME_24MS = 1 # :nodoc:
77
+ INTEGRATION_TIME_101MS = 2 # :nodoc:
78
+ INTEGRATION_TIME_154MS = 3 # :nodoc:
79
+ INTEGRATION_TIME_700MS = 4 # :nodoc:
80
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
81
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
82
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
83
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
84
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
85
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
86
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
87
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
88
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
89
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
90
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
91
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
92
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
93
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
94
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
95
+
96
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
97
+ # the IP Connection <tt>ipcon</tt>.
98
+ def initialize(uid, ipcon)
99
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
100
+
101
+ @api_version = [2, 0, 0]
102
+
103
+ @response_expected[FUNCTION_GET_COLOR] = RESPONSE_EXPECTED_ALWAYS_TRUE
104
+ @response_expected[FUNCTION_SET_COLOR_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
105
+ @response_expected[FUNCTION_GET_COLOR_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
106
+ @response_expected[FUNCTION_GET_ILLUMINANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
107
+ @response_expected[FUNCTION_SET_ILLUMINANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
108
+ @response_expected[FUNCTION_GET_ILLUMINANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
109
+ @response_expected[FUNCTION_GET_COLOR_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
110
+ @response_expected[FUNCTION_SET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
111
+ @response_expected[FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
112
+ @response_expected[FUNCTION_SET_LIGHT] = RESPONSE_EXPECTED_FALSE
113
+ @response_expected[FUNCTION_GET_LIGHT] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
+ @response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
115
+ @response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
116
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
117
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
118
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
119
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
120
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
121
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
122
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
125
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
126
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
127
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
128
+
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']
132
+
133
+ @ipcon.add_device self
134
+ end
135
+
136
+ # Returns the measured color of the sensor.
137
+ #
138
+ # The red (r), green (g), blue (b) and clear (c) colors are measured
139
+ # with four different photodiodes that are responsive at different
140
+ # wavelengths:
141
+ #
142
+ # .. image:: /Images/Bricklets/bricklet_color_wavelength_chart_600.jpg
143
+ # :scale: 100 %
144
+ # :alt: Chart Responsivity / Wavelength
145
+ # :align: center
146
+ # :target: ../../_images/Bricklets/bricklet_color_wavelength_chart_600.jpg
147
+ #
148
+ # If you want to get the color periodically, it is recommended
149
+ # to use the CALLBACK_COLOR callback and set the period with
150
+ # BrickletColorV2#set_color_callback_configuration.
151
+ def get_color
152
+ check_validity
153
+
154
+ send_request FUNCTION_GET_COLOR, [], '', 16, 'S S S S'
155
+ end
156
+
157
+ # The period is the period with which the CALLBACK_COLOR
158
+ # callback is triggered periodically. A value of 0 turns the callback off.
159
+ #
160
+ # If the `value has to change`-parameter is set to true, the callback is only
161
+ # triggered after the value has changed. If the value didn't change within the
162
+ # period, the callback is triggered immediately on change.
163
+ #
164
+ # If it is set to false, the callback is continuously triggered with the period,
165
+ # independent of the value.
166
+ def set_color_callback_configuration(period, value_has_to_change)
167
+ check_validity
168
+
169
+ send_request FUNCTION_SET_COLOR_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
170
+ end
171
+
172
+ # Returns the callback configuration as set by
173
+ # BrickletColorV2#set_color_callback_configuration.
174
+ def get_color_callback_configuration
175
+ check_validity
176
+
177
+ send_request FUNCTION_GET_COLOR_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
178
+ end
179
+
180
+ # Returns the illuminance affected by the gain and integration time as
181
+ # set by BrickletColorV2#set_configuration. To get the illuminance in Lux apply this formula::
182
+ #
183
+ # lux = illuminance * 700 / gain / integration_time
184
+ #
185
+ # To get a correct illuminance measurement make sure that the color
186
+ # values themselves are not saturated. The color value (R, G or B)
187
+ # is saturated if it is equal to the maximum value of 65535.
188
+ # In that case you have to reduce the gain, see BrickletColorV2#set_configuration.
189
+ #
190
+ #
191
+ # If you want to get the value periodically, it is recommended to use the
192
+ # CALLBACK_ILLUMINANCE callback. You can set the callback configuration
193
+ # with BrickletColorV2#set_illuminance_callback_configuration.
194
+ def get_illuminance
195
+ check_validity
196
+
197
+ send_request FUNCTION_GET_ILLUMINANCE, [], '', 12, 'L'
198
+ end
199
+
200
+ # The period is the period with which the CALLBACK_ILLUMINANCE callback is triggered
201
+ # periodically. A value of 0 turns the callback off.
202
+ #
203
+ # If the `value has to change`-parameter is set to true, the callback is only
204
+ # triggered after the value has changed. If the value didn't change
205
+ # within the period, the callback is triggered immediately on change.
206
+ #
207
+ # If it is set to false, the callback is continuously triggered with the period,
208
+ # independent of the value.
209
+ #
210
+ # It is furthermore possible to constrain the callback with thresholds.
211
+ #
212
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_ILLUMINANCE callback.
213
+ #
214
+ # The following options are possible:
215
+ #
216
+ # "Option", "Description"
217
+ #
218
+ # "'x'", "Threshold is turned off"
219
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
220
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
221
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
222
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
223
+ #
224
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
225
+ def set_illuminance_callback_configuration(period, value_has_to_change, option, min, max)
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, ''
229
+ end
230
+
231
+ # Returns the callback configuration as set by BrickletColorV2#set_illuminance_callback_configuration.
232
+ def get_illuminance_callback_configuration
233
+ check_validity
234
+
235
+ send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k L L'
236
+ end
237
+
238
+ # Returns the color temperature.
239
+ #
240
+ # To get a correct color temperature measurement make sure that the color
241
+ # values themselves are not saturated. The color value (R, G or B)
242
+ # is saturated if it is equal to the maximum value of 65535.
243
+ # In that case you have to reduce the gain, see BrickletColorV2#set_configuration.
244
+ #
245
+ #
246
+ # If you want to get the value periodically, it is recommended to use the
247
+ # CALLBACK_COLOR_TEMPERATURE callback. You can set the callback configuration
248
+ # with BrickletColorV2#set_color_temperature_callback_configuration.
249
+ def get_color_temperature
250
+ check_validity
251
+
252
+ send_request FUNCTION_GET_COLOR_TEMPERATURE, [], '', 10, 'S'
253
+ end
254
+
255
+ # The period is the period with which the CALLBACK_COLOR_TEMPERATURE callback is triggered
256
+ # periodically. A value of 0 turns the callback off.
257
+ #
258
+ # If the `value has to change`-parameter is set to true, the callback is only
259
+ # triggered after the value has changed. If the value didn't change
260
+ # within the period, the callback is triggered immediately on change.
261
+ #
262
+ # If it is set to false, the callback is continuously triggered with the period,
263
+ # independent of the value.
264
+ #
265
+ # It is furthermore possible to constrain the callback with thresholds.
266
+ #
267
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_COLOR_TEMPERATURE callback.
268
+ #
269
+ # The following options are possible:
270
+ #
271
+ # "Option", "Description"
272
+ #
273
+ # "'x'", "Threshold is turned off"
274
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
275
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
276
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
277
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
278
+ #
279
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
280
+ def set_color_temperature_callback_configuration(period, value_has_to_change, option, min, max)
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, ''
284
+ end
285
+
286
+ # Returns the callback configuration as set by BrickletColorV2#set_color_temperature_callback_configuration.
287
+ def get_color_temperature_callback_configuration
288
+ check_validity
289
+
290
+ send_request FUNCTION_GET_COLOR_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
291
+ end
292
+
293
+ # Turns the white LED on the Bricklet on/off.
294
+ def set_light(enable)
295
+ check_validity
296
+
297
+ send_request FUNCTION_SET_LIGHT, [enable], '?', 8, ''
298
+ end
299
+
300
+ # Returns the value as set by BrickletColorV2#set_light.
301
+ def get_light
302
+ check_validity
303
+
304
+ send_request FUNCTION_GET_LIGHT, [], '', 9, '?'
305
+ end
306
+
307
+ # Sets the configuration of the sensor. Gain and integration time
308
+ # can be configured this way.
309
+ #
310
+ # For configuring the gain:
311
+ #
312
+ # * 0: 1x Gain
313
+ # * 1: 4x Gain
314
+ # * 2: 16x Gain
315
+ # * 3: 60x Gain
316
+ #
317
+ # For configuring the integration time:
318
+ #
319
+ # * 0: 2.4ms
320
+ # * 1: 24ms
321
+ # * 2: 101ms
322
+ # * 3: 154ms
323
+ # * 4: 700ms
324
+ #
325
+ # Increasing the gain enables the sensor to detect a
326
+ # color from a higher distance.
327
+ #
328
+ # The integration time provides a trade-off between conversion time
329
+ # and accuracy. With a longer integration time the values read will
330
+ # be more accurate but it will take longer to get the conversion
331
+ # results.
332
+ def set_configuration(gain, integration_time)
333
+ check_validity
334
+
335
+ send_request FUNCTION_SET_CONFIGURATION, [gain, integration_time], 'C C', 8, ''
336
+ end
337
+
338
+ # Returns the configuration as set by BrickletColorV2#set_configuration.
339
+ def get_configuration
340
+ check_validity
341
+
342
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
343
+ end
344
+
345
+ # Returns the error count for the communication between Brick and Bricklet.
346
+ #
347
+ # The errors are divided into
348
+ #
349
+ # * ACK checksum errors,
350
+ # * message checksum errors,
351
+ # * framing errors and
352
+ # * overflow errors.
353
+ #
354
+ # The errors counts are for errors that occur on the Bricklet side. All
355
+ # Bricks have a similar function that returns the errors on the Brick side.
356
+ def get_spitfp_error_count
357
+ check_validity
358
+
359
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
360
+ end
361
+
362
+ # Sets the bootloader mode and returns the status after the requested
363
+ # mode change was instigated.
364
+ #
365
+ # You can change from bootloader mode to firmware mode and vice versa. A change
366
+ # from bootloader mode to firmware mode will only take place if the entry function,
367
+ # device identifier and CRC are present and correct.
368
+ #
369
+ # This function is used by Brick Viewer during flashing. It should not be
370
+ # necessary to call it in a normal user program.
371
+ def set_bootloader_mode(mode)
372
+ check_validity
373
+
374
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
375
+ end
376
+
377
+ # Returns the current bootloader mode, see BrickletColorV2#set_bootloader_mode.
378
+ def get_bootloader_mode
379
+ check_validity
380
+
381
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
382
+ end
383
+
384
+ # Sets the firmware pointer for BrickletColorV2#write_firmware. The pointer has
385
+ # to be increased by chunks of size 64. The data is written to flash
386
+ # every 4 chunks (which equals to one page of size 256).
387
+ #
388
+ # This function is used by Brick Viewer during flashing. It should not be
389
+ # necessary to call it in a normal user program.
390
+ def set_write_firmware_pointer(pointer)
391
+ check_validity
392
+
393
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
394
+ end
395
+
396
+ # Writes 64 Bytes of firmware at the position as written by
397
+ # BrickletColorV2#set_write_firmware_pointer before. The firmware is written
398
+ # to flash every 4 chunks.
399
+ #
400
+ # You can only write firmware in bootloader mode.
401
+ #
402
+ # This function is used by Brick Viewer during flashing. It should not be
403
+ # necessary to call it in a normal user program.
404
+ def write_firmware(data)
405
+ check_validity
406
+
407
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
408
+ end
409
+
410
+ # Sets the status LED configuration. By default the LED shows
411
+ # communication traffic between Brick and Bricklet, it flickers once
412
+ # for every 10 received data packets.
413
+ #
414
+ # You can also turn the LED permanently on/off or show a heartbeat.
415
+ #
416
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
417
+ def set_status_led_config(config)
418
+ check_validity
419
+
420
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
421
+ end
422
+
423
+ # Returns the configuration as set by BrickletColorV2#set_status_led_config
424
+ def get_status_led_config
425
+ check_validity
426
+
427
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
428
+ end
429
+
430
+ # Returns the temperature as measured inside the microcontroller. The
431
+ # value returned is not the ambient temperature!
432
+ #
433
+ # The temperature is only proportional to the real temperature and it has bad
434
+ # accuracy. Practically it is only useful as an indicator for
435
+ # temperature changes.
436
+ def get_chip_temperature
437
+ check_validity
438
+
439
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
440
+ end
441
+
442
+ # Calling this function will reset the Bricklet. All configurations
443
+ # will be lost.
444
+ #
445
+ # After a reset you have to create new device objects,
446
+ # calling functions on the existing ones will result in
447
+ # undefined behavior!
448
+ def reset
449
+ check_validity
450
+
451
+ send_request FUNCTION_RESET, [], '', 8, ''
452
+ end
453
+
454
+ # Writes a new UID into flash. If you want to set a new UID
455
+ # you have to decode the Base58 encoded UID string into an
456
+ # integer first.
457
+ #
458
+ # We recommend that you use Brick Viewer to change the UID.
459
+ def write_uid(uid)
460
+ check_validity
461
+
462
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
463
+ end
464
+
465
+ # Returns the current UID as an integer. Encode as
466
+ # Base58 to get the usual string version.
467
+ def read_uid
468
+ check_validity
469
+
470
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
471
+ end
472
+
473
+ # Returns the UID, the UID where the Bricklet is connected to,
474
+ # the position, the hardware and firmware version as well as the
475
+ # device identifier.
476
+ #
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'.
480
+ #
481
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
482
+ # |device_identifier_constant|
483
+ def get_identity
484
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
485
+ end
486
+
487
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
488
+ def register_callback(id, &block)
489
+ callback = block
490
+ @registered_callbacks[id] = callback
491
+ end
492
+ end
493
+ end