tinkerforge 2.1.22 → 2.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# 300° rotary potentiometer
|
|
14
16
|
class BrickletRotaryPoti < Device
|
|
@@ -70,7 +72,7 @@ module Tinkerforge
|
|
|
70
72
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
71
73
|
# the IP Connection <tt>ipcon</tt>.
|
|
72
74
|
def initialize(uid, ipcon)
|
|
73
|
-
super uid, ipcon
|
|
75
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
74
76
|
|
|
75
77
|
@api_version = [2, 0, 0]
|
|
76
78
|
|
|
@@ -88,25 +90,27 @@ module Tinkerforge
|
|
|
88
90
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
89
91
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
92
|
|
|
91
|
-
@callback_formats[CALLBACK_POSITION] = 's'
|
|
92
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
|
93
|
-
@callback_formats[CALLBACK_POSITION_REACHED] = 's'
|
|
94
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
|
93
|
+
@callback_formats[CALLBACK_POSITION] = [10, 's']
|
|
94
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
|
|
95
|
+
@callback_formats[CALLBACK_POSITION_REACHED] = [10, 's']
|
|
96
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
|
|
95
97
|
|
|
98
|
+
@ipcon.add_device self
|
|
96
99
|
end
|
|
97
100
|
|
|
98
|
-
# Returns the position of the rotary potentiometer. The value is
|
|
99
|
-
#
|
|
101
|
+
# Returns the position of the rotary potentiometer. The value is
|
|
102
|
+
# between -150° (turned left) and 150° (turned right).
|
|
100
103
|
#
|
|
101
104
|
# If you want to get the position periodically, it is recommended to use the
|
|
102
105
|
# CALLBACK_POSITION callback and set the period with
|
|
103
106
|
# BrickletRotaryPoti#set_position_callback_period.
|
|
104
107
|
def get_position
|
|
105
|
-
|
|
108
|
+
check_validity
|
|
109
|
+
|
|
110
|
+
send_request FUNCTION_GET_POSITION, [], '', 10, 's'
|
|
106
111
|
end
|
|
107
112
|
|
|
108
113
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
|
109
|
-
# The value is between 0 and 4095.
|
|
110
114
|
#
|
|
111
115
|
# .. note::
|
|
112
116
|
# The value returned by BrickletRotaryPoti#get_position is averaged over several samples
|
|
@@ -118,39 +122,45 @@ module Tinkerforge
|
|
|
118
122
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
|
119
123
|
# BrickletRotaryPoti#set_analog_value_callback_period.
|
|
120
124
|
def get_analog_value
|
|
121
|
-
|
|
125
|
+
check_validity
|
|
126
|
+
|
|
127
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
|
122
128
|
end
|
|
123
129
|
|
|
124
|
-
# Sets the period
|
|
130
|
+
# Sets the period with which the CALLBACK_POSITION callback is triggered
|
|
125
131
|
# periodically. A value of 0 turns the callback off.
|
|
126
132
|
#
|
|
127
133
|
# The CALLBACK_POSITION callback is only triggered if the position has changed since
|
|
128
134
|
# the last triggering.
|
|
129
|
-
#
|
|
130
|
-
# The default value is 0.
|
|
131
135
|
def set_position_callback_period(period)
|
|
132
|
-
|
|
136
|
+
check_validity
|
|
137
|
+
|
|
138
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
133
139
|
end
|
|
134
140
|
|
|
135
141
|
# Returns the period as set by BrickletRotaryPoti#set_position_callback_period.
|
|
136
142
|
def get_position_callback_period
|
|
137
|
-
|
|
143
|
+
check_validity
|
|
144
|
+
|
|
145
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
138
146
|
end
|
|
139
147
|
|
|
140
|
-
# Sets the period
|
|
148
|
+
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
|
141
149
|
# periodically. A value of 0 turns the callback off.
|
|
142
150
|
#
|
|
143
151
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
|
144
152
|
# changed since the last triggering.
|
|
145
|
-
#
|
|
146
|
-
# The default value is 0.
|
|
147
153
|
def set_analog_value_callback_period(period)
|
|
148
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
149
157
|
end
|
|
150
158
|
|
|
151
159
|
# Returns the period as set by BrickletRotaryPoti#set_analog_value_callback_period.
|
|
152
160
|
def get_analog_value_callback_period
|
|
153
|
-
|
|
161
|
+
check_validity
|
|
162
|
+
|
|
163
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
154
164
|
end
|
|
155
165
|
|
|
156
166
|
# Sets the thresholds for the CALLBACK_POSITION_REACHED callback.
|
|
@@ -164,15 +174,17 @@ module Tinkerforge
|
|
|
164
174
|
# "'i'", "Callback is triggered when the position is *inside* the min and max values"
|
|
165
175
|
# "'<'", "Callback is triggered when the position is smaller than the min value (max is ignored)"
|
|
166
176
|
# "'>'", "Callback is triggered when the position is greater than the min value (max is ignored)"
|
|
167
|
-
#
|
|
168
|
-
# The default value is ('x', 0, 0).
|
|
169
177
|
def set_position_callback_threshold(option, min, max)
|
|
170
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
|
|
171
181
|
end
|
|
172
182
|
|
|
173
183
|
# Returns the threshold as set by BrickletRotaryPoti#set_position_callback_threshold.
|
|
174
184
|
def get_position_callback_threshold
|
|
175
|
-
|
|
185
|
+
check_validity
|
|
186
|
+
|
|
187
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
|
|
176
188
|
end
|
|
177
189
|
|
|
178
190
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
|
@@ -186,18 +198,20 @@ module Tinkerforge
|
|
|
186
198
|
# "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
|
|
187
199
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
|
188
200
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
|
189
|
-
#
|
|
190
|
-
# The default value is ('x', 0, 0).
|
|
191
201
|
def set_analog_value_callback_threshold(option, min, max)
|
|
192
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
193
205
|
end
|
|
194
206
|
|
|
195
207
|
# Returns the threshold as set by BrickletRotaryPoti#set_analog_value_callback_threshold.
|
|
196
208
|
def get_analog_value_callback_threshold
|
|
197
|
-
|
|
209
|
+
check_validity
|
|
210
|
+
|
|
211
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
198
212
|
end
|
|
199
213
|
|
|
200
|
-
# Sets the period
|
|
214
|
+
# Sets the period with which the threshold callbacks
|
|
201
215
|
#
|
|
202
216
|
# * CALLBACK_POSITION_REACHED,
|
|
203
217
|
# * CALLBACK_ANALOG_VALUE_REACHED
|
|
@@ -208,27 +222,31 @@ module Tinkerforge
|
|
|
208
222
|
# * BrickletRotaryPoti#set_analog_value_callback_threshold
|
|
209
223
|
#
|
|
210
224
|
# keep being reached.
|
|
211
|
-
#
|
|
212
|
-
# The default value is 100.
|
|
213
225
|
def set_debounce_period(debounce)
|
|
214
|
-
|
|
226
|
+
check_validity
|
|
227
|
+
|
|
228
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
215
229
|
end
|
|
216
230
|
|
|
217
231
|
# Returns the debounce period as set by BrickletRotaryPoti#set_debounce_period.
|
|
218
232
|
def get_debounce_period
|
|
219
|
-
|
|
233
|
+
check_validity
|
|
234
|
+
|
|
235
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
220
236
|
end
|
|
221
237
|
|
|
222
238
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
223
239
|
# the position, the hardware and firmware version as well as the
|
|
224
240
|
# device identifier.
|
|
225
241
|
#
|
|
226
|
-
# The position can be 'a', 'b', 'c' or '
|
|
242
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
243
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
244
|
+
# position 'z'.
|
|
227
245
|
#
|
|
228
246
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
229
247
|
# |device_identifier_constant|
|
|
230
248
|
def get_identity
|
|
231
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
249
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
232
250
|
end
|
|
233
251
|
|
|
234
252
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
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
|
+
# 300° rotary potentiometer
|
|
16
|
+
class BrickletRotaryPotiV2 < Device
|
|
17
|
+
DEVICE_IDENTIFIER = 2140 # :nodoc:
|
|
18
|
+
DEVICE_DISPLAY_NAME = 'Rotary Poti Bricklet 2.0' # :nodoc:
|
|
19
|
+
|
|
20
|
+
# This callback is triggered periodically according to the configuration set by
|
|
21
|
+
# BrickletRotaryPotiV2#set_position_callback_configuration.
|
|
22
|
+
#
|
|
23
|
+
# The parameter is the same as BrickletRotaryPotiV2#get_position.
|
|
24
|
+
CALLBACK_POSITION = 4
|
|
25
|
+
|
|
26
|
+
FUNCTION_GET_POSITION = 1 # :nodoc:
|
|
27
|
+
FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
28
|
+
FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
29
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
30
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
31
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
32
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
33
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
34
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
35
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
36
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
37
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
38
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
39
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
40
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
41
|
+
|
|
42
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
43
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
44
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
45
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
46
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
47
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
48
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
49
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
50
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
51
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
52
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
53
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
54
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
55
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
56
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
57
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
58
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
59
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
60
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
61
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
62
|
+
|
|
63
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
64
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
65
|
+
def initialize(uid, ipcon)
|
|
66
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
67
|
+
|
|
68
|
+
@api_version = [2, 0, 0]
|
|
69
|
+
|
|
70
|
+
@response_expected[FUNCTION_GET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
71
|
+
@response_expected[FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
72
|
+
@response_expected[FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
73
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
74
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
75
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
76
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
77
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
78
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
79
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
80
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
81
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
82
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
83
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
84
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
85
|
+
|
|
86
|
+
@callback_formats[CALLBACK_POSITION] = [10, 's']
|
|
87
|
+
|
|
88
|
+
@ipcon.add_device self
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Returns the position of the rotary potentiometer. The value is
|
|
92
|
+
# between -150° (turned left) and 150° (turned right).
|
|
93
|
+
#
|
|
94
|
+
#
|
|
95
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
96
|
+
# CALLBACK_POSITION callback. You can set the callback configuration
|
|
97
|
+
# with BrickletRotaryPotiV2#set_position_callback_configuration.
|
|
98
|
+
def get_position
|
|
99
|
+
check_validity
|
|
100
|
+
|
|
101
|
+
send_request FUNCTION_GET_POSITION, [], '', 10, 's'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# The period is the period with which the CALLBACK_POSITION callback is triggered
|
|
105
|
+
# periodically. A value of 0 turns the callback off.
|
|
106
|
+
#
|
|
107
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
108
|
+
# triggered after the value has changed. If the value didn't change
|
|
109
|
+
# within the period, the callback is triggered immediately on change.
|
|
110
|
+
#
|
|
111
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
112
|
+
# independent of the value.
|
|
113
|
+
#
|
|
114
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
115
|
+
#
|
|
116
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_POSITION callback.
|
|
117
|
+
#
|
|
118
|
+
# The following options are possible:
|
|
119
|
+
#
|
|
120
|
+
# "Option", "Description"
|
|
121
|
+
#
|
|
122
|
+
# "'x'", "Threshold is turned off"
|
|
123
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
124
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
125
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
126
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
127
|
+
#
|
|
128
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
129
|
+
def set_position_callback_configuration(period, value_has_to_change, option, min, max)
|
|
130
|
+
check_validity
|
|
131
|
+
|
|
132
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Returns the callback configuration as set by BrickletRotaryPotiV2#set_position_callback_configuration.
|
|
136
|
+
def get_position_callback_configuration
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
143
|
+
#
|
|
144
|
+
# The errors are divided into
|
|
145
|
+
#
|
|
146
|
+
# * ACK checksum errors,
|
|
147
|
+
# * message checksum errors,
|
|
148
|
+
# * framing errors and
|
|
149
|
+
# * overflow errors.
|
|
150
|
+
#
|
|
151
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
152
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
153
|
+
def get_spitfp_error_count
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
160
|
+
# mode change was instigated.
|
|
161
|
+
#
|
|
162
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
163
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
164
|
+
# device identifier and CRC are present and correct.
|
|
165
|
+
#
|
|
166
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
167
|
+
# necessary to call it in a normal user program.
|
|
168
|
+
def set_bootloader_mode(mode)
|
|
169
|
+
check_validity
|
|
170
|
+
|
|
171
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns the current bootloader mode, see BrickletRotaryPotiV2#set_bootloader_mode.
|
|
175
|
+
def get_bootloader_mode
|
|
176
|
+
check_validity
|
|
177
|
+
|
|
178
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Sets the firmware pointer for BrickletRotaryPotiV2#write_firmware. The pointer has
|
|
182
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
183
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
184
|
+
#
|
|
185
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
186
|
+
# necessary to call it in a normal user program.
|
|
187
|
+
def set_write_firmware_pointer(pointer)
|
|
188
|
+
check_validity
|
|
189
|
+
|
|
190
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
194
|
+
# BrickletRotaryPotiV2#set_write_firmware_pointer before. The firmware is written
|
|
195
|
+
# to flash every 4 chunks.
|
|
196
|
+
#
|
|
197
|
+
# You can only write firmware in bootloader mode.
|
|
198
|
+
#
|
|
199
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
200
|
+
# necessary to call it in a normal user program.
|
|
201
|
+
def write_firmware(data)
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Sets the status LED configuration. By default the LED shows
|
|
208
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
209
|
+
# for every 10 received data packets.
|
|
210
|
+
#
|
|
211
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
212
|
+
#
|
|
213
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
214
|
+
def set_status_led_config(config)
|
|
215
|
+
check_validity
|
|
216
|
+
|
|
217
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Returns the configuration as set by BrickletRotaryPotiV2#set_status_led_config
|
|
221
|
+
def get_status_led_config
|
|
222
|
+
check_validity
|
|
223
|
+
|
|
224
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
228
|
+
# value returned is not the ambient temperature!
|
|
229
|
+
#
|
|
230
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
231
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
232
|
+
# temperature changes.
|
|
233
|
+
def get_chip_temperature
|
|
234
|
+
check_validity
|
|
235
|
+
|
|
236
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
240
|
+
# will be lost.
|
|
241
|
+
#
|
|
242
|
+
# After a reset you have to create new device objects,
|
|
243
|
+
# calling functions on the existing ones will result in
|
|
244
|
+
# undefined behavior!
|
|
245
|
+
def reset
|
|
246
|
+
check_validity
|
|
247
|
+
|
|
248
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
252
|
+
# you have to decode the Base58 encoded UID string into an
|
|
253
|
+
# integer first.
|
|
254
|
+
#
|
|
255
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
256
|
+
def write_uid(uid)
|
|
257
|
+
check_validity
|
|
258
|
+
|
|
259
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# Returns the current UID as an integer. Encode as
|
|
263
|
+
# Base58 to get the usual string version.
|
|
264
|
+
def read_uid
|
|
265
|
+
check_validity
|
|
266
|
+
|
|
267
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
271
|
+
# the position, the hardware and firmware version as well as the
|
|
272
|
+
# device identifier.
|
|
273
|
+
#
|
|
274
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
275
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
276
|
+
# position 'z'.
|
|
277
|
+
#
|
|
278
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
279
|
+
# |device_identifier_constant|
|
|
280
|
+
def get_identity
|
|
281
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
285
|
+
def register_callback(id, &block)
|
|
286
|
+
callback = block
|
|
287
|
+
@registered_callbacks[id] = callback
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|