tinkerforge 2.1.23 → 2.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +156 -75
- data/lib/tinkerforge/brick_hat.rb +109 -30
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +191 -86
- data/lib/tinkerforge/brick_imu_v2.rb +219 -118
- data/lib/tinkerforge/brick_master.rb +495 -195
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
- data/lib/tinkerforge/brick_stepper.rb +212 -100
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +75 -47
- data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
- data/lib/tinkerforge/bricklet_compass.rb +81 -40
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +68 -33
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +81 -40
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +99 -51
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -39
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +75 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_performance_dc.rb +676 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -26
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +250 -164
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +61 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +92 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
- data/lib/tinkerforge/device_display_names.rb +167 -0
- data/lib/tinkerforge/ip_connection.rb +156 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +8 -3
|
@@ -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 2021-01-15. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
|
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,32 +136,38 @@ 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
|
-
# Sets the period
|
|
151
|
+
# Sets the period with which the CALLBACK_DATE_TIME callback is triggered
|
|
151
152
|
# periodically. A value of 0 turns the callback off.
|
|
152
153
|
#
|
|
153
154
|
# The CALLBACK_DATE_TIME Callback is only triggered if the date or time changed
|
|
154
155
|
# since the last triggering.
|
|
155
156
|
#
|
|
156
|
-
# The default value is 0.
|
|
157
|
-
#
|
|
158
157
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
159
158
|
def set_date_time_callback_period(period)
|
|
160
|
-
|
|
159
|
+
check_validity
|
|
160
|
+
|
|
161
|
+
send_request FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
161
162
|
end
|
|
162
163
|
|
|
163
164
|
# Returns the period as set by BrickletRealTimeClock#set_date_time_callback_period.
|
|
164
165
|
#
|
|
165
166
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
166
167
|
def get_date_time_callback_period
|
|
167
|
-
|
|
168
|
+
check_validity
|
|
169
|
+
|
|
170
|
+
send_request FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
168
171
|
end
|
|
169
172
|
|
|
170
173
|
# Configures a repeatable alarm. The CALLBACK_ALARM callback is triggered if the
|
|
@@ -194,26 +197,32 @@ module Tinkerforge
|
|
|
194
197
|
#
|
|
195
198
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
196
199
|
def set_alarm(month, day, hour, minute, second, weekday, interval)
|
|
197
|
-
|
|
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, ''
|
|
198
203
|
end
|
|
199
204
|
|
|
200
205
|
# Returns the alarm configuration as set by BrickletRealTimeClock#set_alarm.
|
|
201
206
|
#
|
|
202
207
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
203
208
|
def get_alarm
|
|
204
|
-
|
|
209
|
+
check_validity
|
|
210
|
+
|
|
211
|
+
send_request FUNCTION_GET_ALARM, [], '', 18, 'c c c c c c l'
|
|
205
212
|
end
|
|
206
213
|
|
|
207
214
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
208
215
|
# the position, the hardware and firmware version as well as the
|
|
209
216
|
# device identifier.
|
|
210
217
|
#
|
|
211
|
-
# 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
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
220
|
+
# position 'z'.
|
|
212
221
|
#
|
|
213
222
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
214
223
|
# |device_identifier_constant|
|
|
215
224
|
def get_identity
|
|
216
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
225
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
217
226
|
end
|
|
218
227
|
|
|
219
228
|
# 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 2021-01-15. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
|
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,25 +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
|
-
# Sets the period
|
|
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
|
-
# The default value is 0.
|
|
187
186
|
def set_date_time_callback_configuration(period)
|
|
188
|
-
|
|
187
|
+
check_validity
|
|
188
|
+
|
|
189
|
+
send_request FUNCTION_SET_DATE_TIME_CALLBACK_CONFIGURATION, [period], 'L', 8, ''
|
|
189
190
|
end
|
|
190
191
|
|
|
191
192
|
# Returns the period as set by BrickletRealTimeClockV2#set_date_time_callback_configuration.
|
|
192
193
|
def get_date_time_callback_configuration
|
|
193
|
-
|
|
194
|
+
check_validity
|
|
195
|
+
|
|
196
|
+
send_request FUNCTION_GET_DATE_TIME_CALLBACK_CONFIGURATION, [], '', 12, 'L'
|
|
194
197
|
end
|
|
195
198
|
|
|
196
199
|
# Configures a repeatable alarm. The CALLBACK_ALARM callback is triggered if the
|
|
@@ -218,12 +221,16 @@ module Tinkerforge
|
|
|
218
221
|
# example, configuring the alarm as (-1, -1, 7, 30, -1, -1, 300) results in an
|
|
219
222
|
# alarm that triggers every day at 7:30 AM and is then repeated every 5 minutes.
|
|
220
223
|
def set_alarm(month, day, hour, minute, second, weekday, interval)
|
|
221
|
-
|
|
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, ''
|
|
222
227
|
end
|
|
223
228
|
|
|
224
229
|
# Returns the alarm configuration as set by BrickletRealTimeClockV2#set_alarm.
|
|
225
230
|
def get_alarm
|
|
226
|
-
|
|
231
|
+
check_validity
|
|
232
|
+
|
|
233
|
+
send_request FUNCTION_GET_ALARM, [], '', 18, 'c c c c c c l'
|
|
227
234
|
end
|
|
228
235
|
|
|
229
236
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -238,7 +245,9 @@ module Tinkerforge
|
|
|
238
245
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
239
246
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
240
247
|
def get_spitfp_error_count
|
|
241
|
-
|
|
248
|
+
check_validity
|
|
249
|
+
|
|
250
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
242
251
|
end
|
|
243
252
|
|
|
244
253
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -251,12 +260,16 @@ module Tinkerforge
|
|
|
251
260
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
252
261
|
# necessary to call it in a normal user program.
|
|
253
262
|
def set_bootloader_mode(mode)
|
|
254
|
-
|
|
263
|
+
check_validity
|
|
264
|
+
|
|
265
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
255
266
|
end
|
|
256
267
|
|
|
257
268
|
# Returns the current bootloader mode, see BrickletRealTimeClockV2#set_bootloader_mode.
|
|
258
269
|
def get_bootloader_mode
|
|
259
|
-
|
|
270
|
+
check_validity
|
|
271
|
+
|
|
272
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
260
273
|
end
|
|
261
274
|
|
|
262
275
|
# Sets the firmware pointer for BrickletRealTimeClockV2#write_firmware. The pointer has
|
|
@@ -266,7 +279,9 @@ module Tinkerforge
|
|
|
266
279
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
267
280
|
# necessary to call it in a normal user program.
|
|
268
281
|
def set_write_firmware_pointer(pointer)
|
|
269
|
-
|
|
282
|
+
check_validity
|
|
283
|
+
|
|
284
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
270
285
|
end
|
|
271
286
|
|
|
272
287
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -278,7 +293,9 @@ module Tinkerforge
|
|
|
278
293
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
279
294
|
# necessary to call it in a normal user program.
|
|
280
295
|
def write_firmware(data)
|
|
281
|
-
|
|
296
|
+
check_validity
|
|
297
|
+
|
|
298
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
282
299
|
end
|
|
283
300
|
|
|
284
301
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -289,22 +306,28 @@ module Tinkerforge
|
|
|
289
306
|
#
|
|
290
307
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
291
308
|
def set_status_led_config(config)
|
|
292
|
-
|
|
309
|
+
check_validity
|
|
310
|
+
|
|
311
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
293
312
|
end
|
|
294
313
|
|
|
295
314
|
# Returns the configuration as set by BrickletRealTimeClockV2#set_status_led_config
|
|
296
315
|
def get_status_led_config
|
|
297
|
-
|
|
316
|
+
check_validity
|
|
317
|
+
|
|
318
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
298
319
|
end
|
|
299
320
|
|
|
300
|
-
# Returns the temperature
|
|
321
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
301
322
|
# value returned is not the ambient temperature!
|
|
302
323
|
#
|
|
303
324
|
# The temperature is only proportional to the real temperature and it has bad
|
|
304
325
|
# accuracy. Practically it is only useful as an indicator for
|
|
305
326
|
# temperature changes.
|
|
306
327
|
def get_chip_temperature
|
|
307
|
-
|
|
328
|
+
check_validity
|
|
329
|
+
|
|
330
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
308
331
|
end
|
|
309
332
|
|
|
310
333
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -314,7 +337,9 @@ module Tinkerforge
|
|
|
314
337
|
# calling functions on the existing ones will result in
|
|
315
338
|
# undefined behavior!
|
|
316
339
|
def reset
|
|
317
|
-
|
|
340
|
+
check_validity
|
|
341
|
+
|
|
342
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
318
343
|
end
|
|
319
344
|
|
|
320
345
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -323,25 +348,31 @@ module Tinkerforge
|
|
|
323
348
|
#
|
|
324
349
|
# We recommend that you use Brick Viewer to change the UID.
|
|
325
350
|
def write_uid(uid)
|
|
326
|
-
|
|
351
|
+
check_validity
|
|
352
|
+
|
|
353
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
327
354
|
end
|
|
328
355
|
|
|
329
356
|
# Returns the current UID as an integer. Encode as
|
|
330
357
|
# Base58 to get the usual string version.
|
|
331
358
|
def read_uid
|
|
332
|
-
|
|
359
|
+
check_validity
|
|
360
|
+
|
|
361
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
333
362
|
end
|
|
334
363
|
|
|
335
364
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
336
365
|
# the position, the hardware and firmware version as well as the
|
|
337
366
|
# device identifier.
|
|
338
367
|
#
|
|
339
|
-
# 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
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
370
|
+
# position 'z'.
|
|
340
371
|
#
|
|
341
372
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
342
373
|
# |device_identifier_constant|
|
|
343
374
|
def get_identity
|
|
344
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
375
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
345
376
|
end
|
|
346
377
|
|
|
347
378
|
# 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 2021-01-15. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
|
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,115 @@ 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
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
159
|
+
# position 'z'.
|
|
151
160
|
#
|
|
152
161
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
153
162
|
# |device_identifier_constant|
|
|
154
163
|
def get_identity
|
|
155
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
164
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
156
165
|
end
|
|
157
166
|
|
|
158
167
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|