tinkerforge 2.1.22 → 2.1.27

Sign up to get free protection for your applications and to get access to all the features.
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 DC voltage between 0V and 50V
14
16
  class BrickletVoltage < Device
@@ -70,7 +72,7 @@ module Tinkerforge
70
72
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
71
73
  # the IP Connection <tt>ipcon</tt>.
72
74
  def initialize(uid, ipcon)
73
- super uid, ipcon
75
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
74
76
 
75
77
  @api_version = [2, 0, 1]
76
78
 
@@ -88,25 +90,26 @@ module Tinkerforge
88
90
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
91
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
92
 
91
- @callback_formats[CALLBACK_VOLTAGE] = 'S'
92
- @callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
93
- @callback_formats[CALLBACK_VOLTAGE_REACHED] = 'S'
94
- @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
93
+ @callback_formats[CALLBACK_VOLTAGE] = [10, 'S']
94
+ @callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
95
+ @callback_formats[CALLBACK_VOLTAGE_REACHED] = [10, 'S']
96
+ @callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
95
97
 
98
+ @ipcon.add_device self
96
99
  end
97
100
 
98
- # Returns the voltage of the sensor. The value is in mV and
99
- # between 0mV and 50000mV.
101
+ # Returns the voltage of the sensor.
100
102
  #
101
103
  # If you want to get the voltage periodically, it is recommended to use the
102
104
  # CALLBACK_VOLTAGE callback and set the period with
103
105
  # BrickletVoltage#set_voltage_callback_period.
104
106
  def get_voltage
105
- send_request FUNCTION_GET_VOLTAGE, [], '', 2, 'S'
107
+ check_validity
108
+
109
+ send_request FUNCTION_GET_VOLTAGE, [], '', 10, 'S'
106
110
  end
107
111
 
108
112
  # Returns the value as read by a 12-bit analog-to-digital converter.
109
- # The value is between 0 and 4095.
110
113
  #
111
114
  # .. note::
112
115
  # The value returned by BrickletVoltage#get_voltage is averaged over several samples
@@ -118,39 +121,45 @@ module Tinkerforge
118
121
  # CALLBACK_ANALOG_VALUE callback and set the period with
119
122
  # BrickletVoltage#set_analog_value_callback_period.
120
123
  def get_analog_value
121
- send_request FUNCTION_GET_ANALOG_VALUE, [], '', 2, 'S'
124
+ check_validity
125
+
126
+ send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
122
127
  end
123
128
 
124
- # Sets the period in ms with which the CALLBACK_VOLTAGE callback is triggered
129
+ # Sets the period with which the CALLBACK_VOLTAGE callback is triggered
125
130
  # periodically. A value of 0 turns the callback off.
126
131
  #
127
132
  # The CALLBACK_VOLTAGE callback is only triggered if the voltage has changed since
128
133
  # the last triggering.
129
- #
130
- # The default value is 0.
131
134
  def set_voltage_callback_period(period)
132
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, ''
135
+ check_validity
136
+
137
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 8, ''
133
138
  end
134
139
 
135
140
  # Returns the period as set by BrickletVoltage#set_voltage_callback_period.
136
141
  def get_voltage_callback_period
137
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L'
142
+ check_validity
143
+
144
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 12, 'L'
138
145
  end
139
146
 
140
- # Sets the period in ms with which the CALLBACK_ANALOG_VALUE callback is triggered
147
+ # Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
141
148
  # periodically. A value of 0 turns the callback off.
142
149
  #
143
150
  # The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
144
151
  # changed since the last triggering.
145
- #
146
- # The default value is 0.
147
152
  def set_analog_value_callback_period(period)
148
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 0, ''
153
+ check_validity
154
+
155
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
149
156
  end
150
157
 
151
158
  # Returns the period as set by BrickletVoltage#set_analog_value_callback_period.
152
159
  def get_analog_value_callback_period
153
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 4, 'L'
160
+ check_validity
161
+
162
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
154
163
  end
155
164
 
