tinkerforge 2.1.24 → 2.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +155 -74
  3. data/lib/tinkerforge/brick_hat.rb +70 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +56 -22
  5. data/lib/tinkerforge/brick_imu.rb +184 -77
  6. data/lib/tinkerforge/brick_imu_v2.rb +208 -105
  7. data/lib/tinkerforge/brick_master.rb +484 -182
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +185 -101
  10. data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
  11. data/lib/tinkerforge/brick_stepper.rb +210 -98
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
  18. data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +66 -26
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -18
  27. data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +34 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
  30. data/lib/tinkerforge/bricklet_color.rb +69 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +78 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +58 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +58 -24
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
  37. data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
  39. data/lib/tinkerforge/bricklet_dmx.rb +88 -34
  40. data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
  46. data/lib/tinkerforge/bricklet_gps.rb +64 -26
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
  50. data/lib/tinkerforge/bricklet_humidity.rb +51 -21
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
  52. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
  53. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
  54. data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
  55. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
  57. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
  59. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
  62. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
  64. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
  65. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
  66. data/lib/tinkerforge/bricklet_io16.rb +55 -21
  67. data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
  68. data/lib/tinkerforge/bricklet_io4.rb +55 -23
  69. data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
  70. data/lib/tinkerforge/bricklet_isolator.rb +72 -28
  71. data/lib/tinkerforge/bricklet_joystick.rb +59 -25
  72. data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
  73. data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
  74. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
  75. data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
  76. data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
  77. data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
  78. data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
  79. data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
  80. data/lib/tinkerforge/bricklet_line.rb +34 -14
  81. data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
  82. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
  83. data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
  84. data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
  85. data/lib/tinkerforge/bricklet_moisture.rb +40 -16
  86. data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
  87. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
  88. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
  89. data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
  90. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
  91. data/lib/tinkerforge/bricklet_nfc.rb +123 -58
  92. data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
  93. data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
  94. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
  95. data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
  96. data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
  97. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
  98. data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
  99. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
  100. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
  101. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
  102. data/lib/tinkerforge/bricklet_ptc.rb +74 -42
  103. data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
  104. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
  105. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
  106. data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
  107. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
  108. data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
  109. data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
  110. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
  111. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
  112. data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
  113. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
  114. data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
  115. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
  116. data/lib/tinkerforge/bricklet_rs232.rb +90 -28
  117. data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
  118. data/lib/tinkerforge/bricklet_rs485.rb +223 -95
  119. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
  120. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
  121. data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
  122. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
  123. data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
  124. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
  125. data/lib/tinkerforge/bricklet_temperature.rb +40 -16
  126. data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
  127. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
  128. data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
  129. data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
  130. data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
  131. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
  132. data/lib/tinkerforge/bricklet_tilt.rb +24 -10
  133. data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
  134. data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
  135. data/lib/tinkerforge/bricklet_voltage.rb +52 -28
  136. data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
  137. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
  138. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
  139. data/lib/tinkerforge/device_display_names.rb +163 -0
  140. data/lib/tinkerforge/ip_connection.rb +151 -32
  141. data/lib/tinkerforge/version.rb +1 -1
  142. metadata +3 -2
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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
  # 59mm linear potentiometer
14
16
  class BrickletLinearPotiV2 < Device
@@ -61,7 +63,7 @@ module Tinkerforge
61
63
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
62
64
  # the IP Connection <tt>ipcon</tt>.
63
65
  def initialize(uid, ipcon)
64
- super uid, ipcon
66
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
65
67
 
66
68
  @api_version = [2, 0, 0]
67
69
 
@@ -81,8 +83,9 @@ module Tinkerforge
81
83
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
84
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
85
 
84
- @callback_formats[CALLBACK_POSITION] = 'C'
86
+ @callback_formats[CALLBACK_POSITION] = [9, 'C']
85
87
 
88
+ @ipcon.add_device self
86
89
  end
87
90
 
88
91
  # Returns the position of the linear potentiometer. The value is
@@ -93,7 +96,9 @@ module Tinkerforge
93
96
  # CALLBACK_POSITION callback. You can set the callback configuration
94
97
  # with BrickletLinearPotiV2#set_position_callback_configuration.
95
98
  def get_position
