tinkerforge 2.1.22 → 2.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +157 -76
  3. data/lib/tinkerforge/brick_hat.rb +115 -32
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +192 -87
  6. data/lib/tinkerforge/brick_imu_v2.rb +220 -119
  7. data/lib/tinkerforge/brick_master.rb +498 -198
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +187 -103
  10. data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
  11. data/lib/tinkerforge/brick_stepper.rb +214 -102
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +77 -49
  31. data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +397 -0
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  102. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  103. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  104. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  105. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  106. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  107. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  108. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  109. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  110. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  111. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  112. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  113. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  114. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  115. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  116. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  117. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
  118. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  119. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  120. data/lib/tinkerforge/bricklet_rs485.rb +303 -207
  121. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  122. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  123. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  124. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  125. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  126. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  127. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  128. data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
  129. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
  130. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  131. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  132. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  133. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  134. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  135. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  136. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  137. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  138. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  139. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
  140. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
  141. data/lib/tinkerforge/device_display_names.rb +165 -0
  142. data/lib/tinkerforge/ip_connection.rb +155 -33
  143. data/lib/tinkerforge/version.rb +1 -1
  144. metadata +14 -4
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Measures acceleration in three axis
14
16
  class BrickletAccelerometer < Device
@@ -17,7 +19,8 @@ module Tinkerforge
17
19
 
18
20
  # This callback is triggered periodically with the period that is set by
19
21
  # BrickletAccelerometer#set_acceleration_callback_period. The parameters are the
20
- # X, Y and Z acceleration.
22
+ # X, Y and Z acceleration. The range is
23
+ # configured with BrickletAccelerometer#set_configuration.
21
24
  #
22
25
  # The CALLBACK_ACCELERATION callback is only triggered if the acceleration has
23
26
  # changed since the last triggering.
@@ -25,7 +28,8 @@ module Tinkerforge
25
28
 
26
29
  # This callback is triggered when the threshold as set by
27
30
  # BrickletAccelerometer#set_acceleration_callback_threshold is reached.
28
- # The parameters are the X, Y and Z acceleration.
31
+ # The parameters are the X, Y and Z acceleration. The range is
32
+ # configured with BrickletAccelerometer#set_configuration.
29
33
  #
30
34
  # If the threshold keeps being reached, the callback is triggered periodically
31
35
  # with the period as set by BrickletAccelerometer#set_debounce_period.
@@ -74,7 +78,7 @@ module Tinkerforge
74
78
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
75
79
  # the IP Connection <tt>ipcon</tt>.
76
80
  def initialize(uid, ipcon)
77
- super uid, ipcon
81
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
78
82
 
79
83
  @api_version = [2, 0, 1]
80
84
 
@@ -93,35 +97,41 @@ module Tinkerforge
93
97
  @response_expected[FUNCTION_IS_LED_ON] = RESPONSE_EXPECTED_ALWAYS_TRUE
94
98
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
95
99
 
96
- @callback_formats[CALLBACK_ACCELERATION] = 's s s'
97
- @callback_formats[CALLBACK_ACCELERATION_REACHED] = 's s s'
100
+ @callback_formats[CALLBACK_ACCELERATION] = [14, 's s s']
101
+ @callback_formats[CALLBACK_ACCELERATION_REACHED] = [14, 's s s']
98
102
 
103
+ @ipcon.add_device self
99
104
  end
100
105
 
101
106
  # Returns the acceleration in x, y and z direction. The values
102
- # are given in g/1000 (1g = 9.80665m/s²), not to be confused with grams.
107
+ # are given in gₙ/1000 (1g = 9.80665m/s²). The range is
108
+ # configured with BrickletAccelerometer#set_configuration.
103
109
  #
104
110
  # If you want to get the acceleration periodically, it is recommended
105
111
  # to use the CALLBACK_ACCELERATION callback and set the period with
106
112
  # BrickletAccelerometer#set_acceleration_callback_period.
107
113
  def get_acceleration
108
- send_request FUNCTION_GET_ACCELERATION, [], '', 6, 's s s'
114
+ check_validity
115
+
116
+ send_request FUNCTION_GET_ACCELERATION, [], '', 14, 's s s'
109
117
  end
110
118
 
