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
@@ -0,0 +1,160 @@
|
|
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 measures reflectivity to allow following a line
|
14
|
+
class BrickletLine < Device
|
15
|
+
DEVICE_IDENTIFIER = 241 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered periodically with the period that is set by
|
18
|
+
# BrickletLine#set_reflectivity_callback_period. The parameter is the reflectivity
|
19
|
+
# of the sensor.
|
20
|
+
#
|
21
|
+
# CALLBACK_REFLECTIVITY is only triggered if the reflectivity has changed since the
|
22
|
+
# last triggering.
|
23
|
+
CALLBACK_REFLECTIVITY = 8
|
24
|
+
|
25
|
+
# This callback is triggered when the threshold as set by
|
26
|
+
# BrickletLine#set_reflectivity_callback_threshold is reached.
|
27
|
+
# The parameter is the reflectivity of the sensor.
|
28
|
+
#
|
29
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
30
|
+
# with the period as set by BrickletLine#set_debounce_period.
|
31
|
+
CALLBACK_REFLECTIVITY_REACHED = 9
|
32
|
+
|
33
|
+
FUNCTION_GET_REFLECTIVITY = 1 # :nodoc:
|
34
|
+
FUNCTION_SET_REFLECTIVITY_CALLBACK_PERIOD = 2 # :nodoc:
|
35
|
+
FUNCTION_GET_REFLECTIVITY_CALLBACK_PERIOD = 3 # :nodoc:
|
36
|
+
FUNCTION_SET_REFLECTIVITY_CALLBACK_THRESHOLD = 4 # :nodoc:
|
37
|
+
FUNCTION_GET_REFLECTIVITY_CALLBACK_THRESHOLD = 5 # :nodoc:
|
38
|
+
FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
|
39
|
+
FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
|
40
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
41
|
+
|
42
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
43
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
44
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
45
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
46
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
47
|
+
|
48
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
49
|
+
# the IP Connection <tt>ipcon</tt>.
|
50
|
+
def initialize(uid, ipcon)
|
51
|
+
super uid, ipcon
|
52
|
+
|
53
|
+
@api_version = [2, 0, 0]
|
54
|
+
|
55
|
+
@response_expected[FUNCTION_GET_REFLECTIVITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
56
|
+
@response_expected[FUNCTION_SET_REFLECTIVITY_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
57
|
+
@response_expected[FUNCTION_GET_REFLECTIVITY_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
58
|
+
@response_expected[FUNCTION_SET_REFLECTIVITY_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
59
|
+
@response_expected[FUNCTION_GET_REFLECTIVITY_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
60
|
+
@response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
|
61
|
+
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
62
|
+
@response_expected[CALLBACK_REFLECTIVITY] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
63
|
+
@response_expected[CALLBACK_REFLECTIVITY_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
64
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
65
|
+
|
66
|
+
@callback_formats[CALLBACK_REFLECTIVITY] = 'S'
|
67
|
+
@callback_formats[CALLBACK_REFLECTIVITY_REACHED] = 'S'
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns the currently measured reflectivity. The reflectivity is
|
71
|
+
# a value between 0 (not reflective) and 4095 (very reflective).
|
72
|
+
#
|
73
|
+
# Usually black has a low reflectivity while white has a high
|
74
|
+
# reflectivity.
|
75
|
+
#
|
76
|
+
# If you want to get the reflectivity periodically, it is recommended
|
77
|
+
# to use the callback CALLBACK_REFLECTIVITY and set the period with
|
78
|
+
# BrickletLine#set_reflectivity_callback_period.
|
79
|
+
def get_reflectivity
|
80
|
+
send_request(FUNCTION_GET_REFLECTIVITY, [], '', 2, 'S')
|
81
|
+
end
|
82
|
+
|
83
|
+
# Sets the period in ms with which the CALLBACK_REFLECTIVITY callback is triggered
|
84
|
+
# periodically. A value of 0 turns the callback off.
|
85
|
+
#
|
86
|
+
# CALLBACK_REFLECTIVITY is only triggered if the reflectivity has changed since the
|
87
|
+
# last triggering.
|
88
|
+
#
|
89
|
+
# The default value is 0.
|
90
|
+
def set_reflectivity_callback_period(period)
|
91
|
+
send_request(FUNCTION_SET_REFLECTIVITY_CALLBACK_PERIOD, [period], 'L', 0, '')
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns the period as set by BrickletLine#set_reflectivity_callback_period.
|
95
|
+
def get_reflectivity_callback_period
|
96
|
+
send_request(FUNCTION_GET_REFLECTIVITY_CALLBACK_PERIOD, [], '', 4, 'L')
|
97
|
+
end
|
98
|
+
|
99
|
+
# Sets the thresholds for the CALLBACK_REFLECTIVITY_REACHED callback.
|
100
|
+
#
|
101
|
+
# The following options are possible:
|
102
|
+
#
|
103
|
+
# "Option", "Description"
|
104
|
+
#
|
105
|
+
# "'x'", "Callback is turned off"
|
106
|
+
# "'o'", "Callback is triggered when the reflectivity is *outside* the min and max values"
|
107
|
+
# "'i'", "Callback is triggered when the reflectivity is *inside* the min and max values"
|
108
|
+
# "'<'", "Callback is triggered when the reflectivity is smaller than the min value (max is ignored)"
|
109
|
+
# "'>'", "Callback is triggered when the reflectivity is greater than the min value (max is ignored)"
|
110
|
+
#
|
111
|
+
# The default value is ('x', 0, 0).
|
112
|
+
def set_reflectivity_callback_threshold(option, min, max)
|
113
|
+
send_request(FUNCTION_SET_REFLECTIVITY_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the threshold as set by BrickletLine#set_reflectivity_callback_threshold.
|
117
|
+
def get_reflectivity_callback_threshold
|
118
|
+
send_request(FUNCTION_GET_REFLECTIVITY_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
119
|
+
end
|
120
|
+
|
121
|
+
# Sets the period in ms with which the threshold callback
|
122
|
+
#
|
123
|
+
# * CALLBACK_REFLECTIVITY_REACHED
|
124
|
+
#
|
125
|
+
# is triggered, if the threshold
|
126
|
+
#
|
127
|
+
# * BrickletLine#set_reflectivity_callback_threshold
|
128
|
+
#
|
129
|
+
# keeps being reached.
|
130
|
+
#
|
131
|
+
# The default value is 100.
|
132
|
+
def set_debounce_period(debounce)
|
133
|
+
send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns the debounce period as set by BrickletLine#set_debounce_period.
|
137
|
+
def get_debounce_period
|
138
|
+
send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
142
|
+
# the position, the hardware and firmware version as well as the
|
143
|
+
# device identifier.
|
144
|
+
#
|
145
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
146
|
+
#
|
147
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
148
|
+
#
|
149
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
150
|
+
def get_identity
|
151
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
152
|
+
end
|
153
|
+
|
154
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
155
|
+
def register_callback(id, &block)
|
156
|
+
callback = block
|
157
|
+
@registered_callbacks[id] = callback
|
158
|
+
end
|
159
|
+
end
|
160
|
+
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,180 @@
|
|
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 Moisture
|
14
|
+
class BrickletMoisture < Device
|
15
|
+
DEVICE_IDENTIFIER = 232 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered periodically with the period that is set by
|
18
|
+
# BrickletMoisture#set_moisture_callback_period. The parameter is the moisture value
|
19
|
+
# of the sensor.
|
20
|
+
#
|
21
|
+
# CALLBACK_MOISTURE is only triggered if the moisture value has changed since the
|
22
|
+
# last triggering.
|
23
|
+
CALLBACK_MOISTURE = 8
|
24
|
+
|
25
|
+
# This callback is triggered when the threshold as set by
|
26
|
+
# BrickletMoisture#set_moisture_callback_threshold is reached.
|
27
|
+
# The parameter is the moisture value of the sensor.
|
28
|
+
#
|
29
|
+
# If the threshold keeps being reached, the callback is triggered periodically
|
30
|
+
# with the period as set by BrickletMoisture#set_debounce_period.
|
31
|
+
CALLBACK_MOISTURE_REACHED = 9
|
32
|
+
|
33
|
+
FUNCTION_GET_MOISTURE_VALUE = 1 # :nodoc:
|
34
|
+
FUNCTION_SET_MOISTURE_CALLBACK_PERIOD = 2 # :nodoc:
|
35
|
+
FUNCTION_GET_MOISTURE_CALLBACK_PERIOD = 3 # :nodoc:
|
36
|
+
FUNCTION_SET_MOISTURE_CALLBACK_THRESHOLD = 4 # :nodoc:
|
37
|
+
FUNCTION_GET_MOISTURE_CALLBACK_THRESHOLD = 5 # :nodoc:
|
38
|
+
FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
|
39
|
+
FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
|
40
|
+
FUNCTION_SET_MOVING_AVERAGE = 10 # :nodoc:
|
41
|
+
FUNCTION_GET_MOVING_AVERAGE = 11 # :nodoc:
|
42
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
43
|
+
|
44
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
45
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
46
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
47
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
48
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
49
|
+
|
50
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
51
|
+
# the IP Connection <tt>ipcon</tt>.
|
52
|
+
def initialize(uid, ipcon)
|
53
|
+
super uid, ipcon
|
54
|
+
|
55
|
+
@api_version = [2, 0, 0]
|
56
|
+
|
57
|
+
@response_expected[FUNCTION_GET_MOISTURE_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
58
|
+
@response_expected[FUNCTION_SET_MOISTURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
59
|
+
@response_expected[FUNCTION_GET_MOISTURE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
60
|
+
@response_expected[FUNCTION_SET_MOISTURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
|
61
|
+
@response_expected[FUNCTION_GET_MOISTURE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
62
|
+
@response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
|
63
|
+
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
64
|
+
@response_expected[CALLBACK_MOISTURE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
65
|
+
@response_expected[CALLBACK_MOISTURE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
66
|
+
@response_expected[FUNCTION_SET_MOVING_AVERAGE] = RESPONSE_EXPECTED_FALSE
|
67
|
+
@response_expected[FUNCTION_GET_MOVING_AVERAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
68
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
69
|
+
|
70
|
+
@callback_formats[CALLBACK_MOISTURE] = 'S'
|
71
|
+
@callback_formats[CALLBACK_MOISTURE_REACHED] = 'S'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns the current moisture value. The value has a range of
|
75
|
+
# 0 to 4095. A small value corresponds to little moisture, a big
|
76
|
+
# value corresponds to much moisture.
|
77
|
+
#
|
78
|
+
# If you want to get the moisture value periodically, it is recommended
|
79
|
+
# to use the callback CALLBACK_MOISTURE and set the period with
|
80
|
+
# BrickletMoisture#set_moisture_callback_period.
|
81
|
+
def get_moisture_value
|
82
|
+
send_request(FUNCTION_GET_MOISTURE_VALUE, [], '', 2, 'S')
|
83
|
+
end
|
84
|
+
|
85
|
+
# Sets the period in ms with which the CALLBACK_MOISTURE callback is triggered
|
86
|
+
# periodically. A value of 0 turns the callback off.
|
87
|
+
#
|
88
|
+
# CALLBACK_MOISTURE is only triggered if the moisture value has changed since the
|
89
|
+
# last triggering.
|
90
|
+
#
|
91
|
+
# The default value is 0.
|
92
|
+
def set_moisture_callback_period(period)
|
93
|
+
send_request(FUNCTION_SET_MOISTURE_CALLBACK_PERIOD, [period], 'L', 0, '')
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns the period as set by BrickletMoisture#set_moisture_callback_period.
|
97
|
+
def get_moisture_callback_period
|
98
|
+
send_request(FUNCTION_GET_MOISTURE_CALLBACK_PERIOD, [], '', 4, 'L')
|
99
|
+
end
|
100
|
+
|
101
|
+
# Sets the thresholds for the CALLBACK_MOISTURE_REACHED callback.
|
102
|
+
#
|
103
|
+
# The following options are possible:
|
104
|
+
#
|
105
|
+
# "Option", "Description"
|
106
|
+
#
|
107
|
+
# "'x'", "Callback is turned off"
|
108
|
+
# "'o'", "Callback is triggered when the moisture value is *outside* the min and max values"
|
109
|
+
# "'i'", "Callback is triggered when the moisture value is *inside* the min and max values"
|
110
|
+
# "'<'", "Callback is triggered when the moisture value is smaller than the min value (max is ignored)"
|
111
|
+
# "'>'", "Callback is triggered when the moisture value is greater than the min value (max is ignored)"
|
112
|
+
#
|
113
|
+
# The default value is ('x', 0, 0).
|
114
|
+
def set_moisture_callback_threshold(option, min, max)
|
115
|
+
send_request(FUNCTION_SET_MOISTURE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
|
116
|
+
end
|
117
|
+
|
118
|
+
# Returns the threshold as set by BrickletMoisture#set_moisture_callback_threshold.
|
119
|
+
def get_moisture_callback_threshold
|
120
|
+
send_request(FUNCTION_GET_MOISTURE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
|
121
|
+
end
|
122
|
+
|
123
|
+
# Sets the period in ms with which the threshold callback
|
124
|
+
#
|
125
|
+
# * CALLBACK_MOISTURE_REACHED
|
126
|
+
#
|
127
|
+
# is triggered, if the threshold
|
128
|
+
#
|
129
|
+
# * BrickletMoisture#set_moisture_callback_threshold
|
130
|
+
#
|
131
|
+
# keeps being reached.
|
132
|
+
#
|
133
|
+
# The default value is 100.
|
134
|
+
def set_debounce_period(debounce)
|
135
|
+
send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
|
136
|
+
end
|
137
|
+
|
138
|
+
# Returns the debounce period as set by BrickletMoisture#set_debounce_period.
|
139
|
+
def get_debounce_period
|
140
|
+
send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
|
141
|
+
end
|
142
|
+
|
143
|
+
# Sets the length of a `moving averaging <http://en.wikipedia.org/wiki/Moving_average>`__
|
144
|
+
# for the moisture value.
|
145
|
+
#
|
146
|
+
# Setting the length to 0 will turn the averaging completely off. With less
|
147
|
+
# averaging, there is more noise on the data.
|
148
|
+
#
|
149
|
+
# The range for the averaging is 0-100.
|
150
|
+
#
|
151
|
+
# The default value is 100.
|
152
|
+
def set_moving_average(average)
|
153
|
+
send_request(FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 0, '')
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the length moving average as set by BrickletMoisture#set_moving_average.
|
157
|
+
def get_moving_average
|
158
|
+
send_request(FUNCTION_GET_MOVING_AVERAGE, [], '', 1, 'C')
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
162
|
+
# the position, the hardware and firmware version as well as the
|
163
|
+
# device identifier.
|
164
|
+
#
|
165
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
166
|
+
#
|
167
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
168
|
+
#
|
169
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
170
|
+
def get_identity
|
171
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
172
|
+
end
|
173
|
+
|
174
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
175
|
+
def register_callback(id, &block)
|
176
|
+
callback = block
|
177
|
+
@registered_callbacks[id] = callback
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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 reads out PIR motion detector
|
14
|
+
class BrickletMotionDetector < Device
|
15
|
+
DEVICE_IDENTIFIER = 233 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is called after a motion was detected.
|
18
|
+
CALLBACK_MOTION_DETECTED = 2
|
19
|
+
|
20
|
+
# This callback is called when the detection cycle ended. When this
|
21
|
+
# callback is called, a new motion can be detected again after approximately 2
|
22
|
+
# seconds.
|
23
|
+
CALLBACK_DETECTION_CYCLE_ENDED = 3
|
24
|
+
|
25
|
+
FUNCTION_GET_MOTION_DETECTED = 1 # :nodoc:
|
26
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
27
|
+
|
28
|
+
MOTION_NOT_DETECTED = 0 # :nodoc:
|
29
|
+
MOTION_DETECTED = 1 # :nodoc:
|
30
|
+
|
31
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
32
|
+
# the IP Connection <tt>ipcon</tt>.
|
33
|
+
def initialize(uid, ipcon)
|
34
|
+
super uid, ipcon
|
35
|
+
|
36
|
+
@api_version = [2, 0, 0]
|
37
|
+
|
38
|
+
@response_expected[FUNCTION_GET_MOTION_DETECTED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
39
|
+
@response_expected[CALLBACK_MOTION_DETECTED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
40
|
+
@response_expected[CALLBACK_DETECTION_CYCLE_ENDED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
41
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
42
|
+
|
43
|
+
@callback_formats[CALLBACK_MOTION_DETECTED] = ''
|
44
|
+
@callback_formats[CALLBACK_DETECTION_CYCLE_ENDED] = ''
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns 1 if a motion was detected. How long this returns 1 after a motion
|
48
|
+
# was detected can be adjusted with one of the small potentiometers on the
|
49
|
+
# Motion Detector Bricklet, see :ref:`here <motion_detector_bricklet_sensitivity_delay_block_time>`.
|
50
|
+
def get_motion_detected
|
51
|
+
send_request(FUNCTION_GET_MOTION_DETECTED, [], '', 1, 'C')
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
55
|
+
# the position, the hardware and firmware version as well as the
|
56
|
+
# device identifier.
|
57
|
+
#
|
58
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
59
|
+
#
|
60
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
61
|
+
#
|
62
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
63
|
+
def get_identity
|
64
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
65
|
+
end
|
66
|
+
|
67
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
68
|
+
def register_callback(id, &block)
|
69
|
+
callback = block
|
70
|
+
@registered_callbacks[id] = callback
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,143 @@
|
|
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 with 12 touch sensors
|
14
|
+
class BrickletMultiTouch < Device
|
15
|
+
DEVICE_IDENTIFIER = 234 # :nodoc:
|
16
|
+
|
17
|
+
# Returns the current touch state, see BrickletMultiTouch#get_touch_state for
|
18
|
+
# information about the state.
|
19
|
+
#
|
20
|
+
# This callback is triggered every time the touch state changes.
|
21
|
+
CALLBACK_TOUCH_STATE = 5
|
22
|
+
|
23
|
+
FUNCTION_GET_TOUCH_STATE = 1 # :nodoc:
|
24
|
+
FUNCTION_RECALIBRATE = 2 # :nodoc:
|
25
|
+
FUNCTION_SET_ELECTRODE_CONFIG = 3 # :nodoc:
|
26
|
+
FUNCTION_GET_ELECTRODE_CONFIG = 4 # :nodoc:
|
27
|
+
FUNCTION_SET_ELECTRODE_SENSITIVITY = 6 # :nodoc:
|
28
|
+
FUNCTION_GET_ELECTRODE_SENSITIVITY = 7 # :nodoc:
|
29
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
30
|
+
|
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_GET_TOUCH_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
40
|
+
@response_expected[FUNCTION_RECALIBRATE] = RESPONSE_EXPECTED_FALSE
|
41
|
+
@response_expected[FUNCTION_SET_ELECTRODE_CONFIG] = RESPONSE_EXPECTED_FALSE
|
42
|
+
@response_expected[FUNCTION_GET_ELECTRODE_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
43
|
+
@response_expected[CALLBACK_TOUCH_STATE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
44
|
+
@response_expected[FUNCTION_SET_ELECTRODE_SENSITIVITY] = RESPONSE_EXPECTED_FALSE
|
45
|
+
@response_expected[FUNCTION_GET_ELECTRODE_SENSITIVITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
46
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
47
|
+
|
48
|
+
@callback_formats[CALLBACK_TOUCH_STATE] = 'S'
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns the current touch state. The state is given as a bitfield.
|
52
|
+
#
|
53
|
+
# Bits 0 to 11 represent the 12 electrodes and bit 12 represents
|
54
|
+
# the proximity.
|
55
|
+
#
|
56
|
+
# If an electrode is touched, the corresponding bit is true. If
|
57
|
+
# a hand or similar is in proximity to the electrodes, bit 12 is
|
58
|
+
# *true*.
|
59
|
+
#
|
60
|
+
# Example: The state 4103 = 0x1007 = 0b1000000000111 means that
|
61
|
+
# electrodes 0, 1 and 2 are touched and that something is in the
|
62
|
+
# proximity of the electrodes.
|
63
|
+
#
|
64
|
+
# The proximity is activated with a distance of 1-2cm. An electrode
|
65
|
+
# is already counted as touched if a finger is nearly touching the
|
66
|
+
# electrode. This means that you can put a piece of paper or foil
|
67
|
+
# or similar on top of a electrode to build a touch panel with
|
68
|
+
# a professional look.
|
69
|
+
def get_touch_state
|
70
|
+
send_request(FUNCTION_GET_TOUCH_STATE, [], '', 2, 'S')
|
71
|
+
end
|
72
|
+
|
73
|
+
# Recalibrates the electrodes. Call this function whenever you changed
|
74
|
+
# or moved you electrodes.
|
75
|
+
def recalibrate
|
76
|
+
send_request(FUNCTION_RECALIBRATE, [], '', 0, '')
|
77
|
+
end
|
78
|
+
|
79
|
+
# Enables/disables electrodes with a bitfield (see BrickletMultiTouch#get_touch_state).
|
80
|
+
#
|
81
|
+
# *True* enables the electrode, *false* disables the electrode. A
|
82
|
+
# disabled electrode will always return *false* as its state. If you
|
83
|
+
# don't need all electrodes you can disable the electrodes that are
|
84
|
+
# not needed.
|
85
|
+
#
|
86
|
+
# It is recommended that you disable the proximity bit (bit 12) if
|
87
|
+
# the proximity feature is not needed. This will reduce the amount of
|
88
|
+
# traffic that is produced by the CALLBACK_TOUCH_STATE callback.
|
89
|
+
#
|
90
|
+
# Disabling electrodes will also reduce power consumption.
|
91
|
+
#
|
92
|
+
# Default: 8191 = 0x1FFF = 0b1111111111111 (all electrodes enabled)
|
93
|
+
def set_electrode_config(enabled_electrodes)
|
94
|
+
send_request(FUNCTION_SET_ELECTRODE_CONFIG, [enabled_electrodes], 'S', 0, '')
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns the electrode configuration, as set by BrickletMultiTouch#set_electrode_config.
|
98
|
+
def get_electrode_config
|
99
|
+
send_request(FUNCTION_GET_ELECTRODE_CONFIG, [], '', 2, 'S')
|
100
|
+
end
|
101
|
+
|
102
|
+
# Sets the sensitivity of the electrodes. An electrode with a high sensitivity
|
103
|
+
# will register a touch earlier then an electrode with a low sensitivity.
|
104
|
+
#
|
105
|
+
# If you build a big electrode you might need to decrease the sensitivity, since
|
106
|
+
# the area that can be charged will get bigger. If you want to be able to
|
107
|
+
# activate an electrode from further away you need to increase the sensitivity.
|
108
|
+
#
|
109
|
+
# After a new sensitivity is set, you likely want to call BrickletMultiTouch#recalibrate
|
110
|
+
# to calibrate the electrodes with the newly defined sensitivity.
|
111
|
+
#
|
112
|
+
# The valid sensitivity value range is 5-201.
|
113
|
+
#
|
114
|
+
# The default sensitivity value is 181.
|
115
|
+
def set_electrode_sensitivity(sensitivity)
|
116
|
+
send_request(FUNCTION_SET_ELECTRODE_SENSITIVITY, [sensitivity], 'C', 0, '')
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns the current sensitivity, as set by BrickletMultiTouch#set_electrode_sensitivity.
|
120
|
+
def get_electrode_sensitivity
|
121
|
+
send_request(FUNCTION_GET_ELECTRODE_SENSITIVITY, [], '', 1, 'C')
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
125
|
+
# the position, the hardware and firmware version as well as the
|
126
|
+
# device identifier.
|
127
|
+
#
|
128
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
129
|
+
#
|
130
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
131
|
+
#
|
132
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
133
|
+
def get_identity
|
134
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
135
|
+
end
|
136
|
+
|
137
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
138
|
+
def register_callback(id, &block)
|
139
|
+
callback = block
|
140
|
+
@registered_callbacks[id] = callback
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|