96
- send_request FUNCTION_GET_POSITION, [], '', 1, 'C'
99
+ check_validity
100
+
101
+ send_request FUNCTION_GET_POSITION, [], '', 9, 'C'
97
102
  end
98
103
 
99
104
  # The period is the period with which the CALLBACK_POSITION callback is triggered
@@ -122,12 +127,16 @@ module Tinkerforge
122
127
  #
123
128
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
124
129
  def set_position_callback_configuration(period, value_has_to_change, option, min, max)
125
- send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k C C', 0, ''
130
+ check_validity
131
+
132
+ send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k C C', 8, ''
126
133
  end
127
134
 
128
135
  # Returns the callback configuration as set by BrickletLinearPotiV2#set_position_callback_configuration.
129
136
  def get_position_callback_configuration
130
- send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 8, 'L ? k C C'
137
+ check_validity
138
+
139
+ send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 16, 'L ? k C C'
131
140
  end
132
141
 
133
142
  # Returns the error count for the communication between Brick and Bricklet.
@@ -142,7 +151,9 @@ module Tinkerforge
142
151
  # The errors counts are for errors that occur on the Bricklet side. All
143
152
  # Bricks have a similar function that returns the errors on the Brick side.
144
153
  def get_spitfp_error_count
145
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
154
+ check_validity
155
+
156
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
146
157
  end
147
158
 
148
159
  # Sets the bootloader mode and returns the status after the requested
@@ -155,12 +166,16 @@ module Tinkerforge
155
166
  # This function is used by Brick Viewer during flashing. It should not be
156
167
  # necessary to call it in a normal user program.
157
168
  def set_bootloader_mode(mode)
158
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
169
+ check_validity
170
+
171
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
159
172
  end
160
173
 
161
174
  # Returns the current bootloader mode, see BrickletLinearPotiV2#set_bootloader_mode.
162
175
  def get_bootloader_mode
163
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
176
+ check_validity
177
+
178
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
164
179
  end
165
180
 
166
181
  # Sets the firmware pointer for BrickletLinearPotiV2#write_firmware. The pointer has
@@ -170,7 +185,9 @@ module Tinkerforge
170
185
  # This function is used by Brick Viewer during flashing. It should not be
171
186
  # necessary to call it in a normal user program.
172
187
  def set_write_firmware_pointer(pointer)
173
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
188
+ check_validity
189
+
190
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
174
191
  end
175
192
 
176
193
  # Writes 64 Bytes of firmware at the position as written by
@@ -182,7 +199,9 @@ module Tinkerforge
182
199
  # This function is used by Brick Viewer during flashing. It should not be
183
200
  # necessary to call it in a normal user program.
184
201
  def write_firmware(data)
185
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
202
+ check_validity
203
+
204
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
186
205
  end
187
206
 
188
207
  # Sets the status LED configuration. By default the LED shows
@@ -193,22 +212,28 @@ module Tinkerforge
193
212
  #
194
213
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
195
214
  def set_status_led_config(config)
196
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
215
+ check_validity
216
+
217
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
197
218
  end
198
219
 
199
220
  # Returns the configuration as set by BrickletLinearPotiV2#set_status_led_config
200
221
  def get_status_led_config
201
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
222
+ check_validity
223
+
224
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
202
225
  end
203
226
 
204
- # Returns the temperature in °C as measured inside the microcontroller. The
227
+ # Returns the temperature as measured inside the microcontroller. The
205
228
  # value returned is not the ambient temperature!
206
229
  #
207
230
  # The temperature is only proportional to the real temperature and it has bad
208
231
  # accuracy. Practically it is only useful as an indicator for
209
232
  # temperature changes.
210
233
  def get_chip_temperature
211
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
234
+ check_validity
235
+
236
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
212
237
  end
213
238
 
214
239
  # Calling this function will reset the Bricklet. All configurations
@@ -218,7 +243,9 @@ module Tinkerforge
218
243
  # calling functions on the existing ones will result in
219
244
  # undefined behavior!
220
245
  def reset
221
- send_request FUNCTION_RESET, [], '', 0, ''
246
+ check_validity
247
+
248
+ send_request FUNCTION_RESET, [], '', 8, ''
222
249
  end
223
250
 
224
251
  # Writes a new UID into flash. If you want to set a new UID
@@ -227,25 +254,32 @@ module Tinkerforge
227
254
  #
228
255
  # We recommend that you use Brick Viewer to change the UID.
