tinkerforge 2.1.16 → 2.1.17
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 +4 -4
- data/lib/tinkerforge/brick_dc.rb +3 -3
- data/lib/tinkerforge/brick_imu.rb +3 -3
- data/lib/tinkerforge/brick_imu_v2.rb +3 -3
- data/lib/tinkerforge/brick_master.rb +3 -3
- data/lib/tinkerforge/brick_red.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +3 -3
- data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
- data/lib/tinkerforge/brick_stepper.rb +3 -3
- data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -6
- data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer.rb +2 -2
- data/lib/tinkerforge/bricklet_can.rb +3 -3
- data/lib/tinkerforge/bricklet_can_v2.rb +770 -0
- data/lib/tinkerforge/bricklet_co2.rb +2 -2
- data/lib/tinkerforge/bricklet_color.rb +2 -2
- data/lib/tinkerforge/bricklet_current12.rb +2 -2
- data/lib/tinkerforge/bricklet_current25.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
- data/lib/tinkerforge/bricklet_dmx.rb +3 -3
- data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_gps.rb +2 -2
- data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity_v2.rb +11 -13
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_counter.rb +445 -0
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +342 -0
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +263 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +281 -0
- data/lib/tinkerforge/bricklet_io16.rb +2 -2
- data/lib/tinkerforge/bricklet_io4.rb +2 -2
- data/lib/tinkerforge/bricklet_io4_v2.rb +437 -0
- data/lib/tinkerforge/bricklet_joystick.rb +2 -2
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +3 -3
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +3 -3
- data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_line.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +354 -0
- data/lib/tinkerforge/bricklet_moisture.rb +2 -2
- data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -6
- data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc.rb +39 -3
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
- data/lib/tinkerforge/bricklet_particulate_matter.rb +320 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
- data/lib/tinkerforge/bricklet_ptc.rb +33 -3
- data/lib/tinkerforge/bricklet_ptc_v2.rb +433 -0
- data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +353 -0
- data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +8 -9
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232.rb +3 -3
- data/lib/tinkerforge/bricklet_rs232_v2.rb +421 -0
- data/lib/tinkerforge/bricklet_rs485.rb +6 -6
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +420 -0
- data/lib/tinkerforge/bricklet_temperature.rb +3 -3
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +13 -15
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
- data/lib/tinkerforge/bricklet_thermocouple.rb +4 -4
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +340 -0
- data/lib/tinkerforge/bricklet_tilt.rb +2 -2
- data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +453 -0
- data/lib/tinkerforge/ip_connection.rb +4 -4
- data/lib/tinkerforge/version.rb +1 -1
- metadata +17 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2018-
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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 #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2018-
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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 #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2018-
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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 #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2018-
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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 #
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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
|
+
module Tinkerforge
|
|
13
|
+
# Measures power, DC voltage and DC current up to 720W/36V/20A
|
|
14
|
+
class BrickletVoltageCurrentV2 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2105 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Voltage/Current Bricklet 2.0' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered periodically according to the configuration set by
|
|
19
|
+
# BrickletVoltageCurrentV2#set_current_callback_configuration.
|
|
20
|
+
#
|
|
21
|
+
# The parameter is the same as BrickletVoltageCurrentV2#get_current.
|
|
22
|
+
CALLBACK_CURRENT = 4
|
|
23
|
+
|
|
24
|
+
# This callback is triggered periodically according to the configuration set by
|
|
25
|
+
# BrickletVoltageCurrentV2#set_voltage_callback_configuration.
|
|
26
|
+
#
|
|
27
|
+
# The parameter is the same as BrickletVoltageCurrentV2#get_voltage.
|
|
28
|
+
CALLBACK_VOLTAGE = 8
|
|
29
|
+
|
|
30
|
+
# This callback is triggered periodically according to the configuration set by
|
|
31
|
+
# BrickletVoltageCurrentV2#set_power_callback_configuration.
|
|
32
|
+
#
|
|
33
|
+
# The parameter is the same as BrickletVoltageCurrentV2#get_power.
|
|
34
|
+
CALLBACK_POWER = 12
|
|
35
|
+
|
|
36
|
+
FUNCTION_GET_CURRENT = 1 # :nodoc:
|
|
37
|
+
FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
38
|
+
FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
39
|
+
FUNCTION_GET_VOLTAGE = 5 # :nodoc:
|
|
40
|
+
FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION = 6 # :nodoc:
|
|
41
|
+
FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
|
42
|
+
FUNCTION_GET_POWER = 9 # :nodoc:
|
|
43
|
+
FUNCTION_SET_POWER_CALLBACK_CONFIGURATION = 10 # :nodoc:
|
|
44
|
+
FUNCTION_GET_POWER_CALLBACK_CONFIGURATION = 11 # :nodoc:
|
|
45
|
+
FUNCTION_SET_CONFIGURATION = 13 # :nodoc:
|
|
46
|
+
FUNCTION_GET_CONFIGURATION = 14 # :nodoc:
|
|
47
|
+
FUNCTION_SET_CALIBRATION = 15 # :nodoc:
|
|
48
|
+
FUNCTION_GET_CALIBRATION = 16 # :nodoc:
|
|
49
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
50
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
51
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
52
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
53
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
54
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
55
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
56
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
57
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
58
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
59
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
60
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
61
|
+
|
|
62
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
63
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
64
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
65
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
66
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
67
|
+
AVERAGING_1 = 0 # :nodoc:
|
|
68
|
+
AVERAGING_4 = 1 # :nodoc:
|
|
69
|
+
AVERAGING_16 = 2 # :nodoc:
|
|
70
|
+
AVERAGING_64 = 3 # :nodoc:
|
|
71
|
+
AVERAGING_128 = 4 # :nodoc:
|
|
72
|
+
AVERAGING_256 = 5 # :nodoc:
|
|
73
|
+
AVERAGING_512 = 6 # :nodoc:
|
|
74
|
+
AVERAGING_1024 = 7 # :nodoc:
|
|
75
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
76
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
77
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
78
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
79
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
80
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
81
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
82
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
83
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
84
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
85
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
86
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
87
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
88
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
89
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
90
|
+
|
|
91
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
92
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
93
|
+
def initialize(uid, ipcon)
|
|
94
|
+
super uid, ipcon
|
|
95
|
+
|
|
96
|
+
@api_version = [2, 0, 0]
|
|
97
|
+
|
|
98
|
+
@response_expected[FUNCTION_GET_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
99
|
+
@response_expected[FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
100
|
+
@response_expected[FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
|
+
@response_expected[FUNCTION_GET_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
|
+
@response_expected[FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
103
|
+
@response_expected[FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
104
|
+
@response_expected[FUNCTION_GET_POWER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
105
|
+
@response_expected[FUNCTION_SET_POWER_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
106
|
+
@response_expected[FUNCTION_GET_POWER_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
107
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
108
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
109
|
+
@response_expected[FUNCTION_SET_CALIBRATION] = RESPONSE_EXPECTED_FALSE
|
|
110
|
+
@response_expected[FUNCTION_GET_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
111
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
112
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
113
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
115
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
116
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
117
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
118
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
119
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
120
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
121
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
122
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
123
|
+
|
|
124
|
+
@callback_formats[CALLBACK_CURRENT] = 'l'
|
|
125
|
+
@callback_formats[CALLBACK_VOLTAGE] = 'l'
|
|
126
|
+
@callback_formats[CALLBACK_POWER] = 'l'
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Returns the current. The value is in mA
|
|
131
|
+
# and between -20000mA and 20000mA.
|
|
132
|
+
#
|
|
133
|
+
#
|
|
134
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
135
|
+
# CALLBACK_CURRENT callback. You can set the callback configuration
|
|
136
|
+
# with BrickletVoltageCurrentV2#set_current_callback_configuration.
|
|
137
|
+
def get_current
|
|
138
|
+
send_request FUNCTION_GET_CURRENT, [], '', 4, 'l'
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# The period in ms is the period with which the CALLBACK_CURRENT callback is triggered
|
|
142
|
+
# periodically. A value of 0 turns the callback off.
|
|
143
|
+
#
|
|
144
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
145
|
+
# triggered after the value has changed. If the value didn't change
|
|
146
|
+
# within the period, the callback is triggered immediately on change.
|
|
147
|
+
#
|
|
148
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
149
|
+
# independent of the value.
|
|
150
|
+
#
|
|
151
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
152
|
+
#
|
|
153
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_CURRENT callback.
|
|
154
|
+
#
|
|
155
|
+
# The following options are possible:
|
|
156
|
+
#
|
|
157
|
+
# "Option", "Description"
|
|
158
|
+
#
|
|
159
|
+
# "'x'", "Threshold is turned off"
|
|
160
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
161
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
162
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
163
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
164
|
+
#
|
|
165
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
166
|
+
#
|
|
167
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
168
|
+
def set_current_callback_configuration(period, value_has_to_change, option, min, max)
|
|
169
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Returns the callback configuration as set by BrickletVoltageCurrentV2#set_current_callback_configuration.
|
|
173
|
+
def get_current_callback_configuration
|
|
174
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Returns the voltage. The value is in mV
|
|
178
|
+
# and between 0mV and 36000mV.
|
|
179
|
+
#
|
|
180
|
+
#
|
|
181
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
182
|
+
# CALLBACK_VOLTAGE callback. You can set the callback configuration
|
|
183
|
+
# with BrickletVoltageCurrentV2#set_voltage_callback_configuration.
|
|
184
|
+
def get_voltage
|
|
185
|
+
send_request FUNCTION_GET_VOLTAGE, [], '', 4, 'l'
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# The period in ms is the period with which the CALLBACK_VOLTAGE callback is triggered
|
|
189
|
+
# periodically. A value of 0 turns the callback off.
|
|
190
|
+
#
|
|
191
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
192
|
+
# triggered after the value has changed. If the value didn't change
|
|
193
|
+
# within the period, the callback is triggered immediately on change.
|
|
194
|
+
#
|
|
195
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
196
|
+
# independent of the value.
|
|
197
|
+
#
|
|
198
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
199
|
+
#
|
|
200
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_VOLTAGE callback.
|
|
201
|
+
#
|
|
202
|
+
# The following options are possible:
|
|
203
|
+
#
|
|
204
|
+
# "Option", "Description"
|
|
205
|
+
#
|
|
206
|
+
# "'x'", "Threshold is turned off"
|
|
207
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
208
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
209
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
210
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
211
|
+
#
|
|
212
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
213
|
+
#
|
|
214
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
215
|
+
def set_voltage_callback_configuration(period, value_has_to_change, option, min, max)
|
|
216
|
+
send_request FUNCTION_SET_VOLTAGE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Returns the callback configuration as set by BrickletVoltageCurrentV2#set_voltage_callback_configuration.
|
|
220
|
+
def get_voltage_callback_configuration
|
|
221
|
+
send_request FUNCTION_GET_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Returns the power. The value is in mW
|
|
225
|
+
# and between 0mV and 720000mW.
|
|
226
|
+
#
|
|
227
|
+
#
|
|
228
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
229
|
+
# CALLBACK_POWER callback. You can set the callback configuration
|
|
230
|
+
# with BrickletVoltageCurrentV2#set_power_callback_configuration.
|
|
231
|
+
def get_power
|
|
232
|
+
send_request FUNCTION_GET_POWER, [], '', 4, 'l'
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# The period in ms is the period with which the CALLBACK_POWER callback is triggered
|
|
236
|
+
# periodically. A value of 0 turns the callback off.
|
|
237
|
+
#
|
|
238
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
239
|
+
# triggered after the value has changed. If the value didn't change
|
|
240
|
+
# within the period, the callback is triggered immediately on change.
|
|
241
|
+
#
|
|
242
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
243
|
+
# independent of the value.
|
|
244
|
+
#
|
|
245
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
246
|
+
#
|
|
247
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_POWER callback.
|
|
248
|
+
#
|
|
249
|
+
# The following options are possible:
|
|
250
|
+
#
|
|
251
|
+
# "Option", "Description"
|
|
252
|
+
#
|
|
253
|
+
# "'x'", "Threshold is turned off"
|
|
254
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
255
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
256
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
257
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
258
|
+
#
|
|
259
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
260
|
+
#
|
|
261
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
262
|
+
def set_power_callback_configuration(period, value_has_to_change, option, min, max)
|
|
263
|
+
send_request FUNCTION_SET_POWER_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Returns the callback configuration as set by BrickletVoltageCurrentV2#set_power_callback_configuration.
|
|
267
|
+
def get_power_callback_configuration
|
|
268
|
+
send_request FUNCTION_GET_POWER_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Sets the configuration of the Voltage/Current Bricklet 2.0. It is
|
|
272
|
+
# possible to configure number of averages as well as
|
|
273
|
+
# voltage and current conversion time.
|
|
274
|
+
#
|
|
275
|
+
# Averaging:
|
|
276
|
+
#
|
|
277
|
+
# "Value", "Number of Averages"
|
|
278
|
+
#
|
|
279
|
+
# "0", "1"
|
|
280
|
+
# "1", "4"
|
|
281
|
+
# "2", "16"
|
|
282
|
+
# "3", "64"
|
|
283
|
+
# "4", "128"
|
|
284
|
+
# "5", "256"
|
|
285
|
+
# "6", "512"
|
|
286
|
+
# ">=7", "1024"
|
|
287
|
+
#
|
|
288
|
+
# Voltage/Current conversion:
|
|
289
|
+
#
|
|
290
|
+
# "Value", "Conversion time"
|
|
291
|
+
#
|
|
292
|
+
# "0", "140µs"
|
|
293
|
+
# "1", "204µs"
|
|
294
|
+
# "2", "332µs"
|
|
295
|
+
# "3", "588µs"
|
|
296
|
+
# "4", "1.1ms"
|
|
297
|
+
# "5", "2.116ms"
|
|
298
|
+
# "6", "4.156ms"
|
|
299
|
+
# ">=7", "8.244ms"
|
|
300
|
+
#
|
|
301
|
+
# The default values are 3, 4 and 4 (64, 1.1ms, 1.1ms) for averaging, voltage
|
|
302
|
+
# conversion and current conversion.
|
|
303
|
+
def set_configuration(averaging, voltage_conversion_time, current_conversion_time)
|
|
304
|
+
send_request FUNCTION_SET_CONFIGURATION, [averaging, voltage_conversion_time, current_conversion_time], 'C C C', 0, ''
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# Returns the configuration as set by BrickletVoltageCurrentV2#set_configuration.
|
|
308
|
+
def get_configuration
|
|
309
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 3, 'C C C'
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# Since the ADC and the shunt resistor used for the measurements
|
|
313
|
+
# are not perfect they need to be calibrated by a multiplier and
|
|
314
|
+
# a divisor if a very precise reading is needed.
|
|
315
|
+
#
|
|
316
|
+
# For example, if you are expecting a current of 1000mA and you
|
|
317
|
+
# are measuring 1023mA, you can calibrate the Voltage/Current Bricklet
|
|
318
|
+
# by setting the current multiplier to 1000 and the divisor to 1023.
|
|
319
|
+
# The same applies for the voltage.
|
|
320
|
+
def set_calibration(voltage_multiplier, voltage_divisor, current_multiplier, current_divisor)
|
|
321
|
+
send_request FUNCTION_SET_CALIBRATION, [voltage_multiplier, voltage_divisor, current_multiplier, current_divisor], 'S S S S', 0, ''
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Returns the calibration as set by BrickletVoltageCurrentV2#set_calibration.
|
|
325
|
+
def get_calibration
|
|
326
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 8, 'S S S S'
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
330
|
+
#
|
|
331
|
+
# The errors are divided into
|
|
332
|
+
#
|
|
333
|
+
# * ack checksum errors,
|
|
334
|
+
# * message checksum errors,
|
|
335
|
+
# * frameing errors and
|
|
336
|
+
# * overflow errors.
|
|
337
|
+
#
|
|
338
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
339
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
340
|
+
def get_spitfp_error_count
|
|
341
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
345
|
+
# mode change was instigated.
|
|
346
|
+
#
|
|
347
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
348
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
349
|
+
# device identifier und crc are present and correct.
|
|
350
|
+
#
|
|
351
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
352
|
+
# necessary to call it in a normal user program.
|
|
353
|
+
def set_bootloader_mode(mode)
|
|
354
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
# Returns the current bootloader mode, see BrickletVoltageCurrentV2#set_bootloader_mode.
|
|
358
|
+
def get_bootloader_mode
|
|
359
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# Sets the firmware pointer for BrickletVoltageCurrentV2#write_firmware. The pointer has
|
|
363
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
364
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
365
|
+
#
|
|
366
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
367
|
+
# necessary to call it in a normal user program.
|
|
368
|
+
def set_write_firmware_pointer(pointer)
|
|
369
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
373
|
+
# BrickletVoltageCurrentV2#set_write_firmware_pointer before. The firmware is written
|
|
374
|
+
# to flash every 4 chunks.
|
|
375
|
+
#
|
|
376
|
+
# You can only write firmware in bootloader mode.
|
|
377
|
+
#
|
|
378
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
379
|
+
# necessary to call it in a normal user program.
|
|
380
|
+
def write_firmware(data)
|
|
381
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
# Sets the status LED configuration. By default the LED shows
|
|
385
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
386
|
+
# for every 10 received data packets.
|
|
387
|
+
#
|
|
388
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
389
|
+
#
|
|
390
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
391
|
+
def set_status_led_config(config)
|
|
392
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Returns the configuration as set by BrickletVoltageCurrentV2#set_status_led_config
|
|
396
|
+
def get_status_led_config
|
|
397
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
401
|
+
# value returned is not the ambient temperature!
|
|
402
|
+
#
|
|
403
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
404
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
405
|
+
# temperature changes.
|
|
406
|
+
def get_chip_temperature
|
|
407
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
411
|
+
# will be lost.
|
|
412
|
+
#
|
|
413
|
+
# After a reset you have to create new device objects,
|
|
414
|
+
# calling functions on the existing ones will result in
|
|
415
|
+
# undefined behavior!
|
|
416
|
+
def reset
|
|
417
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
421
|
+
# you have to decode the Base58 encoded UID string into an
|
|
422
|
+
# integer first.
|
|
423
|
+
#
|
|
424
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
425
|
+
def write_uid(uid)
|
|
426
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
# Returns the current UID as an integer. Encode as
|
|
430
|
+
# Base58 to get the usual string version.
|
|
431
|
+
def read_uid
|
|
432
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
436
|
+
# the position, the hardware and firmware version as well as the
|
|
437
|
+
# device identifier.
|
|
438
|
+
#
|
|
439
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
440
|
+
#
|
|
441
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
442
|
+
# |device_identifier_constant|
|
|
443
|
+
def get_identity
|
|
444
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
448
|
+
def register_callback(id, &block)
|
|
449
|
+
callback = block
|
|
450
|
+
@registered_callbacks[id] = callback
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
end
|