156
165
  # Sets the thresholds for the CALLBACK_VOLTAGE_REACHED callback.
@@ -164,15 +173,17 @@ module Tinkerforge
164
173
  # "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
165
174
  # "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
166
175
  # "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
167
- #
168
- # The default value is ('x', 0, 0).
169
176
  def set_voltage_callback_threshold(option, min, max)
170
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
177
+ check_validity
178
+
179
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
171
180
  end
172
181
 
173
182
  # Returns the threshold as set by BrickletVoltage#set_voltage_callback_threshold.
174
183
  def get_voltage_callback_threshold
175
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
184
+ check_validity
185
+
186
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
176
187
  end
177
188
 
178
189
  # Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
@@ -186,18 +197,20 @@ module Tinkerforge
186
197
  # "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
187
198
  # "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
188
199
  # "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
189
- #
190
- # The default value is ('x', 0, 0).
191
200
  def set_analog_value_callback_threshold(option, min, max)
192
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
201
+ check_validity
202
+
203
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
193
204
  end
194
205
 
195
206
  # Returns the threshold as set by BrickletVoltage#set_analog_value_callback_threshold.
196
207
  def get_analog_value_callback_threshold
197
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
208
+ check_validity
209
+
210
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
198
211
  end
199
212
 
200
- # Sets the period in ms with which the threshold callbacks
213
+ # Sets the period with which the threshold callbacks
201
214
  #
202
215
  # * CALLBACK_VOLTAGE_REACHED,
203
216
  # * CALLBACK_ANALOG_VALUE_REACHED
@@ -208,27 +221,31 @@ module Tinkerforge
208
221
  # * BrickletVoltage#set_analog_value_callback_threshold
209
222
  #
210
223
  # keep being reached.
211
- #
212
- # The default value is 100.
213
224
  def set_debounce_period(debounce)
214
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
225
+ check_validity
226
+
227
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
215
228
  end
216
229
 
217
230
  # Returns the debounce period as set by BrickletVoltage#set_debounce_period.
218
231
  def get_debounce_period
219
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
232
+ check_validity
233
+
234
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
220
235
  end
221
236
 
222
237
  # Returns the UID, the UID where the Bricklet is connected to,
223
238
  # the position, the hardware and firmware version as well as the
224
239
  # device identifier.
225
240
  #
226
- # The position can be 'a', 'b', 'c' or 'd'.
241
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
242
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
243
+ # position 'z'.
227
244
  #
228
245
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
229
246
  # |device_identifier_constant|
230
247
  def get_identity
231
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
248
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
232
249
  end
233
250
 
234
251
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-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 power, DC voltage and DC current up to 720W/36V/20A
14
16
  class BrickletVoltageCurrent < Device
@@ -99,11 +101,19 @@ module Tinkerforge
99
101
  THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
100
102
  THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
101
103
  THRESHOLD_OPTION_GREATER = '>' # :nodoc:
104
+ CONVERSION_TIME_140US = 0 # :nodoc:
105
+ CONVERSION_TIME_204US = 1 # :nodoc:
106
+ CONVERSION_TIME_332US = 2 # :nodoc:
107
+ CONVERSION_TIME_588US = 3 # :nodoc:
108
+ CONVERSION_TIME_1_1MS = 4 # :nodoc:
109
+ CONVERSION_TIME_2_116MS = 5 # :nodoc:
110
+ CONVERSION_TIME_4_156MS = 6 # :nodoc:
111
+ CONVERSION_TIME_8_244MS = 7 # :nodoc:
102
112
 
103
113
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
104
114
  # the IP Connection <tt>ipcon</tt>.
105
115
  def initialize(uid, ipcon)
106
- super uid, ipcon
116
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
107
117
 
108
118
  @api_version = [2, 0, 0]
109
119
 
@@ -130,84 +140,63 @@ module Tinkerforge
130
140
  @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
141
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
142
 