229
256
  def write_uid(uid)
230
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
257
+ check_validity
258
+
259
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
231
260
  end
232
261
 
233
262
  # Returns the current UID as an integer. Encode as
234
263
  # Base58 to get the usual string version.
235
264
  def read_uid
236
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
265
+ check_validity
266
+
267
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
237
268
  end
238
269
 
239
270
  # Returns the UID, the UID where the Bricklet is connected to,
240
271
  # the position, the hardware and firmware version as well as the
241
272
  # device identifier.
242
273
  #
243
- # The position can be 'a', 'b', 'c' or 'd'.
274
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
275
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
276
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
277
+ # position 'z'.
244
278
  #
245
279
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
246
280
  # |device_identifier_constant|
247
281
  def get_identity
248
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
282
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
249
283
  end
250
284
 
251
285
  # 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-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 weight with a load cell
14
16
  class BrickletLoadCell < Device
@@ -63,7 +65,7 @@ module Tinkerforge
63
65
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
64
66
  # the IP Connection <tt>ipcon</tt>.
65
67
  def initialize(uid, ipcon)
66
- super uid, ipcon
68
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
67
69
 
68
70
  @api_version = [2, 0, 0]
69
71
 
@@ -85,9 +87,10 @@ module Tinkerforge
85
87
  @response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
88
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
87
89
 
88
- @callback_formats[CALLBACK_WEIGHT] = 'l'
89
- @callback_formats[CALLBACK_WEIGHT_REACHED] = 'l'
90
+ @callback_formats[CALLBACK_WEIGHT] = [12, 'l']
91
+ @callback_formats[CALLBACK_WEIGHT_REACHED] = [12, 'l']
90
92
 
93
+ @ipcon.add_device self
91
94
  end
92
95
 
93
96
  # Returns the currently measured weight.
@@ -96,7 +99,9 @@ module Tinkerforge
96
99
  # to use the CALLBACK_WEIGHT callback and set the period with
97
100
  # BrickletLoadCell#set_weight_callback_period.
98
101
  def get_weight
99
- send_request FUNCTION_GET_WEIGHT, [], '', 4, 'l'
102
+ check_validity
103
+
104
+ send_request FUNCTION_GET_WEIGHT, [], '', 12, 'l'
100
105
  end
101
106
 
102
107
  # Sets the period with which the CALLBACK_WEIGHT callback is triggered
@@ -105,12 +110,16 @@ module Tinkerforge
105
110
  # The CALLBACK_WEIGHT callback is only triggered if the weight has changed since the
106
111
  # last triggering.
107
112
  def set_weight_callback_period(period)
108
- send_request FUNCTION_SET_WEIGHT_CALLBACK_PERIOD, [period], 'L', 0, ''
113
+ check_validity
114
+
115
+ send_request FUNCTION_SET_WEIGHT_CALLBACK_PERIOD, [period], 'L', 8, ''
109
116
  end
110
117
 
111
118
  # Returns the period as set by BrickletLoadCell#set_weight_callback_period.
112
119
  def get_weight_callback_period
113
- send_request FUNCTION_GET_WEIGHT_CALLBACK_PERIOD, [], '', 4, 'L'
120
+ check_validity
121
+
122
+ send_request FUNCTION_GET_WEIGHT_CALLBACK_PERIOD, [], '', 12, 'L'
114
123
  end
115
124
 
116
125
  # Sets the thresholds for the CALLBACK_WEIGHT_REACHED callback.
@@ -125,12 +134,16 @@ module Tinkerforge
125
134
  # "'<'", "Callback is triggered when the weight is smaller than the min value (max is ignored)"
126
135
  # "'>'", "Callback is triggered when the weight is greater than the min value (max is ignored)"
127
136
  def set_weight_callback_threshold(option, min, max)
128
- send_request FUNCTION_SET_WEIGHT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, ''
137
+ check_validity
138
+
139
+ send_request FUNCTION_SET_WEIGHT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
129
140
  end
130
141
 
131
142
  # Returns the threshold as set by BrickletLoadCell#set_weight_callback_threshold.
132
143
  def get_weight_callback_threshold
133
- send_request FUNCTION_GET_WEIGHT_CALLBACK_THRESHOLD, [], '', 9, 'k l l'
144
+ check_validity
145
+
146
+ send_request FUNCTION_GET_WEIGHT_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
134
147
  end
