tinkerforge 2.0.11 → 2.0.12
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.
- 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 #
|
@@ -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,163 @@
|
|
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 detects presence of magnetic field via hall effect
|
14
|
+
class BrickletHallEffect < Device
|
15
|
+
DEVICE_IDENTIFIER = 240 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered periodically with the period that is set by
|
18
|
+
# BrickletHallEffect#set_edge_count_callback_period. The parameters are the
|
19
|
+
# current count and the current value (see BrickletHallEffect#get_value and BrickletHallEffect#get_edge_count).
|
20
|
+
#
|
21
|
+
# CALLBACK_EDGE_COUNT is only triggered if the count or value changed since the
|
22
|
+
# last triggering.
|
23
|
+
CALLBACK_EDGE_COUNT = 10
|
24
|
+
|
25
|
+
FUNCTION_GET_VALUE = 1 # :nodoc:
|
26
|
+
FUNCTION_GET_EDGE_COUNT = 2 # :nodoc:
|
27
|
+
FUNCTION_SET_EDGE_COUNT_CONFIG = 3 # :nodoc:
|
28
|
+
FUNCTION_GET_EDGE_COUNT_CONFIG = 4 # :nodoc:
|
29
|
+
FUNCTION_SET_EDGE_INTERRUPT = 5 # :nodoc:
|
30
|
+
FUNCTION_GET_EDGE_INTERRUPT = 6 # :nodoc:
|
31
|
+
FUNCTION_SET_EDGE_COUNT_CALLBACK_PERIOD = 7 # :nodoc:
|
32
|
+
FUNCTION_GET_EDGE_COUNT_CALLBACK_PERIOD = 8 # :nodoc:
|
33
|
+
FUNCTION_EDGE_INTERRUPT = 9 # :nodoc:
|
34
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
35
|
+
|
36
|
+
EDGE_TYPE_RISING = 0 # :nodoc:
|
37
|
+
EDGE_TYPE_FALLING = 1 # :nodoc:
|
38
|
+
EDGE_TYPE_BOTH = 2 # :nodoc:
|
39
|
+
|
40
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
41
|
+
# the IP Connection <tt>ipcon</tt>.
|
42
|
+
def initialize(uid, ipcon)
|
43
|
+
super uid, ipcon
|
44
|
+
|
45
|
+
@api_version = [2, 0, 0]
|
46
|
+
|
47
|
+
@response_expected[FUNCTION_GET_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
48
|
+
@response_expected[FUNCTION_GET_EDGE_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
49
|
+
@response_expected[FUNCTION_SET_EDGE_COUNT_CONFIG] = RESPONSE_EXPECTED_FALSE
|
50
|
+
@response_expected[FUNCTION_GET_EDGE_COUNT_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
51
|
+
@response_expected[FUNCTION_SET_EDGE_INTERRUPT] = RESPONSE_EXPECTED_TRUE
|
52
|
+
@response_expected[FUNCTION_GET_EDGE_INTERRUPT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
53
|
+
@response_expected[FUNCTION_SET_EDGE_COUNT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
|
54
|
+
@response_expected[FUNCTION_GET_EDGE_COUNT_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
55
|
+
@response_expected[FUNCTION_EDGE_INTERRUPT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
56
|
+
@response_expected[CALLBACK_EDGE_COUNT] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
57
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
58
|
+
|
59
|
+
@callback_formats[CALLBACK_EDGE_COUNT] = 'L ?'
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns *true* if a magnetic field of 35 Gauss (3.5mT) or greater is detected.
|
63
|
+
def get_value
|
64
|
+
send_request(FUNCTION_GET_VALUE, [], '', 1, '?')
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the current value of the edge counter. You can configure
|
68
|
+
# edge type (rising, falling, both) that is counted with
|
69
|
+
# BrickletHallEffect#set_edge_count_config.
|
70
|
+
#
|
71
|
+
# If you set the reset counter to *true*, the count is set back to 0
|
72
|
+
# directly after it is read.
|
73
|
+
def get_edge_count(reset_counter)
|
74
|
+
send_request(FUNCTION_GET_EDGE_COUNT, [reset_counter], '?', 4, 'L')
|
75
|
+
end
|
76
|
+
|
77
|
+
# The edge type parameter configures if rising edges, falling edges or
|
78
|
+
# both are counted. Possible edge types are:
|
79
|
+
#
|
80
|
+
# * 0 = rising (default)
|
81
|
+
# * 1 = falling
|
82
|
+
# * 2 = both
|
83
|
+
#
|
84
|
+
# A magnetic field of 35 Gauss (3.5mT) or greater causes a falling edge and a
|
85
|
+
# magnetic field of 25 Gauss (2.5mT) or smaller causes a rising edge.
|
86
|
+
#
|
87
|
+
# If a magnet comes near the Bricklet the signal goes low (falling edge), if
|
88
|
+
# a magnet is removed from the vicinity the signal goes high (rising edge).
|
89
|
+
#
|
90
|
+
# The debounce time is given in ms.
|
91
|
+
#
|
92
|
+
# If you don't know what any of this means, just leave it at default. The
|
93
|
+
# default configuration is very likely OK for you.
|
94
|
+
#
|
95
|
+
# Default values: 0 (edge type) and 100ms (debounce time)
|
96
|
+
def set_edge_count_config(edge_type, debounce)
|
97
|
+
send_request(FUNCTION_SET_EDGE_COUNT_CONFIG, [edge_type, debounce], 'C C', 0, '')
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns the edge type and debounce time as set by BrickletHallEffect#set_edge_count_config.
|
101
|
+
def get_edge_count_config
|
102
|
+
send_request(FUNCTION_GET_EDGE_COUNT_CONFIG, [], '', 2, 'C C')
|
103
|
+
end
|
104
|
+
|
105
|
+
# Sets the number of edges until an interrupt is invoked.
|
106
|
+
#
|
107
|
+
# If *edges* is set to n, an interrupt is invoked for every n-th detected edge.
|
108
|
+
#
|
109
|
+
# If *edges* is set to 0, the interrupt is disabled.
|
110
|
+
#
|
111
|
+
# Default value is 0.
|
112
|
+
def set_edge_interrupt(edges)
|
113
|
+
send_request(FUNCTION_SET_EDGE_INTERRUPT, [edges], 'L', 0, '')
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the edges as set by BrickletHallEffect#set_edge_interrupt.
|
117
|
+
def get_edge_interrupt
|
118
|
+
send_request(FUNCTION_GET_EDGE_INTERRUPT, [], '', 4, 'L')
|
119
|
+
end
|
120
|
+
|
121
|
+
# Sets the period in ms with which the CALLBACK_EDGE_COUNT callback is triggered
|
122
|
+
# periodically. A value of 0 turns the callback off.
|
123
|
+
#
|
124
|
+
# CALLBACK_EDGE_COUNT is only triggered if the edge count has changed since the
|
125
|
+
# last triggering.
|
126
|
+
#
|
127
|
+
# The default value is 0.
|
128
|
+
def set_edge_count_callback_period(period)
|
129
|
+
send_request(FUNCTION_SET_EDGE_COUNT_CALLBACK_PERIOD, [period], 'L', 0, '')
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns the period as set by BrickletHallEffect#set_edge_count_callback_period.
|
133
|
+
def get_edge_count_callback_period
|
134
|
+
send_request(FUNCTION_GET_EDGE_COUNT_CALLBACK_PERIOD, [], '', 4, 'L')
|
135
|
+
end
|
136
|
+
|
137
|
+
# This callback is triggered every n-th count, as configured with
|
138
|
+
# BrickletHallEffect#set_edge_interrupt. The parameters are the
|
139
|
+
# current count and the current value (see BrickletHallEffect#get_value and BrickletHallEffect#get_edge_count).
|
140
|
+
def edge_interrupt
|
141
|
+
send_request(FUNCTION_EDGE_INTERRUPT, [], '', 5, 'L ?')
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
145
|
+
# the position, the hardware and firmware version as well as the
|
146
|
+
# device identifier.
|
147
|
+
#
|
148
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
149
|
+
#
|
150
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
151
|
+
#
|
152
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
153
|
+
def get_identity
|
154
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
155
|
+
end
|
156
|
+
|
157
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
158
|
+
def register_callback(id, &block)
|
159
|
+
callback = block
|
160
|
+
@registered_callbacks[id] = callback
|
161
|
+
end
|
162
|
+
end
|
163
|
+
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 #
|
@@ -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 #
|
@@ -102,7 +102,7 @@ module Tinkerforge
|
|
102
102
|
# pins on the Digital In 4 on port B are assigned to 4-7. It is now possible
|
103
103
|
# to call BrickletIndustrialDigitalIn4#get_value and read out two Bricklets at the same time.
|
104
104
|
#
|
105
|
-
# Changing the group configuration resets
|
105
|
+
# Changing the group configuration resets all edge counter configurations
|
106
106
|
# and values.
|
107
107
|
def set_group(group)
|
108
108
|
send_request(FUNCTION_SET_GROUP, [group], 'k4', 0, '')
|
@@ -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 #
|
@@ -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 #
|
@@ -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 #
|
@@ -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 #
|
@@ -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 #
|
@@ -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 #
|
@@ -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 #
|
@@ -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,134 @@
|
|
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 to control up to 320 RGB LEDs
|
14
|
+
class BrickletLEDStrip < Device
|
15
|
+
DEVICE_IDENTIFIER = 231 # :nodoc:
|
16
|
+
|
17
|
+
# This callback is triggered directly after a new frame is rendered.
|
18
|
+
#
|
19
|
+
# You should send the data for the next frame directly after this callback
|
20
|
+
# was triggered.
|
21
|
+
#
|
22
|
+
# For an explanation of the general approach see BrickletLEDStrip#set_rgb_values.
|
23
|
+
CALLBACK_FRAME_RENDERED = 6
|
24
|
+
|
25
|
+
FUNCTION_SET_RGB_VALUES = 1 # :nodoc:
|
26
|
+
FUNCTION_GET_RGB_VALUES = 2 # :nodoc:
|
27
|
+
FUNCTION_SET_FRAME_DURATION = 3 # :nodoc:
|
28
|
+
FUNCTION_GET_FRAME_DURATION = 4 # :nodoc:
|
29
|
+
FUNCTION_GET_SUPPLY_VOLTAGE = 5 # :nodoc:
|
30
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
31
|
+
|
32
|
+
|
33
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
34
|
+
# the IP Connection <tt>ipcon</tt>.
|
35
|
+
def initialize(uid, ipcon)
|
36
|
+
super uid, ipcon
|
37
|
+
|
38
|
+
@api_version = [2, 0, 0]
|
39
|
+
|
40
|
+
@response_expected[FUNCTION_SET_RGB_VALUES] = RESPONSE_EXPECTED_FALSE
|
41
|
+
@response_expected[FUNCTION_GET_RGB_VALUES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
42
|
+
@response_expected[FUNCTION_SET_FRAME_DURATION] = RESPONSE_EXPECTED_FALSE
|
43
|
+
@response_expected[FUNCTION_GET_FRAME_DURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
44
|
+
@response_expected[FUNCTION_GET_SUPPLY_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
45
|
+
@response_expected[CALLBACK_FRAME_RENDERED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
46
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
47
|
+
|
48
|
+
@callback_formats[CALLBACK_FRAME_RENDERED] = 'S'
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sets the *rgb* values for the LEDs with the given *length* starting
|
52
|
+
# from *index*.
|
53
|
+
#
|
54
|
+
# The maximum length is 16, the index goes from 0 to 319 and the rgb values
|
55
|
+
# have 8 bits each.
|
56
|
+
#
|
57
|
+
# Example: If you set index to 5, length to 3, r to [255, 0, 0],
|
58
|
+
# g to [0, 255, 0] and b to [0, 0, 255] the LEDs with index 5, 6
|
59
|
+
# and 7 will get the color red, green and blue respectively.
|
60
|
+
#
|
61
|
+
# The colors will be transfered to actual LEDs when the next
|
62
|
+
# frame duration ends, see BrickletLEDStrip#set_frame_duration.
|
63
|
+
#
|
64
|
+
# Generic approach:
|
65
|
+
#
|
66
|
+
# * Set the frame duration to a value that represents
|
67
|
+
# the number of frames per second you want to achieve.
|
68
|
+
# * Set all of the LED colors for one frame.
|
69
|
+
# * Wait for the CALLBACK_FRAME_RENDERED callback.
|
70
|
+
# * Set all of the LED colors for next frame.
|
71
|
+
# * Wait for the CALLBACK_FRAME_RENDERED callback.
|
72
|
+
# * and so on.
|
73
|
+
#
|
74
|
+
# This approach ensures that you can change the LED colors with
|
75
|
+
# a fixed frame rate.
|
76
|
+
#
|
77
|
+
# The actual number of controllable LEDs depends on the number of free
|
78
|
+
# Bricklet ports. See :ref:`here <led_strip_bricklet_ram_constraints>` for more
|
79
|
+
# information. A call of BrickletLEDStrip#set_rgb_values with index + length above the
|
80
|
+
# bounds is ignored completely.
|
81
|
+
def set_rgb_values(index, length, r, g, b)
|
82
|
+
send_request(FUNCTION_SET_RGB_VALUES, [index, length, r, g, b], 'S C C16 C16 C16', 0, '')
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the rgb with the given *length* starting from the
|
86
|
+
# given *index*.
|
87
|
+
#
|
88
|
+
# The values are the last values that were set by BrickletLEDStrip#set_rgb_values.
|
89
|
+
def get_rgb_values(index, length)
|
90
|
+
send_request(FUNCTION_GET_RGB_VALUES, [index, length], 'S C', 48, 'C16 C16 C16')
|
91
|
+
end
|
92
|
+
|
93
|
+
# Sets the frame duration in ms.
|
94
|
+
#
|
95
|
+
# Example: If you want to achieve 20 frames per second, you should
|
96
|
+
# set the frame duration to 50ms (50ms * 20 = 1 second).
|
97
|
+
#
|
98
|
+
# For an explanation of the general approach see BrickletLEDStrip#set_rgb_values.
|
99
|
+
#
|
100
|
+
# Default value: 100ms (10 frames per second).
|
101
|
+
def set_frame_duration(duration)
|
102
|
+
send_request(FUNCTION_SET_FRAME_DURATION, [duration], 'S', 0, '')
|
103
|
+
end
|
104
|
+
|
105
|
+
# Returns the frame duration as set by BrickletLEDStrip#set_frame_duration.
|
106
|
+
def get_frame_duration
|
107
|
+
send_request(FUNCTION_GET_FRAME_DURATION, [], '', 2, 'S')
|
108
|
+
end
|
109
|
+
|
110
|
+
# Returns the current supply voltage of the LEDs. The voltage is given in mV.
|
111
|
+
def get_supply_voltage
|
112
|
+
send_request(FUNCTION_GET_SUPPLY_VOLTAGE, [], '', 2, 'S')
|
113
|
+
end
|
114
|
+
|
115
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
116
|
+
# the position, the hardware and firmware version as well as the
|
117
|
+
# device identifier.
|
118
|
+
#
|
119
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
120
|
+
#
|
121
|
+
# The device identifiers can be found :ref:`here <device_identifier>`.
|
122
|
+
#
|
123
|
+
# .. versionadded:: 2.0.0~(Plugin)
|
124
|
+
def get_identity
|
125
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
126
|
+
end
|
127
|
+
|
128
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
129
|
+
def register_callback(id, &block)
|
130
|
+
callback = block
|
131
|
+
@registered_callbacks[id] = callback
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|