133
- @callback_formats[CALLBACK_CURRENT] = 'l'
134
- @callback_formats[CALLBACK_VOLTAGE] = 'l'
135
- @callback_formats[CALLBACK_POWER] = 'l'
136
- @callback_formats[CALLBACK_CURRENT_REACHED] = 'l'
137
- @callback_formats[CALLBACK_VOLTAGE_REACHED] = 'l'
138
- @callback_formats[CALLBACK_POWER_REACHED] = 'l'
143
+ @callback_formats[CALLBACK_CURRENT] = [12, 'l']
144
+ @callback_formats[CALLBACK_VOLTAGE] = [12, 'l']
145
+ @callback_formats[CALLBACK_POWER] = [12, 'l']
146
+ @callback_formats[CALLBACK_CURRENT_REACHED] = [12, 'l']
147
+ @callback_formats[CALLBACK_VOLTAGE_REACHED] = [12, 'l']
148
+ @callback_formats[CALLBACK_POWER_REACHED] = [12, 'l']
139
149
 
150
+ @ipcon.add_device self
140
151
  end
141
152
 
142
- # Returns the current. The value is in mA
143
- # and between -20000mA and 20000mA.
153
+ # Returns the current.
144
154
  #
145
155
  # If you want to get the current periodically, it is recommended to use the
146
156
  # CALLBACK_CURRENT callback and set the period with
147
157
  # BrickletVoltageCurrent#set_current_callback_period.
148
158
  def get_current
149
- send_request FUNCTION_GET_CURRENT, [], '', 4, 'l'
159
+ check_validity
160
+
161
+ send_request FUNCTION_GET_CURRENT, [], '', 12, 'l'
150
162
  end
151
163
 
152
- # Returns the voltage. The value is in mV
153
- # and between 0mV and 36000mV.
164
+ # Returns the voltage.
154
165
  #
155
166
  # If you want to get the voltage periodically, it is recommended to use the
156
167
  # CALLBACK_VOLTAGE callback and set the period with
157
168
  # BrickletVoltageCurrent#set_voltage_callback_period.
158
169
  def get_voltage
159
- send_request FUNCTION_GET_VOLTAGE, [], '', 4, 'l'
170
+ check_validity
171
+
172
+ send_request FUNCTION_GET_VOLTAGE, [], '', 12, 'l'
160
173
  end
161
174
 
162
- # Returns the power. The value is in mW
163
- # and between 0mV and 720000mW.
175
+ # Returns the power.
164
176
  #
165
177
  # If you want to get the power periodically, it is recommended to use the
166
178
  # CALLBACK_POWER callback and set the period with
167
179
  # BrickletVoltageCurrent#set_power_callback_period.
168
180
  def get_power
169
- send_request FUNCTION_GET_POWER, [], '', 4, 'l'
181
+ check_validity
182
+
183
+ send_request FUNCTION_GET_POWER, [], '', 12, 'l'
170
184
  end
171
185
 
172
186
  # Sets the configuration of the Voltage/Current Bricklet. It is
173
187
  # possible to configure number of averages as well as
174
188
  # voltage and current conversion time.
175
- #
176
- # Averaging:
177
- #
178
- # "Value", "Number of Averages"
179
- #
180
- # "0", "1"
181
- # "1", "4"
182
- # "2", "16"
183
- # "3", "64"
184
- # "4", "128"
185
- # "5", "256"
186
- # "6", "512"
187
- # ">=7", "1024"
188
- #
189
- # Voltage/Current conversion:
190
- #
191
- # "Value", "Conversion time"
192
- #
193
- # "0", "140µs"
194
- # "1", "204µs"
195
- # "2", "332µs"
196
- # "3", "588µs"
197
- # "4", "1.1ms"
198
- # "5", "2.116ms"
199
- # "6", "4.156ms"
200
- # ">=7", "8.244ms"
201
- #
202
- # The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage
203
- # conversion and current conversion.
204
189
  def set_configuration(averaging, voltage_conversion_time, current_conversion_time)
205
- send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 0, ''
190
+ check_validity
191
+
192
+ send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 8, ''
206
193
  end
207
194
 
208
195
  # Returns the configuration as set by BrickletVoltageCurrent#set_configuration.
