tinkerforge 2.1.27 → 2.1.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +2 -2
  3. data/lib/tinkerforge/brick_esp32.rb +49 -0
  4. data/lib/tinkerforge/brick_esp32_ethernet.rb +49 -0
  5. data/lib/tinkerforge/brick_hat.rb +33 -3
  6. data/lib/tinkerforge/brick_hat_zero.rb +2 -2
  7. data/lib/tinkerforge/brick_imu.rb +2 -2
  8. data/lib/tinkerforge/brick_imu_v2.rb +2 -2
  9. data/lib/tinkerforge/brick_master.rb +4 -4
  10. data/lib/tinkerforge/brick_red.rb +2 -2
  11. data/lib/tinkerforge/brick_servo.rb +2 -2
  12. data/lib/tinkerforge/brick_silent_stepper.rb +2 -2
  13. data/lib/tinkerforge/brick_stepper.rb +2 -2
  14. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  15. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +2 -2
  16. data/lib/tinkerforge/bricklet_air_quality.rb +2 -2
  17. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  18. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +7 -4
  19. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +7 -4
  20. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  21. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  22. data/lib/tinkerforge/bricklet_analog_in_v3.rb +2 -2
  23. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  24. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  25. data/lib/tinkerforge/bricklet_analog_out_v3.rb +2 -2
  26. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  27. data/lib/tinkerforge/bricklet_barometer_v2.rb +2 -2
  28. data/lib/tinkerforge/bricklet_can.rb +2 -2
  29. data/lib/tinkerforge/bricklet_can_v2.rb +2 -2
  30. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  31. data/lib/tinkerforge/bricklet_co2_v2.rb +2 -2
  32. data/lib/tinkerforge/bricklet_color.rb +2 -2
  33. data/lib/tinkerforge/bricklet_color_v2.rb +2 -2
  34. data/lib/tinkerforge/bricklet_compass.rb +2 -2
  35. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  36. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  37. data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
  38. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  39. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +2 -2
  40. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  41. data/lib/tinkerforge/bricklet_distance_us_v2.rb +2 -2
  42. data/lib/tinkerforge/bricklet_dmx.rb +3 -3
  43. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  44. data/lib/tinkerforge/bricklet_dual_button_v2.rb +2 -2
  45. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  46. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  47. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +32 -3
  48. data/lib/tinkerforge/bricklet_energy_monitor.rb +2 -2
  49. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  50. data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
  51. data/lib/tinkerforge/bricklet_gps_v3.rb +593 -0
  52. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  53. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +2 -2
  54. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  55. data/lib/tinkerforge/bricklet_humidity_v2.rb +2 -2
  56. data/lib/tinkerforge/bricklet_imu_v3.rb +2 -2
  57. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  58. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +2 -2
  59. data/lib/tinkerforge/bricklet_industrial_counter.rb +2 -2
  60. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  61. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +2 -2
  62. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  63. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +2 -2
  64. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  65. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +2 -2
  66. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +2 -2
  67. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  68. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +2 -2
  69. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +2 -2
  70. data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
  71. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  72. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +2 -2
  73. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  74. data/lib/tinkerforge/bricklet_io16_v2.rb +2 -2
  75. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  76. data/lib/tinkerforge/bricklet_io4_v2.rb +2 -2
  77. data/lib/tinkerforge/bricklet_isolator.rb +2 -2
  78. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  79. data/lib/tinkerforge/bricklet_joystick_v2.rb +2 -2
  80. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  81. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +2 -2
  82. data/lib/tinkerforge/bricklet_lcd_128x64.rb +4 -2
  83. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  84. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  85. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  86. data/lib/tinkerforge/bricklet_led_strip_v2.rb +2 -2
  87. data/lib/tinkerforge/bricklet_line.rb +2 -2
  88. data/lib/tinkerforge/bricklet_linear_poti.rb +3 -3
  89. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +3 -3
  90. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  91. data/lib/tinkerforge/bricklet_load_cell_v2.rb +2 -2
  92. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  93. data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
  94. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -5
  95. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
  96. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  97. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +2 -2
  98. data/lib/tinkerforge/bricklet_nfc.rb +21 -3
  99. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  100. data/lib/tinkerforge/bricklet_oled_128x64.rb +4 -2
  101. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +4 -2
  102. data/lib/tinkerforge/bricklet_oled_64x48.rb +4 -2
  103. data/lib/tinkerforge/bricklet_one_wire.rb +2 -2
  104. data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
  105. data/lib/tinkerforge/bricklet_particulate_matter.rb +2 -2
  106. data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
  107. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  108. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  109. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +2 -2
  110. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  111. data/lib/tinkerforge/bricklet_ptc_v2.rb +2 -2
  112. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  113. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +2 -2
  114. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  115. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
  116. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  117. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  118. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  119. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +2 -2
  120. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  121. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +2 -2
  122. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  123. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +2 -2
  124. data/lib/tinkerforge/bricklet_rs232.rb +2 -2
  125. data/lib/tinkerforge/bricklet_rs232_v2.rb +2 -2
  126. data/lib/tinkerforge/bricklet_rs485.rb +2 -2
  127. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  128. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +2 -2
  129. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  130. data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
  131. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  132. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +2 -2
  133. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  134. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +2 -2
  135. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  136. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  137. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +2 -2
  138. data/lib/tinkerforge/bricklet_temperature_v2.rb +2 -2
  139. data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
  140. data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
  141. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +2 -2
  142. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  143. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  144. data/lib/tinkerforge/bricklet_uv_light_v2.rb +2 -2
  145. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  146. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  147. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +2 -2
  148. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +2 -2
  149. data/lib/tinkerforge/device_display_names.rb +11 -3
  150. data/lib/tinkerforge/ip_connection.rb +2 -1
  151. data/lib/tinkerforge/version.rb +1 -1
  152. metadata +10 -2
