tinkerforge 2.1.15 → 2.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +2 -2
  3. data/lib/tinkerforge/brick_imu.rb +2 -2
  4. data/lib/tinkerforge/brick_imu_v2.rb +2 -2
  5. data/lib/tinkerforge/brick_master.rb +2 -2
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +2 -2
  8. data/lib/tinkerforge/brick_silent_stepper.rb +2 -2
  9. data/lib/tinkerforge/brick_stepper.rb +2 -2
  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 +319 -0
  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 +2 -2
  20. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  21. data/lib/tinkerforge/bricklet_color.rb +2 -2
  22. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  23. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  24. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  25. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  26. data/lib/tinkerforge/bricklet_dmx.rb +3 -3
  27. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  28. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  29. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  30. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  31. data/lib/tinkerforge/bricklet_gps_v2.rb +2 -2
  32. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  33. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  34. data/lib/tinkerforge/bricklet_humidity_v2.rb +2 -2
  35. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  36. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  37. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  38. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  39. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  40. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  41. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  42. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  43. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  44. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  45. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  46. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  47. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  48. data/lib/tinkerforge/bricklet_line.rb +2 -2
  49. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  50. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  51. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  52. data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
  53. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +261 -0
  54. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
  55. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  56. data/lib/tinkerforge/bricklet_nfc.rb +998 -0
  57. data/lib/tinkerforge/bricklet_nfc_rfid.rb +5 -5
  58. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  59. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  60. data/lib/tinkerforge/bricklet_outdoor_weather.rb +390 -0
  61. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  62. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  63. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  64. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  65. data/lib/tinkerforge/bricklet_remote_switch.rb +3 -3
  66. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +403 -0
  67. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  68. data/lib/tinkerforge/bricklet_rgb_led_button.rb +3 -3
  69. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  70. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  71. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +284 -0
  72. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  73. data/lib/tinkerforge/bricklet_rs232.rb +2 -2
  74. data/lib/tinkerforge/bricklet_rs485.rb +2 -2
  75. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  76. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  77. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +247 -0
  78. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  79. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  80. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  81. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +369 -0
  82. data/lib/tinkerforge/bricklet_thermal_imaging.rb +5 -2
  83. data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
  84. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  85. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  86. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  87. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  88. data/lib/tinkerforge/version.rb +1 -1
  89. metadata +11 -3
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2017-11-20. #
3
+ # This file was automatically generated on 2018-02-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.15 #
5
+ # Ruby Bindings Version 2.1.16 #
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 2017-11-20. #
3
+ # This file was automatically generated on 2018-02-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.15 #
5
+ # Ruby Bindings Version 2.1.16 #
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 2017-11-20. #
3
+ # This file was automatically generated on 2018-02-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.15 #
5
+ # Ruby Bindings Version 2.1.16 #
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 2017-11-20. #
3
+ # This file was automatically generated on 2018-02-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.15 #
5
+ # Ruby Bindings Version 2.1.16 #
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 #
@@ -15,7 +15,7 @@ module Tinkerforge
15
15
  DEVICE_IDENTIFIER = 235 # :nodoc:
16
16
  DEVICE_DISPLAY_NAME = 'Remote Switch Bricklet' # :nodoc:
17
17
 
18
- # This callback is called whenever the switching state changes
18
+ # This callback is triggered whenever the switching state changes
19
19
  # from busy to ready, see BrickletRemoteSwitch#get_switching_state.
20
20
  CALLBACK_SWITCHING_DONE = 3
21
21
 