111
- # Sets the period in ms with which the CALLBACK_ACCELERATION callback is triggered
119
+ # Sets the period with which the CALLBACK_ACCELERATION callback is triggered
112
120
  # periodically. A value of 0 turns the callback off.
113
121
  #
114
122
  # The CALLBACK_ACCELERATION callback is only triggered if the acceleration has
115
123
  # changed since the last triggering.
116
- #
117
- # The default value is 0.
118
124
  def set_acceleration_callback_period(period)
119
- send_request FUNCTION_SET_ACCELERATION_CALLBACK_PERIOD, [period], 'L', 0, ''
125
+ check_validity
126
+
127
+ send_request FUNCTION_SET_ACCELERATION_CALLBACK_PERIOD, [period], 'L', 8, ''
120
128
  end
121
129
 
122
130
  # Returns the period as set by BrickletAccelerometer#set_acceleration_callback_period.
123
131
  def get_acceleration_callback_period
124
- send_request FUNCTION_GET_ACCELERATION_CALLBACK_PERIOD, [], '', 4, 'L'
132
+ check_validity
133
+
134
+ send_request FUNCTION_GET_ACCELERATION_CALLBACK_PERIOD, [], '', 12, 'L'
125
135
  end
126
136
 
127
137
  # Sets the thresholds for the CALLBACK_ACCELERATION_REACHED callback.
@@ -135,18 +145,20 @@ module Tinkerforge
135
145
  # "'i'", "Callback is triggered when the acceleration is *inside* the min and max values"
136
146
  # "'<'", "Callback is triggered when the acceleration is smaller than the min value (max is ignored)"
137
147
  # "'>'", "Callback is triggered when the acceleration is greater than the min value (max is ignored)"
138
- #
139
- # The default value is ('x', 0, 0, 0, 0, 0, 0).
140
148
  def set_acceleration_callback_threshold(option, min_x, max_x, min_y, max_y, min_z, max_z)
141
- send_request FUNCTION_SET_ACCELERATION_CALLBACK_THRESHOLD, [option, min_x, max_x, min_y, max_y, min_z, max_z], 'k s s s s s s', 0, ''
149
+ check_validity
150
+
151
+ send_request FUNCTION_SET_ACCELERATION_CALLBACK_THRESHOLD, [option, min_x, max_x, min_y, max_y, min_z, max_z], 'k s s s s s s', 8, ''
142
152
  end
143
153
 
144
154
  # Returns the threshold as set by BrickletAccelerometer#set_acceleration_callback_threshold.
145
155
  def get_acceleration_callback_threshold
146
- send_request FUNCTION_GET_ACCELERATION_CALLBACK_THRESHOLD, [], '', 13, 'k s s s s s s'
156
+ check_validity
157
+
158
+ send_request FUNCTION_GET_ACCELERATION_CALLBACK_THRESHOLD, [], '', 21, 'k s s s s s s'
147
159
  end
148
160
 
149
- # Sets the period in ms with which the threshold callback
161
+ # Sets the period with which the threshold callback
150
162
  #
151
163
  # * CALLBACK_ACCELERATION_REACHED
152
164
  #
@@ -155,68 +167,81 @@ module Tinkerforge
155
167
  # * BrickletAccelerometer#set_acceleration_callback_threshold
156
168
  #
157
169
  # keeps being reached.
158
- #
159
- # The default value is 100.
160
170
  def set_debounce_period(debounce)
161
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
171
+ check_validity
172
+
173
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
162
174
  end
163
175
 
164
176
  # Returns the debounce period as set by BrickletAccelerometer#set_debounce_period.
165
177
  def get_debounce_period
166
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
178
+ check_validity
179
+
180
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
167
181
  end
168
182
 
169
- # Returns the temperature of the accelerometer in °C.
183
+ # Returns the temperature of the accelerometer.
170
184
  def get_temperature
171
- send_request FUNCTION_GET_TEMPERATURE, [], '', 2, 's'
185
+ check_validity
186
+
187
+ send_request FUNCTION_GET_TEMPERATURE, [], '', 10, 's'
172
188
  end
173
189
 
174
190
  # Configures the data rate, full scale range and filter bandwidth.
175
191
  # Possible values are:
176
192
  #
177
193
  # * Data rate of 0Hz to 1600Hz.