135
148
 
136
149
  # Sets the period with which the threshold callback
@@ -143,12 +156,16 @@ module Tinkerforge
143
156
  #
144
157
  # keeps being reached.
145
158
  def set_debounce_period(debounce)
146
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
159
+ check_validity
160
+
161
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
147
162
  end
148
163
 
149
164
  # Returns the debounce period as set by BrickletLoadCell#set_debounce_period.
150
165
  def get_debounce_period
151
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
166
+ check_validity
167
+
168
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
152
169
  end
153
170
 
154
171
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -157,27 +174,37 @@ module Tinkerforge
157
174
  # Setting the length to 1 will turn the averaging off. With less
158
175
  # averaging, there is more noise on the data.
159
176
  def set_moving_average(average)
160
- send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 0, ''
177
+ check_validity
178
+
179
+ send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 8, ''
161
180
  end
162
181
 
163
182
  # Returns the length moving average as set by BrickletLoadCell#set_moving_average.
164
183
  def get_moving_average
165
- send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 1, 'C'
184
+ check_validity
185
+
186
+ send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 9, 'C'
166
187
  end
167
188
 
168
189
  # Turns the LED on.
169
190
  def led_on
170
- send_request FUNCTION_LED_ON, [], '', 0, ''
191
+ check_validity
192
+
193
+ send_request FUNCTION_LED_ON, [], '', 8, ''
171
194
  end
172
195
 
173
196
  # Turns the LED off.
174
197
  def led_off
175
- send_request FUNCTION_LED_OFF, [], '', 0, ''
198
+ check_validity
199
+
200
+ send_request FUNCTION_LED_OFF, [], '', 8, ''
176
201
  end
177
202
 
178
203
  # Returns *true* if the led is on, *false* otherwise.
179
204
  def is_led_on
180
- send_request FUNCTION_IS_LED_ON, [], '', 1, '?'
205
+ check_validity
206
+
207
+ send_request FUNCTION_IS_LED_ON, [], '', 9, '?'
181
208
  end
182
209
 
183
210
  # To calibrate your Load Cell Bricklet you have to
@@ -191,12 +218,16 @@ module Tinkerforge
191
218
  # We recommend to use the Brick Viewer for calibration, you don't need
192
219
  # to call this function in your source code.
193
220
  def calibrate(weight)
194
- send_request FUNCTION_CALIBRATE, [weight], 'L', 0, ''
221
+ check_validity
222
+
223
+ send_request FUNCTION_CALIBRATE, [weight], 'L', 8, ''
195
224
  end
196
225
 
197
226
  # Sets the currently measured weight as tare weight.
198
227
  def tare
199
- send_request FUNCTION_TARE, [], '', 0, ''
228
+ check_validity
229
+
230
+ send_request FUNCTION_TARE, [], '', 8, ''
200
231
  end
201
232
 
202
233
  # The measurement rate and gain are configurable.
@@ -218,24 +249,31 @@ module Tinkerforge
218
249
  # We recommend to use the Brick Viewer for configuration, you don't need
219
250
  # to call this function in your source code.
220
251
  def set_configuration(rate, gain)
221
- send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 0, ''
252
+ check_validity
253
+
254
+ send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 8, ''
222
255
  end
223
256
 
224
257
  # Returns the configuration as set by BrickletLoadCell#set_configuration.
225
258
  def get_configuration
226
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
259
+ check_validity
260
+
261
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
227
262
  end
228
263
 
229
264
  # Returns the UID, the UID where the Bricklet is connected to,
230
265
  # the position, the hardware and firmware version as well as the
231
266
  # device identifier.
232
267
  #
233
- # The position can be 'a', 'b', 'c' or 'd'.
268
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
269
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
270
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
271
+ # position 'z'.
234
272
  #
235
273
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
236
274
  # |device_identifier_constant|
237
275
  def get_identity
238
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
276
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
239
277
  end
240
278
 
241
279
  # 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-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 weight with a load cell
14
16
  class BrickletLoadCellV2 < Device
@@ -77,7 +79,7 @@ module Tinkerforge
77
79
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
78
80
  # the IP Connection <tt>ipcon</tt>.
79
81
  def initialize(uid, ipcon)
80
- super uid, ipcon
82
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
81
83
 
82
84
  @api_version = [2, 0, 0]
