tinkerforge 2.0.11 → 2.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tinkerforge/brick_dc.rb +2 -2
- data/lib/tinkerforge/brick_imu.rb +2 -2
- data/lib/tinkerforge/brick_master.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +3 -3
- data/lib/tinkerforge/brick_stepper.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer.rb +2 -2
- data/lib/tinkerforge/bricklet_current12.rb +2 -2
- data/lib/tinkerforge/bricklet_current25.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_us.rb +183 -0
- data/lib/tinkerforge/bricklet_dual_button.rb +123 -0
- data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_gps.rb +2 -2
- data/lib/tinkerforge/bricklet_hall_effect.rb +163 -0
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +3 -3
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_io16.rb +2 -2
- data/lib/tinkerforge/bricklet_io4.rb +2 -2
- data/lib/tinkerforge/bricklet_joystick.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip.rb +134 -0
- data/lib/tinkerforge/bricklet_line.rb +160 -0
- data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_moisture.rb +180 -0
- data/lib/tinkerforge/bricklet_motion_detector.rb +73 -0
- data/lib/tinkerforge/bricklet_multi_touch.rb +143 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +107 -0
- data/lib/tinkerforge/bricklet_ptc.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch.rb +104 -0
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +179 -0
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +110 -0
- data/lib/tinkerforge/bricklet_sound_intensity.rb +160 -0
- data/lib/tinkerforge/bricklet_temperature.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_tilt.rb +99 -0
- data/lib/tinkerforge/bricklet_voltage.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current.rb +3 -3
- data/lib/tinkerforge/version.rb +1 -1
- metadata +16 -2
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on 2013-
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.0.
|
5
|
+
# Bindings Version 2.0.12 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.0.12 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generator git on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Device for controlling a piezo buzzer with configurable frequencies
|
14
|
+
class BrickletPiezoSpeaker < Device
|
15
|
+
DEVICE_IDENTIFIER = 242 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered if a beep set by BrickletPiezoSpeaker#beep is finished
|
18
|
+
CALLBACK_BEEP_FINISHED = 4
|
19
|
+
|
20
|
+
# This callback is triggered if the playback of the morse code set by
|
21
|
+
# BrickletPiezoSpeaker#morse_code is finished.
|
22
|
+
CALLBACK_MORSE_CODE_FINISHED = 5
|
23
|
+
|
24
|
+
FUNCTION_BEEP = 1 # :nodoc:
|
25
|
+
FUNCTION_MORSE_CODE = 2 # :nodoc:
|
26
|
+
FUNCTION_CALIBRATE = 3 # :nodoc:
|
27
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
28
|
+
|
29
|
+
|
30
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
31
|
+
# the IP Connection <tt>ipcon</tt>.
|
32
|
+
def initialize(uid, ipcon)
|
33
|
+
super uid, ipcon
|
34
|
+
|
35
|
+
@api_version = [2, 0, 0]
|
36
|
+
|
37
|
+
@response_expected[FUNCTION_BEEP] = RESPONSE_EXPECTED_FALSE
|
38
|
+
@response_expected[FUNCTION_MORSE_CODE] = RESPONSE_EXPECTED_FALSE
|
39
|
+
@response_expected[FUNCTION_CALIBRATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
40
|
+
@response_expected[CALLBACK_BEEP_FINISHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
41
|
+
@response_expected[CALLBACK_MORSE_CODE_FINISHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
42
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
43
|
+
|
44
|
+
@callback_formats[CALLBACK_BEEP_FINISHED] = ''
|
45
|
+
@callback_formats[CALLBACK_MORSE_CODE_FINISHED] = ''
|
46
|
+
end
|
47
|
+
|
48
|
+
# Beeps with the given frequency for the duration in ms. For example:
|
49
|
+
# If you set a duration of 1000, with a frequency value of 2000
|
50
|
+
# the piezo buzzer will beep for one second with a frequency of
|
51
|
+
# approximately 2 kHz.
|
52
|
+
#
|
53
|
+
# *frequency* can be set between 585 and 7100.
|
54
|
+
#
|
55
|
+
# The Piezo Speaker Bricklet can only approximate the frequency, it will play
|
56
|
+
# the best possible match by applying the calibration (see BrickletPiezoSpeaker#calibrate).
|
57
|
+
def beep(duration, frequency)
|
58
|
+
send_request(FUNCTION_BEEP, [duration, frequency], 'L S', 0, '')
|
59
|
+
end
|
60
|
+
|
61
|
+
# Sets morse code that will be played by the piezo buzzer. The morse code
|
62
|
+
# is given as a string consisting of "." (dot), "-" (minus) and " " (space)
|
63
|
+
# for *dits*, *dahs* and *pauses*. Every other character is ignored.
|
64
|
+
# The second parameter is the frequency (see BrickletPiezoSpeaker#beep).
|
65
|
+
#
|
66
|
+
# For example: If you set the string "...---...", the piezo buzzer will beep
|
67
|
+
# nine times with the durations "short short short long long long short
|
68
|
+
# short short".
|
69
|
+
#
|
70
|
+
# The maximum string size is 60.
|
71
|
+
def morse_code(morse, frequency)
|
72
|
+
send_request(FUNCTION_MORSE_CODE, [morse, frequency], 'Z60 S', 0, '')
|
73
|
+
end
|
74
|
+
|
75
|
+
# The Piezo Speaker Bricklet can play 512 different tones. This function
|
76
|
+
# plays each tone and measures the exact frequency back. The result is a
|
77
|
+
# mapping between setting value and frequency. This mapping is stored
|
78
|
+
# in the EEPROM and loaded on startup.
|
79
|
+
#
|
80
|
+
# The Bricklet should come calibrated, you only need to call this
|
81
|
+
# function (once) every time you reflash the Bricklet plugin.
|
82
|
+
#
|
83
|
+
# Returns *true* after the calibration finishes.
|
84
|
+
def calibrate
|
85
|
+
send_request(FUNCTION_CALIBRATE, [], '', 1, '?')
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
89
|
+
# the position, the hardware and firmware version as well as the
|
90
|
+
# device identifier.
|
91
|
+
#
|
92
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
93
|
+
#
|
94
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
95
|
+
#
|
96
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
97
|
+
def get_identity
|
98
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
99
|
+
end
|
100
|
+
|
101
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
102
|
+
def register_callback(id, &block)
|
103
|
+
callback = block
|
104
|
+
@registered_callbacks[id] = callback
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on 2013-
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.0.
|
5
|
+
# Bindings Version 2.0.12 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.0.12 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generator git on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Device that controls mains switches remotely
|
14
|
+
class BrickletRemoteSwitch < Device
|
15
|
+
DEVICE_IDENTIFIER = 235 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is called whenever the switching state changes
|
18
|
+
# from busy to ready, see BrickletRemoteSwitch#get_switching_state.
|
19
|
+
CALLBACK_SWITCHING_DONE = 3
|
20
|
+
|
21
|
+
FUNCTION_SWITCH_SOCKET = 1 # :nodoc:
|
22
|
+
FUNCTION_GET_SWITCHING_STATE = 2 # :nodoc:
|
23
|
+
FUNCTION_SET_REPEATS = 4 # :nodoc:
|
24
|
+
FUNCTION_GET_REPEATS = 5 # :nodoc:
|
25
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
26
|
+
|
27
|
+
SWITCH_TO_OFF = 0 # :nodoc:
|
28
|
+
SWITCH_TO_ON = 1 # :nodoc:
|
29
|
+
SWITCHING_STATE_READY = 0 # :nodoc:
|
30
|
+
SWITCHING_STATE_BUSY = 1 # :nodoc:
|
31
|
+
|
32
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
33
|
+
# the IP Connection <tt>ipcon</tt>.
|
34
|
+
def initialize(uid, ipcon)
|
35
|
+
super uid, ipcon
|
36
|
+
|
37
|
+
@api_version = [2, 0, 0]
|
38
|
+
|
39
|
+
@response_expected[FUNCTION_SWITCH_SOCKET] = RESPONSE_EXPECTED_FALSE
|
40
|
+
@response_expected[FUNCTION_GET_SWITCHING_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
41
|
+
@response_expected[CALLBACK_SWITCHING_DONE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
42
|
+
@response_expected[FUNCTION_SET_REPEATS] = RESPONSE_EXPECTED_FALSE
|
43
|
+
@response_expected[FUNCTION_GET_REPEATS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
44
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
45
|
+
|
46
|
+
@callback_formats[CALLBACK_SWITCHING_DONE] = ''
|
47
|
+
end
|
48
|
+
|
49
|
+
# To switch a socket you have to give the house code, receiver code and the
|
50
|
+
# state (on or off) you want to switch to.
|
51
|
+
#
|
52
|
+
# A detailed description on how you can find the house and receiver code
|
53
|
+
# can be found :ref:`here <remote_switch_bricklet_house_and_receiver_code>`.
|
54
|
+
def switch_socket(house_code, receiver_code, switch_to)
|
55
|
+
send_request(FUNCTION_SWITCH_SOCKET, [house_code, receiver_code, switch_to], 'C C C', 0, '')
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns the current switching state. If the current state is busy, the
|
59
|
+
# Bricklet is currently sending a code to switch a socket. It will not
|
60
|
+
# accept any calls of BrickletRemoteSwitch#switch_socket until the state changes to ready.
|
61
|
+
#
|
62
|
+
# How long the switching takes is dependent on the number of repeats, see
|
63
|
+
# BrickletRemoteSwitch#set_repeats.
|
64
|
+
def get_switching_state
|
65
|
+
send_request(FUNCTION_GET_SWITCHING_STATE, [], '', 1, 'C')
|
66
|
+
end
|
67
|
+
|
68
|
+
# Sets the number of times the code is send when BrickletRemoteSwitch#switch_socket is called.
|
69
|
+
# The repeats basically correspond to the amount of time that a button of the
|
70
|
+
# remote is pressed.
|
71
|
+
#
|
72
|
+
# Some dimmers are controlled by the length of a button pressed,
|
73
|
+
# this can be simulated by increasing the repeats.
|
74
|
+
#
|
75
|
+
# The default value is 5.
|
76
|
+
def set_repeats(repeats)
|
77
|
+
send_request(FUNCTION_SET_REPEATS, [repeats], 'C', 0, '')
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the number of repeats as set by BrickletRemoteSwitch#set_repeats.
|
81
|
+
def get_repeats
|
82
|
+
send_request(FUNCTION_GET_REPEATS, [], '', 1, 'C')
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
86
|
+
# the position, the hardware and firmware version as well as the
|
87
|
+
# device identifier.
|
88
|
+
#
|
89
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
90
|
+
#
|
91
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
92
|
+
#
|
93
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
94
|
+
def get_identity
|
95
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
96
|
+
end
|
97
|
+
|
98
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
99
|
+
def register_callback(id, &block)
|
100
|
+
callback = block
|
101
|
+
@registered_callbacks[id] = callback
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.0.12 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generator git on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Device for sensing Rotary Encoder input
|
14
|
+
class BrickletRotaryEncoder < Device
|
15
|
+
DEVICE_IDENTIFIER = 236 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered periodically with the period that is set by
|
18
|
+
# BrickletRotaryEncoder#set_count_callback_period. The parameter is the count of
|
19
|
+
# the encoder.
|
20
|
+
#
|
21
|
+
# CALLBACK_COUNT is only triggered if the count has changed since the
|
22
|
+
# last triggering.
|
23
|
+
CALLBACK_COUNT = 8
|
24
|
+
|
25
|
+
# This callback is triggered when the threshold as set by
|
26
|
+
# BrickletRotaryEncoder#set_count_callback_threshold is reached.
|
27
|
+
# The parameter is the count of the encoder.
|
28
|
+
#
|
29
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
30
|
+
# with the period as set by BrickletRotaryEncoder#set_debounce_period.
|
31
|
+
CALLBACK_COUNT_REACHED = 9
|
32
|
+
|
33
|
+
# This callback is triggered when the button is pressed.
|
34
|
+
CALLBACK_PRESSED = 11
|
35
|
+
|
36
|
+
# This callback is triggered when the button is released.
|
37
|
+
CALLBACK_RELEASED = 12
|
38
|
+
|
39
|
+
FUNCTION_GET_COUNT = 1 # :nodoc:
|
40
|
+
FUNCTION_SET_COUNT_CALLBACK_PERIOD = 2 # :nodoc:
|
41
|
+
FUNCTION_GET_COUNT_CALLBACK_PERIOD = 3 # :nodoc:
|
42
|
+
FUNCTION_SET_COUNT_CALLBACK_THRESHOLD = 4 # :nodoc:
|
43
|
+
FUNCTION_GET_COUNT_CALLBACK_THRESHOLD = 5 # :nodoc:
|
44
|
+
FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
|
45
|
+
FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
|
46
|
+
FUNCTION_IS_PRESSED = 10 # :nodoc:
|
47
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
48
|
+
|
49
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
50
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
51
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
52
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
53
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
54
|
+
|
55
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
56
|
+
# the IP Connection <tt>ipcon</tt>.
|
57
|
+
def initialize(uid, ipcon)
|
58
|
+
super uid, ipcon
|
59
|
+
|
60
|
+
@api_version = [2, 0, 0]
|
61
|
+
|
62
|
+
@response_expected[FUNCTION_GET_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
63
|
+
@response_expected[FUNCTION_SET_COUNT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
64
|
+
@response_expected[FUNCTION_GET_COUNT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
65
|
+
@response_expected[FUNCTION_SET_COUNT_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
66
|
+
@response_expected[FUNCTION_GET_COUNT_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
67
|
+
@response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
|
68
|
+
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
69
|
+
@response_expected[CALLBACK_COUNT] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
70
|
+
@response_expected[CALLBACK_COUNT_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
71
|
+
@response_expected[FUNCTION_IS_PRESSED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
72
|
+
@response_expected[CALLBACK_PRESSED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
73
|
+
@response_expected[CALLBACK_RELEASED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
74
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
75
|
+
|
76
|
+
@callback_formats[CALLBACK_COUNT] = 'l'
|
77
|
+
@callback_formats[CALLBACK_COUNT_REACHED] = 'l'
|
78
|
+
@callback_formats[CALLBACK_PRESSED] = ''
|
79
|
+
@callback_formats[CALLBACK_RELEASED] = ''
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns the current count of the encoder. If you set reset
|
83
|
+
# to true, the count is set back to 0 directly after the
|
84
|
+
# current count is read.
|
85
|
+
#
|
86
|
+
# The encoder has 24 steps per rotation
|
87
|
+
#
|
88
|
+
# Turning the encoder to the left decrements the counter,
|
89
|
+
# so a negative count is possible.
|
90
|
+
def get_count(reset)
|
91
|
+
send_request(FUNCTION_GET_COUNT, [reset], '?', 4, 'l')
|
92
|
+
end
|
93
|
+
|
94
|
+
# Sets the period in ms with which the CALLBACK_COUNT callback is triggered
|
95
|
+
# periodically. A value of 0 turns the callback off.
|
96
|
+
#
|
97
|
+
# CALLBACK_COUNT is only triggered if the count has changed since the
|
98
|
+
# last triggering.
|
99
|
+
#
|
100
|
+
# The default value is 0.
|
101
|
+
def set_count_callback_period(period)
|
102
|
+
send_request(FUNCTION_SET_COUNT_CALLBACK_PERIOD, [period], 'L', 0, '')
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns the period as set by BrickletRotaryEncoder#set_count_callback_period.
|
106
|
+
def get_count_callback_period
|
107
|
+
send_request(FUNCTION_GET_COUNT_CALLBACK_PERIOD, [], '', 4, 'L')
|
108
|
+
end
|
109
|
+
|
110
|
+
# Sets the thresholds for the CALLBACK_COUNT_REACHED callback.
|
111
|
+
#
|
112
|
+
# The following options are possible:
|
113
|
+
#
|
114
|
+
# "Option", "Description"
|
115
|
+
#
|
116
|
+
# "'x'", "Callback is turned off"
|
117
|
+
# "'o'", "Callback is triggered when the count is *outside* the min and max values"
|
118
|
+
# "'i'", "Callback is triggered when the count is *inside* the min and max values"
|
119
|
+
# "'<'", "Callback is triggered when the count is smaller than the min value (max is ignored)"
|
120
|
+
# "'>'", "Callback is triggered when the count is greater than the min value (max is ignored)"
|
121
|
+
#
|
122
|
+
# The default value is ('x', 0, 0).
|
123
|
+
def set_count_callback_threshold(option, min, max)
|
124
|
+
send_request(FUNCTION_SET_COUNT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 0, '')
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns the threshold as set by BrickletRotaryEncoder#set_count_callback_threshold.
|
128
|
+
def get_count_callback_threshold
|
129
|
+
send_request(FUNCTION_GET_COUNT_CALLBACK_THRESHOLD, [], '', 9, 'k l l')
|
130
|
+
end
|
131
|
+
|
132
|
+
# Sets the period in ms with which the threshold callback
|
133
|
+
#
|
134
|
+
# * CALLBACK_COUNT_REACHED
|
135
|
+
#
|
136
|
+
# is triggered, if the thresholds
|
137
|
+
#
|
138
|
+
# * BrickletRotaryEncoder#set_count_callback_threshold
|
139
|
+
#
|
140
|
+
# keeps being reached.
|
141
|
+
#
|
142
|
+
# The default value is 100.
|
143
|
+
def set_debounce_period(debounce)
|
144
|
+
send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns the debounce period as set by BrickletRotaryEncoder#set_debounce_period.
|
148
|
+
def get_debounce_period
|
149
|
+
send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns *true* if the button is pressed and *false* otherwise.
|
153
|
+
#
|
154
|
+
# It is recommended to use the CALLBACK_PRESSED and CALLBACK_RELEASED callbacks
|
155
|
+
# to handle the button.
|
156
|
+
def is_pressed
|
157
|
+
send_request(FUNCTION_IS_PRESSED, [], '', 1, '?')
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
161
|
+
# the position, the hardware and firmware version as well as the
|
162
|
+
# device identifier.
|
163
|
+
#
|
164
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
165
|
+
#
|
166
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
167
|
+
#
|
168
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
169
|
+
def get_identity
|
170
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
171
|
+
end
|
172
|
+
|
173
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
174
|
+
def register_callback(id, &block)
|
175
|
+
callback = block
|
176
|
+
@registered_callbacks[id] = callback
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on 2013-
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.0.
|
5
|
+
# Bindings Version 2.0.12 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2013-11-27. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.0.12 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generator git on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Device for controling four 7-segment displays
|
14
|
+
class BrickletSegmentDisplay4x7 < Device
|
15
|
+
DEVICE_IDENTIFIER = 237 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered when the counter (see BrickletSegmentDisplay4x7#start_counter) is
|
18
|
+
# finished.
|
19
|
+
CALLBACK_COUNTER_FINISHED = 5
|
20
|
+
|
21
|
+
FUNCTION_SET_SEGMENTS = 1 # :nodoc:
|
22
|
+
FUNCTION_GET_SEGMENTS = 2 # :nodoc:
|
23
|
+
FUNCTION_START_COUNTER = 3 # :nodoc:
|
24
|
+
FUNCTION_GET_COUNTER_VALUE = 4 # :nodoc:
|
25
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
26
|
+
|
27
|
+
|
28
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
29
|
+
# the IP Connection <tt>ipcon</tt>.
|
30
|
+
def initialize(uid, ipcon)
|
31
|
+
super uid, ipcon
|
32
|
+
|
33
|
+
@api_version = [2, 0, 0]
|
34
|
+
|
35
|
+
@response_expected[FUNCTION_SET_SEGMENTS] = RESPONSE_EXPECTED_FALSE
|
36
|
+
@response_expected[FUNCTION_GET_SEGMENTS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
37
|
+
@response_expected[FUNCTION_START_COUNTER] = RESPONSE_EXPECTED_FALSE
|
38
|
+
@response_expected[FUNCTION_GET_COUNTER_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
39
|
+
@response_expected[CALLBACK_COUNTER_FINISHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
40
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
41
|
+
|
42
|
+
@callback_formats[CALLBACK_COUNTER_FINISHED] = ''
|
43
|
+
end
|
44
|
+
|
45
|
+
# The 7-segment display can be set with bitmaps. Every bit controls one
|
46
|
+
# segment:
|
47
|
+
#
|
48
|
+
# .. image:: /Images/Bricklets/bricklet_segment_display_4x7_bit_order.png
|
49
|
+
# :scale: 100 %
|
50
|
+
# :alt: Bit order of one segment
|
51
|
+
# :align: center
|
52
|
+
#
|
53
|
+
# For example to set a "5" you would want to activate segments 0, 2, 3, 5 and 6.
|
54
|
+
# This is represented by the number 0b00110101 = 0x35 = 53.
|
55
|
+
#
|
56
|
+
# The brightness can be set between 0 (dark) and 7 (bright). The colon
|
57
|
+
# parameter turns the colon of the display on or off.
|
58
|
+
def set_segments(segments, brightness, colon)
|
59
|
+
send_request(FUNCTION_SET_SEGMENTS, [segments, brightness, colon], 'C4 C ?', 0, '')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the segment, brightness and color data as set by
|
63
|
+
# BrickletSegmentDisplay4x7#set_segments.
|
64
|
+
def get_segments
|
65
|
+
send_request(FUNCTION_GET_SEGMENTS, [], '', 6, 'C4 C ?')
|
66
|
+
end
|
67
|
+
|
68
|
+
# Starts a counter with the *from* value that counts to the *to*
|
69
|
+
# value with the each step incremented by *increment*.
|
70
|
+
# The *length* of the increment is given in ms.
|
71
|
+
#
|
72
|
+
# Example: If you set *from* to 0, *to* to 100, *increment* to 1 and
|
73
|
+
# *length* to 1000, a counter that goes from 0 to 100 with 1 second
|
74
|
+
# pause between each increment will be started.
|
75
|
+
#
|
76
|
+
# The maximum values for *from*, *to* and *increment* is 9999,
|
77
|
+
# the minimum value is -999.
|
78
|
+
#
|
79
|
+
# You can stop the counter at every time by calling BrickletSegmentDisplay4x7#set_segments.
|
80
|
+
def start_counter(value_from, value_to, increment, length)
|
81
|
+
send_request(FUNCTION_START_COUNTER, [value_from, value_to, increment, length], 's s s L', 0, '')
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns the counter value that is currently shown on the display.
|
85
|
+
#
|
86
|
+
# If there is no counter running a 0 will be returned.
|
87
|
+
def get_counter_value
|
88
|
+
send_request(FUNCTION_GET_COUNTER_VALUE, [], '', 2, 'S')
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
92
|
+
# the position, the hardware and firmware version as well as the
|
93
|
+
# device identifier.
|
94
|
+
#
|
95
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
96
|
+
#
|
97
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
98
|
+
#
|
99
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
100
|
+
def get_identity
|
101
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
102
|
+
end
|
103
|
+
|
104
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
105
|
+
def register_callback(id, &block)
|
106
|
+
callback = block
|
107
|
+
@registered_callbacks[id] = callback
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|