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
|
# Measures two DC voltages between -35V and +35V with 24bit resolution each
|
|
14
16
|
class BrickletIndustrialDualAnalogIn < Device
|
|
@@ -62,7 +64,7 @@ module Tinkerforge
|
|
|
62
64
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
63
65
|
# the IP Connection <tt>ipcon</tt>.
|
|
64
66
|
def initialize(uid, ipcon)
|
|
65
|
-
super uid, ipcon
|
|
67
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
66
68
|
|
|
67
69
|
@api_version = [2, 0, 0]
|
|
68
70
|
|
|
@@ -80,34 +82,39 @@ module Tinkerforge
|
|
|
80
82
|
@response_expected[FUNCTION_GET_ADC_VALUES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
81
83
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
82
84
|
|
|
83
|
-
@callback_formats[CALLBACK_VOLTAGE] = 'C l'
|
|
84
|
-
@callback_formats[CALLBACK_VOLTAGE_REACHED] = 'C l'
|
|
85
|
+
@callback_formats[CALLBACK_VOLTAGE] = [13, 'C l']
|
|
86
|
+
@callback_formats[CALLBACK_VOLTAGE_REACHED] = [13, 'C l']
|
|
85
87
|
|
|
88
|
+
@ipcon.add_device self
|
|
86
89
|
end
|
|
87
90
|
|
|
88
|
-
# Returns the voltage for the given channel
|
|
91
|
+
# Returns the voltage for the given channel.
|
|
89
92
|
#
|
|
90
93
|
# If you want to get the voltage periodically, it is recommended to use the
|
|
91
94
|
# CALLBACK_VOLTAGE callback and set the period with
|
|
92
95
|
# BrickletIndustrialDualAnalogIn#set_voltage_callback_period.
|
|
93
96
|
def get_voltage(channel)
|
|
94
|
-
|
|
97
|
+
check_validity
|
|
98
|
+
|
|
99
|
+
send_request FUNCTION_GET_VOLTAGE, [channel], 'C', 12, 'l'
|
|
95
100
|
end
|
|
96
101
|
|
|
97
|
-
# Sets the period
|
|
102
|
+
# Sets the period with which the CALLBACK_VOLTAGE callback is triggered
|
|
98
103
|
# periodically for the given channel. A value of 0 turns the callback off.
|
|
99
104
|
#
|
|
100
105
|
# The CALLBACK_VOLTAGE callback is only triggered if the voltage has changed since the
|
|
101
106
|
# last triggering.
|
|
102
|
-
#
|
|
103
|
-
# The default value is 0.
|
|
104
107
|
def set_voltage_callback_period(channel, period)
|
|
105
|
-
|
|
108
|
+
check_validity
|
|
109
|
+
|
|
110
|
+
send_request FUNCTION_SET_VOLTAGE_CALLBACK_PERIOD, [channel, period], 'C L', 8, ''
|
|
106
111
|
end
|
|
107
112
|
|
|
108
113
|
# Returns the period as set by BrickletIndustrialDualAnalogIn#set_voltage_callback_period.
|
|
109
114
|
def get_voltage_callback_period(channel)
|
|
110
|
-
|
|
115
|
+
check_validity
|
|
116
|
+
|
|
117
|
+
send_request FUNCTION_GET_VOLTAGE_CALLBACK_PERIOD, [channel], 'C', 12, 'L'
|
|
111
118
|
end
|
|
112
119
|
|
|
113
120
|
# Sets the thresholds for the CALLBACK_VOLTAGE_REACHED callback for the given
|
|
@@ -122,18 +129,20 @@ module Tinkerforge
|
|
|
122
129
|
# "'i'", "Callback is triggered when the voltage is *inside* the min and max values"
|
|
123
130
|
# "'<'", "Callback is triggered when the voltage is smaller than the min value (max is ignored)"
|
|
124
131
|
# "'>'", "Callback is triggered when the voltage is greater than the min value (max is ignored)"
|
|
125
|
-
#
|
|
126
|
-
# The default value is ('x', 0, 0).
|
|
127
132
|
def set_voltage_callback_threshold(channel, option, min, max)
|
|
128
|
-
|
|
133
|
+
check_validity
|
|
134
|
+
|
|
135
|
+
send_request FUNCTION_SET_VOLTAGE_CALLBACK_THRESHOLD, [channel, option, min, max], 'C k l l', 8, ''
|
|
129
136
|
end
|
|
130
137
|
|
|
131
138
|
# Returns the threshold as set by BrickletIndustrialDualAnalogIn#set_voltage_callback_threshold.
|
|
132
139
|
def get_voltage_callback_threshold(channel)
|
|
133
|
-
|
|
140
|
+
check_validity
|
|
141
|
+
|
|
142
|
+
send_request FUNCTION_GET_VOLTAGE_CALLBACK_THRESHOLD, [channel], 'C', 17, 'k l l'
|
|
134
143
|
end
|
|
135
144
|
|
|
136
|
-
# Sets the period
|
|
145
|
+
# Sets the period with which the threshold callback
|
|
137
146
|
#
|
|
138
147
|
# * CALLBACK_VOLTAGE_REACHED
|
|
139
148
|
#
|
|
@@ -142,29 +151,33 @@ module Tinkerforge
|
|
|
142
151
|
# * BrickletIndustrialDualAnalogIn#set_voltage_callback_threshold
|
|
143
152
|
#
|
|
144
153
|
# keeps being reached.
|
|
145
|
-
#
|
|
146
|
-
# The default value is 100.
|
|
147
154
|
def set_debounce_period(debounce)
|
|
148
|
-
|
|
155
|
+
check_validity
|
|
156
|
+
|
|
157
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
149
158
|
end
|
|
150
159
|
|
|
151
160
|
# Returns the debounce period as set by BrickletIndustrialDualAnalogIn#set_debounce_period.
|
|
152
161
|
def get_debounce_period
|
|
153
|
-
|
|
162
|
+
check_validity
|
|
163
|
+
|
|
164
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
154
165
|
end
|
|
155
166
|
|
|
156
167
|
# Sets the sample rate. The sample rate can be between 1 sample per second
|
|
157
168
|
# and 976 samples per second. Decreasing the sample rate will also decrease the
|
|
158
169
|
# noise on the data.
|
|
159
|
-
#
|
|
160
|
-
# The default value is 6 (2 samples per second).
|
|
161
170
|
def set_sample_rate(rate)
|
|
162
|
-
|
|
171
|
+
check_validity
|
|
172
|
+
|
|
173
|
+
send_request FUNCTION_SET_SAMPLE_RATE, [rate], 'C', 8, ''
|
|
163
174
|
end
|
|
164
175
|
|
|
165
176
|
# Returns the sample rate as set by BrickletIndustrialDualAnalogIn#set_sample_rate.
|
|
166
177
|
def get_sample_rate
|
|
167
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_GET_SAMPLE_RATE, [], '', 9, 'C'
|
|
168
181
|
end
|
|
169
182
|
|
|
170
183
|
# Sets offset and gain of MCP3911 internal calibration registers.
|
|
@@ -173,30 +186,38 @@ module Tinkerforge
|
|
|
173
186
|
# is already factory calibrated by Tinkerforge. It should not be necessary
|
|
174
187
|
# for you to use this function
|
|
175
188
|
def set_calibration(offset, gain)
|
|
176
|
-
|
|
189
|
+
check_validity
|
|
190
|
+
|
|
191
|
+
send_request FUNCTION_SET_CALIBRATION, [offset, gain], 'l2 l2', 8, ''
|
|
177
192
|
end
|
|
178
193
|
|
|
179
194
|
# Returns the calibration as set by BrickletIndustrialDualAnalogIn#set_calibration.
|
|
180
195
|
def get_calibration
|
|
181
|
-
|
|
196
|
+
check_validity
|
|
197
|
+
|
|
198
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 24, 'l2 l2'
|
|
182
199
|
end
|
|
183
200
|
|
|
184
201
|
# Returns the ADC values as given by the MCP3911 IC. This function
|
|
185
202
|
# is needed for proper calibration, see BrickletIndustrialDualAnalogIn#set_calibration.
|
|
186
203
|
def get_adc_values
|
|
187
|
-
|
|
204
|
+
check_validity
|
|
205
|
+
|
|
206
|
+
send_request FUNCTION_GET_ADC_VALUES, [], '', 16, 'l2'
|
|
188
207
|
end
|
|
189
208
|
|
|
190
209
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
191
210
|
# the position, the hardware and firmware version as well as the
|
|
192
211
|
# device identifier.
|
|
193
212
|
#
|
|
194
|
-
# The position can be 'a', 'b', 'c' or '
|
|
213
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
214
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
215
|
+
# position 'z'.
|
|
195
216
|
#
|
|
196
217
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
197
218
|
# |device_identifier_constant|
|
|
198
219
|
def get_identity
|
|
199
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
220
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
200
221
|
end
|
|
201
222
|
|
|
202
223
|
# 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
|
|
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
|
# Measures two DC voltages between -35V and +35V with 24bit resolution each
|
|
14
16
|
class BrickletIndustrialDualAnalogInV2 < Device
|
|
@@ -21,6 +23,14 @@ module Tinkerforge
|
|
|
21
23
|
# The parameter is the same as BrickletIndustrialDualAnalogInV2#get_voltage.
|
|
22
24
|
CALLBACK_VOLTAGE = 4
|
|
23
25
|
|
|
26
|
+
# This callback is triggered periodically according to the configuration set by
|
|
27
|
+
# BrickletIndustrialDualAnalogInV2#set_all_voltages_callback_configuration.
|
|
28
|
+
#
|
|
29
|
+
# The parameters are the same as BrickletIndustrialDualAnalogInV2#get_all_voltages.
|
|
30
|
+
#
|
|
31
|
+
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
|
32
|
+
CALLBACK_ALL_VOLTAGES = 17
|
|
33
|
+
|
|
24
34
|
FUNCTION_GET_VOLTAGE = 1 # :nodoc:
|
|
25
35
|
FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
26
36
|
FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
@@ -33,6 +43,9 @@ module Tinkerforge
|
|
|
33
43
|
FUNCTION_GET_CHANNEL_LED_CONFIG = 11 # :nodoc:
|
|
34
44
|
FUNCTION_SET_CHANNEL_LED_STATUS_CONFIG = 12 # :nodoc:
|
|
35
45
|
FUNCTION_GET_CHANNEL_LED_STATUS_CONFIG = 13 # :nodoc:
|
|
46
|
+
FUNCTION_GET_ALL_VOLTAGES = 14 # :nodoc:
|
|
47
|
+
FUNCTION_SET_ALL_VOLTAGES_CALLBACK_CONFIGURATION = 15 # :nodoc:
|
|
48
|
+
FUNCTION_GET_ALL_VOLTAGES_CALLBACK_CONFIGURATION = 16 # :nodoc:
|
|
36
49
|
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
37
50
|
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
38
51
|
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
@@ -84,9 +97,9 @@ module Tinkerforge
|
|
|
84
97
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
98
|
# the IP Connection <tt>ipcon</tt>.
|
|
86
99
|
def initialize(uid, ipcon)
|
|
87
|
-
super uid, ipcon
|
|
100
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
88
101
|
|
|
89
|
-
@api_version = [2, 0,
|
|
102
|
+
@api_version = [2, 0, 1]
|
|
90
103
|
|
|
91
104
|
@response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
105
|
@response_expected[FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
@@ -100,6 +113,9 @@ module Tinkerforge
|
|
|
100
113
|
@response_expected[FUNCTION_GET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
114
|
@response_expected[FUNCTION_SET_CHANNEL_LED_STATUS_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
102
115
|
@response_expected[FUNCTION_GET_CHANNEL_LED_STATUS_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
116
|
+
@response_expected[FUNCTION_GET_ALL_VOLTAGES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
117
|
+
@response_expected[FUNCTION_SET_ALL_VOLTAGES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
118
|
+
@response_expected[FUNCTION_GET_ALL_VOLTAGES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
119
|
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
104
120
|
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
105
121
|
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -113,21 +129,25 @@ module Tinkerforge
|
|
|
113
129
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
130
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
115
131
|
|
|
116
|
-
@callback_formats[CALLBACK_VOLTAGE] = 'C l'
|
|
132
|
+
@callback_formats[CALLBACK_VOLTAGE] = [13, 'C l']
|
|
133
|
+
@callback_formats[CALLBACK_ALL_VOLTAGES] = [16, 'l2']
|
|
117
134
|
|
|
135
|
+
@ipcon.add_device self
|
|
118
136
|
end
|
|
119
137
|
|
|
120
|
-
# Returns the voltage for the given channel
|
|
138
|
+
# Returns the voltage for the given channel.
|
|
121
139
|
#
|
|
122
140
|
#
|
|
123
141
|
# If you want to get the value periodically, it is recommended to use the
|
|
124
142
|
# CALLBACK_VOLTAGE callback. You can set the callback configuration
|
|
125
143
|
# with BrickletIndustrialDualAnalogInV2#set_voltage_callback_configuration.
|
|
126
144
|
def get_voltage(channel)
|
|
127
|
-
|
|
145
|
+
check_validity
|
|
146
|
+
|
|
147
|
+
send_request FUNCTION_GET_VOLTAGE, [channel], 'C', 12, 'l'
|
|
128
148
|
end
|
|
129
149
|
|
|
130
|
-
# The period
|
|
150
|
+
# The period is the period with which the CALLBACK_VOLTAGE callback is triggered
|
|
131
151
|
# periodically. A value of 0 turns the callback off.
|
|
132
152
|
#
|
|
133
153
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -152,29 +172,33 @@ module Tinkerforge
|
|
|
152
172
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
153
173
|
#
|
|
154
174
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
155
|
-
#
|
|
156
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
157
175
|
def set_voltage_callback_configuration(channel, period, value_has_to_change, option, min, max)
|
|
158
|
-
|
|
176
|
+
check_validity
|
|
177
|
+
|
|
178
|
+
send_request FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change, option, min, max], 'C L ? k l l', 8, ''
|
|
159
179
|
end
|
|
160
180
|
|
|
161
181
|
# Returns the callback configuration as set by BrickletIndustrialDualAnalogInV2#set_voltage_callback_configuration.
|
|
162
182
|
def get_voltage_callback_configuration(channel)
|
|
163
|
-
|
|
183
|
+
check_validity
|
|
184
|
+
|
|
185
|
+
send_request FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION, [channel], 'C', 22, 'L ? k l l'
|
|
164
186
|
end
|
|
165
187
|
|
|
166
188
|
# Sets the sample rate. The sample rate can be between 1 sample per second
|
|
167
189
|
# and 976 samples per second. Decreasing the sample rate will also decrease the
|
|
168
190
|
# noise on the data.
|
|
169
|
-
#
|
|
170
|
-
# The default value is 6 (2 samples per second).
|
|
171
191
|
def set_sample_rate(rate)
|
|
172
|
-
|
|
192
|
+
check_validity
|
|
193
|
+
|
|
194
|
+
send_request FUNCTION_SET_SAMPLE_RATE, [rate], 'C', 8, ''
|
|
173
195
|
end
|
|
174
196
|
|
|
175
197
|
# Returns the sample rate as set by BrickletIndustrialDualAnalogInV2#set_sample_rate.
|
|
176
198
|
def get_sample_rate
|
|
177
|
-
|
|
199
|
+
check_validity
|
|
200
|
+
|
|
201
|
+
send_request FUNCTION_GET_SAMPLE_RATE, [], '', 9, 'C'
|
|
178
202
|
end
|
|
179
203
|
|
|
180
204
|
# Sets offset and gain of MCP3911 internal calibration registers.
|
|
@@ -183,18 +207,24 @@ module Tinkerforge
|
|
|
183
207
|
# is already factory calibrated by Tinkerforge. It should not be necessary
|
|
184
208
|
# for you to use this function
|
|
185
209
|
def set_calibration(offset, gain)
|
|
186
|
-
|
|
210
|
+
check_validity
|
|
211
|
+
|
|
212
|
+
send_request FUNCTION_SET_CALIBRATION, [offset, gain], 'l2 l2', 8, ''
|
|
187
213
|
end
|
|
188
214
|
|
|
189
215
|
# Returns the calibration as set by BrickletIndustrialDualAnalogInV2#set_calibration.
|
|
190
216
|
def get_calibration
|
|
191
|
-
|
|
217
|
+
check_validity
|
|
218
|
+
|
|
219
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 24, 'l2 l2'
|
|
192
220
|
end
|
|
193
221
|
|
|
194
222
|
# Returns the ADC values as given by the MCP3911 IC. This function
|
|
195
223
|
# is needed for proper calibration, see BrickletIndustrialDualAnalogInV2#set_calibration.
|
|
196
224
|
def get_adc_values
|
|
197
|
-
|
|
225
|
+
check_validity
|
|
226
|
+
|
|
227
|
+
send_request FUNCTION_GET_ADC_VALUES, [], '', 16, 'l2'
|
|
198
228
|
end
|
|
199
229
|
|
|
200
230
|
# Each channel has a corresponding LED. You can turn the LED off, on or show a
|
|
@@ -206,12 +236,16 @@ module Tinkerforge
|
|
|
206
236
|
#
|
|
207
237
|
# By default all channel LEDs are configured as "Channel Status".
|
|
208
238
|
def set_channel_led_config(channel, config)
|
|
209
|
-
|
|
239
|
+
check_validity
|
|
240
|
+
|
|
241
|
+
send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [channel, config], 'C C', 8, ''
|
|
210
242
|
end
|
|
211
243
|
|
|
212
244
|
# Returns the channel LED configuration as set by BrickletIndustrialDualAnalogInV2#set_channel_led_config
|
|
213
245
|
def get_channel_led_config(channel)
|
|
214
|
-
|
|
246
|
+
check_validity
|
|
247
|
+
|
|
248
|
+
send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [channel], 'C', 9, 'C'
|
|
215
249
|
end
|
|
216
250
|
|
|
217
251
|
# Sets the channel LED status config. This config is used if the channel LED is
|
|
@@ -234,17 +268,58 @@ module Tinkerforge
|
|
|
234
268
|
# and the brightness is linearly scaled between the values 4V and 20V. If the
|
|
235
269
|
# min value is greater than the max value, the LED brightness is scaled the other
|
|
236
270
|
# way around.
|
|
237
|
-
#
|
|
238
|
-
# By default the channel LED status config is set to intensity with min=0V and
|
|
239
|
-
# max=10V.
|
|
240
271
|
def set_channel_led_status_config(channel, min, max, config)
|
|
241
|
-
|
|
272
|
+
check_validity
|
|
273
|
+
|
|
274
|
+
send_request FUNCTION_SET_CHANNEL_LED_STATUS_CONFIG, [channel, min, max, config], 'C l l C', 8, ''
|
|
242
275
|
end
|
|
243
276
|
|
|
244
277
|
# Returns the channel LED status configuration as set by
|
|
245
278
|
# BrickletIndustrialDualAnalogInV2#set_channel_led_status_config.
|
|
246
279
|
def get_channel_led_status_config(channel)
|
|
247
|
-
|
|
280
|
+
check_validity
|
|
281
|
+
|
|
282
|
+
send_request FUNCTION_GET_CHANNEL_LED_STATUS_CONFIG, [channel], 'C', 17, 'l l C'
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Returns the voltages for all channels.
|
|
286
|
+
#
|
|
287
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
288
|
+
# CALLBACK_ALL_VOLTAGES callback. You can set the callback configuration
|
|
289
|
+
# with BrickletIndustrialDualAnalogInV2#set_all_voltages_callback_configuration.
|
|
290
|
+
#
|
|
291
|
+
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
|
292
|
+
def get_all_voltages
|
|
293
|
+
check_validity
|
|
294
|
+
|
|
295
|
+
send_request FUNCTION_GET_ALL_VOLTAGES, [], '', 16, 'l2'
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# The period is the period with which the CALLBACK_ALL_VOLTAGES
|
|
299
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
300
|
+
#
|
|
301
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
302
|
+
# triggered after at least one of the values has changed. If the values didn't
|
|
303
|
+
# change within the period, the callback is triggered immediately on change.
|
|
304
|
+
#
|
|
305
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
306
|
+
# independent of the value.
|
|
307
|
+
#
|
|
308
|
+
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
|
309
|
+
def set_all_voltages_callback_configuration(period, value_has_to_change)
|
|
310
|
+
check_validity
|
|
311
|
+
|
|
312
|
+
send_request FUNCTION_SET_ALL_VOLTAGES_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# Returns the callback configuration as set by
|
|
316
|
+
# BrickletIndustrialDualAnalogInV2#set_all_voltages_callback_configuration.
|
|
317
|
+
#
|
|
318
|
+
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
|
319
|
+
def get_all_voltages_callback_configuration
|
|
320
|
+
check_validity
|
|
321
|
+
|
|
322
|
+
send_request FUNCTION_GET_ALL_VOLTAGES_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
248
323
|
end
|
|
249
324
|
|
|
250
325
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -259,7 +334,9 @@ module Tinkerforge
|
|
|
259
334
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
260
335
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
261
336
|
def get_spitfp_error_count
|
|
262
|
-
|
|
337
|
+
check_validity
|
|
338
|
+
|
|
339
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
263
340
|
end
|
|
264
341
|
|
|
265
342
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -272,12 +349,16 @@ module Tinkerforge
|
|
|
272
349
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
273
350
|
# necessary to call it in a normal user program.
|
|
274
351
|
def set_bootloader_mode(mode)
|
|
275
|
-
|
|
352
|
+
check_validity
|
|
353
|
+
|
|
354
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
276
355
|
end
|
|
277
356
|
|
|
278
357
|
# Returns the current bootloader mode, see BrickletIndustrialDualAnalogInV2#set_bootloader_mode.
|
|
279
358
|
def get_bootloader_mode
|
|
280
|
-
|
|
359
|
+
check_validity
|
|
360
|
+
|
|
361
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
281
362
|
end
|
|
282
363
|
|
|
283
364
|
# Sets the firmware pointer for BrickletIndustrialDualAnalogInV2#write_firmware. The pointer has
|
|
@@ -287,7 +368,9 @@ module Tinkerforge
|
|
|
287
368
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
288
369
|
# necessary to call it in a normal user program.
|
|
289
370
|
def set_write_firmware_pointer(pointer)
|
|
290
|
-
|
|
371
|
+
check_validity
|
|
372
|
+
|
|
373
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
291
374
|
end
|
|
292
375
|
|
|
293
376
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -299,7 +382,9 @@ module Tinkerforge
|
|
|
299
382
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
300
383
|
# necessary to call it in a normal user program.
|
|
301
384
|
def write_firmware(data)
|
|
302
|
-
|
|
385
|
+
check_validity
|
|
386
|
+
|
|
387
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
303
388
|
end
|
|
304
389
|
|
|
305
390
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -310,22 +395,28 @@ module Tinkerforge
|
|
|
310
395
|
#
|
|
311
396
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
312
397
|
def set_status_led_config(config)
|
|
313
|
-
|
|
398
|
+
check_validity
|
|
399
|
+
|
|
400
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
314
401
|
end
|
|
315
402
|
|
|
316
403
|
# Returns the configuration as set by BrickletIndustrialDualAnalogInV2#set_status_led_config
|
|
317
404
|
def get_status_led_config
|
|
318
|
-
|
|
405
|
+
check_validity
|
|
406
|
+
|
|
407
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
319
408
|
end
|
|
320
409
|
|
|
321
|
-
# Returns the temperature
|
|
410
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
322
411
|
# value returned is not the ambient temperature!
|
|
323
412
|
#
|
|
324
413
|
# The temperature is only proportional to the real temperature and it has bad
|
|
325
414
|
# accuracy. Practically it is only useful as an indicator for
|
|
326
415
|
# temperature changes.
|
|
327
416
|
def get_chip_temperature
|
|
328
|
-
|
|
417
|
+
check_validity
|
|
418
|
+
|
|
419
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
329
420
|
end
|
|
330
421
|
|
|
331
422
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -335,7 +426,9 @@ module Tinkerforge
|
|
|
335
426
|
# calling functions on the existing ones will result in
|
|
336
427
|
# undefined behavior!
|
|
337
428
|
def reset
|
|
338
|
-
|
|
429
|
+
check_validity
|
|
430
|
+
|
|
431
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
339
432
|
end
|
|
340
433
|
|
|
341
434
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -344,25 +437,31 @@ module Tinkerforge
|
|
|
344
437
|
#
|
|
345
438
|
# We recommend that you use Brick Viewer to change the UID.
|
|
346
439
|
def write_uid(uid)
|
|
347
|
-
|
|
440
|
+
check_validity
|
|
441
|
+
|
|
442
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
348
443
|
end
|
|
349
444
|
|
|
350
445
|
# Returns the current UID as an integer. Encode as
|
|
351
446
|
# Base58 to get the usual string version.
|
|
352
447
|
def read_uid
|
|
353
|
-
|
|
448
|
+
check_validity
|
|
449
|
+
|
|
450
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
354
451
|
end
|
|
355
452
|
|
|
356
453
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
357
454
|
# the position, the hardware and firmware version as well as the
|
|
358
455
|
# device identifier.
|
|
359
456
|
#
|
|
360
|
-
# The position can be 'a', 'b', 'c' or '
|
|
457
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
458
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
459
|
+
# position 'z'.
|
|
361
460
|
#
|
|
362
461
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
363
462
|
# |device_identifier_constant|
|
|
364
463
|
def get_identity
|
|
365
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
464
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
366
465
|
end
|
|
367
466
|
|
|
368
467
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|