209
196
  def get_configuration
210
- send_request FUNCTION_GET_CONFIGURATION, [], '', 3, 'C C C'
197
+ check_validity
198
+
199
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 11, 'C C C'
211
200
  end
212
201
 
213
202
  # Since the shunt resistor that is used to measure the current is not
@@ -218,60 +207,70 @@ module Tinkerforge
218
207
  # are measuring 1023mA, you can calibrate the Voltage/Current Bricklet
219
208
  # by setting the multiplier to 1000 and the divisor to 1023.
220
209
  def set_calibration(gain_multiplier, gain_divisor)
221
- send_request FUNCTION_SET_CALIBRATION, [gain_multiplier, gain_divisor], 'S S', 0, ''
210
+ check_validity
211
+
212
+ send_request FUNCTION_SET_CALIBRATION, [gain_multiplier, gain_divisor], 'S S', 8, ''
222
213
  end
223
214
 
224
215
  # Returns the calibration as set by BrickletVoltageCurrent#set_calibration.
225
216
  def get_calibration
226
- send_request FUNCTION_GET_CALIBRATION, [], '', 4, 'S S'
217
+ check_validity
218
+
219
+ send_request FUNCTION_GET_CALIBRATION, [], '', 12, 'S S'
227
220
  end
228
221
 
229
- # Sets the period in ms with which the CALLBACK_CURRENT callback is triggered
222
+ # Sets the period with which the CALLBACK_CURRENT callback is triggered
230
223
  # periodically. A value of 0 turns the callback off.
231
224
  #
232
225
  # The CALLBACK_CURRENT callback is only triggered if the current has changed since
233
226
  # the last triggering.
234
- #
235
- # The default value is 0.
236
227
  def set_current_callback_period(period)
237
- send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 0, ''
228
+ check_validity
229
+
230
+ send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 8, ''
238
231
  end
239
232
 
240
233
  # Returns the period as set by BrickletVoltageCurrent#set_current_callback_period.
241
234
  def get_current_callback_period
242
- send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 4, 'L'
235
+ check_validity
236
+
237
+ send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 12, 'L'
243
238
  end
244
239
 
245
- # Sets the period in ms with which the CALLBACK_VOLTAGE callback is triggered
240
+ # Sets the period with which the CALLBACK_VOLTAGE callback is triggered
246
241
  # periodically. A value of 0 turns the callback off.
247
242
  #
248
243
  # The CALLBACK_VOLTAGE callback is only triggered if the voltage has changed since
249
244
  # the last triggering.
250
- #
251
- # The default value is 0.
252
245
  def set_voltage_callback_period(period)
253
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 0, ''
246
+ check_validity
247
+
248
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [period], 'L', 8, ''
254
249
  end
255
250
 
256
251
  # Returns the period as set by BrickletVoltageCurrent#set_voltage_callback_period.
257
252
  def get_voltage_callback_period
258
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 4, 'L'
253
+ check_validity
254
+
255
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [], '', 12, 'L'
259
256
  end
260
257
 
261
- # Sets the period in ms with which the CALLBACK_POWER callback is triggered
258
+ # Sets the period with which the CALLBACK_POWER callback is triggered
262
259
  # periodically. A value of 0 turns the callback off.
263
260
  #
264
261
  # The CALLBACK_POWER callback is only triggered if the power has changed since the
265
262
  # last triggering.
266
- #
267
- # The default value is 0.
268
263
  def set_power_callback_period(period)
269
- send_request FUNCTION_SET_POWER_CALLBACK_PERIOD, [period], 'L', 0, ''
264
+ check_validity
265
+
266
+ send_request FUNCTION_SET_POWER_CALLBACK_PERIOD, [period], 'L', 8, ''
270
267
  end
271
268
 
272
269
  # Returns the period as set by BrickletVoltageCurrent#get_power_callback_period.
273
270
  def get_power_callback_period
