tinkerforge 2.1.16 → 2.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +3 -3
  3. data/lib/tinkerforge/brick_imu.rb +3 -3
  4. data/lib/tinkerforge/brick_imu_v2.rb +3 -3
  5. data/lib/tinkerforge/brick_master.rb +3 -3
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +3 -3
  8. data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
  9. data/lib/tinkerforge/brick_stepper.rb +3 -3
  10. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  11. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  12. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
  13. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  14. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  15. data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -6
  16. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  17. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  18. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  19. data/lib/tinkerforge/bricklet_can.rb +3 -3
  20. data/lib/tinkerforge/bricklet_can_v2.rb +770 -0
  21. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  22. data/lib/tinkerforge/bricklet_color.rb +2 -2
  23. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  24. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  25. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  26. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  27. data/lib/tinkerforge/bricklet_dmx.rb +3 -3
  28. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  29. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  30. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  31. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  32. data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
  33. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  34. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  35. data/lib/tinkerforge/bricklet_humidity_v2.rb +11 -13
  36. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  37. data/lib/tinkerforge/bricklet_industrial_counter.rb +445 -0
  38. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  39. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +342 -0
  40. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  41. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  42. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  43. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +263 -0
  44. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  45. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +281 -0
  46. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  47. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  48. data/lib/tinkerforge/bricklet_io4_v2.rb +437 -0
  49. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  50. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  51. data/lib/tinkerforge/bricklet_lcd_16x2.rb +3 -3
  52. data/lib/tinkerforge/bricklet_lcd_20x4.rb +3 -3
  53. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  54. data/lib/tinkerforge/bricklet_led_strip_v2.rb +493 -0
  55. data/lib/tinkerforge/bricklet_line.rb +2 -2
  56. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  57. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  58. data/lib/tinkerforge/bricklet_load_cell_v2.rb +354 -0
  59. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  60. data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
  61. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
  62. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -6
  63. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  64. data/lib/tinkerforge/bricklet_nfc.rb +39 -3
  65. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  66. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  67. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  68. data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
  69. data/lib/tinkerforge/bricklet_particulate_matter.rb +320 -0
  70. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  71. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  72. data/lib/tinkerforge/bricklet_ptc.rb +33 -3
  73. data/lib/tinkerforge/bricklet_ptc_v2.rb +433 -0
  74. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  75. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +353 -0
  76. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  77. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
  78. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  79. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  80. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  81. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  82. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +8 -9
  83. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  84. data/lib/tinkerforge/bricklet_rs232.rb +3 -3
  85. data/lib/tinkerforge/bricklet_rs232_v2.rb +421 -0
  86. data/lib/tinkerforge/bricklet_rs485.rb +6 -6
  87. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  88. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  89. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
  90. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  91. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +420 -0
  92. data/lib/tinkerforge/bricklet_temperature.rb +3 -3
  93. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  94. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +13 -15
  95. data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
  96. data/lib/tinkerforge/bricklet_thermocouple.rb +4 -4
  97. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +340 -0
  98. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  99. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  100. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  101. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  102. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +453 -0
  103. data/lib/tinkerforge/ip_connection.rb +4 -4
  104. data/lib/tinkerforge/version.rb +1 -1
  105. metadata +17 -2
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 #
@@ -41,7 +41,7 @@ module Tinkerforge
41
41
  def initialize(uid, ipcon)
42
42
  super uid, ipcon
43
43
 
44
- @api_version = [2, 0, 0]
44
+ @api_version = [2, 0, 1]
45
45
 
46
46
  @response_expected[FUNCTION_WRITE_LINE] = RESPONSE_EXPECTED_FALSE
47
47
  @response_expected[FUNCTION_CLEAR_DISPLAY] = RESPONSE_EXPECTED_FALSE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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 #
@@ -45,7 +45,7 @@ module Tinkerforge
45
45
  def initialize(uid, ipcon)
46
46
  super uid, ipcon
47
47
 
48
- @api_version = [2, 0, 0]
48
+ @api_version = [2, 0, 2]
49
49
 
50
50
  @response_expected[FUNCTION_WRITE_LINE] = RESPONSE_EXPECTED_FALSE