178
- # * Full scale range of -2G to +2G up to -16G to +16G.
194
+ # * Full scale range of ±2gₙ up to ±16gₙ.
179
195
  # * Filter bandwidth between 50Hz and 800Hz.
180
196
  #
181
197
  # Decreasing data rate or full scale range will also decrease the noise on
182
198
  # the data.
183
- #
184
- # The default values are 100Hz data rate, -4G to +4G range and 200Hz
185
- # filter bandwidth.
186
199
  def set_configuration(data_rate, full_scale, filter_bandwidth)
187
- send_request FUNCTION_SET_CONFIGURATION, [data_rate, full_scale, filter_bandwidth], 'C C C', 0, ''
200
+ check_validity
201
+
202
+ send_request FUNCTION_SET_CONFIGURATION, [data_rate, full_scale, filter_bandwidth], 'C C C', 8, ''
188
203
  end
189
204
 
190
205
  # Returns the configuration as set by BrickletAccelerometer#set_configuration.
191
206
  def get_configuration
192
- send_request FUNCTION_GET_CONFIGURATION, [], '', 3, 'C C C'
207
+ check_validity
208
+
209
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 11, 'C C C'
193
210
  end
194
211
 
195
212
  # Enables the LED on the Bricklet.
196
213
  def led_on
197
- send_request FUNCTION_LED_ON, [], '', 0, ''
214
+ check_validity
215
+
216
+ send_request FUNCTION_LED_ON, [], '', 8, ''
198
217
  end
199
218
 
200
219
  # Disables the LED on the Bricklet.
201
220
  def led_off
202
- send_request FUNCTION_LED_OFF, [], '', 0, ''
221
+ check_validity
222
+
223
+ send_request FUNCTION_LED_OFF, [], '', 8, ''
203
224
  end
204
225
 
205
226
  # Returns *true* if the LED is enabled, *false* otherwise.
206
227
  def is_led_on
207
- send_request FUNCTION_IS_LED_ON, [], '', 1, '?'
228
+ check_validity
229
+
230
+ send_request FUNCTION_IS_LED_ON, [], '', 9, '?'
208
231
  end
209
232
 
210
233
  # Returns the UID, the UID where the Bricklet is connected to,
211
234
  # the position, the hardware and firmware version as well as the
212
235
  # device identifier.
213
236
  #
214
- # The position can be 'a', 'b', 'c' or 'd'.
237
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
238
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
239
+ # position 'z'.
215
240
  #
216
241
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
217
242
  # |device_identifier_constant|
218
243
  def get_identity
219
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
244
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
220
245
  end
221
246
 
222
247
  # 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 acceleration in three axis
14
16
  class BrickletAccelerometerV2 < Device
@@ -25,28 +27,52 @@ module Tinkerforge
25
27
  # be configured with BrickletAccelerometerV2#set_configuration and this callback can be
26
28
  # enabled with BrickletAccelerometerV2#set_continuous_acceleration_configuration.
27
29
  #
28
- # The unit of the values is g/10000.
30
+ # The returned values are raw ADC data. If you want to put this data into
31
+ # a FFT to determine the occurrences of specific frequencies we recommend
32
+ # that you use the data as is. It has all of the ADC noise in it. This noise
33
+ # looks like pure noise at first glance, but it might still have some frequnecy
34
+ # information in it that can be utilized by the FFT.
35
+ #
36
+ # Otherwise you have to use the following formulas that depend on the
37
+ # full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
38
+ # the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
39
+ #
40
+ # * Full scale 2g: acceleration = value * 625 / 1024
41
+ # * Full scale 4g: acceleration = value * 1250 / 1024
42
+ # * Full scale 8g: acceleration = value * 2500 / 1024
29
43
  #
30
44
  # The data is formated in the sequence "x, y, z, x, y, z, ..." depending on
31
45
  # the enabled axis. Examples:
32
46
  #
33
- # * x, y, z enabled: "x, y, z, ... 10x ..., x, y, z"
34
- # * x, z enabled: "x, z, ... 15x ..., x, z"
35
- # * y enabled: "y, ... 30x ..., y"
47
+ # * x, y, z enabled: "x, y, z, ..." 10x repeated
48
+ # * x, z enabled: "x, z, ..." 15x repeated
49
+ # * y enabled: "y, ..." 30x repeated
36
50
  CALLBACK_CONTINUOUS_ACCELERATION_16_BIT = 11