@@ -0,0 +1,403 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2018-02-28. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.16 #
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
+ # Controls remote mains switches
14
+ class BrickletRemoteSwitchV2 < Device
15
+ DEVICE_IDENTIFIER = 289 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Remote Switch Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered whenever the switching state changes
19
+ # from busy to ready, see BrickletRemoteSwitchV2#get_switching_state.
20
+ CALLBACK_SWITCHING_DONE = 2
21
+
22
+ # Returns the house code, receiver code, switch state (on/off) and number of repeats for
23
+ # remote type A.
24
+ #
25
+ # The repeats are the number of received identical data packets. The longer the button is pressed,
26
+ # the higher the repeat number. The callback is triggered with every repeat.
27
+ #
28
+ # You have to enable the callback with BrickletRemoteSwitchV2#set_remote_configuration. The number
29
+ # of repeats that you can set in the configuration is the minimum number of repeats that have
30
+ # to be seen before the callback is triggered for the first time.
31
+ CALLBACK_REMOTE_STATUS_A = 14
32
+
33
+ # Returns the address (unique per remote), unit (button number), switch state (on/off) and number of repeats for
34
+ # remote type B.
35
+ #
36
+ # If the remote supports dimming the dim value is used instead of the switch state.
37
+ #
38
+ # The repeats are the number of received identical data packets. The longer the button is pressed,
39
+ # the higher the repeat number. The callback is triggered with every repeat.
40
+ #
41
+ # You have to enable the callback with BrickletRemoteSwitchV2#set_remote_configuration. The number
42
+ # of repeats that you can set in the configuration is the minimum number of repeats that have
43
+ # to be seen before the callback is triggered for the first time.
44
+ CALLBACK_REMOTE_STATUS_B = 15
45
+
46
+ # Returns the system code, device code, switch state (on/off) and number of repeats for
47
+ # remote type C.
48
+ #
49
+ # The repeats are the number of received identical data packets. The longer the button is pressed,
50
+ # the higher the repeat number. The callback is triggered with every repeat.
51
+ #
52
+ # You have to enable the callback with BrickletRemoteSwitchV2#set_remote_configuration. The number
53
+ # of repeats that you can set in the configuration is the minimum number of repeats that have
54
+ # to be seen before the callback is triggered for the first time.
55
+ CALLBACK_REMOTE_STATUS_C = 16
56
+
57
+ FUNCTION_GET_SWITCHING_STATE = 1 # :nodoc:
58
+ FUNCTION_SET_REPEATS = 3 # :nodoc:
59
+ FUNCTION_GET_REPEATS = 4 # :nodoc:
60
+ FUNCTION_SWITCH_SOCKET_A = 5 # :nodoc:
61
+ FUNCTION_SWITCH_SOCKET_B = 6 # :nodoc:
62
+ FUNCTION_DIM_SOCKET_B = 7 # :nodoc:
63
+ FUNCTION_SWITCH_SOCKET_C = 8 # :nodoc:
64
+ FUNCTION_SET_REMOTE_CONFIGURATION = 9 # :nodoc:
65
+ FUNCTION_GET_REMOTE_CONFIGURATION = 10 # :nodoc:
66
+ FUNCTION_GET_REMOTE_STATUS_A = 11 # :nodoc:
67
+ FUNCTION_GET_REMOTE_STATUS_B = 12 # :nodoc:
68
+ FUNCTION_GET_REMOTE_STATUS_C = 13 # :nodoc:
69
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
70
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
71
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
72
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
73
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
74
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
75
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
76
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
77
+ FUNCTION_RESET = 243 # :nodoc:
78
+ FUNCTION_WRITE_UID = 248 # :nodoc:
79
+ FUNCTION_READ_UID = 249 # :nodoc:
80
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
81
+
82
+ SWITCHING_STATE_READY = 0 # :nodoc:
83
+ SWITCHING_STATE_BUSY = 1 # :nodoc:
84
+ SWITCH_TO_OFF = 0 # :nodoc:
85
+ SWITCH_TO_ON = 1 # :nodoc:
86
+ REMOTE_TYPE_A = 0 # :nodoc:
87
+ REMOTE_TYPE_B = 1 # :nodoc:
88
+ REMOTE_TYPE_C = 2 # :nodoc:
89
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
90
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
91
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
92
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
93
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
94
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
95
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
96
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
97
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
98
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
99
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
100
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
101
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
102
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
103
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
104
+
105
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
106
+ # the IP Connection <tt>ipcon</tt>.
107
+ def initialize(uid, ipcon)
108
+ super uid, ipcon
109
+
110
+ @api_version = [2, 0, 0]
111
+
112
+ @response_expected[FUNCTION_GET_SWITCHING_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
+ @response_expected[FUNCTION_SET_REPEATS] = RESPONSE_EXPECTED_FALSE
114
+ @response_expected[FUNCTION_GET_REPEATS] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
+ @response_expected[FUNCTION_SWITCH_SOCKET_A] = RESPONSE_EXPECTED_FALSE
116
+ @response_expected[FUNCTION_SWITCH_SOCKET_B] = RESPONSE_EXPECTED_FALSE
117
+ @response_expected[FUNCTION_DIM_SOCKET_B] = RESPONSE_EXPECTED_FALSE
118
+ @response_expected[FUNCTION_SWITCH_SOCKET_C] = RESPONSE_EXPECTED_FALSE
119
+ @response_expected[FUNCTION_SET_REMOTE_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
120
+ @response_expected[FUNCTION_GET_REMOTE_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
121
+ @response_expected[FUNCTION_GET_REMOTE_STATUS_A] = RESPONSE_EXPECTED_ALWAYS_TRUE
122
+ @response_expected[FUNCTION_GET_REMOTE_STATUS_B] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_GET_REMOTE_STATUS_C] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
125
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
126
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
127
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
128
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
129
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
130
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
133
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
134
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
135
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
136
+
137
+ @callback_formats[CALLBACK_SWITCHING_DONE] = ''
138
+ @callback_formats[CALLBACK_REMOTE_STATUS_A] = 'C C C S'
139
+ @callback_formats[CALLBACK_REMOTE_STATUS_B] = 'L C C C S'
140
+ @callback_formats[CALLBACK_REMOTE_STATUS_C] = 'k C C S'
141
+
142
+ end
143
+
144
+ # Returns the current switching state. If the current state is busy, the
145
+ # Bricklet is currently sending a code to switch a socket. It will not
146
+ # accept any calls of switch socket functions until the state changes to ready.
147
+ #
148
+ # How long the switching takes is dependent on the number of repeats, see
149
+ # BrickletRemoteSwitchV2#set_repeats.
150
+ def get_switching_state
151
+ send_request FUNCTION_GET_SWITCHING_STATE, [], '', 1, 'C'
152
+ end
153
+
154
+ # Sets the number of times the code is send when one of the Switch Socket
155
+ # functions is called. The repeats basically correspond to the amount of time
156
+ # that a button of the remote is pressed.
157
+ #
158
+ # Some dimmers are controlled by the length of a button pressed,
159
+ # this can be simulated by increasing the repeats.
160
+ #
161
+ # The default value is 5.
162
+ def set_repeats(repeats)
163
+ send_request FUNCTION_SET_REPEATS, [repeats], 'C', 0, ''
164
+ end
165
+
166
+ # Returns the number of repeats as set by BrickletRemoteSwitchV2#set_repeats.
167
+ def get_repeats
168
+ send_request FUNCTION_GET_REPEATS, [], '', 1, 'C'
169
+ end
170
+
171
+ # To switch a type A socket you have to give the house code, receiver code and the
172
+ # state (on or off) you want to switch to.
173
+ #
174
+ # The house code and receiver code have a range of 0 to 31 (5bit).
175
+ #
176
+ # A detailed description on how you can figure out the house and receiver code
177
+ # can be found :ref:`here <remote_switch_bricklet_type_a_house_and_receiver_code>`.
178
+ def switch_socket_a(house_code, receiver_code, switch_to)
179
+ send_request FUNCTION_SWITCH_SOCKET_A, [house_code, receiver_code, switch_to], 'C C C', 0, ''
180
+ end
181
+
182
+ # To switch a type B socket you have to give the address, unit and the state
183
+ # (on or off) you want to switch to.
184
+ #
185
+ # The address has a range of 0 to 67108863 (26bit) and the unit has a range
186
+ # of 0 to 15 (4bit). To switch all devices with the same address use 255 for
187
+ # the unit.
188
+ #
189
+ # A detailed description on how you can teach a socket the address and unit can
190
+ # be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
191
+ def switch_socket_b(address, unit, switch_to)
192
+ send_request FUNCTION_SWITCH_SOCKET_B, [address, unit, switch_to], 'L C C', 0, ''
193
+ end
194
+
195
+ # To control a type B dimmer you have to give the address, unit and the
196
+ # dim value you want to set the dimmer to.
197
+ #
198
+ # The address has a range of 0 to 67108863 (26bit), the unit and the dim value
199
+ # has a range of 0 to 15 (4bit).
200
+ #
201
+ # A detailed description on how you can teach a dimmer the address and unit can
202
+ # be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
203
+ def dim_socket_b(address, unit, dim_value)
204
+ send_request FUNCTION_DIM_SOCKET_B, [address, unit, dim_value], 'L C C', 0, ''
205
+ end
206
+
207
+ # To switch a type C socket you have to give the system code, device code and the
208
+ # state (on or off) you want to switch to.
209
+ #
210
+ # The system code has a range of 'A' to 'P' (4bit) and the device code has a
211
+ # range of 1 to 16 (4bit).
212
+ #
213
+ # A detailed description on how you can figure out the system and device code
214
+ # can be found :ref:`here <remote_switch_bricklet_type_c_system_and_device_code>`.
215
+ def switch_socket_c(system_code, device_code, switch_to)
216
+ send_request FUNCTION_SWITCH_SOCKET_C, [system_code, device_code, switch_to], 'k C C', 0, ''
217
+ end
218
+
219
+ # Sets the configuration for **receiving** data from a remote of type A, B or C.
220
+ #
221
+ # * Remote Type: A, B or C depending on the type of remote you want to receive.
222
+ # * Minimum Repeats: The minimum number of repeated data packets until the callback
223
+ # is triggered (if enabled).
224
+ # * Callback Enabled: Enable or disable callback (see CALLBACK_REMOTE_STATUS_A callback,
225
+ # CALLBACK_REMOTE_STATUS_B callback and CALLBACK_REMOTE_STATUS_C callback).
226
+ #
227
+ # Default is ('A', 2, false).
228
+ def set_remote_configuration(remote_type, minimum_repeats, callback_enabled)
229
+ send_request FUNCTION_SET_REMOTE_CONFIGURATION, [remote_type, minimum_repeats, callback_enabled], 'C S ?', 0, ''
230
+ end
231
+
232
+ # Returns the remote configuration as set by BrickletRemoteSwitchV2#set_remote_configuration
233
+ def get_remote_configuration
234
+ send_request FUNCTION_GET_REMOTE_CONFIGURATION, [], '', 4, 'C S ?'
235
+ end
236
+
237
+ # Returns the house code, receiver code, switch state (on/off) and number of
238
+ # repeats for remote type A.
239
+ #
240
+ # Repeats == 0 means there was no button press. Repeats >= 1 means there
241
+ # was a button press with the specified house/receiver code. The repeats are the
242
+ # number of received identical data packets. The longer the button is pressed,
243
+ # the higher the repeat number.
244
+ #
245
+ # Use the callback to get this data automatically when a button is pressed,
246
+ # see BrickletRemoteSwitchV2#set_remote_configuration and CALLBACK_REMOTE_STATUS_A callback.
247
+ def get_remote_status_a
248
+ send_request FUNCTION_GET_REMOTE_STATUS_A, [], '', 5, 'C C C S'
249
+ end
250
+
251
+ # Returns the address (unique per remote), unit (button number), switch state
252
+ # (on/off) and number of repeats for remote type B.
253
+ #
254
+ # If the remote supports dimming the dim value is used instead of the switch state.
255
+ #
256
+ # If repeats=0 there was no button press. If repeats >= 1 there
257
+ # was a button press with the specified address/unit. The repeats are the number of received
258
+ # identical data packets. The longer the button is pressed, the higher the repeat number.
259
+ #
260
+ # Use the callback to get this data automatically when a button is pressed,
261
+ # see BrickletRemoteSwitchV2#set_remote_configuration and CALLBACK_REMOTE_STATUS_B callback.
262
+ def get_remote_status_b
263
+ send_request FUNCTION_GET_REMOTE_STATUS_B, [], '', 9, 'L C C C S'
264
+ end
265
+
266
+ # Returns the system code, device code, switch state (on/off) and number of repeats for
267
+ # remote type C.
268
+ #
269
+ # If repeats=0 there was no button press. If repeats >= 1 there
270
+ # was a button press with the specified system/device code. The repeats are the number of received
271
+ # identical data packets. The longer the button is pressed, the higher the repeat number.
272
+ #
273
+ # Use the callback to get this data automatically when a button is pressed,
274
+ # see BrickletRemoteSwitchV2#set_remote_configuration and CALLBACK_REMOTE_STATUS_C callback.
275
+ def get_remote_status_c
276
+ send_request FUNCTION_GET_REMOTE_STATUS_C, [], '', 5, 'k C C S'
277
+ end
278
+
279
+ # Returns the error count for the communication between Brick and Bricklet.
280
+ #
281
+ # The errors are divided into
282
+ #
283
+ # * ack checksum errors,
284
+ # * message checksum errors,
285
+ # * frameing errors and
286
+ # * overflow errors.
287
+ #
288
+ # The errors counts are for errors that occur on the Bricklet side. All
289
+ # Bricks have a similar function that returns the errors on the Brick side.
290
+ def get_spitfp_error_count
291
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
292
+ end
293
+
294
+ # Sets the bootloader mode and returns the status after the requested
295
+ # mode change was instigated.
296
+ #
297
+ # You can change from bootloader mode to firmware mode and vice versa. A change
298
+ # from bootloader mode to firmware mode will only take place if the entry function,
299
+ # device identifier und crc are present and correct.
300
+ #
301
+ # This function is used by Brick Viewer during flashing. It should not be
302
+ # necessary to call it in a normal user program.
303
+ def set_bootloader_mode(mode)
304
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
305
+ end
306
+
307
+ # Returns the current bootloader mode, see BrickletRemoteSwitchV2#set_bootloader_mode.
308
+ def get_bootloader_mode
309
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
310
+ end
311
+
312
+ # Sets the firmware pointer for BrickletRemoteSwitchV2#write_firmware. The pointer has
313
+ # to be increased by chunks of size 64. The data is written to flash
314
+ # every 4 chunks (which equals to one page of size 256).
315
+ #
316
+ # This function is used by Brick Viewer during flashing. It should not be
317
+ # necessary to call it in a normal user program.
318
+ def set_write_firmware_pointer(pointer)
319
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
320
+ end
321
+
322
+ # Writes 64 Bytes of firmware at the position as written by
323
+ # BrickletRemoteSwitchV2#set_write_firmware_pointer before. The firmware is written
324
+ # to flash every 4 chunks.
325
+ #
326
+ # You can only write firmware in bootloader mode.
327
+ #
328
+ # This function is used by Brick Viewer during flashing. It should not be
329
+ # necessary to call it in a normal user program.
330
+ def write_firmware(data)
331
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
332
+ end
333
+
334
+ # Sets the status LED configuration. By default the LED shows
335
+ # communication traffic between Brick and Bricklet, it flickers once
336
+ # for every 10 received data packets.
337
+ #
338
+ # You can also turn the LED permanently on/off or show a heartbeat.
339
+ #
340
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
341
+ def set_status_led_config(config)
342
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
343
+ end
344
+
345
+ # Returns the configuration as set by BrickletRemoteSwitchV2#set_status_led_config
346
+ def get_status_led_config
347
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
348
+ end
349
+
350
+ # Returns the temperature in °C as measured inside the microcontroller. The
351
+ # value returned is not the ambient temperature!
352
+ #
353
+ # The temperature is only proportional to the real temperature and it has bad
354
+ # accuracy. Practically it is only useful as an indicator for
355
+ # temperature changes.
356
+ def get_chip_temperature
357
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
358
+ end
359
+
360
+ # Calling this function will reset the Bricklet. All configurations
361
+ # will be lost.
362
+ #
363
+ # After a reset you have to create new device objects,
364
+ # calling functions on the existing ones will result in
365
+ # undefined behavior!
366
+ def reset
367
+ send_request FUNCTION_RESET, [], '', 0, ''
368
+ end
369
+
370
+ # Writes a new UID into flash. If you want to set a new UID
371
+ # you have to decode the Base58 encoded UID string into an
372
+ # integer first.
373
+ #
374
+ # We recommend that you use Brick Viewer to change the UID.
375
+ def write_uid(uid)
376
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
377
+ end
378
+
379
+ # Returns the current UID as an integer. Encode as
380
+ # Base58 to get the usual string version.
381
+ def read_uid
382
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
383
+ end
384
+
385
+ # Returns the UID, the UID where the Bricklet is connected to,
386
+ # the position, the hardware and firmware version as well as the
387
+ # device identifier.
388
+ #
389
+ # The position can be 'a', 'b', 'c' or 'd'.
390
+ #
391
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
392
+ # |device_identifier_constant|
393
+ def get_identity
394
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
395
+ end
396
+
397
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
398
+ def register_callback(id, &block)
399
+ callback = block
400
+ @registered_callbacks[id] = callback
401
+ end
402
+ end
403
+ end