274
- send_request FUNCTION_GET_POWER_CALLBACK_PERIOD, [], '', 4, 'L'
271
+ check_validity
272
+
273
+ send_request FUNCTION_GET_POWER_CALLBACK_PERIOD, [], '', 12, 'L'
275
274
  end
276
275
 
277
276
  # Sets the thresholds for the CALLBACK_CURRENT_REACHED callback.
@@ -285,15 +284,17 @@ module Tinkerforge
285
284
  # "'i'", "Callback is triggered when the current is *inside* the min and max values"
286
285
  # "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
287
286
  # "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
288
- #
289
- # The default value is ('x', 0, 0).
290
287
  def set_current_callback_threshold(option, min, max)
291
- send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
288
+ check_validity
289
+
290
+ send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
292
291
  end
293
292
 
294
293
  # Returns the threshold as set by BrickletVoltageCurrent#set_current_callback_threshold.
295
294
  def get_current_callback_threshold
296
- send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
295
+ check_validity
296
+
297
+ send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
297
298
  end
298
299
 
299
300
  # Sets the thresholds for the CALLBACK_VOLTAGE_REACHED callback.
@@ -307,15 +308,17 @@ module Tinkerforge
307
308
  # "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
308
309
  # "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
309
310
  # "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
310
- #
311
- # The default value is ('x', 0, 0).
312
311
  def set_voltage_callback_threshold(option, min, max)
313
- send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
312
+ check_validity
313
+
314
+ send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
314
315
  end
315
316
 
316
317
  # Returns the threshold as set by BrickletVoltageCurrent#set_voltage_callback_threshold.
317
318
  def get_voltage_callback_threshold
318
- send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
319
+ check_validity
320
+
321
+ send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
319
322
  end
320
323
 
321
324
  # Sets the thresholds for the CALLBACK_POWER_REACHED callback.
@@ -329,18 +332,20 @@ module Tinkerforge
329
332
  # "'i'", "Callback is triggered when the power is *inside* the min and max values"
330
333
  # "'<'", "Callback is triggered when the power is smaller than the min value (max is ignored)"
331
334
  # "'>'", "Callback is triggered when the power is greater than the min value (max is ignored)"
332
- #
333
- # The default value is ('x', 0, 0).
334
335
  def set_power_callback_threshold(option, min, max)
335
- send_request FUNCTION_SET_POWER_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
336
+ check_validity
337
+
338
+ send_request FUNCTION_SET_POWER_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
336
339
  end
337
340
 
338
341
  # Returns the threshold as set by BrickletVoltageCurrent#set_power_callback_threshold.
339
342
  def get_power_callback_threshold
340
- send_request FUNCTION_GET_POWER_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
343
+ check_validity
344
+
345
+ send_request FUNCTION_GET_POWER_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
341
346
  end
342
347
 
343
- # Sets the period in ms with which the threshold callbacks
348
+ # Sets the period with which the threshold callbacks
344
349
  #
345
350
  # * CALLBACK_CURRENT_REACHED,
346
351
  # * CALLBACK_VOLTAGE_REACHED,
@@ -353,27 +358,31 @@ module Tinkerforge
353
358
  # * BrickletVoltageCurrent#set_power_callback_threshold
354
359
  #
355
360
  # keep being reached.
356
- #
357
- # The default value is 100.
358
361
  def set_debounce_period(debounce)
359
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
362
+ check_validity
363
+
364
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
360
365
  end
361
366
 
362
367
  # Returns the debounce period as set by BrickletVoltageCurrent#set_debounce_period.
363
368
  def get_debounce_period
364
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
369
+ check_validity
370
+
371
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
365
372
  end
366
373
 
367
374
  # Returns the UID, the UID where the Bricklet is connected to,
368
375
  # the position, the hardware and firmware version as well as the
369
376
  # device identifier.
370
377
  #
371
- # The position can be 'a', 'b', 'c' or 'd'.
378
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
379
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
380
+ # position 'z'.
372
381
  #
373
382
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
374
383
  # |device_identifier_constant|
375
384
  def get_identity
376
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
385
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
377
386
  end
378
387
 
379
388
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.