37
51
 
38
- # Returns 30 acceleration values with 8 bit resolution. The data rate can
52
+ # Returns 60 acceleration values with 8 bit resolution. The data rate can
39
53
  # be configured with BrickletAccelerometerV2#set_configuration and this callback can be
40
54
  # enabled with BrickletAccelerometerV2#set_continuous_acceleration_configuration.
41
55
  #
42
- # The unit of the values is g*256/10000.
56
+ # The returned values are raw ADC data. If you want to put this data into
57
+ # a FFT to determine the occurrences of specific frequencies we recommend
58
+ # that you use the data as is. It has all of the ADC noise in it. This noise
59
+ # looks like pure noise at first glance, but it might still have some frequnecy
60
+ # information in it that can be utilized by the FFT.
61
+ #
62
+ # Otherwise you have to use the following formulas that depend on the
63
+ # full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
64
+ # the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
65
+ #
66
+ # * Full scale 2g: acceleration = value * 256 * 625 / 1024
67
+ # * Full scale 4g: acceleration = value * 256 * 1250 / 1024
68
+ # * Full scale 8g: acceleration = value * 256 * 2500 / 1024
43
69
  #
44
70
  # The data is formated in the sequence "x, y, z, x, y, z, ..." depending on
45
71
  # the enabled axis. Examples:
46
72
  #
47
- # * x, y, z enabled: "x, y, z, ... 20x ..., x, y, z"
48
- # * x, z enabled: "x, z, ... 30x ..., x, z"
49
- # * y enabled: "y, ... 60x ..., y"
73
+ # * x, y, z enabled: "x, y, z, ..." 20x repeated
74
+ # * x, z enabled: "x, z, ..." 30x repeated
75
+ # * y enabled: "y, ..." 60x repeated
50
76
  CALLBACK_CONTINUOUS_ACCELERATION_8_BIT = 12
51
77
 
52
78
  FUNCTION_GET_ACCELERATION = 1 # :nodoc:
@@ -58,6 +84,8 @@ module Tinkerforge
58
84
  FUNCTION_GET_INFO_LED_CONFIG = 7 # :nodoc:
59
85
  FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION = 9 # :nodoc:
60
86
  FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION = 10 # :nodoc:
87
+ FUNCTION_SET_FILTER_CONFIGURATION = 13 # :nodoc:
88
+ FUNCTION_GET_FILTER_CONFIGURATION = 14 # :nodoc:
61
89
  FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
62
90
  FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
63
91
  FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
@@ -95,6 +123,10 @@ module Tinkerforge
95
123
  INFO_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
96
124
  RESOLUTION_8BIT = 0 # :nodoc:
97
125
  RESOLUTION_16BIT = 1 # :nodoc:
126
+ IIR_BYPASS_APPLIED = 0 # :nodoc:
127
+ IIR_BYPASS_BYPASSED = 1 # :nodoc:
128
+ LOW_PASS_FILTER_NINTH = 0 # :nodoc:
129
+ LOW_PASS_FILTER_HALF = 1 # :nodoc:
98
130
  BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
99
131
  BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
100
132
  BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
@@ -114,9 +146,9 @@ module Tinkerforge
114
146
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
115
147
  # the IP Connection <tt>ipcon</tt>.
116
148
  def initialize(uid, ipcon)
117
- super uid, ipcon
149
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
118
150
 
119
- @api_version = [2, 0, 0]
151
+ @api_version = [2, 0, 1]
120
152
 