51
51
  @response_expected[FUNCTION_CLEAR_DISPLAY] = RESPONSE_EXPECTED_FALSE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
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,493 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2018-06-08. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.17 #
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 generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Controls up to 2048 RGB(W) LEDs
14
+ class BrickletLEDStripV2 < Device
15
+ DEVICE_IDENTIFIER = 2103 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'LED Strip Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered directly after a new frame render is started.
19
+ # The parameter is the number of LEDs in that frame.
20
+ #
21
+ # You should send the data for the next frame directly after this callback
22
+ # was triggered.
23
+ #
24
+ # For an explanation of the general approach see BrickletLEDStripV2#set_led_values.
25
+ CALLBACK_FRAME_STARTED = 6
26
+
27
+ FUNCTION_SET_LED_VALUES_LOW_LEVEL = 1 # :nodoc:
28
+ FUNCTION_GET_LED_VALUES_LOW_LEVEL = 2 # :nodoc:
29
+ FUNCTION_SET_FRAME_DURATION = 3 # :nodoc:
30
+ FUNCTION_GET_FRAME_DURATION = 4 # :nodoc:
31
+ FUNCTION_GET_SUPPLY_VOLTAGE = 5 # :nodoc:
32
+ FUNCTION_SET_CLOCK_FREQUENCY = 7 # :nodoc:
33
+ FUNCTION_GET_CLOCK_FREQUENCY = 8 # :nodoc:
34
+ FUNCTION_SET_CHIP_TYPE = 9 # :nodoc:
35
+ FUNCTION_GET_CHIP_TYPE = 10 # :nodoc:
36
+ FUNCTION_SET_CHANNEL_MAPPING = 11 # :nodoc:
37
+ FUNCTION_GET_CHANNEL_MAPPING = 12 # :nodoc:
38
+ FUNCTION_SET_FRAME_STARTED_CALLBACK_CONFIGURATION = 13 # :nodoc:
39
+ FUNCTION_GET_FRAME_STARTED_CALLBACK_CONFIGURATION = 14 # :nodoc:
40
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
41
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
42
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
43
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
44
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
45
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
46
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
47
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
48
+ FUNCTION_RESET = 243 # :nodoc:
49
+ FUNCTION_WRITE_UID = 248 # :nodoc:
50
+ FUNCTION_READ_UID = 249 # :nodoc:
51
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
52
+
53
+ CHIP_TYPE_WS2801 = 2801 # :nodoc:
54
+ CHIP_TYPE_WS2811 = 2811 # :nodoc:
55
+ CHIP_TYPE_WS2812 = 2812 # :nodoc:
56
+ CHIP_TYPE_LPD8806 = 8806 # :nodoc:
57
+ CHIP_TYPE_APA102 = 102 # :nodoc:
58
+ CHANNEL_MAPPING_RGB = 6 # :nodoc:
59
+ CHANNEL_MAPPING_RBG = 9 # :nodoc:
60
+ CHANNEL_MAPPING_BRG = 33 # :nodoc:
61
+ CHANNEL_MAPPING_BGR = 36 # :nodoc:
62
+ CHANNEL_MAPPING_GRB = 18 # :nodoc:
63
+ CHANNEL_MAPPING_GBR = 24 # :nodoc:
64
+ CHANNEL_MAPPING_RGBW = 27 # :nodoc:
65
+ CHANNEL_MAPPING_RGWB = 30 # :nodoc:
66
+ CHANNEL_MAPPING_RBGW = 39 # :nodoc:
67
+ CHANNEL_MAPPING_RBWG = 45 # :nodoc:
68
+ CHANNEL_MAPPING_RWGB = 54 # :nodoc:
69
+ CHANNEL_MAPPING_RWBG = 57 # :nodoc:
70
+ CHANNEL_MAPPING_GRWB = 78 # :nodoc:
71
+ CHANNEL_MAPPING_GRBW = 75 # :nodoc:
72
+ CHANNEL_MAPPING_GBWR = 108 # :nodoc:
73
+ CHANNEL_MAPPING_GBRW = 99 # :nodoc:
74
+ CHANNEL_MAPPING_GWBR = 120 # :nodoc:
75
+ CHANNEL_MAPPING_GWRB = 114 # :nodoc:
76
+ CHANNEL_MAPPING_BRGW = 135 # :nodoc:
77
+ CHANNEL_MAPPING_BRWG = 141 # :nodoc:
78
+ CHANNEL_MAPPING_BGRW = 147 # :nodoc:
79
+ CHANNEL_MAPPING_BGWR = 156 # :nodoc:
80
+ CHANNEL_MAPPING_BWRG = 177 # :nodoc:
81
+ CHANNEL_MAPPING_BWGR = 180 # :nodoc:
82
+ CHANNEL_MAPPING_WRBG = 201 # :nodoc:
83
+ CHANNEL_MAPPING_WRGB = 198 # :nodoc:
84
+ CHANNEL_MAPPING_WGBR = 216 # :nodoc:
85
+ CHANNEL_MAPPING_WGRB = 210 # :nodoc:
86
+ CHANNEL_MAPPING_WBGR = 228 # :nodoc:
87
+ CHANNEL_MAPPING_WBRG = 225 # :nodoc:
88
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
89
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
90
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
91
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
92
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
93
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
94
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
95
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
96
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
97
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
98
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
99
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
100
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
101
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
102
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
103
+
104
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
105
+ # the IP Connection <tt>ipcon</tt>.
106
+ def initialize(uid, ipcon)
107
+ super uid, ipcon
108
+
109
+ @api_version = [2, 0, 0]
110
+
111
+ @response_expected[FUNCTION_SET_LED_VALUES_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
112
+ @response_expected[FUNCTION_GET_LED_VALUES_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
+ @response_expected[FUNCTION_SET_FRAME_DURATION] = RESPONSE_EXPECTED_FALSE
114
+ @response_expected[FUNCTION_GET_FRAME_DURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
+ @response_expected[FUNCTION_GET_SUPPLY_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
116
+ @response_expected[FUNCTION_SET_CLOCK_FREQUENCY] = RESPONSE_EXPECTED_FALSE
117
+ @response_expected[FUNCTION_GET_CLOCK_FREQUENCY] = RESPONSE_EXPECTED_ALWAYS_TRUE
118
+ @response_expected[FUNCTION_SET_CHIP_TYPE] = RESPONSE_EXPECTED_FALSE
119
+ @response_expected[FUNCTION_GET_CHIP_TYPE] = RESPONSE_EXPECTED_ALWAYS_TRUE
120
+ @response_expected[FUNCTION_SET_CHANNEL_MAPPING] = RESPONSE_EXPECTED_FALSE
121
+ @response_expected[FUNCTION_GET_CHANNEL_MAPPING] = RESPONSE_EXPECTED_ALWAYS_TRUE
122
+ @response_expected[FUNCTION_SET_FRAME_STARTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
123
+ @response_expected[FUNCTION_GET_FRAME_STARTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
125
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
126
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
127
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
128
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
129
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
130
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
131
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
133
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
134
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
135
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
136
+
137
+ @callback_formats[CALLBACK_FRAME_STARTED] = 'S'
138
+
139
+ end
140
+
141
+ # Sets the RGB(W) values for the LEDs starting from *index*.
142
+ # You can set at most 2048 RGB values or 1536 RGBW values.
143
+ #
144
+ # To make the colors show correctly you need to configure the chip type
145
+ # (see BrickletLEDStripV2#set_chip_type) and a channel mapping (see BrickletLEDStripV2#set_channel_mapping)
146
+ # according to the connected LEDs.
147
+ #
148
+ # If the channel mapping has 3 colors, you need to give the data in the sequence
149
+ # RGBRGBRGB... if the channel mapping has 4 colors you need to give data in the
150
+ # sequence RGBWRGBWRGBW...
151
+ #
152
+ # The data is double buffered and the colors will be transfered to the
153
+ # LEDs when the next frame duration ends (see BrickletLEDStripV2#set_frame_duration).
154
+ #
155
+ # Generic approach:
156
+ #
157
+ # * Set the frame duration to a value that represents the number of frames per
158
+ # second you want to achieve.
159
+ # * Set all of the LED colors for one frame.
160
+ # * Wait for the CALLBACK_FRAME_STARTED callback.
161
+ # * Set all of the LED colors for next frame.
162
+ # * Wait for the CALLBACK_FRAME_STARTED callback.
163
+ # * And so on.
164
+ #
165
+ # This approach ensures that you can change the LED colors with a fixed frame rate.
166
+ def set_led_values_low_level(index, value_length, value_chunk_offset, value_chunk_data)
167
+ send_request FUNCTION_SET_LED_VALUES_LOW_LEVEL, [index, value_length, value_chunk_offset, value_chunk_data], 'S S S C58', 0, ''
168
+ end
169
+
170
+ # Returns the RGB(W) values as set by BrickletLEDStripV2#set_led_values.
171
+ def get_led_values_low_level(index, length)
172
+ send_request FUNCTION_GET_LED_VALUES_LOW_LEVEL, [index, length], 'S S', 64, 'S S C60'
173
+ end
174
+
175
+ # Sets the frame duration in ms.
176
+ #
177
+ # Example: If you want to achieve 20 frames per second, you should
178
+ # set the frame duration to 50ms (50ms * 20 = 1 second).
179
+ #
180
+ # For an explanation of the general approach see BrickletLEDStripV2#set_led_values.
181
+ #
182
+ # Default value: 100ms (10 frames per second).
183
+ def set_frame_duration(duration)
184
+ send_request FUNCTION_SET_FRAME_DURATION, [duration], 'S', 0, ''
185
+ end
186
+
187
+ # Returns the frame duration in ms as set by BrickletLEDStripV2#set_frame_duration.
188
+ def get_frame_duration
189
+ send_request FUNCTION_GET_FRAME_DURATION, [], '', 2, 'S'
190
+ end
191
+
192
+ # Returns the current supply voltage of the LEDs. The voltage is given in mV.
193
+ def get_supply_voltage
194
+ send_request FUNCTION_GET_SUPPLY_VOLTAGE, [], '', 2, 'S'
195
+ end
196
+
197
+ # Sets the frequency of the clock in Hz. The range is 10000Hz (10kHz) up to
198
+ # 2000000Hz (2MHz).
199
+ #
200
+ # The Bricklet will choose the nearest achievable frequency, which may
201
+ # be off by a few Hz. You can get the exact frequency that is used by
202
+ # calling BrickletLEDStripV2#get_clock_frequency.
203
+ #
204
+ # If you have problems with flickering LEDs, they may be bits flipping. You
205
+ # can fix this by either making the connection between the LEDs and the
206
+ # Bricklet shorter or by reducing the frequency.
207
+ #
208
+ # With a decreasing frequency your maximum frames per second will decrease
209
+ # too.
210
+ #
211
+ # The default value is 1.66MHz.
212
+ def set_clock_frequency(frequency)
213
+ send_request FUNCTION_SET_CLOCK_FREQUENCY, [frequency], 'L', 0, ''
214
+ end
215
+
216
+ # Returns the currently used clock frequency as set by BrickletLEDStripV2#set_clock_frequency.
217
+ def get_clock_frequency
218
+ send_request FUNCTION_GET_CLOCK_FREQUENCY, [], '', 4, 'L'
219
+ end
220
+
221
+ # Sets the type of the LED driver chip. We currently support the chips
222
+ #
223
+ # * WS2801,
224
+ # * WS2811,
225
+ # * WS2812 / SK6812 / NeoPixel RGB,
226
+ # * SK6812RGBW / NeoPixel RGBW (Chip Type = WS2812),
227
+ # * LPD8806 and
228
+ # * APA102 / DotStar.
229
+ #
230
+ # The default value is WS2801 (2801).
231
+ def set_chip_type(chip)
232
+ send_request FUNCTION_SET_CHIP_TYPE, [chip], 'S', 0, ''
233
+ end
234
+
235
+ # Returns the currently used chip type as set by BrickletLEDStripV2#set_chip_type.
236
+ def get_chip_type
237
+ send_request FUNCTION_GET_CHIP_TYPE, [], '', 2, 'S'
238
+ end
239
+
240
+ # Sets the channel mapping for the connected LEDs.
241
+ #
242
+ # If the mapping has 4 colors, the function BrickletLEDStripV2#set_led_values expects 4
243
+ # values per pixel and if the mapping has 3 colors it expects 3 values per pixel.
244
+ #
245
+ # The function always expects the order RGB(W). The connected LED driver chips
246
+ # might have their 3 or 4 channels in a different order. For example, the WS2801
247
+ # chips typically use BGR order, then WS2812 chips typically use GRB order and
248
+ # the APA102 chips typically use WBGR order.
249
+ #
250
+ # The APA102 chips are special. They have three 8-bit channels for RGB
251
+ # and an additional 5-bit channel for the overall brightness of the RGB LED
252
+ # making them 4-channel chips. Internally the brightness channel is the first
253
+ # channel, therefore one of the Wxyz channel mappings should be used. Then
254
+ # the W channel controls the brightness.
255
+ #
256
+ # The default value is BGR (36).
257
+ def set_channel_mapping(mapping)
258
+ send_request FUNCTION_SET_CHANNEL_MAPPING, [mapping], 'C', 0, ''
259
+ end
260
+
261
+ # Returns the currently used channel mapping as set by BrickletLEDStripV2#set_channel_mapping.
262
+ def get_channel_mapping
263
+ send_request FUNCTION_GET_CHANNEL_MAPPING, [], '', 1, 'C'
264
+ end
265
+
266
+ # Enables/disables the CALLBACK_FRAME_STARTED callback.
267
+ #
268
+ # By default the callback is enabled.
269
+ def set_frame_started_callback_configuration(enable)
270
+ send_request FUNCTION_SET_FRAME_STARTED_CALLBACK_CONFIGURATION, [enable], '?', 0, ''
271
+ end
272
+
273
+ # Returns the configuration as set by
274
+ # BrickletLEDStripV2#set_frame_started_callback_configuration.
275
+ def get_frame_started_callback_configuration
276
+ send_request FUNCTION_GET_FRAME_STARTED_CALLBACK_CONFIGURATION, [], '', 1, '?'
277
+ end
278
+
279
+ # Returns the error count for the communication between Brick and Bricklet.
280
+ #
281
+ # The errors are divided into
282
+ #
283
+ # * ack checksum errors,
284
+ # * message checksum errors,
285
+ # * frameing errors and
286
+ # * overflow errors.
287
+ #
288
+ # The errors counts are for errors that occur on the Bricklet side. All
289
+ # Bricks have a similar function that returns the errors on the Brick side.
290
+ def get_spitfp_error_count
291
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
292
+ end
293
+
294
+ # Sets the bootloader mode and returns the status after the requested
295
+ # mode change was instigated.
296
+ #
297
+ # You can change from bootloader mode to firmware mode and vice versa. A change
298
+ # from bootloader mode to firmware mode will only take place if the entry function,
299
+ # device identifier und crc are present and correct.
300
+ #
301
+ # This function is used by Brick Viewer during flashing. It should not be
302
+ # necessary to call it in a normal user program.
303
+ def set_bootloader_mode(mode)
304
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
305
+ end
306
+
307
+ # Returns the current bootloader mode, see BrickletLEDStripV2#set_bootloader_mode.
308
+ def get_bootloader_mode
309
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
310
+ end
311
+
312
+ # Sets the firmware pointer for BrickletLEDStripV2#write_firmware. The pointer has
313
+ # to be increased by chunks of size 64. The data is written to flash
314
+ # every 4 chunks (which equals to one page of size 256).
315
+ #
316
+ # This function is used by Brick Viewer during flashing. It should not be
317
+ # necessary to call it in a normal user program.
318
+ def set_write_firmware_pointer(pointer)
319
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
320
+ end
321
+
322
+ # Writes 64 Bytes of firmware at the position as written by
323
+ # BrickletLEDStripV2#set_write_firmware_pointer before. The firmware is written
324
+ # to flash every 4 chunks.
325
+ #
326
+ # You can only write firmware in bootloader mode.
327
+ #
328
+ # This function is used by Brick Viewer during flashing. It should not be
329
+ # necessary to call it in a normal user program.
330
+ def write_firmware(data)
331
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
332
+ end
333
+
334
+ # Sets the status LED configuration. By default the LED shows
335
+ # communication traffic between Brick and Bricklet, it flickers once
336
+ # for every 10 received data packets.
337
+ #
338
+ # You can also turn the LED permanently on/off or show a heartbeat.
339
+ #
340
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
341
+ def set_status_led_config(config)
342
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
343
+ end
344
+
345
+ # Returns the configuration as set by BrickletLEDStripV2#set_status_led_config
346
+ def get_status_led_config
347
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
348
+ end
349
+
350
+ # Returns the temperature in °C as measured inside the microcontroller. The
351
+ # value returned is not the ambient temperature!
352
+ #
353
+ # The temperature is only proportional to the real temperature and it has bad
354
+ # accuracy. Practically it is only useful as an indicator for
355
+ # temperature changes.
356
+ def get_chip_temperature
357
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
358
+ end
359
+
360
+ # Calling this function will reset the Bricklet. All configurations
361
+ # will be lost.
362
+ #
363
+ # After a reset you have to create new device objects,
364
+ # calling functions on the existing ones will result in
365
+ # undefined behavior!
366
+ def reset
367
+ send_request FUNCTION_RESET, [], '', 0, ''
368
+ end
369
+
370
+ # Writes a new UID into flash. If you want to set a new UID
371
+ # you have to decode the Base58 encoded UID string into an
372
+ # integer first.
373
+ #
374
+ # We recommend that you use Brick Viewer to change the UID.
375
+ def write_uid(uid)
376
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
377
+ end
378
+
379
+ # Returns the current UID as an integer. Encode as
380
+ # Base58 to get the usual string version.
381
+ def read_uid
382
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
383
+ end
384
+
385
+ # Returns the UID, the UID where the Bricklet is connected to,
386
+ # the position, the hardware and firmware version as well as the
387
+ # device identifier.
388
+ #
389
+ # The position can be 'a', 'b', 'c' or 'd'.
390
+ #
391
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
392
+ # |device_identifier_constant|
393
+ def get_identity
394
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
395
+ end
396
+
397
+ # Sets the RGB(W) values for the LEDs starting from *index*.
398
+ # You can set at most 2048 RGB values or 1536 RGBW values.
399
+ #
400
+ # To make the colors show correctly you need to configure the chip type
401
+ # (see BrickletLEDStripV2#set_chip_type) and a channel mapping (see BrickletLEDStripV2#set_channel_mapping)
402
+ # according to the connected LEDs.
403
+ #
404
+ # If the channel mapping has 3 colors, you need to give the data in the sequence
405
+ # RGBRGBRGB... if the channel mapping has 4 colors you need to give data in the
406
+ # sequence RGBWRGBWRGBW...
407
+ #
408
+ # The data is double buffered and the colors will be transfered to the
409
+ # LEDs when the next frame duration ends (see BrickletLEDStripV2#set_frame_duration).
410
+ #
411
+ # Generic approach:
412
+ #
413
+ # * Set the frame duration to a value that represents the number of frames per
414
+ # second you want to achieve.
415
+ # * Set all of the LED colors for one frame.
416
+ # * Wait for the CALLBACK_FRAME_STARTED callback.
417
+ # * Set all of the LED colors for next frame.
418
+ # * Wait for the CALLBACK_FRAME_STARTED callback.
419
+ # * And so on.
420
+ #
421
+ # This approach ensures that you can change the LED colors with a fixed frame rate.
422
+ def set_led_values(index, value)
423
+ if value.length > 65535
424
+ raise ArgumentError, 'Value can be at most 65535 items long'
425
+ end
426
+
427
+ value_length = value.length
428
+ value_chunk_offset = 0
429
+
430
+ if value_length == 0
431
+ value_chunk_data = [0] * 58
432
+ ret = set_led_values_low_level index, value_length, value_chunk_offset, value_chunk_data
433
+ else
434
+ ret = nil # assigned in block
435
+
436
+ @stream_mutex.synchronize {
437
+ while value_chunk_offset < value_length
438
+ value_chunk_data = value[value_chunk_offset, 58]
439
+
440
+ if value_chunk_data.length < 58
441
+ value_chunk_data += [0] * (58 - value_chunk_data.length)
442
+ end
443
+
444
+ ret = set_led_values_low_level index, value_length, value_chunk_offset, value_chunk_data
445
+ value_chunk_offset += 58
446
+ end
447
+ }
448
+ end
449
+
450
+ ret
451
+ end
452
+
453
+ # Returns the RGB(W) values as set by BrickletLEDStripV2#set_led_values.
454
+ def get_led_values(index, length)
455
+ value_length = nil # assigned in block
456
+ value_data = nil # assigned in block
457
+
458
+ @stream_mutex.synchronize {
459
+ ret = get_led_values_low_level index, length
460
+ value_length = ret[0]
461
+ value_chunk_offset = ret[1]
462
+ value_out_of_sync = value_chunk_offset != 0
463
+ value_data = ret[2]
464
+
465
+ while not value_out_of_sync and value_data.length < value_length
466
+ ret = get_led_values_low_level index, length
467
+ value_length = ret[0]
468
+ value_chunk_offset = ret[1]
469
+ value_out_of_sync = value_chunk_offset != value_data.length
470
+ value_data += ret[2]
471
+ end
472
+
473
+ if value_out_of_sync # discard remaining stream to bring it back in-sync
474
+ while value_chunk_offset + 60 < value_length
475
+ ret = get_led_values_low_level index, length
476
+ value_length = ret[0]
477
+ value_chunk_offset = ret[1]
478
+ end
479
+
480
+ raise StreamOutOfSyncException, 'Value stream is out-of-sync'
481
+ end
482
+ }
483
+
484
+ value_data[0, value_length]
485
+ end
486
+
487
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
488
+ def register_callback(id, &block)
489
+ callback = block
490
+ @registered_callbacks[id] = callback
491
+ end
492
+ end
493
+ end