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
|
# Creates 1kHz beep
|
|
14
16
|
class BrickletPiezoBuzzer < Device
|
|
@@ -30,7 +32,7 @@ module Tinkerforge
|
|
|
30
32
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
31
33
|
# the IP Connection <tt>ipcon</tt>.
|
|
32
34
|
def initialize(uid, ipcon)
|
|
33
|
-
super uid, ipcon
|
|
35
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
34
36
|
|
|
35
37
|
@api_version = [2, 0, 0]
|
|
36
38
|
|
|
@@ -38,15 +40,17 @@ module Tinkerforge
|
|
|
38
40
|
@response_expected[FUNCTION_MORSE_CODE] = RESPONSE_EXPECTED_FALSE
|
|
39
41
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
40
42
|
|
|
41
|
-
@callback_formats[CALLBACK_BEEP_FINISHED] = ''
|
|
42
|
-
@callback_formats[CALLBACK_MORSE_CODE_FINISHED] = ''
|
|
43
|
+
@callback_formats[CALLBACK_BEEP_FINISHED] = [8, '']
|
|
44
|
+
@callback_formats[CALLBACK_MORSE_CODE_FINISHED] = [8, '']
|
|
43
45
|
|
|
46
|
+
@ipcon.add_device self
|
|
44
47
|
end
|
|
45
48
|
|
|
46
|
-
# Beeps
|
|
47
|
-
# the piezo buzzer will beep for one second.
|
|
49
|
+
# Beeps for the given duration.
|
|
48
50
|
def beep(duration)
|
|
49
|
-
|
|
51
|
+
check_validity
|
|
52
|
+
|
|
53
|
+
send_request FUNCTION_BEEP, [duration], 'L', 8, ''
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
# Sets morse code that will be played by the piezo buzzer. The morse code
|
|
@@ -56,22 +60,24 @@ module Tinkerforge
|
|
|
56
60
|
# For example: If you set the string "...---...", the piezo buzzer will beep
|
|
57
61
|
# nine times with the durations "short short short long long long short
|
|
58
62
|
# short short".
|
|
59
|
-
#
|
|
60
|
-
# The maximum string size is 60.
|
|
61
63
|
def morse_code(morse)
|
|
62
|
-
|
|
64
|
+
check_validity
|
|
65
|
+
|
|
66
|
+
send_request FUNCTION_MORSE_CODE, [morse], 'Z60', 8, ''
|
|
63
67
|
end
|
|
64
68
|
|
|
65
69
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
66
70
|
# the position, the hardware and firmware version as well as the
|
|
67
71
|
# device identifier.
|
|
68
72
|
#
|
|
69
|
-
# The position can be 'a', 'b', 'c' or '
|
|
73
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
74
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
75
|
+
# position 'z'.
|
|
70
76
|
#
|
|
71
77
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
72
78
|
# |device_identifier_constant|
|
|
73
79
|
def get_identity
|
|
74
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
80
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
75
81
|
end
|
|
76
82
|
|
|
77
83
|
# 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
|
# Creates beep with configurable frequency
|
|
14
16
|
class BrickletPiezoSpeaker < Device
|
|
@@ -33,7 +35,7 @@ module Tinkerforge
|
|
|
33
35
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
34
36
|
# the IP Connection <tt>ipcon</tt>.
|
|
35
37
|
def initialize(uid, ipcon)
|
|
36
|
-
super uid, ipcon
|
|
38
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
37
39
|
|
|
38
40
|
@api_version = [2, 0, 0]
|
|
39
41
|
|
|
@@ -42,40 +44,37 @@ module Tinkerforge
|
|
|
42
44
|
@response_expected[FUNCTION_CALIBRATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
43
45
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
44
46
|
|
|
45
|
-
@callback_formats[CALLBACK_BEEP_FINISHED] = ''
|
|
46
|
-
@callback_formats[CALLBACK_MORSE_CODE_FINISHED] = ''
|
|
47
|
+
@callback_formats[CALLBACK_BEEP_FINISHED] = [8, '']
|
|
48
|
+
@callback_formats[CALLBACK_MORSE_CODE_FINISHED] = [8, '']
|
|
47
49
|
|
|
50
|
+
@ipcon.add_device self
|
|
48
51
|
end
|
|
49
52
|
|
|
50
|
-
# Beeps with the given frequency for the duration
|
|
51
|
-
# If you set a duration of 1000, with a frequency value of 2000
|
|
52
|
-
# the piezo buzzer will beep for one second with a frequency of
|
|
53
|
-
# approximately 2 kHz.
|
|
53
|
+
# Beeps with the given frequency for the given duration.
|
|
54
54
|
#
|
|
55
55
|
# .. versionchanged:: 2.0.2$nbsp;(Plugin)
|
|
56
56
|
# A duration of 0 stops the current beep if any, the frequency parameter is
|
|
57
57
|
# ignored. A duration of 4294967295 results in an infinite beep.
|
|
58
58
|
#
|
|
59
|
-
# The *frequency* parameter can be set between 585 and 7100.
|
|
60
|
-
#
|
|
61
59
|
# The Piezo Speaker Bricklet can only approximate the frequency, it will play
|
|
62
60
|
# the best possible match by applying the calibration (see BrickletPiezoSpeaker#calibrate).
|
|
63
61
|
def beep(duration, frequency)
|
|
64
|
-
|
|
62
|
+
check_validity
|
|
63
|
+
|
|
64
|
+
send_request FUNCTION_BEEP, [duration, frequency], 'L S', 8, ''
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# Sets morse code that will be played by the piezo buzzer. The morse code
|
|
68
68
|
# is given as a string consisting of "." (dot), "-" (minus) and " " (space)
|
|
69
69
|
# for *dits*, *dahs* and *pauses*. Every other character is ignored.
|
|
70
|
-
# The second parameter is the frequency (see BrickletPiezoSpeaker#beep).
|
|
71
70
|
#
|
|
72
71
|
# For example: If you set the string "...---...", the piezo buzzer will beep
|
|
73
72
|
# nine times with the durations "short short short long long long short
|
|
74
73
|
# short short".
|
|
75
|
-
#
|
|
76
|
-
# The maximum string size is 60.
|
|
77
74
|
def morse_code(morse, frequency)
|
|
78
|
-
|
|
75
|
+
check_validity
|
|
76
|
+
|
|
77
|
+
send_request FUNCTION_MORSE_CODE, [morse, frequency], 'Z60 S', 8, ''
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
# The Piezo Speaker Bricklet can play 512 different tones. This function
|
|
@@ -88,19 +87,23 @@ module Tinkerforge
|
|
|
88
87
|
#
|
|
89
88
|
# Returns *true* after the calibration finishes.
|
|
90
89
|
def calibrate
|
|
91
|
-
|
|
90
|
+
check_validity
|
|
91
|
+
|
|
92
|
+
send_request FUNCTION_CALIBRATE, [], '', 9, '?'
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
95
96
|
# the position, the hardware and firmware version as well as the
|
|
96
97
|
# device identifier.
|
|
97
98
|
#
|
|
98
|
-
# The position can be 'a', 'b', 'c' or '
|
|
99
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
100
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
101
|
+
# position 'z'.
|
|
99
102
|
#
|
|
100
103
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
101
104
|
# |device_identifier_constant|
|
|
102
105
|
def get_identity
|
|
103
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
106
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
104
107
|
end
|
|
105
108
|
|
|
106
109
|
# 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
|
# Creates beep and alarm with configurable volume and frequency
|
|
14
16
|
class BrickletPiezoSpeakerV2 < Device
|
|
@@ -63,7 +65,7 @@ module Tinkerforge
|
|
|
63
65
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
64
66
|
# the IP Connection <tt>ipcon</tt>.
|
|
65
67
|
def initialize(uid, ipcon)
|
|
66
|
-
super uid, ipcon
|
|
68
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
67
69
|
|
|
68
70
|
@api_version = [2, 0, 0]
|
|
69
71
|
|
|
@@ -86,47 +88,42 @@ module Tinkerforge
|
|
|
86
88
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
87
89
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
88
90
|
|
|
89
|
-
@callback_formats[CALLBACK_BEEP_FINISHED] = ''
|
|
90
|
-
@callback_formats[CALLBACK_ALARM_FINISHED] = ''
|
|
91
|
+
@callback_formats[CALLBACK_BEEP_FINISHED] = [8, '']
|
|
92
|
+
@callback_formats[CALLBACK_ALARM_FINISHED] = [8, '']
|
|
91
93
|
|
|
94
|
+
@ipcon.add_device self
|
|
92
95
|
end
|
|
93
96
|
|
|
94
|
-
# Beeps with the given frequency and volume for the duration
|
|
95
|
-
#
|
|
96
|
-
# For example: If you set a duration of 1000, with a volume of 10 and a frequency
|
|
97
|
-
# value of 2000 the piezo buzzer will beep with maximum loudness for one
|
|
98
|
-
# second with a frequency of 2 kHz.
|
|
97
|
+
# Beeps with the given frequency and volume for the duration.
|
|
99
98
|
#
|
|
100
99
|
# A duration of 0 stops the current beep if any is ongoing.
|
|
101
100
|
# A duration of 4294967295 results in an infinite beep.
|
|
102
|
-
#
|
|
103
|
-
# The ranges are:
|
|
104
|
-
#
|
|
105
|
-
# * Frequency: 50Hz - 15000Hz
|
|
106
|
-
# * Volume: 0 - 10
|
|
107
|
-
# * Duration: 0ms - 4294967295ms
|
|
108
101
|
def set_beep(frequency, volume, duration)
|
|
109
|
-
|
|
102
|
+
check_validity
|
|
103
|
+
|
|
104
|
+
send_request FUNCTION_SET_BEEP, [frequency, volume, duration], 'S C L', 8, ''
|
|
110
105
|
end
|
|
111
106
|
|
|
112
|
-
# Returns the last beep settings as set by BrickletPiezoSpeakerV2#set_beep. If a beep is currently
|
|
113
|
-
# running it also returns the remaining duration of the beep
|
|
107
|
+
# Returns the last beep settings as set by BrickletPiezoSpeakerV2#set_beep. If a beep is currently
|
|
108
|
+
# running it also returns the remaining duration of the beep.
|
|
114
109
|
#
|
|
115
|
-
# If the frequency or volume is updated during a beep (with BrickletPiezoSpeakerV2#update_frequency
|
|
110
|
+
# If the frequency or volume is updated during a beep (with BrickletPiezoSpeakerV2#update_frequency
|
|
116
111
|
# or BrickletPiezoSpeakerV2#update_volume) this function returns the updated value.
|
|
117
112
|
def get_beep
|
|
118
|
-
|
|
113
|
+
check_validity
|
|
114
|
+
|
|
115
|
+
send_request FUNCTION_GET_BEEP, [], '', 19, 'S C L L'
|
|
119
116
|
end
|
|
120
117
|
|
|
121
118
|
# Creates an alarm (a tone that goes back and force between two specified frequencies).
|
|
122
119
|
#
|
|
123
120
|
# The following parameters can be set:
|
|
124
121
|
#
|
|
125
|
-
# * Start Frequency: Start frequency of the alarm
|
|
126
|
-
# * End Frequency: End frequency of the alarm
|
|
127
|
-
# * Step Size: Size of one step of the sweep between the start/end frequencies
|
|
128
|
-
# * Step Delay: Delay between two steps (duration of time that one tone is used in a sweep)
|
|
129
|
-
# * Duration: Duration of the alarm
|
|
122
|
+
# * Start Frequency: Start frequency of the alarm.
|
|
123
|
+
# * End Frequency: End frequency of the alarm.
|
|
124
|
+
# * Step Size: Size of one step of the sweep between the start/end frequencies.
|
|
125
|
+
# * Step Delay: Delay between two steps (duration of time that one tone is used in a sweep).
|
|
126
|
+
# * Duration: Duration of the alarm.
|
|
130
127
|
#
|
|
131
128
|
# A duration of 0 stops the current alarm if any is ongoing.
|
|
132
129
|
# A duration of 4294967295 results in an infinite alarm.
|
|
@@ -152,36 +149,42 @@ module Tinkerforge
|
|
|
152
149
|
# * Volume = 0
|
|
153
150
|
# * Duration = 10000
|
|
154
151
|
#
|
|
155
|
-
# The
|
|
152
|
+
# The following conditions must be met:
|
|
156
153
|
#
|
|
157
|
-
# * Start Frequency:
|
|
158
|
-
# * End Frequency:
|
|
159
|
-
# * Step Size:
|
|
160
|
-
# * Step Delay:
|
|
161
|
-
# * Volume: 0 - 10
|
|
162
|
-
# * Duration: 0ms - 4294967295ms
|
|
154
|
+
# * Start Frequency: has to be smaller than end frequency
|
|
155
|
+
# * End Frequency: has to be bigger than start frequency
|
|
156
|
+
# * Step Size: has to be small enough to fit into the frequency range
|
|
157
|
+
# * Step Delay: has to be small enough to fit into the duration
|
|
163
158
|
def set_alarm(start_frequency, end_frequency, step_size, step_delay, volume, duration)
|
|
164
|
-
|
|
159
|
+
check_validity
|
|
160
|
+
|
|
161
|
+
send_request FUNCTION_SET_ALARM, [start_frequency, end_frequency, step_size, step_delay, volume, duration], 'S S S S C L', 8, ''
|
|
165
162
|
end
|
|
166
163
|
|
|
167
|
-
# Returns the last alarm settings as set by BrickletPiezoSpeakerV2#set_alarm. If an alarm is currently
|
|
168
|
-
# running it also returns the remaining duration of the alarm
|
|
169
|
-
# current frequency of the alarm
|
|
164
|
+
# Returns the last alarm settings as set by BrickletPiezoSpeakerV2#set_alarm. If an alarm is currently
|
|
165
|
+
# running it also returns the remaining duration of the alarm as well as the
|
|
166
|
+
# current frequency of the alarm.
|
|
170
167
|
#
|
|
171
|
-
# If the volume is updated during
|
|
168
|
+
# If the volume is updated during an alarm (with BrickletPiezoSpeakerV2#update_volume)
|
|
172
169
|
# this function returns the updated value.
|
|
173
170
|
def get_alarm
|
|
174
|
-
|
|
171
|
+
check_validity
|
|
172
|
+
|
|
173
|
+
send_request FUNCTION_GET_ALARM, [], '', 27, 'S S S S C L L S'
|
|
175
174
|
end
|
|
176
175
|
|
|
177
|
-
# Updates the volume of an ongoing beep or alarm.
|
|
176
|
+
# Updates the volume of an ongoing beep or alarm.
|
|
178
177
|
def update_volume(volume)
|
|
179
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_UPDATE_VOLUME, [volume], 'C', 8, ''
|
|
180
181
|
end
|
|
181
182
|
|
|
182
|
-
# Updates the frequency of an ongoing beep.
|
|
183
|
+
# Updates the frequency of an ongoing beep.
|
|
183
184
|
def update_frequency(frequency)
|
|
184
|
-
|
|
185
|
+
check_validity
|
|
186
|
+
|
|
187
|
+
send_request FUNCTION_UPDATE_FREQUENCY, [frequency], 'S', 8, ''
|
|
185
188
|
end
|
|
186
189
|
|
|
187
190
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -196,7 +199,9 @@ module Tinkerforge
|
|
|
196
199
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
197
200
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
198
201
|
def get_spitfp_error_count
|
|
199
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
200
205
|
end
|
|
201
206
|
|
|
202
207
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -209,12 +214,16 @@ module Tinkerforge
|
|
|
209
214
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
210
215
|
# necessary to call it in a normal user program.
|
|
211
216
|
def set_bootloader_mode(mode)
|
|
212
|
-
|
|
217
|
+
check_validity
|
|
218
|
+
|
|
219
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
213
220
|
end
|
|
214
221
|
|
|
215
222
|
# Returns the current bootloader mode, see BrickletPiezoSpeakerV2#set_bootloader_mode.
|
|
216
223
|
def get_bootloader_mode
|
|
217
|
-
|
|
224
|
+
check_validity
|
|
225
|
+
|
|
226
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
218
227
|
end
|
|
219
228
|
|
|
220
229
|
# Sets the firmware pointer for BrickletPiezoSpeakerV2#write_firmware. The pointer has
|
|
@@ -224,7 +233,9 @@ module Tinkerforge
|
|
|
224
233
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
225
234
|
# necessary to call it in a normal user program.
|
|
226
235
|
def set_write_firmware_pointer(pointer)
|
|
227
|
-
|
|
236
|
+
check_validity
|
|
237
|
+
|
|
238
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
228
239
|
end
|
|
229
240
|
|
|
230
241
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -236,7 +247,9 @@ module Tinkerforge
|
|
|
236
247
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
237
248
|
# necessary to call it in a normal user program.
|
|
238
249
|
def write_firmware(data)
|
|
239
|
-
|
|
250
|
+
check_validity
|
|
251
|
+
|
|
252
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
240
253
|
end
|
|
241
254
|
|
|
242
255
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -247,22 +260,28 @@ module Tinkerforge
|
|
|
247
260
|
#
|
|
248
261
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
249
262
|
def set_status_led_config(config)
|
|
250
|
-
|
|
263
|
+
check_validity
|
|
264
|
+
|
|
265
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
251
266
|
end
|
|
252
267
|
|
|
253
268
|
# Returns the configuration as set by BrickletPiezoSpeakerV2#set_status_led_config
|
|
254
269
|
def get_status_led_config
|
|
255
|
-
|
|
270
|
+
check_validity
|
|
271
|
+
|
|
272
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
256
273
|
end
|
|
257
274
|
|
|
258
|
-
# Returns the temperature
|
|
275
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
259
276
|
# value returned is not the ambient temperature!
|
|
260
277
|
#
|
|
261
278
|
# The temperature is only proportional to the real temperature and it has bad
|
|
262
279
|
# accuracy. Practically it is only useful as an indicator for
|
|
263
280
|
# temperature changes.
|
|
264
281
|
def get_chip_temperature
|
|
265
|
-
|
|
282
|
+
check_validity
|
|
283
|
+
|
|
284
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
266
285
|
end
|
|
267
286
|
|
|
268
287
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -272,7 +291,9 @@ module Tinkerforge
|
|
|
272
291
|
# calling functions on the existing ones will result in
|
|
273
292
|
# undefined behavior!
|
|
274
293
|
def reset
|
|
275
|
-
|
|
294
|
+
check_validity
|
|
295
|
+
|
|
296
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
276
297
|
end
|
|
277
298
|
|
|
278
299
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -281,25 +302,31 @@ module Tinkerforge
|
|
|
281
302
|
#
|
|
282
303
|
# We recommend that you use Brick Viewer to change the UID.
|
|
283
304
|
def write_uid(uid)
|
|
284
|
-
|
|
305
|
+
check_validity
|
|
306
|
+
|
|
307
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
285
308
|
end
|
|
286
309
|
|
|
287
310
|
# Returns the current UID as an integer. Encode as
|
|
288
311
|
# Base58 to get the usual string version.
|
|
289
312
|
def read_uid
|
|
290
|
-
|
|
313
|
+
check_validity
|
|
314
|
+
|
|
315
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
291
316
|
end
|
|
292
317
|
|
|
293
318
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
294
319
|
# the position, the hardware and firmware version as well as the
|
|
295
320
|
# device identifier.
|
|
296
321
|
#
|
|
297
|
-
# The position can be 'a', 'b', 'c' or '
|
|
322
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
323
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
324
|
+
# position 'z'.
|
|
298
325
|
#
|
|
299
326
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
300
327
|
# |device_identifier_constant|
|
|
301
328
|
def get_identity
|
|
302
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
329
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
303
330
|
end
|
|
304
331
|
|
|
305
332
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|