tinkerforge 2.1.23 → 2.1.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +109 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +191 -86
  6. data/lib/tinkerforge/brick_imu_v2.rb +219 -118
  7. data/lib/tinkerforge/brick_master.rb +495 -195
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
  11. data/lib/tinkerforge/brick_stepper.rb +212 -100
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
  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 +75 -47
  31. data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
  32. data/lib/tinkerforge/bricklet_compass.rb +81 -40
  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 +68 -33
  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 +81 -40
  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 +99 -51
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -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 +76 -39
  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 +75 -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_performance_dc.rb +676 -0
  102. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  103. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  104. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  105. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  106. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  107. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  108. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  109. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  110. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  111. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  112. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  113. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  114. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  115. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  116. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  117. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  118. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -26
  119. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  120. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  121. data/lib/tinkerforge/bricklet_rs485.rb +250 -164
  122. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  123. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  124. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  125. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  126. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  127. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  128. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  129. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  130. data/lib/tinkerforge/bricklet_temperature_ir.rb +61 -47
  131. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
  132. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  133. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  134. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  135. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  136. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  137. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  138. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  139. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  140. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  141. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +92 -77
  142. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
  143. data/lib/tinkerforge/device_display_names.rb +167 -0
  144. data/lib/tinkerforge/ip_connection.rb +156 -33
  145. data/lib/tinkerforge/version.rb +1 -1
  146. metadata +8 -3
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
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-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
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
@@ -33,21 +35,21 @@ module Tinkerforge
33
35
  #
34
36
  # Otherwise you have to use the following formulas that depend on the
35
37
  # full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
36
- # the data in g/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
38
+ # the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
37
39
  #
38
- # * Full scale 2G: acceleration = value*625/1024
39
- # * Full scale 4G: acceleration = value*1250/1024
40
- # * Full scale 8G: acceleration = value*2500/1024
40
+ # * Full scale 2g: acceleration = value * 625 / 1024
41
+ # * Full scale 4g: acceleration = value * 1250 / 1024
42
+ # * Full scale 8g: acceleration = value * 2500 / 1024
41
43
  #
42
44
  # The data is formated in the sequence "x, y, z, x, y, z, ..." depending on
43
45
  # the enabled axis. Examples:
44
46
  #
45
- # * x, y, z enabled: "x, y, z, ... 10x ..., x, y, z"
46
- # * x, z enabled: "x, z, ... 15x ..., x, z"
47
- # * 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
48
50
  CALLBACK_CONTINUOUS_ACCELERATION_16_BIT = 11
49
51
 
50
- # 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
51
53
  # be configured with BrickletAccelerometerV2#set_configuration and this callback can be
52
54
  # enabled with BrickletAccelerometerV2#set_continuous_acceleration_configuration.
53
55
  #
@@ -59,18 +61,18 @@ module Tinkerforge
59
61
  #
60
62
  # Otherwise you have to use the following formulas that depend on the
61
63
  # full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
62
- # the data in g/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
64
+ # the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
63
65
  #
64
- # * Full scale 2G: acceleration = value*256*625/1024
65
- # * Full scale 4G: acceleration = value*256*1250/1024
66
- # * Full scale 8G: acceleration = value*256*2500/1024
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
67
69
  #
68
70
  # The data is formated in the sequence "x, y, z, x, y, z, ..." depending on
69
71
  # the enabled axis. Examples:
70
72
  #
71
- # * x, y, z enabled: "x, y, z, ... 20x ..., x, y, z"
72
- # * x, z enabled: "x, z, ... 30x ..., x, z"
73
- # * 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
74
76
  CALLBACK_CONTINUOUS_ACCELERATION_8_BIT = 12
75
77
 
76
78
  FUNCTION_GET_ACCELERATION = 1 # :nodoc:
@@ -144,7 +146,7 @@ module Tinkerforge
144
146
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
145
147
  # the IP Connection <tt>ipcon</tt>.
146
148
  def initialize(uid, ipcon)
147
- super uid, ipcon
149
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
148
150
 
149
151
  @api_version = [2, 0, 1]
150
152
 
