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 #
|
|
@@ -0,0 +1,342 @@
|
|
|
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
|
+
# 4 galvanically isolated digital inputs
|
|
14
|
+
class BrickletIndustrialDigitalIn4V2 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2100 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Digital In 4 Bricklet 2.0' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered periodically according to the configuration set by
|
|
19
|
+
# BrickletIndustrialDigitalIn4V2#set_value_callback_configuration.
|
|
20
|
+
#
|
|
21
|
+
# The parameters are the channel, a value-changed indicator and the actual
|
|
22
|
+
# value for the channel. The `changed` parameter is true if the value has changed
|
|
23
|
+
# since the last callback.
|
|
24
|
+
CALLBACK_VALUE = 11
|
|
25
|
+
|
|
26
|
+
# This callback is triggered periodically according to the configuration set by
|
|
27
|
+
# BrickletIndustrialDigitalIn4V2#set_all_value_callback_configuration.
|
|
28
|
+
#
|
|
29
|
+
# The parameters are the same as BrickletIndustrialDigitalIn4V2#get_value. Additional the
|
|
30
|
+
# `changed` parameter is true if the value has changed since
|
|
31
|
+
# the last callback.
|
|
32
|
+
CALLBACK_ALL_VALUE = 12
|
|
33
|
+
|
|
34
|
+
FUNCTION_GET_VALUE = 1 # :nodoc:
|
|
35
|
+
FUNCTION_SET_VALUE_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
36
|
+
FUNCTION_GET_VALUE_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
37
|
+
FUNCTION_SET_ALL_VALUE_CALLBACK_CONFIGURATION = 4 # :nodoc:
|
|
38
|
+
FUNCTION_GET_ALL_VALUE_CALLBACK_CONFIGURATION = 5 # :nodoc:
|
|
39
|
+
FUNCTION_GET_EDGE_COUNT = 6 # :nodoc:
|
|
40
|
+
FUNCTION_SET_EDGE_COUNT_CONFIGURATION = 7 # :nodoc:
|
|
41
|
+
FUNCTION_GET_EDGE_COUNT_CONFIGURATION = 8 # :nodoc:
|
|
42
|
+
FUNCTION_SET_CHANNEL_LED_CONFIG = 9 # :nodoc:
|
|
43
|
+
FUNCTION_GET_CHANNEL_LED_CONFIG = 10 # :nodoc:
|
|
44
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
45
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
46
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
47
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
48
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
49
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
50
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
51
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
52
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
53
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
54
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
55
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
56
|
+
|
|
57
|
+
CHANNEL_0 = 0 # :nodoc:
|
|
58
|
+
CHANNEL_1 = 1 # :nodoc:
|
|
59
|
+
CHANNEL_2 = 2 # :nodoc:
|
|
60
|
+
CHANNEL_3 = 3 # :nodoc:
|
|
61
|
+
EDGE_TYPE_RISING = 0 # :nodoc:
|
|
62
|
+
EDGE_TYPE_FALLING = 1 # :nodoc:
|
|
63
|
+
EDGE_TYPE_BOTH = 2 # :nodoc:
|
|
64
|
+
CHANNEL_LED_CONFIG_OFF = 0 # :nodoc:
|
|
65
|
+
CHANNEL_LED_CONFIG_ON = 1 # :nodoc:
|
|
66
|
+
CHANNEL_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
67
|
+
CHANNEL_LED_CONFIG_SHOW_CHANNEL_STATUS = 3 # :nodoc:
|
|
68
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
69
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
70
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
71
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
72
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
73
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
74
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
75
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
76
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
77
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
78
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
79
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
80
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
81
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
82
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
83
|
+
|
|
84
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
86
|
+
def initialize(uid, ipcon)
|
|
87
|
+
super uid, ipcon
|
|
88
|
+
|
|
89
|
+
@api_version = [2, 0, 0]
|
|
90
|
+
|
|
91
|
+
@response_expected[FUNCTION_GET_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
|
+
@response_expected[FUNCTION_SET_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
93
|
+
@response_expected[FUNCTION_GET_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
94
|
+
@response_expected[FUNCTION_SET_ALL_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
95
|
+
@response_expected[FUNCTION_GET_ALL_VALUE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
96
|
+
@response_expected[FUNCTION_GET_EDGE_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
97
|
+
@response_expected[FUNCTION_SET_EDGE_COUNT_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
98
|
+
@response_expected[FUNCTION_GET_EDGE_COUNT_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
99
|
+
@response_expected[FUNCTION_SET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
100
|
+
@response_expected[FUNCTION_GET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
104
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
105
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
106
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
107
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
108
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
109
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
110
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
111
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
112
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
113
|
+
|
|
114
|
+
@callback_formats[CALLBACK_VALUE] = 'C ? ?'
|
|
115
|
+
@callback_formats[CALLBACK_ALL_VALUE] = '?4 ?4'
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Returns the input value as bools, *true* refers to high and *false* refers to low.
|
|
120
|
+
def get_value
|
|
121
|
+
send_request FUNCTION_GET_VALUE, [], '', 4, '?4'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# This callback can be configured per channel.
|
|
125
|
+
#
|
|
126
|
+
# The period in ms is the period with which the CALLBACK_VALUE
|
|
127
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
128
|
+
#
|
|
129
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
130
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
131
|
+
# period, the callback is triggered immediately on change.
|
|
132
|
+
#
|
|
133
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
134
|
+
# independent of the value.
|
|
135
|
+
#
|
|
136
|
+
# The default value is (0, false).
|
|
137
|
+
def set_value_callback_configuration(channel, period, value_has_to_change)
|
|
138
|
+
send_request FUNCTION_SET_VALUE_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change], 'C L ?', 0, ''
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Returns the callback configuration for the given channel as set by
|
|
142
|
+
# BrickletIndustrialDigitalIn4V2#set_value_callback_configuration.
|
|
143
|
+
def get_value_callback_configuration(channel)
|
|
144
|
+
send_request FUNCTION_GET_VALUE_CALLBACK_CONFIGURATION, [channel], 'C', 5, 'L ?'
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# The period in ms is the period with which the CALLBACK_ALL_VALUE
|
|
148
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
149
|
+
#
|
|
150
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
151
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
152
|
+
# period, the callback is triggered immediately on change.
|
|
153
|
+
#
|
|
154
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
155
|
+
# independent of the value.
|
|
156
|
+
#
|
|
157
|
+
# The default value is (0, false).
|
|
158
|
+
def set_all_value_callback_configuration(period, value_has_to_change)
|
|
159
|
+
send_request FUNCTION_SET_ALL_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Returns the callback configuration as set by
|
|
163
|
+
# BrickletIndustrialDigitalIn4V2#set_all_value_callback_configuration.
|
|
164
|
+
def get_all_value_callback_configuration
|
|
165
|
+
send_request FUNCTION_GET_ALL_VALUE_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Returns the current value of the edge counter for the selected channel. You can
|
|
169
|
+
# configure the edges that are counted with BrickletIndustrialDigitalIn4V2#set_edge_count_configuration.
|
|
170
|
+
#
|
|
171
|
+
# If you set the reset counter to *true*, the count is set back to 0
|
|
172
|
+
# directly after it is read.
|
|
173
|
+
def get_edge_count(channel, reset_counter)
|
|
174
|
+
send_request FUNCTION_GET_EDGE_COUNT, [channel, reset_counter], 'C ?', 4, 'L'
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Configures the edge counter for a specific channel.
|
|
178
|
+
#
|
|
179
|
+
# The edge type parameter configures if rising edges, falling edges or both are
|
|
180
|
+
# counted. Possible edge types are:
|
|
181
|
+
#
|
|
182
|
+
# * 0 = rising (default)
|
|
183
|
+
# * 1 = falling
|
|
184
|
+
# * 2 = both
|
|
185
|
+
#
|
|
186
|
+
# The debounce time is given in ms.
|
|
187
|
+
#
|
|
188
|
+
# Configuring an edge counter resets its value to 0.
|
|
189
|
+
#
|
|
190
|
+
# If you don't know what any of this means, just leave it at default. The
|
|
191
|
+
# default configuration is very likely OK for you.
|
|
192
|
+
#
|
|
193
|
+
# Default values: 0 (edge type) and 100ms (debounce time)
|
|
194
|
+
def set_edge_count_configuration(channel, edge_type, debounce)
|
|
195
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIGURATION, [channel, edge_type, debounce], 'C C C', 0, ''
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Returns the edge type and debounce time for the selected channel as set by
|
|
199
|
+
# BrickletIndustrialDigitalIn4V2#set_edge_count_configuration.
|
|
200
|
+
def get_edge_count_configuration(channel)
|
|
201
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIGURATION, [channel], 'C', 2, 'C C'
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Each channel has a corresponding LED. You can turn the LED Off, On or show a
|
|
205
|
+
# heartbeat. You can also set the LED to "Channel Status". In this mode the
|
|
206
|
+
# LED is on if the channel is high and off otherwise.
|
|
207
|
+
#
|
|
208
|
+
# By default all channel LEDs are configured as "Channel Status".
|
|
209
|
+
def set_channel_led_config(channel, config)
|
|
210
|
+
send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [channel, config], 'C C', 0, ''
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Returns the Channel LED configuration as set by BrickletIndustrialDigitalIn4V2#set_channel_led_config
|
|
214
|
+
def get_channel_led_config(channel)
|
|
215
|
+
send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [channel], 'C', 1, 'C'
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
219
|
+
#
|
|
220
|
+
# The errors are divided into
|
|
221
|
+
#
|
|
222
|
+
# * ack checksum errors,
|
|
223
|
+
# * message checksum errors,
|
|
224
|
+
# * frameing errors and
|
|
225
|
+
# * overflow errors.
|
|
226
|
+
#
|
|
227
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
228
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
229
|
+
def get_spitfp_error_count
|
|
230
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
234
|
+
# mode change was instigated.
|
|
235
|
+
#
|
|
236
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
237
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
238
|
+
# device identifier und crc are present and correct.
|
|
239
|
+
#
|
|
240
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
241
|
+
# necessary to call it in a normal user program.
|
|
242
|
+
def set_bootloader_mode(mode)
|
|
243
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Returns the current bootloader mode, see BrickletIndustrialDigitalIn4V2#set_bootloader_mode.
|
|
247
|
+
def get_bootloader_mode
|
|
248
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Sets the firmware pointer for BrickletIndustrialDigitalIn4V2#write_firmware. The pointer has
|
|
252
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
253
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
254
|
+
#
|
|
255
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
256
|
+
# necessary to call it in a normal user program.
|
|
257
|
+
def set_write_firmware_pointer(pointer)
|
|
258
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
262
|
+
# BrickletIndustrialDigitalIn4V2#set_write_firmware_pointer before. The firmware is written
|
|
263
|
+
# to flash every 4 chunks.
|
|
264
|
+
#
|
|
265
|
+
# You can only write firmware in bootloader mode.
|
|
266
|
+
#
|
|
267
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
268
|
+
# necessary to call it in a normal user program.
|
|
269
|
+
def write_firmware(data)
|
|
270
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Sets the status LED configuration. By default the LED shows
|
|
274
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
275
|
+
# for every 10 received data packets.
|
|
276
|
+
#
|
|
277
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
278
|
+
#
|
|
279
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
280
|
+
def set_status_led_config(config)
|
|
281
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Returns the configuration as set by BrickletIndustrialDigitalIn4V2#set_status_led_config
|
|
285
|
+
def get_status_led_config
|
|
286
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
290
|
+
# value returned is not the ambient temperature!
|
|
291
|
+
#
|
|
292
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
293
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
294
|
+
# temperature changes.
|
|
295
|
+
def get_chip_temperature
|
|
296
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
300
|
+
# will be lost.
|
|
301
|
+
#
|
|
302
|
+
# After a reset you have to create new device objects,
|
|
303
|
+
# calling functions on the existing ones will result in
|
|
304
|
+
# undefined behavior!
|
|
305
|
+
def reset
|
|
306
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
310
|
+
# you have to decode the Base58 encoded UID string into an
|
|
311
|
+
# integer first.
|
|
312
|
+
#
|
|
313
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
314
|
+
def write_uid(uid)
|
|
315
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# Returns the current UID as an integer. Encode as
|
|
319
|
+
# Base58 to get the usual string version.
|
|
320
|
+
def read_uid
|
|
321
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
325
|
+
# the position, the hardware and firmware version as well as the
|
|
326
|
+
# device identifier.
|
|
327
|
+
#
|
|
328
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
329
|
+
#
|
|
330
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
331
|
+
# |device_identifier_constant|
|
|
332
|
+
def get_identity
|
|
333
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
337
|
+
def register_callback(id, &block)
|
|
338
|
+
callback = block
|
|
339
|
+
@registered_callbacks[id] = callback
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
end
|
|
@@ -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,263 @@
|
|
|
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
|
+
# Two relays to switch AC/DC devices
|
|
14
|
+
class BrickletIndustrialDualRelay < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 284 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Industrial Dual Relay Bricklet' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered whenever a monoflop timer reaches 0. The
|
|
19
|
+
# parameter contain the relay (0 or 1) and the current state of the relay
|
|
20
|
+
# (the state after the monoflop).
|
|
21
|
+
CALLBACK_MONOFLOP_DONE = 5
|
|
22
|
+
|
|
23
|
+
FUNCTION_SET_VALUE = 1 # :nodoc:
|
|
24
|
+
FUNCTION_GET_VALUE = 2 # :nodoc:
|
|
25
|
+
FUNCTION_SET_MONOFLOP = 3 # :nodoc:
|
|
26
|
+
FUNCTION_GET_MONOFLOP = 4 # :nodoc:
|
|
27
|
+
FUNCTION_SET_SELECTED_VALUE = 6 # :nodoc:
|
|
28
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
29
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
30
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
31
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
32
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
33
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
34
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
35
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
36
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
37
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
38
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
39
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
40
|
+
|
|
41
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
42
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
43
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
44
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
45
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
46
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
47
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
48
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
49
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
50
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
51
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
52
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
53
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
54
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
55
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
56
|
+
|
|
57
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
58
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
59
|
+
def initialize(uid, ipcon)
|
|
60
|
+
super uid, ipcon
|
|
61
|
+
|
|
62
|
+
@api_version = [2, 0, 0]
|
|
63
|
+
|
|
64
|
+
@response_expected[FUNCTION_SET_VALUE] = RESPONSE_EXPECTED_FALSE
|
|
65
|
+
@response_expected[FUNCTION_GET_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
66
|
+
@response_expected[FUNCTION_SET_MONOFLOP] = RESPONSE_EXPECTED_FALSE
|
|
67
|
+
@response_expected[FUNCTION_GET_MONOFLOP] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
68
|
+
@response_expected[FUNCTION_SET_SELECTED_VALUE] = RESPONSE_EXPECTED_FALSE
|
|
69
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
70
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
71
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
72
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
73
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
74
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
75
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
76
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
77
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
78
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
79
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
80
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
81
|
+
|
|
82
|
+
@callback_formats[CALLBACK_MONOFLOP_DONE] = 'C ?'
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Sets the state of the relays, *true* means on and *false* means off.
|
|
87
|
+
# For example: (true, false) turns relay 0 on and relay 1 off.
|
|
88
|
+
#
|
|
89
|
+
# If you just want to set one of the relays and don't know the current state
|
|
90
|
+
# of the other relay, you can get the state with BrickletIndustrialDualRelay#get_value or you
|
|
91
|
+
# can use BrickletIndustrialDualRelay#set_selected_value.
|
|
92
|
+
#
|
|
93
|
+
# Running monoflop timers will be overwritten if this function is called.
|
|
94
|
+
#
|
|
95
|
+
# The default value is (*false*, *false*).
|
|
96
|
+
def set_value(channel0, channel1)
|
|
97
|
+
send_request FUNCTION_SET_VALUE, [channel0, channel1], '? ?', 0, ''
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Returns the state of the relays, *true* means on and *false* means off.
|
|
101
|
+
def get_value
|
|
102
|
+
send_request FUNCTION_GET_VALUE, [], '', 2, '? ?'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# The first parameter can be 0 or 1 (relay 0 or relay 1). The second parameter
|
|
106
|
+
# is the desired state of the relay (*true* means on and *false* means off).
|
|
107
|
+
# The third parameter indicates the time (in ms) that the relay should hold
|
|
108
|
+
# the state.
|
|
109
|
+
#
|
|
110
|
+
# If this function is called with the parameters (1, true, 1500):
|
|
111
|
+
# Relay 1 will turn on and in 1.5s it will turn off again.
|
|
112
|
+
#
|
|
113
|
+
# A monoflop can be used as a failsafe mechanism. For example: Lets assume you
|
|
114
|
+
# have a RS485 bus and a Industrial Dual Relay Bricklet connected to one of the
|
|
115
|
+
# slave stacks. You can now call this function every second, with a time parameter
|
|
116
|
+
# of two seconds. The relay will be on all the time. If now the RS485
|
|
117
|
+
# connection is lost, the relay will turn off in at most two seconds.
|
|
118
|
+
def set_monoflop(channel, value, time)
|
|
119
|
+
send_request FUNCTION_SET_MONOFLOP, [channel, value, time], 'C ? L', 0, ''
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Returns (for the given relay) the current state and the time as set by
|
|
123
|
+
# BrickletIndustrialDualRelay#set_monoflop as well as the remaining time until the state flips.
|
|
124
|
+
#
|
|
125
|
+
# If the timer is not running currently, the remaining time will be returned
|
|
126
|
+
# as 0.
|
|
127
|
+
def get_monoflop(channel)
|
|
128
|
+
send_request FUNCTION_GET_MONOFLOP, [channel], 'C', 9, '? L L'
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Sets the state of the selected relay (0 or 1), *true* means on and *false*
|
|
132
|
+
# means off.
|
|
133
|
+
#
|
|
134
|
+
# The other relay remains untouched.
|
|
135
|
+
def set_selected_value(channel, value)
|
|
136
|
+
send_request FUNCTION_SET_SELECTED_VALUE, [channel, value], 'C ?', 0, ''
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
140
|
+
#
|
|
141
|
+
# The errors are divided into
|
|
142
|
+
#
|
|
143
|
+
# * ack checksum errors,
|
|
144
|
+
# * message checksum errors,
|
|
145
|
+
# * frameing errors and
|
|
146
|
+
# * overflow errors.
|
|
147
|
+
#
|
|
148
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
149
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
150
|
+
def get_spitfp_error_count
|
|
151
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
155
|
+
# mode change was instigated.
|
|
156
|
+
#
|
|
157
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
158
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
159
|
+
# device identifier und crc are present and correct.
|
|
160
|
+
#
|
|
161
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
162
|
+
# necessary to call it in a normal user program.
|
|
163
|
+
def set_bootloader_mode(mode)
|
|
164
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Returns the current bootloader mode, see BrickletIndustrialDualRelay#set_bootloader_mode.
|
|
168
|
+
def get_bootloader_mode
|
|
169
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Sets the firmware pointer for BrickletIndustrialDualRelay#write_firmware. The pointer has
|
|
173
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
174
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
175
|
+
#
|
|
176
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
177
|
+
# necessary to call it in a normal user program.
|
|
178
|
+
def set_write_firmware_pointer(pointer)
|
|
179
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
183
|
+
# BrickletIndustrialDualRelay#set_write_firmware_pointer before. The firmware is written
|
|
184
|
+
# to flash every 4 chunks.
|
|
185
|
+
#
|
|
186
|
+
# You can only write firmware in bootloader mode.
|
|
187
|
+
#
|
|
188
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
189
|
+
# necessary to call it in a normal user program.
|
|
190
|
+
def write_firmware(data)
|
|
191
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Sets the status LED configuration. By default the LED shows
|
|
195
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
196
|
+
# for every 10 received data packets.
|
|
197
|
+
#
|
|
198
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
199
|
+
#
|
|
200
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
201
|
+
def set_status_led_config(config)
|
|
202
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Returns the configuration as set by BrickletIndustrialDualRelay#set_status_led_config
|
|
206
|
+
def get_status_led_config
|
|
207
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
211
|
+
# value returned is not the ambient temperature!
|
|
212
|
+
#
|
|
213
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
214
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
215
|
+
# temperature changes.
|
|
216
|
+
def get_chip_temperature
|
|
217
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
221
|
+
# will be lost.
|
|
222
|
+
#
|
|
223
|
+
# After a reset you have to create new device objects,
|
|
224
|
+
# calling functions on the existing ones will result in
|
|
225
|
+
# undefined behavior!
|
|
226
|
+
def reset
|
|
227
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
231
|
+
# you have to decode the Base58 encoded UID string into an
|
|
232
|
+
# integer first.
|
|
233
|
+
#
|
|
234
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
235
|
+
def write_uid(uid)
|
|
236
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Returns the current UID as an integer. Encode as
|
|
240
|
+
# Base58 to get the usual string version.
|
|
241
|
+
def read_uid
|
|
242
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
246
|
+
# the position, the hardware and firmware version as well as the
|
|
247
|
+
# device identifier.
|
|
248
|
+
#
|
|
249
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
250
|
+
#
|
|
251
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
252
|
+
# |device_identifier_constant|
|
|
253
|
+
def get_identity
|
|
254
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
258
|
+
def register_callback(id, &block)
|
|
259
|
+
callback = block
|
|
260
|
+
@registered_callbacks[id] = callback
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|