121
153
  @response_expected[FUNCTION_GET_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
122
154
  @response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
@@ -125,8 +157,10 @@ module Tinkerforge
125
157
  @response_expected[FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
126
158
  @response_expected[FUNCTION_SET_INFO_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
127
159
  @response_expected[FUNCTION_GET_INFO_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
128
- @response_expected[FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
160
+ @response_expected[FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
129
161
  @response_expected[FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
162
+ @response_expected[FUNCTION_SET_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
163
+ @response_expected[FUNCTION_GET_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
130
164
  @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
165
  @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
166
  @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -140,42 +174,48 @@ module Tinkerforge
140
174
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
141
175
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
142
176
 
143
- @callback_formats[CALLBACK_ACCELERATION] = 'l l l'
144
- @callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_16_BIT] = 's30'
145
- @callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_8_BIT] = 'c60'
177
+ @callback_formats[CALLBACK_ACCELERATION] = [20, 'l l l']
178
+ @callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_16_BIT] = [68, 's30']
179
+ @callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_8_BIT] = [68, 'c60']
146
180
 
181
+ @ipcon.add_device self
147
182
  end
148
183
 
149
184
  # Returns the acceleration in x, y and z direction. The values
150
- # are given in g/10000 (1g = 9.80665m/s²), not to be confused with grams.
185
+ # are given in gₙ/10000 (1g = 9.80665m/s²). The range is
186
+ # configured with BrickletAccelerometerV2#set_configuration.
151
187
  #
152
188
  # If you want to get the acceleration periodically, it is recommended
153
189
  # to use the CALLBACK_ACCELERATION callback and set the period with
154
190
  # BrickletAccelerometerV2#set_acceleration_callback_configuration.
155
191
  def get_acceleration
156
- send_request FUNCTION_GET_ACCELERATION, [], '', 12, 'l l l'
192
+ check_validity
193
+
194
+ send_request FUNCTION_GET_ACCELERATION, [], '', 20, 'l l l'
157
195
  end
158
196
 
159
197
  # Configures the data rate and full scale range.
160
198
  # Possible values are:
161
199
  #
162
200
  # * Data rate of 0.781Hz to 25600Hz.
163
- # * Full scale range of -2g to +2g up to -8g to +8g.
201
+ # * Full scale range of ±2g up to ±8g.
164
202
  #
165
203
  # Decreasing data rate or full scale range will also decrease the noise on
166
204
  # the data.
167
- #
168
- # The default values are 100Hz data rate and -2g to +2g range.
169
205
  def set_configuration(data_rate, full_scale)
170
- send_request FUNCTION_SET_CONFIGURATION, [data_rate, full_scale], 'C C', 0, ''
206
+ check_validity
207
+
208
+ send_request FUNCTION_SET_CONFIGURATION, [data_rate, full_scale], 'C C', 8, ''
171
209
  end
172
210
 
173
211
  # Returns the configuration as set by BrickletAccelerometerV2#set_configuration.
174
212
  def get_configuration
175
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
213
+ check_validity
214
+
215
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
176
216
  end
177
217
 
178
- # The period in ms is the period with which the CALLBACK_ACCELERATION
218
+ # The period is the period with which the CALLBACK_ACCELERATION
179
219
  # callback is triggered periodically. A value of 0 turns the callback off.
180
220
  #
181
221
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -187,27 +227,33 @@ module Tinkerforge
187
227
  #
188
228
  # If this callback is enabled, the CALLBACK_CONTINUOUS_ACCELERATION_16_BIT callback
189
229
  # and CALLBACK_CONTINUOUS_ACCELERATION_8_BIT callback will automatically be disabled.
190
- #
191
- # The default value is (0, false).
192
230
  def set_acceleration_callback_configuration(period, value_has_to_change)
193
- send_request FUNCTION_SET_ACCELERATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
231
+ check_validity
232
+
233
+ send_request FUNCTION_SET_ACCELERATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
194
234
  end
195
235
 
196
236
  # Returns the callback configuration as set by
197
237
  # BrickletAccelerometerV2#set_acceleration_callback_configuration.
198
238
  def get_acceleration_callback_configuration
199
- send_request FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
239
+ check_validity
240
+
241
+ send_request FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
200
242
  end
201
243
 
202
244
  # Configures the info LED (marked as "Force" on the Bricklet) to be either turned off,
203
245
  # turned on, or blink in heartbeat mode.
204
246
  def set_info_led_config(config)
205
- send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 0, ''
247
+ check_validity
248
+
249
+ send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 8, ''
206
250
  end
207
251
 
208
252
  # Returns the LED configuration as set by BrickletAccelerometerV2#set_info_led_config
209
253
  def get_info_led_config
210
- send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 1, 'C'
254
+ check_validity
255
+
256
+ send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 9, 'C'
211
257
  end
212
258
 
213
259
  # For high throughput of acceleration data (> 1000Hz) you have to use the
@@ -222,8 +268,26 @@ module Tinkerforge
222
268
  # one of the axis is enabled and the resolution is set to 16 bit,
223
269
  # the CALLBACK_CONTINUOUS_ACCELERATION_16_BIT callback is activated.
224
270
  #
271
+ # The returned values are raw ADC data. If you want to put this data into
272
+ # a FFT to determine the occurrences of specific frequencies we recommend
273
+ # that you use the data as is. It has all of the ADC noise in it. This noise
274
+ # looks like pure noise at first glance, but it might still have some frequnecy
275
+ # information in it that can be utilized by the FFT.
276
+ #
277
+ # Otherwise you have to use the following formulas that depend on the configured
278
+ # resolution (8/16 bit) and the full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
279
+ # the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
280
+ #
281
+ # * 16 bit, full scale 2g: acceleration = value * 625 / 1024
282
+ # * 16 bit, full scale 4g: acceleration = value * 1250 / 1024
283
+ # * 16 bit, full scale 8g: acceleration = value * 2500 / 1024
284
+ #
225
285
  # If a resolution of 8 bit is used, only the 8 most significant bits will be
226
- # transferred. This means that the unit changes from g/10000 to g*256/10000.
286
+ # transferred, so you can use the following formulas:
287
+ #
288
+ # * 8 bit, full scale 2g: acceleration = value * 256 * 625 / 1024
289
+ # * 8 bit, full scale 4g: acceleration = value * 256 * 1250 / 1024
290
+ # * 8 bit, full scale 8g: acceleration = value * 256 * 2500 / 1024
227
291
  #
228
292
  # If no axis is enabled, both callbacks are disabled. If one of the continuous
229
293
  # callbacks is enabled, the CALLBACK_ACCELERATION callback is disabled.
@@ -236,13 +300,44 @@ module Tinkerforge
236
300
  # "2", "25600Hz", "15000Hz"
237
301
  # "3", "20000Hz", "10000Hz"
238
302
  def set_continuous_acceleration_configuration(enable_x, enable_y, enable_z, resolution)
239
- send_request FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION, [enable_x, enable_y, enable_z, resolution], '? ? ? C', 0, ''
303
+ check_validity
304
+
305
+ send_request FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION, [enable_x, enable_y, enable_z, resolution], '? ? ? C', 8, ''
240
306
  end
241
307
 
242
308
  # Returns the continuous acceleration configuration as set by
243
309
  # BrickletAccelerometerV2#set_continuous_acceleration_configuration.
244
310
  def get_continuous_acceleration_configuration
245
- send_request FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION, [], '', 4, '? ? ? C'
311
+ check_validity
312
+
313
+ send_request FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION, [], '', 12, '? ? ? C'
314
+ end
315
+
316
+ # Configures IIR Bypass filter mode and low pass filter roll off corner frequency.
317
+ #
318
+ # The filter can be applied or bypassed and the corner frequency can be
319
+ # half or a ninth of the output data rate.
320
+ #
321
+ # .. image:: /Images/Bricklets/bricklet_accelerometer_v2_filter.png
322
+ # :scale: 100 %
323
+ # :alt: Accelerometer filter
324
+ # :align: center
325
+ # :target: ../../_images/Bricklets/bricklet_accelerometer_v2_filter.png
326
+ #
327
+ # .. versionadded:: 2.0.2$nbsp;(Plugin)
328
+ def set_filter_configuration(iir_bypass, low_pass_filter)
329
+ check_validity
330
+
331
+ send_request FUNCTION_SET_FILTER_CONFIGURATION, [iir_bypass, low_pass_filter], 'C C', 8, ''
332
+ end
333
+
334
+ # Returns the configuration as set by BrickletAccelerometerV2#set_filter_configuration.
335
+ #
336
+ # .. versionadded:: 2.0.2$nbsp;(Plugin)
337
+ def get_filter_configuration
338
+ check_validity
339
+
340
+ send_request FUNCTION_GET_FILTER_CONFIGURATION, [], '', 10, 'C C'
246
341
  end
247
342
 
248
343
  # Returns the error count for the communication between Brick and Bricklet.
@@ -257,7 +352,9 @@ module Tinkerforge
257
352
  # The errors counts are for errors that occur on the Bricklet side. All
258
353
  # Bricks have a similar function that returns the errors on the Brick side.
259
354
  def get_spitfp_error_count
260
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
355
+ check_validity
356
+
357
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
261
358
  end
262
359
 
263
360
  # Sets the bootloader mode and returns the status after the requested
@@ -270,12 +367,16 @@ module Tinkerforge
270
367
  # This function is used by Brick Viewer during flashing. It should not be
271
368
  # necessary to call it in a normal user program.
272
369
  def set_bootloader_mode(mode)
273
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
370
+ check_validity
371
+
372
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
274
373
  end
275
374
 
276
375
  # Returns the current bootloader mode, see BrickletAccelerometerV2#set_bootloader_mode.
277
376
  def get_bootloader_mode
278
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
377
+ check_validity
378
+
379
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
279
380
  end
280
381
 
281
382
  # Sets the firmware pointer for BrickletAccelerometerV2#write_firmware. The pointer has
@@ -285,7 +386,9 @@ module Tinkerforge
285
386
  # This function is used by Brick Viewer during flashing. It should not be
286
387
  # necessary to call it in a normal user program.
287
388
  def set_write_firmware_pointer(pointer)
288
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
389
+ check_validity
390
+
391
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
289
392
  end
290
393
 
291
394
  # Writes 64 Bytes of firmware at the position as written by
@@ -297,7 +400,9 @@ module Tinkerforge
297
400
  # This function is used by Brick Viewer during flashing. It should not be
298
401
  # necessary to call it in a normal user program.
299
402
  def write_firmware(data)
300
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
403
+ check_validity
404
+
405
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
301
406
  end
302
407
 
303
408
  # Sets the status LED configuration. By default the LED shows
@@ -308,22 +413,28 @@ module Tinkerforge
308
413
  #
309
414
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
310
415
  def set_status_led_config(config)
311
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
416
+ check_validity
417
+
418
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
312
419
  end
313
420
 
314
421
  # Returns the configuration as set by BrickletAccelerometerV2#set_status_led_config
315
422
  def get_status_led_config
316
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
423
+ check_validity
424
+
425
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
317
426
  end
318
427
 
319
- # Returns the temperature in °C as measured inside the microcontroller. The
428
+ # Returns the temperature as measured inside the microcontroller. The
320
429
  # value returned is not the ambient temperature!
321
430
  #
322
431
  # The temperature is only proportional to the real temperature and it has bad
323
432
  # accuracy. Practically it is only useful as an indicator for
324
433
  # temperature changes.
325
434
  def get_chip_temperature
326
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
435
+ check_validity
436
+
437
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
327
438
  end
328
439
 
329
440
  # Calling this function will reset the Bricklet. All configurations
@@ -333,7 +444,9 @@ module Tinkerforge
333
444
  # calling functions on the existing ones will result in
334
445
  # undefined behavior!
335
446
  def reset
336
- send_request FUNCTION_RESET, [], '', 0, ''
447
+ check_validity
448
+
449
+ send_request FUNCTION_RESET, [], '', 8, ''
337
450
  end
338
451
 
339
452
  # Writes a new UID into flash. If you want to set a new UID
@@ -342,25 +455,31 @@ module Tinkerforge
342
455
  #
343
456
  # We recommend that you use Brick Viewer to change the UID.
344
457
  def write_uid(uid)
345
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
458
+ check_validity
459
+
460
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
346
461
  end
347
462
 
348
463
  # Returns the current UID as an integer. Encode as
349
464
  # Base58 to get the usual string version.
350
465
  def read_uid
351
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
466
+ check_validity
467
+
468
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
352
469
  end
353
470
 
354
471
  # Returns the UID, the UID where the Bricklet is connected to,
355
472
  # the position, the hardware and firmware version as well as the
356
473
  # device identifier.
357
474
  #
358
- # The position can be 'a', 'b', 'c' or 'd'.
475
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
476
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
477
+ # position 'z'.
359
478
  #
360
479
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
361
480
  # |device_identifier_constant|
362
481
  def get_identity
363
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
482
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
364
483
  end
365
484
 
366
485
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.