83
85
 
@@ -105,18 +107,21 @@ module Tinkerforge
105
107
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
106
108
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
107
109
 
108
- @callback_formats[CALLBACK_WEIGHT] = 'l'
110
+ @callback_formats[CALLBACK_WEIGHT] = [12, 'l']
109
111
 
112
+ @ipcon.add_device self
110
113
  end
111
114
 
112
- # Returns the currently measured weight in grams.
115
+ # Returns the currently measured weight.
113
116
  #
114
117
  #
115
118
  # If you want to get the value periodically, it is recommended to use the
116
119
  # CALLBACK_WEIGHT callback. You can set the callback configuration
117
120
  # with BrickletLoadCellV2#set_weight_callback_configuration.
118
121
  def get_weight
119
- send_request FUNCTION_GET_WEIGHT, [], '', 4, 'l'
122
+ check_validity
123
+
124
+ send_request FUNCTION_GET_WEIGHT, [], '', 12, 'l'
120
125
  end
121
126
 
122
127
  # The period is the period with which the CALLBACK_WEIGHT callback is triggered
@@ -145,12 +150,16 @@ module Tinkerforge
145
150
  #
146
151
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
147
152
  def set_weight_callback_configuration(period, value_has_to_change, option, min, max)
148
- send_request FUNCTION_SET_WEIGHT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
153
+ check_validity
154
+
155
+ send_request FUNCTION_SET_WEIGHT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
149
156
  end
150
157
 
151
158
  # Returns the callback configuration as set by BrickletLoadCellV2#set_weight_callback_configuration.
152
159
  def get_weight_callback_configuration
153
- send_request FUNCTION_GET_WEIGHT_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
160
+ check_validity
161
+
162
+ send_request FUNCTION_GET_WEIGHT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
154
163
  end
155
164
 
156
165
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -159,23 +168,31 @@ module Tinkerforge
159
168
  # Setting the length to 1 will turn the averaging off. With less
160
169
  # averaging, there is more noise on the data.
161
170
  def set_moving_average(average)
162
- send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'S', 0, ''
171
+ check_validity
172
+
173
+ send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'S', 8, ''
163
174
  end
164
175
 
165
176
  # Returns the length moving average as set by BrickletLoadCellV2#set_moving_average.
166
177
  def get_moving_average
167
- send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 2, 'S'
178
+ check_validity
179
+
180
+ send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 10, 'S'
168
181
  end
169
182
 
170
183
  # Configures the info LED to be either turned off, turned on, or blink in
171
184
  # heartbeat mode.
172
185
  def set_info_led_config(config)
173
- send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 0, ''
186
+ check_validity
187
+
188
+ send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 8, ''
174
189
  end
175
190
 
176
191
  # Returns the LED configuration as set by BrickletLoadCellV2#set_info_led_config
177
192
  def get_info_led_config
178
- send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 1, 'C'
193
+ check_validity
194
+
195
+ send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 9, 'C'
179
196
  end
180
197
 
181
198
  # To calibrate your Load Cell Bricklet 2.0 you have to
@@ -189,12 +206,16 @@ module Tinkerforge
189
206
  # We recommend to use the Brick Viewer for calibration, you don't need
190
207
  # to call this function in your source code.
191
208
  def calibrate(weight)
192
- send_request FUNCTION_CALIBRATE, [weight], 'L', 0, ''
209
+ check_validity
210
+
211
+ send_request FUNCTION_CALIBRATE, [weight], 'L', 8, ''
193
212
  end
194
213
 
195
214
  # Sets the currently measured weight as tare weight.
196
215
  def tare
197
- send_request FUNCTION_TARE, [], '', 0, ''
216
+ check_validity
217
+
218
+ send_request FUNCTION_TARE, [], '', 8, ''
198
219
  end
199
220
 
200
221
  # The measurement rate and gain are configurable.
@@ -210,12 +231,16 @@ module Tinkerforge
210
231
  # is best). If you don't know what all of this means you should keep it at
211
232
  # 128x, it will most likely be correct.
212
233
  def set_configuration(rate, gain)
213
- send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 0, ''
234
+ check_validity
235
+
236
+ send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 8, ''
214
237
  end
215
238
 
216
239
  # Returns the configuration as set by BrickletLoadCellV2#set_configuration.
217
240
  def get_configuration
