tinkerforge 2.1.24 → 2.1.25
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 +155 -74
- data/lib/tinkerforge/brick_hat.rb +70 -30
- data/lib/tinkerforge/brick_hat_zero.rb +56 -22
- data/lib/tinkerforge/brick_imu.rb +184 -77
- data/lib/tinkerforge/brick_imu_v2.rb +208 -105
- data/lib/tinkerforge/brick_master.rb +484 -182
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +185 -101
- data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
- data/lib/tinkerforge/brick_stepper.rb +210 -98
- data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
- data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
- data/lib/tinkerforge/bricklet_barometer.rb +66 -26
- data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -18
- data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
- data/lib/tinkerforge/bricklet_co2.rb +34 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
- data/lib/tinkerforge/bricklet_color.rb +69 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
- data/lib/tinkerforge/bricklet_compass.rb +78 -30
- data/lib/tinkerforge/bricklet_current12.rb +58 -24
- data/lib/tinkerforge/bricklet_current25.rb +58 -24
- data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_dmx.rb +88 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
- data/lib/tinkerforge/bricklet_gps.rb +64 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_humidity.rb +51 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_io16.rb +55 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
- data/lib/tinkerforge/bricklet_io4.rb +55 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -28
- data/lib/tinkerforge/bricklet_joystick.rb +59 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
- data/lib/tinkerforge/bricklet_line.rb +34 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
- data/lib/tinkerforge/bricklet_moisture.rb +40 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
- data/lib/tinkerforge/bricklet_nfc.rb +123 -58
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
- data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
- data/lib/tinkerforge/bricklet_ptc.rb +74 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_rs232.rb +90 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
- data/lib/tinkerforge/bricklet_rs485.rb +223 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
- data/lib/tinkerforge/bricklet_temperature.rb +40 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
- data/lib/tinkerforge/bricklet_tilt.rb +24 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
- data/lib/tinkerforge/bricklet_voltage.rb +52 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
- data/lib/tinkerforge/device_display_names.rb +163 -0
- data/lib/tinkerforge/ip_connection.rb +151 -32
- data/lib/tinkerforge/version.rb +1 -1
- metadata +3 -2
|
@@ -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-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
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
|
# Battery-backed real-time clock
|
|
14
16
|
class BrickletRealTimeClock < Device
|
|
@@ -56,7 +58,7 @@ module Tinkerforge
|
|
|
56
58
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
57
59
|
# the IP Connection <tt>ipcon</tt>.
|
|
58
60
|
def initialize(uid, ipcon)
|
|
59
|
-
super uid, ipcon
|
|
61
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
60
62
|
|
|
61
63
|
@api_version = [2, 0, 1]
|
|
62
64
|
|
|
@@ -71,24 +73,13 @@ module Tinkerforge
|
|
|
71
73
|
@response_expected[FUNCTION_GET_ALARM] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
72
74
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
73
75
|
|
|
74
|
-
@callback_formats[CALLBACK_DATE_TIME] = 'S C C C C C C C q'
|
|
75
|
-
@callback_formats[CALLBACK_ALARM] = 'S C C C C C C C q'
|
|
76
|
+
@callback_formats[CALLBACK_DATE_TIME] = [25, 'S C C C C C C C q']
|
|
77
|
+
@callback_formats[CALLBACK_ALARM] = [25, 'S C C C C C C C q']
|
|
76
78
|
|
|
79
|
+
@ipcon.add_device self
|
|
77
80
|
end
|
|
78
81
|
|
|
79
|
-
# Sets the current date (including weekday) and the current time
|
|
80
|
-
# of a second resolution.
|
|
81
|
-
#
|
|
82
|
-
# Possible value ranges:
|
|
83
|
-
#
|
|
84
|
-
# * Year: 2000 to 2099
|
|
85
|
-
# * Month: 1 to 12 (January to December)
|
|
86
|
-
# * Day: 1 to 31
|
|
87
|
-
# * Hour: 0 to 23
|
|
88
|
-
# * Minute: 0 to 59
|
|
89
|
-
# * Second: 0 to 59
|
|
90
|
-
# * Centisecond: 0 to 99
|
|
91
|
-
# * Weekday: 1 to 7 (Monday to Sunday)
|
|
82
|
+
# Sets the current date (including weekday) and the current time.
|
|
92
83
|
#
|
|
93
84
|
# If the backup battery is installed then the real-time clock keeps date and
|
|
94
85
|
# time even if the Bricklet is not powered by a Brick.
|
|
@@ -97,20 +88,26 @@ module Tinkerforge
|
|
|
97
88
|
# accordingly. But leap seconds, time zones and daylight saving time are not
|
|
98
89
|
# handled.
|
|
99
90
|
def set_date_time(year, month, day, hour, minute, second, centisecond, weekday)
|
|
100
|
-
|
|
91
|
+
check_validity
|
|
92
|
+
|
|
93
|
+
send_request FUNCTION_SET_DATE_TIME, [year, month, day, hour, minute, second, centisecond, weekday], 'S C C C C C C C', 8, ''
|
|
101
94
|
end
|
|
102
95
|
|
|
103
96
|
# Returns the current date (including weekday) and the current time of the
|
|
104
|
-
# real-time clock
|
|
97
|
+
# real-time clock.
|
|
105
98
|
def get_date_time
|
|
106
|
-
|
|
99
|
+
check_validity
|
|
100
|
+
|
|
101
|
+
send_request FUNCTION_GET_DATE_TIME, [], '', 17, 'S C C C C C C C'
|
|
107
102
|
end
|
|
108
103
|
|
|
109
|
-
# Returns the current date and the time of the real-time clock
|
|
110
|
-
#
|
|
111
|
-
# second.
|
|
104
|
+
# Returns the current date and the time of the real-time clock.
|
|
105
|
+
# The timestamp has an effective resolution of hundredths of a
|
|
106
|
+
# second and is an offset to 2000-01-01 00:00:00.000.
|
|
112
107
|
def get_timestamp
|
|
113
|
-
|
|
108
|
+
check_validity
|
|
109
|
+
|
|
110
|
+
send_request FUNCTION_GET_TIMESTAMP, [], '', 16, 'q'
|
|
114
111
|
end
|
|
115
112
|
|
|
116
113
|
# Sets the offset the real-time clock should compensate for in 2.17 ppm steps
|
|
@@ -139,12 +136,16 @@ module Tinkerforge
|
|
|
139
136
|
# The offset is saved in the EEPROM of the Bricklet and only needs to be
|
|
140
137
|
# configured once.
|
|
141
138
|
def set_offset(offset)
|
|
142
|
-
|
|
139
|
+
check_validity
|
|
140
|
+
|
|
141
|
+
send_request FUNCTION_SET_OFFSET, [offset], 'c', 8, ''
|
|
143
142
|
end
|
|
144
143
|
|
|
145
144
|
# Returns the offset as set by BrickletRealTimeClock#set_offset.
|
|
146
145
|
def get_offset
|
|
147
|
-
|
|
146
|
+
check_validity
|
|
147
|
+
|
|
148
|
+
send_request FUNCTION_GET_OFFSET, [], '', 9, 'c'
|
|
148
149
|
end
|
|
149
150
|
|
|
150
151
|
# Sets the period with which the CALLBACK_DATE_TIME callback is triggered
|
|
@@ -155,14 +156,18 @@ module Tinkerforge
|
|
|
155
156
|
#
|
|
156
157
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
157
158
|
def set_date_time_callback_period(period)
|
|
158
|
-
|
|
159
|
+
check_validity
|
|
160
|
+
|
|
161
|
+
send_request FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
159
162
|
end
|
|
160
163
|
|
|
161
164
|
# Returns the period as set by BrickletRealTimeClock#set_date_time_callback_period.
|
|
162
165
|
#
|
|
163
166
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
164
167
|
def get_date_time_callback_period
|
|
165
|
-
|
|
168
|
+
check_validity
|
|
169
|
+
|
|
170
|
+
send_request FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
166
171
|
end
|
|
167
172
|
|
|
168
173
|
# Configures a repeatable alarm. The CALLBACK_ALARM callback is triggered if the
|
|
@@ -192,26 +197,33 @@ module Tinkerforge
|
|
|
192
197
|
#
|
|
193
198
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
194
199
|
def set_alarm(month, day, hour, minute, second, weekday, interval)
|
|
195
|
-
|
|
200
|
+
check_validity
|
|
201
|
+
|
|
202
|
+
send_request FUNCTION_SET_ALARM, [month, day, hour, minute, second, weekday, interval], 'c c c c c c l', 8, ''
|
|
196
203
|
end
|
|
197
204
|
|
|
198
205
|
# Returns the alarm configuration as set by BrickletRealTimeClock#set_alarm.
|
|
199
206
|
#
|
|
200
207
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
201
208
|
def get_alarm
|
|
202
|
-
|
|
209
|
+
check_validity
|
|
210
|
+
|
|
211
|
+
send_request FUNCTION_GET_ALARM, [], '', 18, 'c c c c c c l'
|
|
203
212
|
end
|
|
204
213
|
|
|
205
214
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
206
215
|
# the position, the hardware and firmware version as well as the
|
|
207
216
|
# device identifier.
|
|
208
217
|
#
|
|
209
|
-
# The position can be 'a', 'b', 'c' or '
|
|
218
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
219
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
220
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
221
|
+
# position 'z'.
|
|
210
222
|
#
|
|
211
223
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
212
224
|
# |device_identifier_constant|
|
|
213
225
|
def get_identity
|
|
214
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
226
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
215
227
|
end
|
|
216
228
|
|
|
217
229
|
# 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-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
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
|
# Battery-backed real-time clock
|
|
14
16
|
class BrickletRealTimeClockV2 < Device
|
|
@@ -75,7 +77,7 @@ module Tinkerforge
|
|
|
75
77
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
76
78
|
# the IP Connection <tt>ipcon</tt>.
|
|
77
79
|
def initialize(uid, ipcon)
|
|
78
|
-
super uid, ipcon
|
|
80
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
79
81
|
|
|
80
82
|
@api_version = [2, 0, 0]
|
|
81
83
|
|
|
@@ -101,24 +103,13 @@ module Tinkerforge
|
|
|
101
103
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
104
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
105
|
|
|
104
|
-
@callback_formats[CALLBACK_DATE_TIME] = 'S C C C C C C C q'
|
|
105
|
-
@callback_formats[CALLBACK_ALARM] = 'S C C C C C C C q'
|
|
106
|
+
@callback_formats[CALLBACK_DATE_TIME] = [25, 'S C C C C C C C q']
|
|
107
|
+
@callback_formats[CALLBACK_ALARM] = [25, 'S C C C C C C C q']
|
|
106
108
|
|
|
109
|
+
@ipcon.add_device self
|
|
107
110
|
end
|
|
108
111
|
|
|
109
|
-
# Sets the current date (including weekday) and the current time
|
|
110
|
-
# of a second resolution.
|
|
111
|
-
#
|
|
112
|
-
# Possible value ranges:
|
|
113
|
-
#
|
|
114
|
-
# * Year: 2000 to 2099
|
|
115
|
-
# * Month: 1 to 12 (January to December)
|
|
116
|
-
# * Day: 1 to 31
|
|
117
|
-
# * Hour: 0 to 23
|
|
118
|
-
# * Minute: 0 to 59
|
|
119
|
-
# * Second: 0 to 59
|
|
120
|
-
# * Centisecond: 0 to 99
|
|
121
|
-
# * Weekday: 1 to 7 (Monday to Sunday)
|
|
112
|
+
# Sets the current date (including weekday) and the current time.
|
|
122
113
|
#
|
|
123
114
|
# If the backup battery is installed then the real-time clock keeps date and
|
|
124
115
|
# time even if the Bricklet is not powered by a Brick.
|
|
@@ -127,23 +118,29 @@ module Tinkerforge
|
|
|
127
118
|
# accordingly. But leap seconds, time zones and daylight saving time are not
|
|
128
119
|
# handled.
|
|
129
120
|
def set_date_time(year, month, day, hour, minute, second, centisecond, weekday)
|
|
130
|
-
|
|
121
|
+
check_validity
|
|
122
|
+
|
|
123
|
+
send_request FUNCTION_SET_DATE_TIME, [year, month, day, hour, minute, second, centisecond, weekday], 'S C C C C C C C', 8, ''
|
|
131
124
|
end
|
|
132
125
|
|
|
133
126
|
# Returns the current date (including weekday) and the current time of the
|
|
134
|
-
# real-time
|
|
127
|
+
# real-time.
|
|
135
128
|
#
|
|
136
129
|
# The timestamp represents the current date and the the current time of the
|
|
137
|
-
# real-time clock converted to milliseconds.
|
|
130
|
+
# real-time clock converted to milliseconds and is an offset to 2000-01-01 00:00:00.0000.
|
|
138
131
|
def get_date_time
|
|
139
|
-
|
|
132
|
+
check_validity
|
|
133
|
+
|
|
134
|
+
send_request FUNCTION_GET_DATE_TIME, [], '', 25, 'S C C C C C C C q'
|
|
140
135
|
end
|
|
141
136
|
|
|
142
137
|
# Returns the current date and the time of the real-time clock converted to
|
|
143
138
|
# milliseconds. The timestamp has an effective resolution of hundredths of a
|
|
144
|
-
# second.
|
|
139
|
+
# second and is an offset to 2000-01-01 00:00:00.0000.
|
|
145
140
|
def get_timestamp
|
|
146
|
-
|
|
141
|
+
check_validity
|
|
142
|
+
|
|
143
|
+
send_request FUNCTION_GET_TIMESTAMP, [], '', 16, 'q'
|
|
147
144
|
end
|
|
148
145
|
|
|
149
146
|
# Sets the offset the real-time clock should compensate for in 2.17 ppm steps
|
|
@@ -172,23 +169,31 @@ module Tinkerforge
|
|
|
172
169
|
# The offset is saved in the EEPROM of the Bricklet and only needs to be
|
|
173
170
|
# configured once.
|
|
174
171
|
def set_offset(offset)
|
|
175
|
-
|
|
172
|
+
check_validity
|
|
173
|
+
|
|
174
|
+
send_request FUNCTION_SET_OFFSET, [offset], 'c', 8, ''
|
|
176
175
|
end
|
|
177
176
|
|
|
178
177
|
# Returns the offset as set by BrickletRealTimeClockV2#set_offset.
|
|
179
178
|
def get_offset
|
|
180
|
-
|
|
179
|
+
check_validity
|
|
180
|
+
|
|
181
|
+
send_request FUNCTION_GET_OFFSET, [], '', 9, 'c'
|
|
181
182
|
end
|
|
182
183
|
|
|
183
184
|
# Sets the period with which the CALLBACK_DATE_TIME callback is triggered
|
|
184
185
|
# periodically. A value of 0 turns the callback off.
|
|
185
186
|
def set_date_time_callback_configuration(period)
|
|
186
|
-
|
|
187
|
+
check_validity
|
|
188
|
+
|
|
189
|
+
send_request FUNCTION_SET_DATE_TIME_CALLBACK_CONFIGURATION, [period], 'L', 8, ''
|
|
187
190
|
end
|
|
188
191
|
|
|
189
192
|
# Returns the period as set by BrickletRealTimeClockV2#set_date_time_callback_configuration.
|
|
190
193
|
def get_date_time_callback_configuration
|
|
191
|
-
|
|
194
|
+
check_validity
|
|
195
|
+
|
|
196
|
+
send_request FUNCTION_GET_DATE_TIME_CALLBACK_CONFIGURATION, [], '', 12, 'L'
|
|
192
197
|
end
|
|
193
198
|
|
|
194
199
|
# Configures a repeatable alarm. The CALLBACK_ALARM callback is triggered if the
|
|
@@ -216,12 +221,16 @@ module Tinkerforge
|
|
|
216
221
|
# example, configuring the alarm as (-1, -1, 7, 30, -1, -1, 300) results in an
|
|
217
222
|
# alarm that triggers every day at 7:30 AM and is then repeated every 5 minutes.
|
|
218
223
|
def set_alarm(month, day, hour, minute, second, weekday, interval)
|
|
219
|
-
|
|
224
|
+
check_validity
|
|
225
|
+
|
|
226
|
+
send_request FUNCTION_SET_ALARM, [month, day, hour, minute, second, weekday, interval], 'c c c c c c l', 8, ''
|
|
220
227
|
end
|
|
221
228
|
|
|
222
229
|
# Returns the alarm configuration as set by BrickletRealTimeClockV2#set_alarm.
|
|
223
230
|
def get_alarm
|
|
224
|
-
|
|
231
|
+
check_validity
|
|
232
|
+
|
|
233
|
+
send_request FUNCTION_GET_ALARM, [], '', 18, 'c c c c c c l'
|
|
225
234
|
end
|
|
226
235
|
|
|
227
236
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -236,7 +245,9 @@ module Tinkerforge
|
|
|
236
245
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
237
246
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
238
247
|
def get_spitfp_error_count
|
|
239
|
-
|
|
248
|
+
check_validity
|
|
249
|
+
|
|
250
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
240
251
|
end
|
|
241
252
|
|
|
242
253
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -249,12 +260,16 @@ module Tinkerforge
|
|
|
249
260
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
250
261
|
# necessary to call it in a normal user program.
|
|
251
262
|
def set_bootloader_mode(mode)
|
|
252
|
-
|
|
263
|
+
check_validity
|
|
264
|
+
|
|
265
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
253
266
|
end
|
|
254
267
|
|
|
255
268
|
# Returns the current bootloader mode, see BrickletRealTimeClockV2#set_bootloader_mode.
|
|
256
269
|
def get_bootloader_mode
|
|
257
|
-
|
|
270
|
+
check_validity
|
|
271
|
+
|
|
272
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
258
273
|
end
|
|
259
274
|
|
|
260
275
|
# Sets the firmware pointer for BrickletRealTimeClockV2#write_firmware. The pointer has
|
|
@@ -264,7 +279,9 @@ module Tinkerforge
|
|
|
264
279
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
265
280
|
# necessary to call it in a normal user program.
|
|
266
281
|
def set_write_firmware_pointer(pointer)
|
|
267
|
-
|
|
282
|
+
check_validity
|
|
283
|
+
|
|
284
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
268
285
|
end
|
|
269
286
|
|
|
270
287
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -276,7 +293,9 @@ module Tinkerforge
|
|
|
276
293
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
277
294
|
# necessary to call it in a normal user program.
|
|
278
295
|
def write_firmware(data)
|
|
279
|
-
|
|
296
|
+
check_validity
|
|
297
|
+
|
|
298
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
280
299
|
end
|
|
281
300
|
|
|
282
301
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -287,22 +306,28 @@ module Tinkerforge
|
|
|
287
306
|
#
|
|
288
307
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
289
308
|
def set_status_led_config(config)
|
|
290
|
-
|
|
309
|
+
check_validity
|
|
310
|
+
|
|
311
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
291
312
|
end
|
|
292
313
|
|
|
293
314
|
# Returns the configuration as set by BrickletRealTimeClockV2#set_status_led_config
|
|
294
315
|
def get_status_led_config
|
|
295
|
-
|
|
316
|
+
check_validity
|
|
317
|
+
|
|
318
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
296
319
|
end
|
|
297
320
|
|
|
298
|
-
# Returns the temperature
|
|
321
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
299
322
|
# value returned is not the ambient temperature!
|
|
300
323
|
#
|
|
301
324
|
# The temperature is only proportional to the real temperature and it has bad
|
|
302
325
|
# accuracy. Practically it is only useful as an indicator for
|
|
303
326
|
# temperature changes.
|
|
304
327
|
def get_chip_temperature
|
|
305
|
-
|
|
328
|
+
check_validity
|
|
329
|
+
|
|
330
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
306
331
|
end
|
|
307
332
|
|
|
308
333
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -312,7 +337,9 @@ module Tinkerforge
|
|
|
312
337
|
# calling functions on the existing ones will result in
|
|
313
338
|
# undefined behavior!
|
|
314
339
|
def reset
|
|
315
|
-
|
|
340
|
+
check_validity
|
|
341
|
+
|
|
342
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
316
343
|
end
|
|
317
344
|
|
|
318
345
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -321,25 +348,32 @@ module Tinkerforge
|
|
|
321
348
|
#
|
|
322
349
|
# We recommend that you use Brick Viewer to change the UID.
|
|
323
350
|
def write_uid(uid)
|
|
324
|
-
|
|
351
|
+
check_validity
|
|
352
|
+
|
|
353
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
325
354
|
end
|
|
326
355
|
|
|
327
356
|
# Returns the current UID as an integer. Encode as
|
|
328
357
|
# Base58 to get the usual string version.
|
|
329
358
|
def read_uid
|
|
330
|
-
|
|
359
|
+
check_validity
|
|
360
|
+
|
|
361
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
331
362
|
end
|
|
332
363
|
|
|
333
364
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
334
365
|
# the position, the hardware and firmware version as well as the
|
|
335
366
|
# device identifier.
|
|
336
367
|
#
|
|
337
|
-
# The position can be 'a', 'b', 'c' or '
|
|
368
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
369
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
370
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
371
|
+
# position 'z'.
|
|
338
372
|
#
|
|
339
373
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
340
374
|
# |device_identifier_constant|
|
|
341
375
|
def get_identity
|
|
342
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
376
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
343
377
|
end
|
|
344
378
|
|
|
345
379
|
# 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-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
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
|
# Controls remote mains switches
|
|
14
16
|
class BrickletRemoteSwitch < Device
|
|
@@ -37,7 +39,7 @@ module Tinkerforge
|
|
|
37
39
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
38
40
|
# the IP Connection <tt>ipcon</tt>.
|
|
39
41
|
def initialize(uid, ipcon)
|
|
40
|
-
super uid, ipcon
|
|
42
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
41
43
|
|
|
42
44
|
@api_version = [2, 0, 1]
|
|
43
45
|
|
|
@@ -51,108 +53,116 @@ module Tinkerforge
|
|
|
51
53
|
@response_expected[FUNCTION_SWITCH_SOCKET_C] = RESPONSE_EXPECTED_FALSE
|
|
52
54
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
53
55
|
|
|
54
|
-
@callback_formats[CALLBACK_SWITCHING_DONE] = ''
|
|
56
|
+
@callback_formats[CALLBACK_SWITCHING_DONE] = [8, '']
|
|
55
57
|
|
|
58
|
+
@ipcon.add_device self
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
# This function is deprecated, use BrickletRemoteSwitch#switch_socket_a instead.
|
|
59
62
|
def switch_socket(house_code, receiver_code, switch_to)
|
|
60
|
-
|
|
63
|
+
check_validity
|
|
64
|
+
|
|
65
|
+
send_request FUNCTION_SWITCH_SOCKET, [house_code, receiver_code, switch_to], 'C C C', 8, ''
|
|
61
66
|
end
|
|
62
67
|
|
|
63
68
|
# Returns the current switching state. If the current state is busy, the
|
|
64
69
|
# Bricklet is currently sending a code to switch a socket. It will not
|
|
65
|
-
# accept any
|
|
70
|
+
# accept any requests to switch sockets until the state changes to ready.
|
|
66
71
|
#
|
|
67
72
|
# How long the switching takes is dependent on the number of repeats, see
|
|
68
73
|
# BrickletRemoteSwitch#set_repeats.
|
|
69
74
|
def get_switching_state
|
|
70
|
-
|
|
75
|
+
check_validity
|
|
76
|
+
|
|
77
|
+
send_request FUNCTION_GET_SWITCHING_STATE, [], '', 9, 'C'
|
|
71
78
|
end
|
|
72
79
|
|
|
73
|
-
# Sets the number of times the code is
|
|
80
|
+
# Sets the number of times the code is sent when one of the switch socket
|
|
74
81
|
# functions is called. The repeats basically correspond to the amount of time
|
|
75
82
|
# that a button of the remote is pressed.
|
|
76
83
|
#
|
|
77
84
|
# Some dimmers are controlled by the length of a button pressed,
|
|
78
85
|
# this can be simulated by increasing the repeats.
|
|
79
|
-
#
|
|
80
|
-
# The default value is 5.
|
|
81
86
|
def set_repeats(repeats)
|
|
82
|
-
|
|
87
|
+
check_validity
|
|
88
|
+
|
|
89
|
+
send_request FUNCTION_SET_REPEATS, [repeats], 'C', 8, ''
|
|
83
90
|
end
|
|
84
91
|
|
|
85
92
|
# Returns the number of repeats as set by BrickletRemoteSwitch#set_repeats.
|
|
86
93
|
def get_repeats
|
|
87
|
-
|
|
94
|
+
check_validity
|
|
95
|
+
|
|
96
|
+
send_request FUNCTION_GET_REPEATS, [], '', 9, 'C'
|
|
88
97
|
end
|
|
89
98
|
|
|
90
99
|
# To switch a type A socket you have to give the house code, receiver code and the
|
|
91
100
|
# state (on or off) you want to switch to.
|
|
92
101
|
#
|
|
93
|
-
# The house code and receiver code have a range of 0 to 31 (5bit).
|
|
94
|
-
#
|
|
95
102
|
# A detailed description on how you can figure out the house and receiver code
|
|
96
103
|
# can be found :ref:`here <remote_switch_bricklet_type_a_house_and_receiver_code>`.
|
|
97
104
|
#
|
|
98
105
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
99
106
|
def switch_socket_a(house_code, receiver_code, switch_to)
|
|
100
|
-
|
|
107
|
+
check_validity
|
|
108
|
+
|
|
109
|
+
send_request FUNCTION_SWITCH_SOCKET_A, [house_code, receiver_code, switch_to], 'C C C', 8, ''
|
|
101
110
|
end
|
|
102
111
|
|
|
103
112
|
# To switch a type B socket you have to give the address, unit and the state
|
|
104
113
|
# (on or off) you want to switch to.
|
|
105
114
|
#
|
|
106
|
-
#
|
|
107
|
-
# of 0 to 15 (4bit). To switch all devices with the same address use 255 for
|
|
108
|
-
# the unit.
|
|
115
|
+
# To switch all devices with the same address use 255 for the unit.
|
|
109
116
|
#
|
|
110
117
|
# A detailed description on how you can teach a socket the address and unit can
|
|
111
118
|
# be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
|
|
112
119
|
#
|
|
113
120
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
114
121
|
def switch_socket_b(address, unit, switch_to)
|
|
115
|
-
|
|
122
|
+
check_validity
|
|
123
|
+
|
|
124
|
+
send_request FUNCTION_SWITCH_SOCKET_B, [address, unit, switch_to], 'L C C', 8, ''
|
|
116
125
|
end
|
|
117
126
|
|
|
118
127
|
# To control a type B dimmer you have to give the address, unit and the
|
|
119
128
|
# dim value you want to set the dimmer to.
|
|
120
129
|
#
|
|
121
|
-
# The address has a range of 0 to 67108863 (26bit), the unit and the dim value
|
|
122
|
-
# has a range of 0 to 15 (4bit).
|
|
123
|
-
#
|
|
124
130
|
# A detailed description on how you can teach a dimmer the address and unit can
|
|
125
131
|
# be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
|
|
126
132
|
#
|
|
127
133
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
128
134
|
def dim_socket_b(address, unit, dim_value)
|
|
129
|
-
|
|
135
|
+
check_validity
|
|
136
|
+
|
|
137
|
+
send_request FUNCTION_DIM_SOCKET_B, [address, unit, dim_value], 'L C C', 8, ''
|
|
130
138
|
end
|
|
131
139
|
|
|
132
140
|
# To switch a type C socket you have to give the system code, device code and the
|
|
133
141
|
# state (on or off) you want to switch to.
|
|
134
142
|
#
|
|
135
|
-
# The system code has a range of 'A' to 'P' (4bit) and the device code has a
|
|
136
|
-
# range of 1 to 16 (4bit).
|
|
137
|
-
#
|
|
138
143
|
# A detailed description on how you can figure out the system and device code
|
|
139
144
|
# can be found :ref:`here <remote_switch_bricklet_type_c_system_and_device_code>`.
|
|
140
145
|
#
|
|
141
146
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
142
147
|
def switch_socket_c(system_code, device_code, switch_to)
|
|
143
|
-
|
|
148
|
+
check_validity
|
|
149
|
+
|
|
150
|
+
send_request FUNCTION_SWITCH_SOCKET_C, [system_code, device_code, switch_to], 'k C C', 8, ''
|
|
144
151
|
end
|
|
145
152
|
|
|
146
153
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
147
154
|
# the position, the hardware and firmware version as well as the
|
|
148
155
|
# device identifier.
|
|
149
156
|
#
|
|
150
|
-
# The position can be 'a', 'b', 'c' or '
|
|
157
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
158
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
159
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
160
|
+
# position 'z'.
|
|
151
161
|
#
|
|
152
162
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
153
163
|
# |device_identifier_constant|
|
|
154
164
|
def get_identity
|
|
155
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
165
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
156
166
|
end
|
|
157
167
|
|
|
158
168
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|