tinkerforge 2.1.16 → 2.1.17

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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +3 -3
  3. data/lib/tinkerforge/brick_imu.rb +3 -3
  4. data/lib/tinkerforge/brick_imu_v2.rb +3 -3
  5. data/lib/tinkerforge/brick_master.rb +3 -3
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +3 -3
  8. data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
  9. data/lib/tinkerforge/brick_stepper.rb +3 -3
  10. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  11. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  12. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
  13. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  14. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  15. data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -6
  16. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  17. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  18. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  19. data/lib/tinkerforge/bricklet_can.rb +3 -3
  20. data/lib/tinkerforge/bricklet_can_v2.rb +770 -0
  21. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  22. data/lib/tinkerforge/bricklet_color.rb +2 -2
  23. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  24. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  25. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  26. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  27. data/lib/tinkerforge/bricklet_dmx.rb +3 -3
  28. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  29. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  30. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  31. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  32. data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
  33. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  34. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  35. data/lib/tinkerforge/bricklet_humidity_v2.rb +11 -13
  36. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  37. data/lib/tinkerforge/bricklet_industrial_counter.rb +445 -0
  38. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  39. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +342 -0
  40. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  41. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  42. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  43. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +263 -0
  44. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  45. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +281 -0
  46. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  47. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  48. data/lib/tinkerforge/bricklet_io4_v2.rb +437 -0
  49. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  50. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  51. data/lib/tinkerforge/bricklet_lcd_16x2.rb +3 -3
  52. data/lib/tinkerforge/bricklet_lcd_20x4.rb +3 -3
  53. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  54. data/lib/tinkerforge/bricklet_led_strip_v2.rb +493 -0
  55. data/lib/tinkerforge/bricklet_line.rb +2 -2
  56. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  57. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  58. data/lib/tinkerforge/bricklet_load_cell_v2.rb +354 -0
  59. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  60. data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
  61. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
  62. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -6
  63. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  64. data/lib/tinkerforge/bricklet_nfc.rb +39 -3
  65. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  66. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  67. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  68. data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
  69. data/lib/tinkerforge/bricklet_particulate_matter.rb +320 -0
  70. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  71. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  72. data/lib/tinkerforge/bricklet_ptc.rb +33 -3
  73. data/lib/tinkerforge/bricklet_ptc_v2.rb +433 -0
  74. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  75. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +353 -0
  76. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  77. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
  78. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  79. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  80. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  81. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  82. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +8 -9
  83. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  84. data/lib/tinkerforge/bricklet_rs232.rb +3 -3
  85. data/lib/tinkerforge/bricklet_rs232_v2.rb +421 -0
  86. data/lib/tinkerforge/bricklet_rs485.rb +6 -6
  87. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  88. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  89. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
  90. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  91. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +420 -0
  92. data/lib/tinkerforge/bricklet_temperature.rb +3 -3
  93. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  94. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +13 -15
  95. data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
  96. data/lib/tinkerforge/bricklet_thermocouple.rb +4 -4
  97. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +340 -0
  98. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  99. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  100. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  101. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  102. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +453 -0
  103. data/lib/tinkerforge/ip_connection.rb +4 -4
  104. data/lib/tinkerforge/version.rb +1 -1
  105. metadata +17 -2
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 #
@@ -0,0 +1,281 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2018-06-08. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.17 #
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
+ module Tinkerforge
13
+ # 4 galvanically isolated solid state relays
14
+ class BrickletIndustrialQuadRelayV2 < Device
15
+ DEVICE_IDENTIFIER = 2102 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Industrial Quad Relay Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered whenever a monoflop timer reaches 0. The
19
+ # parameters contain the channel and the current value of the channel
20
+ # (the value after the monoflop).
21
+ CALLBACK_MONOFLOP_DONE = 8
22
+
23
+ FUNCTION_SET_VALUE = 1 # :nodoc:
24
+ FUNCTION_GET_VALUE = 2 # :nodoc:
25
+ FUNCTION_SET_MONOFLOP = 3 # :nodoc:
26
+ FUNCTION_GET_MONOFLOP = 4 # :nodoc:
27
+ FUNCTION_SET_SELECTED_VALUE = 5 # :nodoc:
28
+ FUNCTION_SET_CHANNEL_LED_CONFIG = 6 # :nodoc:
29
+ FUNCTION_GET_CHANNEL_LED_CONFIG = 7 # :nodoc:
30
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
31
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
32
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
33
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
34
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
35
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
36
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
37
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
38
+ FUNCTION_RESET = 243 # :nodoc:
39
+ FUNCTION_WRITE_UID = 248 # :nodoc:
40
+ FUNCTION_READ_UID = 249 # :nodoc:
41
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
42
+
43
+ CHANNEL_LED_CONFIG_OFF = 0 # :nodoc:
44
+ CHANNEL_LED_CONFIG_ON = 1 # :nodoc:
45
+ CHANNEL_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
46
+ CHANNEL_LED_CONFIG_SHOW_CHANNEL_STATUS = 3 # :nodoc:
47
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
48
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
49
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
50
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
51
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
52
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
53
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
54
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
55
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
56
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
57
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
58
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
59
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
60
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
61
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
62
+
63
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
64
+ # the IP Connection <tt>ipcon</tt>.
65
+ def initialize(uid, ipcon)
66
+ super uid, ipcon
67
+
68
+ @api_version = [2, 0, 0]
69
+
70
+ @response_expected[FUNCTION_SET_VALUE] = RESPONSE_EXPECTED_FALSE
71
+ @response_expected[FUNCTION_GET_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
72
+ @response_expected[FUNCTION_SET_MONOFLOP] = RESPONSE_EXPECTED_FALSE
73
+ @response_expected[FUNCTION_GET_MONOFLOP] = RESPONSE_EXPECTED_ALWAYS_TRUE
74
+ @response_expected[FUNCTION_SET_SELECTED_VALUE] = RESPONSE_EXPECTED_FALSE
75
+ @response_expected[FUNCTION_SET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
76
+ @response_expected[FUNCTION_GET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
77
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
78
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
79
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
81
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
83
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
85
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
86
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
87
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
+
90
+ @callback_formats[CALLBACK_MONOFLOP_DONE] = 'C ?'
91
+
92
+ end
93
+
94
+ # Sets the value of all four relays. A value of *true* closes the
95
+ # relay and a value of *false* opens the relay.
96
+ #
97
+ # Use BrickletIndustrialQuadRelayV2#set_selected_value to only change one relay.
98
+ def set_value(value)
99
+ send_request FUNCTION_SET_VALUE, [value], '?4', 0, ''
100
+ end
101
+
102
+ # Returns the values as set by BrickletIndustrialQuadRelayV2#set_value.
103
+ def get_value
104
+ send_request FUNCTION_GET_VALUE, [], '', 4, '?4'
105
+ end
106
+
107
+ # Configures a monoflop of the specified channel.
108
+ #
109
+ # The second parameter is the desired value of the specified
110
+ # channel. A *true* means relay closed and a *false* means relay open.
111
+ #
112
+ # The third parameter indicates the time (in ms) that the channels should hold
113
+ # the value.
114
+ #
115
+ # If this function is called with the parameters (0, 1, 1500) channel 0 will
116
+ # close and in 1.5s channel 0 will open again
117
+ #
118
+ # A monoflop can be used as a fail-safe mechanism. For example: Lets assume you
119
+ # have a RS485 bus and a Industrial Quad Relay Bricklet 2.0 connected to one of
120
+ # the slave stacks. You can now call this function every second, with a time
121
+ # parameter of two seconds and channel 0 closed. Channel 0 will be closed all the
122
+ # time. If now the RS485 connection is lost, then channel 0 will be opened in at
123
+ # most two seconds.
124
+ def set_monoflop(channel, value, time)
125
+ send_request FUNCTION_SET_MONOFLOP, [channel, value, time], 'C ? L', 0, ''
126
+ end
127
+
128
+ # Returns (for the given channel) the current value and the time as set by
129
+ # BrickletIndustrialQuadRelayV2#set_monoflop as well as the remaining time until the value flips.
130
+ #
131
+ # If the timer is not running currently, the remaining time will be returned
132
+ # as 0.
133
+ def get_monoflop(channel)
134
+ send_request FUNCTION_GET_MONOFLOP, [channel], 'C', 9, '? L L'
135
+ end
136
+
137
+ # Sets the output value of the specified channel without affecting the other
138
+ # channels.
139
+ def set_selected_value(channel, value)
140
+ send_request FUNCTION_SET_SELECTED_VALUE, [channel, value], 'C ?', 0, ''
141
+ end
142
+
143
+ # Each channel has a corresponding LED. You can turn the LED Off, On or show a
144
+ # heartbeat. You can also set the LED to "Channel Status". In this mode the
145
+ # LED is on if the channel is high and off otherwise.
146
+ #
147
+ # By default all channel LEDs are configured as "Channel Status".
148
+ def set_channel_led_config(led, config)
149
+ send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [led, config], 'C C', 0, ''
150
+ end
151
+
152
+ # Returns the Channel LED configuration as set by BrickletIndustrialQuadRelayV2#set_channel_led_config
153
+ def get_channel_led_config(led)
154
+ send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [led], 'C', 1, 'C'
155
+ end
156
+
157
+ # Returns the error count for the communication between Brick and Bricklet.
158
+ #
159
+ # The errors are divided into
160
+ #
161
+ # * ack checksum errors,
162
+ # * message checksum errors,
163
+ # * frameing errors and
164
+ # * overflow errors.
165
+ #
166
+ # The errors counts are for errors that occur on the Bricklet side. All
167
+ # Bricks have a similar function that returns the errors on the Brick side.
168
+ def get_spitfp_error_count
169
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
170
+ end
171
+
172
+ # Sets the bootloader mode and returns the status after the requested
173
+ # mode change was instigated.
174
+ #
175
+ # You can change from bootloader mode to firmware mode and vice versa. A change
176
+ # from bootloader mode to firmware mode will only take place if the entry function,
177
+ # device identifier und crc are present and correct.
178
+ #
179
+ # This function is used by Brick Viewer during flashing. It should not be
180
+ # necessary to call it in a normal user program.
181
+ def set_bootloader_mode(mode)
182
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
183
+ end
184
+
185
+ # Returns the current bootloader mode, see BrickletIndustrialQuadRelayV2#set_bootloader_mode.
186
+ def get_bootloader_mode
187
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
188
+ end
189
+
190
+ # Sets the firmware pointer for BrickletIndustrialQuadRelayV2#write_firmware. The pointer has
191
+ # to be increased by chunks of size 64. The data is written to flash
192
+ # every 4 chunks (which equals to one page of size 256).
193
+ #
194
+ # This function is used by Brick Viewer during flashing. It should not be
195
+ # necessary to call it in a normal user program.
196
+ def set_write_firmware_pointer(pointer)
197
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
198
+ end
199
+
200
+ # Writes 64 Bytes of firmware at the position as written by
201
+ # BrickletIndustrialQuadRelayV2#set_write_firmware_pointer before. The firmware is written
202
+ # to flash every 4 chunks.
203
+ #
204
+ # You can only write firmware in bootloader mode.
205
+ #
206
+ # This function is used by Brick Viewer during flashing. It should not be
207
+ # necessary to call it in a normal user program.
208
+ def write_firmware(data)
209
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
210
+ end
211
+
212
+ # Sets the status LED configuration. By default the LED shows
213
+ # communication traffic between Brick and Bricklet, it flickers once
214
+ # for every 10 received data packets.
215
+ #
216
+ # You can also turn the LED permanently on/off or show a heartbeat.
217
+ #
218
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
219
+ def set_status_led_config(config)
220
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
221
+ end
222
+
223
+ # Returns the configuration as set by BrickletIndustrialQuadRelayV2#set_status_led_config
224
+ def get_status_led_config
225
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
226
+ end
227
+
228
+ # Returns the temperature in °C as measured inside the microcontroller. The
229
+ # value returned is not the ambient temperature!
230
+ #
231
+ # The temperature is only proportional to the real temperature and it has bad
232
+ # accuracy. Practically it is only useful as an indicator for
233
+ # temperature changes.
234
+ def get_chip_temperature
235
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
236
+ end
237
+
238
+ # Calling this function will reset the Bricklet. All configurations
239
+ # will be lost.
240
+ #
241
+ # After a reset you have to create new device objects,
242
+ # calling functions on the existing ones will result in
243
+ # undefined behavior!
244
+ def reset
245
+ send_request FUNCTION_RESET, [], '', 0, ''
246
+ end
247
+
248
+ # Writes a new UID into flash. If you want to set a new UID
249
+ # you have to decode the Base58 encoded UID string into an
250
+ # integer first.
251
+ #
252
+ # We recommend that you use Brick Viewer to change the UID.
253
+ def write_uid(uid)
254
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
255
+ end
256
+
257
+ # Returns the current UID as an integer. Encode as
258
+ # Base58 to get the usual string version.
259
+ def read_uid
260
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
261
+ end
262
+
263
+ # Returns the UID, the UID where the Bricklet is connected to,
264
+ # the position, the hardware and firmware version as well as the
265
+ # device identifier.
266
+ #
267
+ # The position can be 'a', 'b', 'c' or 'd'.
268
+ #
269
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
270
+ # |device_identifier_constant|
271
+ def get_identity
272
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
273
+ end
274
+
275
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
276
+ def register_callback(id, &block)
277
+ callback = block
278
+ @registered_callbacks[id] = callback
279
+ end
280
+ end
281
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 #
@@ -0,0 +1,437 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2018-06-08. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.17 #
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
+ module Tinkerforge
13
+ # 4-channel digital input/output
14
+ class BrickletIO4V2 < Device
15
+ DEVICE_IDENTIFIER = 2111 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'IO-4 Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered periodically according to the configuration set by
19
+ # BrickletIO4V2#set_input_value_callback_configuration.
20
+ #
21
+ # The parameters are the channel, a value-changed indicator and the actual value
22
+ # for the channel. The `changed` parameter is true if the value has changed since
23
+ # the last callback.
24
+ CALLBACK_INPUT_VALUE = 17
25
+
26
+ # This callback is triggered periodically according to the configuration set by
27
+ # BrickletIO4V2#set_all_input_value_callback_configuration.
28
+ #
29
+ # The parameters are the same as BrickletIO4V2#get_value. Additional the
30
+ # `changed` parameter is true if the value has changed since
31
+ # the last callback.
32
+ CALLBACK_ALL_INPUT_VALUE = 18
33
+
34
+ # This callback is triggered whenever a monoflop timer reaches 0. The
35
+ # parameters contain the channel and the current value of the channel
36
+ # (the value after the monoflop).
37
+ CALLBACK_MONOFLOP_DONE = 19
38
+
39
+ FUNCTION_SET_VALUE = 1 # :nodoc:
40
+ FUNCTION_GET_VALUE = 2 # :nodoc:
41
+ FUNCTION_SET_SELECTED_VALUE = 3 # :nodoc:
42
+ FUNCTION_SET_CONFIGURATION = 4 # :nodoc:
43
+ FUNCTION_GET_CONFIGURATION = 5 # :nodoc:
44
+ FUNCTION_SET_INPUT_VALUE_CALLBACK_CONFIGURATION = 6 # :nodoc:
45
+ FUNCTION_GET_INPUT_VALUE_CALLBACK_CONFIGURATION = 7 # :nodoc:
46
+ FUNCTION_SET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION = 8 # :nodoc:
47
+ FUNCTION_GET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION = 9 # :nodoc:
48
+ FUNCTION_SET_MONOFLOP = 10 # :nodoc:
49
+ FUNCTION_GET_MONOFLOP = 11 # :nodoc:
50
+ FUNCTION_GET_EDGE_COUNT = 12 # :nodoc:
51
+ FUNCTION_SET_EDGE_COUNT_CONFIGURATION = 13 # :nodoc:
52
+ FUNCTION_GET_EDGE_COUNT_CONFIGURATION = 14 # :nodoc:
53
+ FUNCTION_SET_PWM_CONFIGURATION = 15 # :nodoc:
54
+ FUNCTION_GET_PWM_CONFIGURATION = 16 # :nodoc:
55
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
56
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
57
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
58
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
59
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
60
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
61
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
62
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
63
+ FUNCTION_RESET = 243 # :nodoc:
64
+ FUNCTION_WRITE_UID = 248 # :nodoc:
65
+ FUNCTION_READ_UID = 249 # :nodoc:
66
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
67
+
68
+ DIRECTION_IN = 'i' # :nodoc:
69
+ DIRECTION_OUT = 'o' # :nodoc:
70
+ EDGE_TYPE_RISING = 0 # :nodoc:
71
+ EDGE_TYPE_FALLING = 1 # :nodoc:
72
+ EDGE_TYPE_BOTH = 2 # :nodoc:
73
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
74
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
75
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
76
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
77
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
78
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
79
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
80
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
81
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
82
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
83
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
84
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
85
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
86
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
87
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
88
+
89
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
90
+ # the IP Connection <tt>ipcon</tt>.
91
+ def initialize(uid, ipcon)
92
+ super uid, ipcon
93
+
94
+ @api_version = [2, 0, 0]
95
+
96
+ @response_expected[FUNCTION_SET_VALUE] = RESPONSE_EXPECTED_FALSE
97
+ @response_expected[FUNCTION_GET_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
98
+ @response_expected[FUNCTION_SET_SELECTED_VALUE] = RESPONSE_EXPECTED_FALSE
99
+ @response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
100
+ @response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
101
+ @response_expected[FUNCTION_SET_INPUT_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
102
+ @response_expected[FUNCTION_GET_INPUT_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
103
+ @response_expected[FUNCTION_SET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
104
+ @response_expected[FUNCTION_GET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
+ @response_expected[FUNCTION_SET_MONOFLOP] = RESPONSE_EXPECTED_FALSE
106
+ @response_expected[FUNCTION_GET_MONOFLOP] = RESPONSE_EXPECTED_ALWAYS_TRUE
107
+ @response_expected[FUNCTION_GET_EDGE_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
108
+ @response_expected[FUNCTION_SET_EDGE_COUNT_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
109
+ @response_expected[FUNCTION_GET_EDGE_COUNT_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
110
+ @response_expected[FUNCTION_SET_PWM_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
111
+ @response_expected[FUNCTION_GET_PWM_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
112
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
116
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
117
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
118
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
119
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
120
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
121
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
122
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+
125
+ @callback_formats[CALLBACK_INPUT_VALUE] = 'C ? ?'
126
+ @callback_formats[CALLBACK_ALL_INPUT_VALUE] = '?4 ?4'
127
+ @callback_formats[CALLBACK_MONOFLOP_DONE] = 'C ?'
128
+
129
+ end
130
+
131
+ # Sets the output value of all four channels. A value of *true* or *false* outputs
132
+ # logic 1 or logic 0 respectively on the corresponding channel.
133
+ #
134
+ # Use BrickletIO4V2#set_selected_value to change only one output channel state.
135
+ #
136
+ # For example: (True, True, False, False) will turn the channels 0-1 high and the
137
+ # channels 2-3 low.
138
+ #
139
+ # .. note::
140
+ # This function does nothing for channels that are configured as input. Pull-up
141
+ # resistors can be switched on with BrickletIO4V2#set_configuration.
142
+ def set_value(value)
143
+ send_request FUNCTION_SET_VALUE, [value], '?4', 0, ''
144
+ end
145
+
146
+ # Returns the logic levels that are currently measured on the channels.
147
+ # This function works if the channel is configured as input as well as if it is
148
+ # configured as output.
149
+ def get_value
150
+ send_request FUNCTION_GET_VALUE, [], '', 4, '?4'
151
+ end
152
+
153
+ # Sets the output value of a specific channel without affecting the other channels.
154
+ #
155
+ # .. note::
156
+ # This function does nothing for channels that are configured as input. Pull-up
157
+ # resistors can be switched on with BrickletIO4V2#set_configuration.
158
+ def set_selected_value(channel, value)
159
+ send_request FUNCTION_SET_SELECTED_VALUE, [channel, value], 'C ?', 0, ''
160
+ end
161
+
162
+ # Configures the value and direction of a specific channel. Possible directions
163
+ # are 'i' and 'o' for input and output.
164
+ #
165
+ # If the direction is configured as output, the value is either high or low
166
+ # (set as *true* or *false*).
167
+ #
168
+ # If the direction is configured as input, the value is either pull-up or
169
+ # default (set as *true* or *false*).
170
+ #
171
+ # For example:
172
+ #
173
+ # * (0, 'i', true) will set channel 0 as input pull-up.
174
+ # * (1, 'i', false) will set channel 1 as input default (floating if nothing is connected).
175
+ # * (2, 'o', true) will set channel 2 as output high.
176
+ # * (3, 'o', false) will set channel 3 as output low.
177
+ #
178
+ # The default configuration is input with pull-up.
179
+ def set_configuration(channel, direction, value)
180
+ send_request FUNCTION_SET_CONFIGURATION, [channel, direction, value], 'C k ?', 0, ''
181
+ end
182
+
183
+ # Returns the channel configuration as set by BrickletIO4V2#set_configuration.
184
+ def get_configuration(channel)
185
+ send_request FUNCTION_GET_CONFIGURATION, [channel], 'C', 2, 'k ?'
186
+ end
187
+
188
+ # This callback can be configured per channel.
189
+ #
190
+ # The period in ms is the period with which the CALLBACK_INPUT_VALUE
191
+ # callback is triggered periodically. A value of 0 turns the callback off.
192
+ #
193
+ # If the `value has to change`-parameter is set to true, the callback is only
194
+ # triggered after the value has changed. If the value didn't change within the
195
+ # period, the callback is triggered immediately on change.
196
+ #
197
+ # If it is set to false, the callback is continuously triggered with the period,
198
+ # independent of the value.
199
+ #
200
+ # The default value is (0, false).
201
+ def set_input_value_callback_configuration(channel, period, value_has_to_change)
202
+ send_request FUNCTION_SET_INPUT_VALUE_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change], 'C L ?', 0, ''
203
+ end
204
+
205
+ # Returns the callback configuration for the given channel as set by
206
+ # BrickletIO4V2#set_input_value_callback_configuration.
207
+ def get_input_value_callback_configuration(channel)
208
+ send_request FUNCTION_GET_INPUT_VALUE_CALLBACK_CONFIGURATION, [channel], 'C', 5, 'L ?'
209
+ end
210
+
211
+ # The period in ms is the period with which the CALLBACK_ALL_INPUT_VALUE
212
+ # callback is triggered periodically. A value of 0 turns the callback off.
213
+ #
214
+ # If the `value has to change`-parameter is set to true, the callback is only
215
+ # triggered after the value has changed. If the value didn't change within the
216
+ # period, the callback is triggered immediately on change.
217
+ #
218
+ # If it is set to false, the callback is continuously triggered with the period,
219
+ # independent of the value.
220
+ #
221
+ # The default value is (0, false).
222
+ def set_all_input_value_callback_configuration(period, value_has_to_change)
223
+ send_request FUNCTION_SET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
224
+ end
225
+
226
+ # Returns the callback configuration as set by
227
+ # BrickletIO4V2#set_all_input_value_callback_configuration.
228
+ def get_all_input_value_callback_configuration
229
+ send_request FUNCTION_GET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
230
+ end
231
+
232
+ # The first parameter is the desired state of the channel (*true* means output *high*
233
+ # and *false* means output *low*). The second parameter indicates the time (in ms) that
234
+ # the channel should hold the state.
235
+ #
236
+ # If this function is called with the parameters (true, 1500):
237
+ # The channel will turn on and in 1.5s it will turn off again.
238
+ #
239
+ # A monoflop can be used as a failsafe mechanism. For example: Lets assume you
240
+ # have a RS485 bus and a IO-4 Bricklet 2.0 is connected to one of the slave
241
+ # stacks. You can now call this function every second, with a time parameter
242
+ # of two seconds. The channel will be *high* all the time. If now the RS485
243
+ # connection is lost, the channel will turn *low* in at most two seconds.
244
+ def set_monoflop(channel, value, time)
245
+ send_request FUNCTION_SET_MONOFLOP, [channel, value, time], 'C ? L', 0, ''
246
+ end
247
+
248
+ # Returns (for the given channel) the current value and the time as set by
249
+ # BrickletIO4V2#set_monoflop as well as the remaining time until the value flips.
250
+ #
251
+ # If the timer is not running currently, the remaining time will be returned
252
+ # as 0.
253
+ def get_monoflop(channel)
254
+ send_request FUNCTION_GET_MONOFLOP, [channel], 'C', 9, '? L L'
255
+ end
256
+
257
+ # Returns the current value of the edge counter for the selected channel. You can
258
+ # configure the edges that are counted with BrickletIO4V2#set_edge_count_configuration.
259
+ #
260
+ # If you set the reset counter to *true*, the count is set back to 0
261
+ # directly after it is read.
262
+ def get_edge_count(channel, reset_counter)
263
+ send_request FUNCTION_GET_EDGE_COUNT, [channel, reset_counter], 'C ?', 4, 'L'
264
+ end
265
+
266
+ # Configures the edge counter for a specific channel.
267
+ #
268
+ # The edge type parameter configures if rising edges, falling edges or
269
+ # both are counted if the channel is configured for input. Possible edge types are:
270
+ #
271
+ # * 0 = rising (default)
272
+ # * 1 = falling
273
+ # * 2 = both
274
+ #
275
+ # The debounce time is given in ms.
276
+ #
277
+ # Configuring an edge counter resets its value to 0.
278
+ #
279
+ # If you don't know what any of this means, just leave it at default. The
280
+ # default configuration is very likely OK for you.
281
+ #
282
+ # Default values: 0 (edge type) and 100ms (debounce time)
283
+ def set_edge_count_configuration(channel, edge_type, debounce)
284
+ send_request FUNCTION_SET_EDGE_COUNT_CONFIGURATION, [channel, edge_type, debounce], 'C C C', 0, ''
285
+ end
286
+
287
+ # Returns the edge type and debounce time for the selected channel as set by
288
+ # BrickletIO4V2#set_edge_count_configuration.
289
+ def get_edge_count_configuration(channel)
290
+ send_request FUNCTION_GET_EDGE_COUNT_CONFIGURATION, [channel], 'C', 2, 'C C'
291
+ end
292
+
293
+ # Activates a PWM for the given channel with the frequency given in 1/10Hz and the duty
294
+ # cycle given in 1/100%.
295
+ #
296
+ # You need to set the channel to output before you call this function, otherwise it will
297
+ # be ignored. To turn the PWM off again, you can set the frequency to 0 or any other
298
+ # function that changes a value of the channel (e.g. BrickletIO4V2#set_selected_value).
299
+ #
300
+ # The maximum frequency value is 320000000 (32MHz). The maximum duty cycle value is
301
+ # 10000 (100%).
302
+ #
303
+ # The default values are 0, 0.
304
+ def set_pwm_configuration(channel, frequency, duty_cycle)
305
+ send_request FUNCTION_SET_PWM_CONFIGURATION, [channel, frequency, duty_cycle], 'C L S', 0, ''
306
+ end
307
+
308
+ # Returns the PWM configuration as set by BrickletIO4V2#set_pwm_configuration.
309
+ def get_pwm_configuration(channel)
310
+ send_request FUNCTION_GET_PWM_CONFIGURATION, [channel], 'C', 6, 'L S'
311
+ end
312
+
313
+ # Returns the error count for the communication between Brick and Bricklet.
314
+ #
315
+ # The errors are divided into
316
+ #
317
+ # * ack checksum errors,
318
+ # * message checksum errors,
319
+ # * frameing errors and
320
+ # * overflow errors.
321
+ #
322
+ # The errors counts are for errors that occur on the Bricklet side. All
323
+ # Bricks have a similar function that returns the errors on the Brick side.
324
+ def get_spitfp_error_count
325
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
326
+ end
327
+
328
+ # Sets the bootloader mode and returns the status after the requested
329
+ # mode change was instigated.
330
+ #
331
+ # You can change from bootloader mode to firmware mode and vice versa. A change
332
+ # from bootloader mode to firmware mode will only take place if the entry function,
333
+ # device identifier und crc are present and correct.
334
+ #
335
+ # This function is used by Brick Viewer during flashing. It should not be
336
+ # necessary to call it in a normal user program.
337
+ def set_bootloader_mode(mode)
338
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
339
+ end
340
+
341
+ # Returns the current bootloader mode, see BrickletIO4V2#set_bootloader_mode.
342
+ def get_bootloader_mode
343
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
344
+ end
345
+
346
+ # Sets the firmware pointer for BrickletIO4V2#write_firmware. The pointer has
347
+ # to be increased by chunks of size 64. The data is written to flash
348
+ # every 4 chunks (which equals to one page of size 256).
349
+ #
350
+ # This function is used by Brick Viewer during flashing. It should not be
351
+ # necessary to call it in a normal user program.
352
+ def set_write_firmware_pointer(pointer)
353
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
354
+ end
355
+
356
+ # Writes 64 Bytes of firmware at the position as written by
357
+ # BrickletIO4V2#set_write_firmware_pointer before. The firmware is written
358
+ # to flash every 4 chunks.
359
+ #
360
+ # You can only write firmware in bootloader mode.
361
+ #
362
+ # This function is used by Brick Viewer during flashing. It should not be
363
+ # necessary to call it in a normal user program.
364
+ def write_firmware(data)
365
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
366
+ end
367
+
368
+ # Sets the status LED configuration. By default the LED shows
369
+ # communication traffic between Brick and Bricklet, it flickers once
370
+ # for every 10 received data packets.
371
+ #
372
+ # You can also turn the LED permanently on/off or show a heartbeat.
373
+ #
374
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
375
+ def set_status_led_config(config)
376
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
377
+ end
378
+
379
+ # Returns the configuration as set by BrickletIO4V2#set_status_led_config
380
+ def get_status_led_config
381
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
382
+ end
383
+
384
+ # Returns the temperature in °C as measured inside the microcontroller. The
385
+ # value returned is not the ambient temperature!
386
+ #
387
+ # The temperature is only proportional to the real temperature and it has bad
388
+ # accuracy. Practically it is only useful as an indicator for
389
+ # temperature changes.
390
+ def get_chip_temperature
391
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
392
+ end
393
+
394
+ # Calling this function will reset the Bricklet. All configurations
395
+ # will be lost.
396
+ #
397
+ # After a reset you have to create new device objects,
398
+ # calling functions on the existing ones will result in
399
+ # undefined behavior!
400
+ def reset
401
+ send_request FUNCTION_RESET, [], '', 0, ''
402
+ end
403
+
404
+ # Writes a new UID into flash. If you want to set a new UID
405
+ # you have to decode the Base58 encoded UID string into an
406
+ # integer first.
407
+ #
408
+ # We recommend that you use Brick Viewer to change the UID.
409
+ def write_uid(uid)
410
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
411
+ end
412
+
413
+ # Returns the current UID as an integer. Encode as
414
+ # Base58 to get the usual string version.
415
+ def read_uid
416
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
417
+ end
418
+
419
+ # Returns the UID, the UID where the Bricklet is connected to,
420
+ # the position, the hardware and firmware version as well as the
421
+ # device identifier.
422
+ #
423
+ # The position can be 'a', 'b', 'c' or 'd'.
424
+ #
425
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
426
+ # |device_identifier_constant|
427
+ def get_identity
428
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
429
+ end
430
+
431
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
432
+ def register_callback(id, &block)
433
+ callback = block
434
+ @registered_callbacks[id] = callback
435
+ end
436
+ end
437
+ end