218
- send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C C'
241
+ check_validity
242
+
243
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
219
244
  end
220
245
 
221
246
  # Returns the error count for the communication between Brick and Bricklet.
@@ -230,7 +255,9 @@ module Tinkerforge
230
255
  # The errors counts are for errors that occur on the Bricklet side. All
231
256
  # Bricks have a similar function that returns the errors on the Brick side.
232
257
  def get_spitfp_error_count
233
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
258
+ check_validity
259
+
260
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
234
261
  end
235
262
 
236
263
  # Sets the bootloader mode and returns the status after the requested
@@ -243,12 +270,16 @@ module Tinkerforge
243
270
  # This function is used by Brick Viewer during flashing. It should not be
244
271
  # necessary to call it in a normal user program.
245
272
  def set_bootloader_mode(mode)
246
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
273
+ check_validity
274
+
275
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
247
276
  end
248
277
 
249
278
  # Returns the current bootloader mode, see BrickletLoadCellV2#set_bootloader_mode.
250
279
  def get_bootloader_mode
251
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
280
+ check_validity
281
+
282
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
252
283
  end
253
284
 
254
285
  # Sets the firmware pointer for BrickletLoadCellV2#write_firmware. The pointer has
@@ -258,7 +289,9 @@ module Tinkerforge
258
289
  # This function is used by Brick Viewer during flashing. It should not be
259
290
  # necessary to call it in a normal user program.
260
291
  def set_write_firmware_pointer(pointer)
261
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
292
+ check_validity
293
+
294
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
262
295
  end
263
296
 
264
297
  # Writes 64 Bytes of firmware at the position as written by
@@ -270,7 +303,9 @@ module Tinkerforge
270
303
  # This function is used by Brick Viewer during flashing. It should not be
271
304
  # necessary to call it in a normal user program.
272
305
  def write_firmware(data)
273
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
306
+ check_validity
307
+
308
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
274
309
  end
275
310
 
276
311
  # Sets the status LED configuration. By default the LED shows
@@ -281,22 +316,28 @@ module Tinkerforge
281
316
  #
282
317
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
283
318
  def set_status_led_config(config)
284
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
319
+ check_validity
320
+
321
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
285
322
  end
286
323
 
287
324
  # Returns the configuration as set by BrickletLoadCellV2#set_status_led_config
288
325
  def get_status_led_config
289
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
326
+ check_validity
327
+
328
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
290
329
  end
291
330
 
292
- # Returns the temperature in °C as measured inside the microcontroller. The
331
+ # Returns the temperature as measured inside the microcontroller. The
293
332
  # value returned is not the ambient temperature!
294
333
  #
295
334
  # The temperature is only proportional to the real temperature and it has bad
296
335
  # accuracy. Practically it is only useful as an indicator for
297
336
  # temperature changes.
298
337
  def get_chip_temperature
299
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
338
+ check_validity
339
+
340
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
300
341
  end
301
342
 
302
343
  # Calling this function will reset the Bricklet. All configurations
@@ -306,7 +347,9 @@ module Tinkerforge
306
347
  # calling functions on the existing ones will result in
307
348
  # undefined behavior!
308
349
  def reset
309
- send_request FUNCTION_RESET, [], '', 0, ''
350
+ check_validity
351
+
352
+ send_request FUNCTION_RESET, [], '', 8, ''
310
353
  end
311
354
 
312
355
  # Writes a new UID into flash. If you want to set a new UID
@@ -315,25 +358,32 @@ module Tinkerforge
315
358
  #
316
359
  # We recommend that you use Brick Viewer to change the UID.
317
360
  def write_uid(uid)
318
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
361
+ check_validity
362
+
363
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
319
364
  end
320
365
 
321
366
  # Returns the current UID as an integer. Encode as
322
367
  # Base58 to get the usual string version.
323
368
  def read_uid
324
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
369
+ check_validity
370
+
371
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
325
372
  end
326
373
 
327
374
  # Returns the UID, the UID where the Bricklet is connected to,
328
375
  # the position, the hardware and firmware version as well as the
329
376
  # device identifier.
330
377
  #
331
- # 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
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
380
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
381
+ # position 'z'.
332
382
  #
333
383
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
334
384
  # |device_identifier_constant|
335
385
  def get_identity
336
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
386
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
337
387
  end
338
388
 
339
389
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.