@@ -0,0 +1,565 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2022-05-11. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.30 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ require_relative './ip_connection'
13
+
14
+ module Tinkerforge
15
+ # Drives up to 10 RC Servos
16
+ class BrickletServoV2 < Device
17
+ DEVICE_IDENTIFIER = 2157 # :nodoc:
18
+ DEVICE_DISPLAY_NAME = 'Servo Bricklet 2.0' # :nodoc:
19
+
20
+ # This callback is triggered when a position set by BrickletServoV2#set_position
21
+ # is reached. If the new position matches the current position then the
22
+ # callback is not triggered, because the servo didn't move.
23
+ # The parameters are the servo and the position that is reached.
24
+ #
25
+ # You can enable this callback with BrickletServoV2#set_position_reached_callback_configuration.
26
+ #
27
+ # .. note::
28
+ # Since we can't get any feedback from the servo, this only works if the
29
+ # velocity (see BrickletServoV2#set_motion_configuration) is set smaller or equal to the
30
+ # maximum velocity of the servo. Otherwise the servo will lag behind the
31
+ # control value and the callback will be triggered too early.
32
+ CALLBACK_POSITION_REACHED = 27
33
+
34
+ FUNCTION_GET_STATUS = 1 # :nodoc:
35
+ FUNCTION_SET_ENABLE = 2 # :nodoc:
36
+ FUNCTION_GET_ENABLED = 3 # :nodoc:
37
+ FUNCTION_SET_POSITION = 4 # :nodoc:
38
+ FUNCTION_GET_POSITION = 5 # :nodoc:
39
+ FUNCTION_GET_CURRENT_POSITION = 6 # :nodoc:
40
+ FUNCTION_GET_CURRENT_VELOCITY = 7 # :nodoc:
41
+ FUNCTION_SET_MOTION_CONFIGURATION = 8 # :nodoc:
42
+ FUNCTION_GET_MOTION_CONFIGURATION = 9 # :nodoc:
43
+ FUNCTION_SET_PULSE_WIDTH = 10 # :nodoc:
44
+ FUNCTION_GET_PULSE_WIDTH = 11 # :nodoc:
45
+ FUNCTION_SET_DEGREE = 12 # :nodoc:
46
+ FUNCTION_GET_DEGREE = 13 # :nodoc:
47
+ FUNCTION_SET_PERIOD = 14 # :nodoc:
48
+ FUNCTION_GET_PERIOD = 15 # :nodoc:
49
+ FUNCTION_GET_SERVO_CURRENT = 16 # :nodoc:
50
+ FUNCTION_SET_SERVO_CURRENT_CONFIGURATION = 17 # :nodoc:
51
+ FUNCTION_GET_SERVO_CURRENT_CONFIGURATION = 18 # :nodoc:
52
+ FUNCTION_SET_INPUT_VOLTAGE_CONFIGURATION = 19 # :nodoc:
53
+ FUNCTION_GET_INPUT_VOLTAGE_CONFIGURATION = 20 # :nodoc:
54
+ FUNCTION_GET_OVERALL_CURRENT = 21 # :nodoc:
55
+ FUNCTION_GET_INPUT_VOLTAGE = 22 # :nodoc:
56
+ FUNCTION_SET_CURRENT_CALIBRATION = 23 # :nodoc:
57
+ FUNCTION_GET_CURRENT_CALIBRATION = 24 # :nodoc:
58
+ FUNCTION_SET_POSITION_REACHED_CALLBACK_CONFIGURATION = 25 # :nodoc:
59
+ FUNCTION_GET_POSITION_REACHED_CALLBACK_CONFIGURATION = 26 # :nodoc:
60
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
61
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
62
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
63
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
64
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
65
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
66
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
67
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
68
+ FUNCTION_RESET = 243 # :nodoc:
69
+ FUNCTION_WRITE_UID = 248 # :nodoc:
70
+ FUNCTION_READ_UID = 249 # :nodoc:
71
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
72
+
73
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
74
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
75
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
76
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
77
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
78
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
79
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
80
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
81
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
82
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
83
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
84
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
85
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
86
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
87
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
88
+
89
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
90
+ # the IP Connection <tt>ipcon</tt>.
91
+ def initialize(uid, ipcon)
92
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
93
+
94
+ @api_version = [2, 0, 0]
95
+
96
+ @response_expected[FUNCTION_GET_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
97
+ @response_expected[FUNCTION_SET_ENABLE] = RESPONSE_EXPECTED_FALSE
98
+ @response_expected[FUNCTION_GET_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
99
+ @response_expected[FUNCTION_SET_POSITION] = RESPONSE_EXPECTED_FALSE
100
+ @response_expected[FUNCTION_GET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
101
+ @response_expected[FUNCTION_GET_CURRENT_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
102
+ @response_expected[FUNCTION_GET_CURRENT_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
103
+ @response_expected[FUNCTION_SET_MOTION_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
104
+ @response_expected[FUNCTION_GET_MOTION_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
+ @response_expected[FUNCTION_SET_PULSE_WIDTH] = RESPONSE_EXPECTED_FALSE
106
+ @response_expected[FUNCTION_GET_PULSE_WIDTH] = RESPONSE_EXPECTED_ALWAYS_TRUE
107
+ @response_expected[FUNCTION_SET_DEGREE] = RESPONSE_EXPECTED_FALSE
108
+ @response_expected[FUNCTION_GET_DEGREE] = RESPONSE_EXPECTED_ALWAYS_TRUE
109
+ @response_expected[FUNCTION_SET_PERIOD] = RESPONSE_EXPECTED_FALSE
110
+ @response_expected[FUNCTION_GET_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
111
+ @response_expected[FUNCTION_GET_SERVO_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
112
+ @response_expected[FUNCTION_SET_SERVO_CURRENT_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
113
+ @response_expected[FUNCTION_GET_SERVO_CURRENT_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
+ @response_expected[FUNCTION_SET_INPUT_VOLTAGE_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
115
+ @response_expected[FUNCTION_GET_INPUT_VOLTAGE_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
116
+ @response_expected[FUNCTION_GET_OVERALL_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
117
+ @response_expected[FUNCTION_GET_INPUT_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
118
+ @response_expected[FUNCTION_SET_CURRENT_CALIBRATION] = RESPONSE_EXPECTED_FALSE
119
+ @response_expected[FUNCTION_GET_CURRENT_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
120
+ @response_expected[FUNCTION_SET_POSITION_REACHED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
121
+ @response_expected[FUNCTION_GET_POSITION_REACHED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
122
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
125
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
126
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
127
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
128
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
129
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
130
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
131
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
132
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
133
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
134
+
135
+ @callback_formats[CALLBACK_POSITION_REACHED] = [12, 'S s']
136
+
137
+ @ipcon.add_device self
138
+ end
139
+
140
+ # Returns the status information of the Servo Bricklet 2.0.
141
+ #
142
+ # The status includes
143
+ #
144
+ # * for each channel if it is enabled or disabled,
145
+ # * for each channel the current position,
146
+ # * for each channel the current velocity,
147
+ # * for each channel the current usage and
148
+ # * the input voltage.
149
+ #
150
+ # Please note that the position and the velocity is a snapshot of the
151
+ # current position and velocity of the servo in motion.
152
+ def get_status
153
+ check_validity
154
+
155
+ send_request FUNCTION_GET_STATUS, [], '', 72, '?10 s10 s10 S10 S'
156
+ end
157
+
158
+ # Enables a servo channel (0 to 9). If a servo is enabled, the configured position,
159
+ # velocity, acceleration, etc. are applied immediately.
160
+ def set_enable(servo_channel, enable)
161
+ check_validity
162
+
163
+ send_request FUNCTION_SET_ENABLE, [servo_channel, enable], 'S ?', 8, ''
164
+ end
165
+
166
+ # Returns *true* if the specified servo channel is enabled, *false* otherwise.
167
+ def get_enabled(servo_channel)
168
+ check_validity
169
+
170
+ send_request FUNCTION_GET_ENABLED, [servo_channel], 'S', 9, '?'
171
+ end
172
+
173
+ # Sets the position in °/100 for the specified servo channel.
174
+ #
175
+ # The default range of the position is -9000 to 9000, but it can be specified
176
+ # according to your servo with BrickletServoV2#set_degree.
177
+ #
178
+ # If you want to control a linear servo or RC brushless motor controller or
179
+ # similar with the Servo Brick, you can also define lengths or speeds with
180
+ # BrickletServoV2#set_degree.
181
+ def set_position(servo_channel, position)
182
+ check_validity
183
+
184
+ send_request FUNCTION_SET_POSITION, [servo_channel, position], 'S s', 8, ''
185
+ end
186
+
187
+ # Returns the position of the specified servo channel as set by BrickletServoV2#set_position.
188
+ def get_position(servo_channel)
189
+ check_validity
190
+
191
+ send_request FUNCTION_GET_POSITION, [servo_channel], 'S', 10, 's'
192
+ end
193
+
194
+ # Returns the *current* position of the specified servo channel. This may not be the
195
+ # value of BrickletServoV2#set_position if the servo is currently approaching a
196
+ # position goal.
197
+ def get_current_position(servo_channel)
198
+ check_validity
199
+
200
+ send_request FUNCTION_GET_CURRENT_POSITION, [servo_channel], 'S', 10, 's'
201
+ end
202
+
203
+ # Returns the *current* velocity of the specified servo channel. This may not be the
204
+ # velocity specified by BrickletServoV2#set_motion_configuration. if the servo is
205
+ # currently approaching a velocity goal.
206
+ def get_current_velocity(servo_channel)
207
+ check_validity
208
+
209
+ send_request FUNCTION_GET_CURRENT_VELOCITY, [servo_channel], 'S', 10, 'S'
210
+ end
211
+
212
+ # Sets the maximum velocity of the specified servo channel in °/100s as well as
213
+ # the acceleration and deceleration in °/100s²
214
+ #
215
+ # With a velocity of 0 °/100s the position will be set immediately (no velocity).
216
+ #
217
+ # With an acc-/deceleration of 0 °/100s² the velocity will be set immediately
218
+ # (no acc-/deceleration).
219
+ def set_motion_configuration(servo_channel, velocity, acceleration, deceleration)
220
+ check_validity
221
+
222
+ send_request FUNCTION_SET_MOTION_CONFIGURATION, [servo_channel, velocity, acceleration, deceleration], 'S L L L', 8, ''
223
+ end
224
+
225
+ # Returns the motion configuration as set by BrickletServoV2#set_motion_configuration.
226
+ def get_motion_configuration(servo_channel)
227
+ check_validity
228
+
229
+ send_request FUNCTION_GET_MOTION_CONFIGURATION, [servo_channel], 'S', 20, 'L L L'
230
+ end
231
+
232
+ # Sets the minimum and maximum pulse width of the specified servo channel in µs.
233
+ #
234
+ # Usually, servos are controlled with a
235
+ # `PWM <https://en.wikipedia.org/wiki/Pulse-width_modulation>`__, whereby the
236
+ # length of the pulse controls the position of the servo. Every servo has
237
+ # different minimum and maximum pulse widths, these can be specified with
238
+ # this function.
239
+ #
240
+ # If you have a datasheet for your servo that specifies the minimum and
241
+ # maximum pulse width, you should set the values accordingly. If your servo
242
+ # comes without any datasheet you have to find the values via trial and error.
243
+ #
244
+ # Both values have a range from 1 to 65535 (unsigned 16-bit integer). The
245
+ # minimum must be smaller than the maximum.
246
+ #
247
+ # The default values are 1000µs (1ms) and 2000µs (2ms) for minimum and
248
+ # maximum pulse width.
249
+ def set_pulse_width(servo_channel, min, max)
250
+ check_validity
251
+
252
+ send_request FUNCTION_SET_PULSE_WIDTH, [servo_channel, min, max], 'S L L', 8, ''
253
+ end
254
+
255
+ # Returns the minimum and maximum pulse width for the specified servo channel as set by
256
+ # BrickletServoV2#set_pulse_width.
257
+ def get_pulse_width(servo_channel)
258
+ check_validity
259
+
260
+ send_request FUNCTION_GET_PULSE_WIDTH, [servo_channel], 'S', 16, 'L L'
261
+ end
262
+
263
+ # Sets the minimum and maximum degree for the specified servo channel (by default
264
+ # given as °/100).
265
+ #
266
+ # This only specifies the abstract values between which the minimum and maximum
267
+ # pulse width is scaled. For example: If you specify a pulse width of 1000µs
268
+ # to 2000µs and a degree range of -90° to 90°, a call of BrickletServoV2#set_position
269
+ # with 0 will result in a pulse width of 1500µs
270
+ # (-90° = 1000µs, 90° = 2000µs, etc.).
271
+ #
272
+ # Possible usage:
273
+ #
274
+ # * The datasheet of your servo specifies a range of 200° with the middle position
275
+ # at 110°. In this case you can set the minimum to -9000 and the maximum to 11000.
276
+ # * You measure a range of 220° on your servo and you don't have or need a middle
277
+ # position. In this case you can set the minimum to 0 and the maximum to 22000.
278
+ # * You have a linear servo with a drive length of 20cm, In this case you could
279
+ # set the minimum to 0 and the maximum to 20000. Now you can set the Position
280
+ # with BrickletServoV2#set_position with a resolution of cm/100. Also the velocity will
281
+ # have a resolution of cm/100s and the acceleration will have a resolution of
282
+ # cm/100s².
283
+ # * You don't care about units and just want the highest possible resolution. In
284
+ # this case you should set the minimum to -32767 and the maximum to 32767.
285
+ # * You have a brushless motor with a maximum speed of 10000 rpm and want to
286
+ # control it with a RC brushless motor controller. In this case you can set the
287
+ # minimum to 0 and the maximum to 10000. BrickletServoV2#set_position now controls the rpm.
288
+ #
289
+ # Both values have a possible range from -32767 to 32767
290
+ # (signed 16-bit integer). The minimum must be smaller than the maximum.
291
+ #
292
+ # The default values are -9000 and 9000 for the minimum and maximum degree.
293
+ def set_degree(servo_channel, min, max)
294
+ check_validity
295
+
296
+ send_request FUNCTION_SET_DEGREE, [servo_channel, min, max], 'S s s', 8, ''
297
+ end
298
+
299
+ # Returns the minimum and maximum degree for the specified servo channel as set by
300
+ # BrickletServoV2#set_degree.
301
+ def get_degree(servo_channel)
302
+ check_validity
303
+
304
+ send_request FUNCTION_GET_DEGREE, [servo_channel], 'S', 12, 's s'
305
+ end
306
+
307
+ # Sets the period of the specified servo channel in µs.
308
+ #
309
+ # Usually, servos are controlled with a
310
+ # `PWM <https://en.wikipedia.org/wiki/Pulse-width_modulation>`__. Different
311
+ # servos expect PWMs with different periods. Most servos run well with a
312
+ # period of about 20ms.
313
+ #
314
+ # If your servo comes with a datasheet that specifies a period, you should
315
+ # set it accordingly. If you don't have a datasheet and you have no idea
316
+ # what the correct period is, the default value (19.5ms) will most likely
317
+ # work fine.
318
+ #
319
+ # The minimum possible period is 1µs and the maximum is 1000000µs.
320
+ #
321
+ # The default value is 19.5ms (19500µs).
322
+ def set_period(servo_channel, period)
323
+ check_validity
324
+
325
+ send_request FUNCTION_SET_PERIOD, [servo_channel, period], 'S L', 8, ''
326
+ end
327
+
328
+ # Returns the period for the specified servo channel as set by BrickletServoV2#set_period.
329
+ def get_period(servo_channel)
330
+ check_validity
331
+
332
+ send_request FUNCTION_GET_PERIOD, [servo_channel], 'S', 12, 'L'
333
+ end
334
+
335
+ # Returns the current consumption of the specified servo channel in mA.
336
+ def get_servo_current(servo_channel)
337
+ check_validity
338
+
339
+ send_request FUNCTION_GET_SERVO_CURRENT, [servo_channel], 'S', 10, 'S'
340
+ end
341
+
342
+ # Sets the averaging duration of the current measurement for the specified servo channel in ms.
343
+ def set_servo_current_configuration(servo_channel, averaging_duration)
344
+ check_validity
345
+
346
+ send_request FUNCTION_SET_SERVO_CURRENT_CONFIGURATION, [servo_channel, averaging_duration], 'S C', 8, ''
347
+ end
348
+
349
+ # Returns the servo current configuration for the specified servo channel as set
350
+ # by BrickletServoV2#set_servo_current_configuration.
351
+ def get_servo_current_configuration(servo_channel)
352
+ check_validity
353
+
354
+ send_request FUNCTION_GET_SERVO_CURRENT_CONFIGURATION, [servo_channel], 'S', 9, 'C'
355
+ end
356
+
357
+ # Sets the averaging duration of the input voltage measurement for the specified servo channel in ms.
358
+ def set_input_voltage_configuration(averaging_duration)
359
+ check_validity
360
+
361
+ send_request FUNCTION_SET_INPUT_VOLTAGE_CONFIGURATION, [averaging_duration], 'C', 8, ''
362
+ end
363
+
364
+ # Returns the input voltage configuration as set by BrickletServoV2#set_input_voltage_configuration.
365
+ def get_input_voltage_configuration
366
+ check_validity
367
+
368
+ send_request FUNCTION_GET_INPUT_VOLTAGE_CONFIGURATION, [], '', 9, 'C'
369
+ end
370
+
371
+ # Returns the current consumption of all servos together in mA.
372
+ def get_overall_current
373
+ check_validity
374
+
375
+ send_request FUNCTION_GET_OVERALL_CURRENT, [], '', 10, 'S'
376
+ end
377
+
378
+ # Returns the input voltage in mV. The input voltage is
379
+ # given via the black power input connector on the Servo Brick.
380
+ def get_input_voltage
381
+ check_validity
382
+
383
+ send_request FUNCTION_GET_INPUT_VOLTAGE, [], '', 10, 'S'
384
+ end
385
+
386
+ # Sets an offset value (in mA) for each channel.
387
+ #
388
+ # Note: On delivery the Servo Bricklet 2.0 is already calibrated.
389
+ def set_current_calibration(offset)
390
+ check_validity
391
+
392
+ send_request FUNCTION_SET_CURRENT_CALIBRATION, [offset], 's10', 8, ''
393
+ end
394
+
395
+ # Returns the current calibration as set by BrickletServoV2#set_current_calibration.
396
+ def get_current_calibration
397
+ check_validity
398
+
399
+ send_request FUNCTION_GET_CURRENT_CALIBRATION, [], '', 28, 's10'
400
+ end
401
+
402
+ # Enable/Disable CALLBACK_POSITION_REACHED callback.
403
+ def set_position_reached_callback_configuration(servo_channel, enabled)
404
+ check_validity
405
+
406
+ send_request FUNCTION_SET_POSITION_REACHED_CALLBACK_CONFIGURATION, [servo_channel, enabled], 'S ?', 8, ''
407
+ end
408
+
409
+ # Returns the callback configuration as set by
410
+ # BrickletServoV2#set_position_reached_callback_configuration.
411
+ def get_position_reached_callback_configuration(servo_channel)
412
+ check_validity
413
+
414
+ send_request FUNCTION_GET_POSITION_REACHED_CALLBACK_CONFIGURATION, [servo_channel], 'S', 9, '?'
415
+ end
416
+
417
+ # Returns the error count for the communication between Brick and Bricklet.
418
+ #
419
+ # The errors are divided into
420
+ #
421
+ # * ACK checksum errors,
422
+ # * message checksum errors,
423
+ # * framing errors and
424
+ # * overflow errors.
425
+ #
426
+ # The errors counts are for errors that occur on the Bricklet side. All
427
+ # Bricks have a similar function that returns the errors on the Brick side.
428
+ def get_spitfp_error_count
429
+ check_validity
430
+
431
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
432
+ end
433
+
434
+ # Sets the bootloader mode and returns the status after the requested
435
+ # mode change was instigated.
436
+ #
437
+ # You can change from bootloader mode to firmware mode and vice versa. A change
438
+ # from bootloader mode to firmware mode will only take place if the entry function,
439
+ # device identifier and CRC are present and correct.
440
+ #
441
+ # This function is used by Brick Viewer during flashing. It should not be
442
+ # necessary to call it in a normal user program.
443
+ def set_bootloader_mode(mode)
444
+ check_validity
445
+
446
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
447
+ end
448
+
449
+ # Returns the current bootloader mode, see BrickletServoV2#set_bootloader_mode.
450
+ def get_bootloader_mode
451
+ check_validity
452
+
453
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
454
+ end
455
+
456
+ # Sets the firmware pointer for BrickletServoV2#write_firmware. The pointer has
457
+ # to be increased by chunks of size 64. The data is written to flash
458
+ # every 4 chunks (which equals to one page of size 256).
459
+ #
460
+ # This function is used by Brick Viewer during flashing. It should not be
461
+ # necessary to call it in a normal user program.
462
+ def set_write_firmware_pointer(pointer)
463
+ check_validity
464
+
465
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
466
+ end
467
+
468
+ # Writes 64 Bytes of firmware at the position as written by
469
+ # BrickletServoV2#set_write_firmware_pointer before. The firmware is written
470
+ # to flash every 4 chunks.
471
+ #
472
+ # You can only write firmware in bootloader mode.
473
+ #
474
+ # This function is used by Brick Viewer during flashing. It should not be
475
+ # necessary to call it in a normal user program.
476
+ def write_firmware(data)
477
+ check_validity
478
+
479
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
480
+ end
481
+
482
+ # Sets the status LED configuration. By default the LED shows
483
+ # communication traffic between Brick and Bricklet, it flickers once
484
+ # for every 10 received data packets.
485
+ #
486
+ # You can also turn the LED permanently on/off or show a heartbeat.
487
+ #
488
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
489
+ def set_status_led_config(config)
490
+ check_validity
491
+
492
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
493
+ end
494
+
495
+ # Returns the configuration as set by BrickletServoV2#set_status_led_config
496
+ def get_status_led_config
497
+ check_validity
498
+
499
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
500
+ end
501
+
502
+ # Returns the temperature as measured inside the microcontroller. The
503
+ # value returned is not the ambient temperature!
504
+ #
505
+ # The temperature is only proportional to the real temperature and it has bad
506
+ # accuracy. Practically it is only useful as an indicator for
507
+ # temperature changes.
508
+ def get_chip_temperature
509
+ check_validity
510
+
511
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
512
+ end
513
+
514
+ # Calling this function will reset the Bricklet. All configurations
515
+ # will be lost.
516
+ #
517
+ # After a reset you have to create new device objects,
518
+ # calling functions on the existing ones will result in
519
+ # undefined behavior!
520
+ def reset
521
+ check_validity
522
+
523
+ send_request FUNCTION_RESET, [], '', 8, ''
524
+ end
525
+
526
+ # Writes a new UID into flash. If you want to set a new UID
527
+ # you have to decode the Base58 encoded UID string into an
528
+ # integer first.
529
+ #
530
+ # We recommend that you use Brick Viewer to change the UID.
531
+ def write_uid(uid)
532
+ check_validity
533
+
534
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
535
+ end
536
+
537
+ # Returns the current UID as an integer. Encode as
538
+ # Base58 to get the usual string version.
539
+ def read_uid
540
+ check_validity
541
+
542
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
543
+ end
544
+
545
+ # Returns the UID, the UID where the Bricklet is connected to,
546
+ # the position, the hardware and firmware version as well as the
547
+ # device identifier.
548
+ #
549
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
550
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
551
+ # position 'z'.
552
+ #
553
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
554
+ # |device_identifier_constant|
555
+ def get_identity
556
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
557
+ end
558
+
559
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
560
+ def register_callback(id, &block)
561
+ callback = block
562
+ @registered_callbacks[id] = callback
563
+ end
564
+ end
565
+ end