@@ -155,7 +157,7 @@ module Tinkerforge
155
157
  @response_expected[FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
156
158
  @response_expected[FUNCTION_SET_INFO_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
157
159
  @response_expected[FUNCTION_GET_INFO_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
158
- @response_expected[FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
160
+ @response_expected[FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
159
161
  @response_expected[FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
160
162
  @response_expected[FUNCTION_SET_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
161
163
  @response_expected[FUNCTION_GET_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -172,42 +174,48 @@ module Tinkerforge
172
174
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
173
175
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
174
176
 
175
- @callback_formats[CALLBACK_ACCELERATION] = 'l l l'
176
- @callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_16_BIT] = 's30'
177
- @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']
178
180
 
181
+ @ipcon.add_device self
179
182
  end
180
183
 
181
184
  # Returns the acceleration in x, y and z direction. The values
182
- # 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.
183
187
  #
184
188
  # If you want to get the acceleration periodically, it is recommended
185
189
  # to use the CALLBACK_ACCELERATION callback and set the period with
186
190
  # BrickletAccelerometerV2#set_acceleration_callback_configuration.
187
191
  def get_acceleration
188
- send_request FUNCTION_GET_ACCELERATION, [], '', 12, 'l l l'
192
+ check_validity
193
+
194
+ send_request FUNCTION_GET_ACCELERATION, [], '', 20, 'l l l'
189
195
  end
190
196
 
191
197
  # Configures the data rate and full scale range.
192
198
  # Possible values are:
193
199
  #
194
200
  # * Data rate of 0.781Hz to 25600Hz.
195
- # * Full scale range of -2g to +2g up to -8g to +8g.
201
+ # * Full scale range of ±2g up to ±8g.
196
202
  #
197
203
  # Decreasing data rate or full scale range will also decrease the noise on
198
204
  # the data.
199
- #
200
- # The default values are 100Hz data rate and -2g to +2g range.
201
205
  def set_configuration(data_rate, full_scale)
202
- 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, ''
203
209
  end
204
210
 
205
211
  # Returns the configuration as set by BrickletAccelerometerV2#set_configuration.
206
212
  def get_configuration
207
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
213
+ check_validity
214
+
215
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
208
216
  end
209
217
 
210
- # The period in ms is the period with which the CALLBACK_ACCELERATION
218
+ # The period is the period with which the CALLBACK_ACCELERATION
211
219
  # callback is triggered periodically. A value of 0 turns the callback off.
212
220
  #
213
221
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -219,27 +227,33 @@ module Tinkerforge
219
227
  #
220
228
  # If this callback is enabled, the CALLBACK_CONTINUOUS_ACCELERATION_16_BIT callback
221
229
  # and CALLBACK_CONTINUOUS_ACCELERATION_8_BIT callback will automatically be disabled.
222
- #
223
- # The default value is (0, false).
224
230
  def set_acceleration_callback_configuration(period, value_has_to_change)
225
- 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, ''
226
234
  end
227
235
 
228
236
  # Returns the callback configuration as set by
229
237
  # BrickletAccelerometerV2#set_acceleration_callback_configuration.
230
238
  def get_acceleration_callback_configuration
231
- send_request FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
239
+ check_validity
240
+
241
+ send_request FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
232
242
  end
233
243
 
234
244
  # Configures the info LED (marked as "Force" on the Bricklet) to be either turned off,
235
245
  # turned on, or blink in heartbeat mode.
236
246
  def set_info_led_config(config)
237
- 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, ''
238
250
  end
239
251
 
240
252
  # Returns the LED configuration as set by BrickletAccelerometerV2#set_info_led_config
241
253
  def get_info_led_config
242
- send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 1, 'C'
254
+ check_validity
255
+
256
+ send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 9, 'C'
243
257
  end
244
258
 
245
259
  # For high throughput of acceleration data (> 1000Hz) you have to use the
@@ -262,18 +276,18 @@ module Tinkerforge
262
276
  #
263
277
  # Otherwise you have to use the following formulas that depend on the configured
264
278
  # resolution (8/16 bit) and the full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
265
- # the data in g/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
279
+ # the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
266
280
  #
267
- # * 16 bit, full scale 2G: acceleration = value*625/1024
268
- # * 16 bit, full scale 4G: acceleration = value*1250/1024
269
- # * 16 bit, full scale 8G: acceleration = value*2500/1024
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
270
284
  #
271
285
  # If a resolution of 8 bit is used, only the 8 most significant bits will be
272
286
  # transferred, so you can use the following formulas:
273
287
  #
274
- # * 8 bit, full scale 2G: acceleration = value*256*625/1024
275
- # * 8 bit, full scale 4G: acceleration = value*256*1250/1024
276
- # * 8 bit, full scale 8G: acceleration = value*256*2500/1024
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
277
291
  #
278
292
  # If no axis is enabled, both callbacks are disabled. If one of the continuous
279
293
  # callbacks is enabled, the CALLBACK_ACCELERATION callback is disabled.
@@ -286,13 +300,17 @@ module Tinkerforge
286
300
  # "2", "25600Hz", "15000Hz"
287
301
  # "3", "20000Hz", "10000Hz"
288
302
  def set_continuous_acceleration_configuration(enable_x, enable_y, enable_z, resolution)
289
- 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, ''
290
306
  end
291
307
 
292
308
  # Returns the continuous acceleration configuration as set by
293
309
  # BrickletAccelerometerV2#set_continuous_acceleration_configuration.
294
310
  def get_continuous_acceleration_configuration
295
- send_request FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION, [], '', 4, '? ? ? C'
311
+ check_validity
312
+
313
+ send_request FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION, [], '', 12, '? ? ? C'
296
314
  end
297
315
 
298
316
  # Configures IIR Bypass filter mode and low pass filter roll off corner frequency.
@@ -306,18 +324,20 @@ module Tinkerforge
306
324
  # :align: center
307
325
  # :target: ../../_images/Bricklets/bricklet_accelerometer_v2_filter.png
308
326
  #
309
- # By default filtering is applied and the filter corner frequency is a ninth of the output data rate.
310
- #
311
327
  # .. versionadded:: 2.0.2$nbsp;(Plugin)
312
328
  def set_filter_configuration(iir_bypass, low_pass_filter)
313
- send_request FUNCTION_SET_FILTER_CONFIGURATION, [iir_bypass, low_pass_filter], 'C C', 0, ''
329
+ check_validity
330
+
331
+ send_request FUNCTION_SET_FILTER_CONFIGURATION, [iir_bypass, low_pass_filter], 'C C', 8, ''
314
332
  end
315
333
 
316
334
  # Returns the configuration as set by BrickletAccelerometerV2#set_filter_configuration.
317
335
  #
318
336
  # .. versionadded:: 2.0.2$nbsp;(Plugin)
319
337
  def get_filter_configuration
320
- send_request FUNCTION_GET_FILTER_CONFIGURATION, [], '', 2, 'C C'
338
+ check_validity
339
+
340
+ send_request FUNCTION_GET_FILTER_CONFIGURATION, [], '', 10, 'C C'
321
341
  end
322
342
 
323
343
  # Returns the error count for the communication between Brick and Bricklet.
@@ -332,7 +352,9 @@ module Tinkerforge
332
352
  # The errors counts are for errors that occur on the Bricklet side. All
333
353
  # Bricks have a similar function that returns the errors on the Brick side.
334
354
  def get_spitfp_error_count
335
- 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'
336
358
  end
337
359
 
338
360
  # Sets the bootloader mode and returns the status after the requested
@@ -345,12 +367,16 @@ module Tinkerforge
345
367
  # This function is used by Brick Viewer during flashing. It should not be
346
368
  # necessary to call it in a normal user program.
347
369
  def set_bootloader_mode(mode)
348
- 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'
349
373
  end
350
374
 
351
375
  # Returns the current bootloader mode, see BrickletAccelerometerV2#set_bootloader_mode.
352
376
  def get_bootloader_mode
353
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
377
+ check_validity
378
+
379
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
354
380
  end
355
381
 
356
382
  # Sets the firmware pointer for BrickletAccelerometerV2#write_firmware. The pointer has
@@ -360,7 +386,9 @@ module Tinkerforge
360
386
  # This function is used by Brick Viewer during flashing. It should not be
361
387
  # necessary to call it in a normal user program.
362
388
  def set_write_firmware_pointer(pointer)
363
- 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, ''
364
392
  end
365
393
 
366
394
  # Writes 64 Bytes of firmware at the position as written by
@@ -372,7 +400,9 @@ module Tinkerforge
372
400
  # This function is used by Brick Viewer during flashing. It should not be
373
401
  # necessary to call it in a normal user program.
374
402
  def write_firmware(data)
375
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
403
+ check_validity
404
+
405
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
376
406
  end
377
407
 
378
408
  # Sets the status LED configuration. By default the LED shows
@@ -383,22 +413,28 @@ module Tinkerforge
383
413
  #
384
414
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
385
415
  def set_status_led_config(config)
386
- 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, ''
387
419
  end
388
420
 
389
421
  # Returns the configuration as set by BrickletAccelerometerV2#set_status_led_config
390
422
  def get_status_led_config
391
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
423
+ check_validity
424
+
425
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
392
426
  end
393
427
 
394
- # Returns the temperature in °C as measured inside the microcontroller. The
428
+ # Returns the temperature as measured inside the microcontroller. The
395
429
  # value returned is not the ambient temperature!
396
430
  #
397
431
  # The temperature is only proportional to the real temperature and it has bad
398
432
  # accuracy. Practically it is only useful as an indicator for
399
433
  # temperature changes.
400
434
  def get_chip_temperature
401
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
435
+ check_validity
436
+
437
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
402
438
  end
403
439
 
404
440
  # Calling this function will reset the Bricklet. All configurations
@@ -408,7 +444,9 @@ module Tinkerforge
408
444
  # calling functions on the existing ones will result in
409
445
  # undefined behavior!
410
446
  def reset
411
- send_request FUNCTION_RESET, [], '', 0, ''
447
+ check_validity
448
+
449
+ send_request FUNCTION_RESET, [], '', 8, ''
412
450
  end
413
451
 
414
452
  # Writes a new UID into flash. If you want to set a new UID
@@ -417,25 +455,31 @@ module Tinkerforge
417
455
  #
418
456
  # We recommend that you use Brick Viewer to change the UID.
419
457
  def write_uid(uid)
420
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
458
+ check_validity
459
+
460
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
421
461
  end
422
462
 
423
463
  # Returns the current UID as an integer. Encode as
424
464
  # Base58 to get the usual string version.
425
465
  def read_uid
426
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
466
+ check_validity
467
+
468
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
427
469
  end
428
470
 
429
471
  # Returns the UID, the UID where the Bricklet is connected to,
430
472
  # the position, the hardware and firmware version as well as the
431
473
  # device identifier.
432
474
  #
433
- # 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'.
434
478
  #
435
479
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
436
480
  # |device_identifier_constant|
437
481
  def get_identity
438
- 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'
439
483
  end
440
484
 
441
485
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.