tinkerforge 2.1.14 → 2.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tinkerforge/brick_dc.rb +2 -2
  3. data/lib/tinkerforge/brick_imu.rb +2 -2
  4. data/lib/tinkerforge/brick_imu_v2.rb +2 -2
  5. data/lib/tinkerforge/brick_master.rb +2 -2
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +2 -2
  8. data/lib/tinkerforge/brick_silent_stepper.rb +2 -2
  9. data/lib/tinkerforge/brick_stepper.rb +2 -2
  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_out.rb +2 -2
  16. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  17. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  18. data/lib/tinkerforge/bricklet_can.rb +2 -2
  19. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  20. data/lib/tinkerforge/bricklet_color.rb +2 -2
  21. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  22. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  23. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  24. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  25. data/lib/tinkerforge/bricklet_dmx.rb +520 -0
  26. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  27. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  28. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  29. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  30. data/lib/tinkerforge/bricklet_gps_v2.rb +27 -3
  31. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  32. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  33. data/lib/tinkerforge/bricklet_humidity_v2.rb +368 -0
  34. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  35. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  36. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  37. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  38. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  39. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  40. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  41. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  42. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  43. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  44. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  45. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  46. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  47. data/lib/tinkerforge/bricklet_line.rb +2 -2
  48. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  49. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  50. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  51. data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
  52. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +330 -0
  53. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  54. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  55. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  56. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  57. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  58. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  59. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  60. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  61. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  62. data/lib/tinkerforge/bricklet_rgb_led.rb +3 -3
  63. data/lib/tinkerforge/bricklet_rgb_led_button.rb +248 -0
  64. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +300 -0
  65. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  66. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  67. data/lib/tinkerforge/bricklet_rs232.rb +2 -2
  68. data/lib/tinkerforge/bricklet_rs485.rb +3 -3
  69. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  70. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  71. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  72. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  73. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  74. data/lib/tinkerforge/bricklet_thermal_imaging.rb +555 -0
  75. data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
  76. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  77. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  78. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  79. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  80. data/lib/tinkerforge/version.rb +1 -1
  81. metadata +74 -70
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 2017-07-27. #
3
+ # This file was automatically generated on 2017-11-20. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.14 #
5
+ # Ruby Bindings Version 2.1.15 #
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 #
@@ -34,7 +34,7 @@ module Tinkerforge
34
34
 
35
35
  end
36
36
 
37
- # Sets the *rgb* value for the LED.
37
+ # Sets the *rgb* value for the LED. The value can be between 0 and 255.
38
38
  def set_rgb_value(r, g, b)
39
39
  send_request FUNCTION_SET_RGB_VALUE, [r, g, b], 'C C C', 0, ''
40
40
  end
@@ -0,0 +1,248 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2017-11-20. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.15 #
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
+ # RGB LED Button
14
+ class BrickletRGBLEDButton < Device
15
+ DEVICE_IDENTIFIER = 282 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'RGB LED Button Bricklet' # :nodoc:
17
+
18
+ # This callback is triggered every time the button state changes from pressed to
19
+ # released or from released to pressed.
20
+ #
21
+ # The parameter is the current state of the button.
22
+ CALLBACK_BUTTON_STATE_CHANGED = 4
23
+
24
+ FUNCTION_SET_COLOR = 1 # :nodoc:
25
+ FUNCTION_GET_COLOR = 2 # :nodoc:
26
+ FUNCTION_GET_BUTTON_STATE = 3 # :nodoc:
27
+ FUNCTION_SET_COLOR_CALIBRATION = 5 # :nodoc:
28
+ FUNCTION_GET_COLOR_CALIBRATION = 6 # :nodoc:
29
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
30
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
31
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
32
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
33
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
34
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
35
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
36
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
37
+ FUNCTION_RESET = 243 # :nodoc:
38
+ FUNCTION_WRITE_UID = 248 # :nodoc:
39
+ FUNCTION_READ_UID = 249 # :nodoc:
40
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
41
+
42
+ BUTTON_STATE_PRESSED = 0 # :nodoc:
43
+ BUTTON_STATE_RELEASED = 1 # :nodoc:
44
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
45
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
46
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
47
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
48
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
49
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
50
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
51
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
52
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
53
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
54
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
55
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
56
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
57
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
58
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
59
+
60
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
61
+ # the IP Connection <tt>ipcon</tt>.
62
+ def initialize(uid, ipcon)
63
+ super uid, ipcon
64
+
65
+ @api_version = [2, 0, 0]
66
+
67
+ @response_expected[FUNCTION_SET_COLOR] = RESPONSE_EXPECTED_FALSE
68
+ @response_expected[FUNCTION_GET_COLOR] = RESPONSE_EXPECTED_ALWAYS_TRUE
69
+ @response_expected[FUNCTION_GET_BUTTON_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
70
+ @response_expected[FUNCTION_SET_COLOR_CALIBRATION] = RESPONSE_EXPECTED_FALSE
71
+ @response_expected[FUNCTION_GET_COLOR_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
72
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
73
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
74
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
75
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
76
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
77
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
78
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
79
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
81
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
82
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+
85
+ @callback_formats[CALLBACK_BUTTON_STATE_CHANGED] = 'C'
86
+
87
+ end
88
+
89
+ # Sets the color of the LED.
90
+ #
91
+ # By default the LED is off (0, 0, 0).
92
+ def set_color(red, green, blue)
93
+ send_request FUNCTION_SET_COLOR, [red, green, blue], 'C C C', 0, ''
94
+ end
95
+
96
+ # Returns the LED color as set by BrickletRGBLEDButton#set_color.
97
+ def get_color
98
+ send_request FUNCTION_GET_COLOR, [], '', 3, 'C C C'
99
+ end
100
+
101
+ # Returns the current state of the button (either pressed or released).
102
+ def get_button_state
103
+ send_request FUNCTION_GET_BUTTON_STATE, [], '', 1, 'C'
104
+ end
105
+
106
+ # Sets a color calibration. Some colors appear brighter then others,
107
+ # so a calibration may be necessary for nice uniform colors.
108
+ #
109
+ # The values range from 0% to 100%.
110
+ #
111
+ # The calibration is saved in flash. You don't need to call this
112
+ # function on every startup.
113
+ #
114
+ # Default value is (100, 100, 55).
115
+ def set_color_calibration(red, green, blue)
116
+ send_request FUNCTION_SET_COLOR_CALIBRATION, [red, green, blue], 'C C C', 0, ''
117
+ end
118
+
119
+ # Returns the color calibration as set by BrickletRGBLEDButton#set_color_calibration.
120
+ def get_color_calibration
121
+ send_request FUNCTION_GET_COLOR_CALIBRATION, [], '', 3, 'C C C'
122
+ end
123
+
124
+ # Returns the error count for the communication between Brick and Bricklet.
125
+ #
126
+ # The errors are divided into
127
+ #
128
+ # * ack checksum errors,
129
+ # * message checksum errors,
130
+ # * frameing errors and
131
+ # * overflow errors.
132
+ #
133
+ # The errors counts are for errors that occur on the Bricklet side. All
134
+ # Bricks have a similar function that returns the errors on the Brick side.
135
+ def get_spitfp_error_count
136
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
137
+ end
138
+
139
+ # Sets the bootloader mode and returns the status after the requested
140
+ # mode change was instigated.
141
+ #
142
+ # You can change from bootloader mode to firmware mode and vice versa. A change
143
+ # from bootloader mode to firmware mode will only take place if the entry function,
144
+ # device identifier und crc are present and correct.
145
+ #
146
+ # This function is used by Brick Viewer during flashing. It should not be
147
+ # necessary to call it in a normal user program.
148
+ def set_bootloader_mode(mode)
149
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
150
+ end
151
+
152
+ # Returns the current bootloader mode, see BrickletRGBLEDButton#set_bootloader_mode.
153
+ def get_bootloader_mode
154
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
155
+ end
156
+
157
+ # Sets the firmware pointer for BrickletRGBLEDButton#write_firmware. The pointer has
158
+ # to be increased by chunks of size 64. The data is written to flash
159
+ # every 4 chunks (which equals to one page of size 256).
160
+ #
161
+ # This function is used by Brick Viewer during flashing. It should not be
162
+ # necessary to call it in a normal user program.
163
+ def set_write_firmware_pointer(pointer)
164
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
165
+ end
166
+
167
+ # Writes 64 Bytes of firmware at the position as written by
168
+ # BrickletRGBLEDButton#set_write_firmware_pointer before. The firmware is written
169
+ # to flash every 4 chunks.
170
+ #
171
+ # You can only write firmware in bootloader mode.
172
+ #
173
+ # This function is used by Brick Viewer during flashing. It should not be
174
+ # necessary to call it in a normal user program.
175
+ def write_firmware(data)
176
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
177
+ end
178
+
179
+ # Sets the status LED configuration. By default the LED shows
180
+ # communication traffic between Brick and Bricklet, it flickers once
181
+ # for every 10 received data packets.
182
+ #
183
+ # You can also turn the LED permanently on/off or show a heartbeat.
184
+ #
185
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
186
+ def set_status_led_config(config)
187
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
188
+ end
189
+
190
+ # Returns the configuration as set by BrickletRGBLEDButton#set_status_led_config
191
+ def get_status_led_config
192
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
193
+ end
194
+
195
+ # Returns the temperature in °C as measured inside the microcontroller. The
196
+ # value returned is not the ambient temperature!
197
+ #
198
+ # The temperature is only proportional to the real temperature and it has bad
199
+ # accuracy. Practically it is only useful as an indicator for
200
+ # temperature changes.
201
+ def get_chip_temperature
202
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
203
+ end
204
+
205
+ # Calling this function will reset the Bricklet. All configurations
206
+ # will be lost.
207
+ #
208
+ # After a reset you have to create new device objects,
209
+ # calling functions on the existing ones will result in
210
+ # undefined behavior!
211
+ def reset
212
+ send_request FUNCTION_RESET, [], '', 0, ''
213
+ end
214
+
215
+ # Writes a new UID into flash. If you want to set a new UID
216
+ # you have to decode the Base58 encoded UID string into an
217
+ # integer first.
218
+ #
219
+ # We recommend that you use Brick Viewer to change the UID.
220
+ def write_uid(uid)
221
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
222
+ end
223
+
224
+ # Returns the current UID as an integer. Encode as
225
+ # Base58 to get the usual string version.
226
+ def read_uid
227
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
228
+ end
229
+
230
+ # Returns the UID, the UID where the Bricklet is connected to,
231
+ # the position, the hardware and firmware version as well as the
232
+ # device identifier.
233
+ #
234
+ # The position can be 'a', 'b', 'c' or 'd'.
235
+ #
236
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
237
+ # |device_identifier_constant|
238
+ def get_identity
239
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
240
+ end
241
+
242
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
243
+ def register_callback(id, &block)
244
+ callback = block
245
+ @registered_callbacks[id] = callback
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,300 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2017-11-20. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.15 #
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
+ # RGB LED Matrix with 8x8 pixel
14
+ class BrickletRGBLEDMatrix < Device
15
+ DEVICE_IDENTIFIER = 272 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'RGB LED Matrix Bricklet' # :nodoc:
17
+
18
+ # This callback is triggered as soon as a new frame write is started.
19
+ # The LED values are double buffered, so you can send the LED values
20
+ # for the next frame directly after this callback is triggered.
21
+ CALLBACK_FRAME_STARTED = 11
22
+
23
+ FUNCTION_SET_RED = 1 # :nodoc:
24
+ FUNCTION_GET_RED = 2 # :nodoc:
25
+ FUNCTION_SET_GREEN = 3 # :nodoc:
26
+ FUNCTION_GET_GREEN = 4 # :nodoc:
27
+ FUNCTION_SET_BLUE = 5 # :nodoc:
28
+ FUNCTION_GET_BLUE = 6 # :nodoc:
29
+ FUNCTION_SET_FRAME_DURATION = 7 # :nodoc:
30
+ FUNCTION_GET_FRAME_DURATION = 8 # :nodoc:
31
+ FUNCTION_DRAW_FRAME = 9 # :nodoc:
32
+ FUNCTION_GET_SUPPLY_VOLTAGE = 10 # :nodoc:
33
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
34
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
35
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
36
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
37
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
38
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
39
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
40
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
41
+ FUNCTION_RESET = 243 # :nodoc:
42
+ FUNCTION_WRITE_UID = 248 # :nodoc:
43
+ FUNCTION_READ_UID = 249 # :nodoc:
44
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
45
+
46
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
47
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
48
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
49
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
50
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
51
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
52
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
53
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
54
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
55
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
56
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
57
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
58
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
59
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
60
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
61
+
62
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
63
+ # the IP Connection <tt>ipcon</tt>.
64
+ def initialize(uid, ipcon)
65
+ super uid, ipcon
66
+
67
+ @api_version = [2, 0, 0]
68
+
69
+ @response_expected[FUNCTION_SET_RED] = RESPONSE_EXPECTED_FALSE
70
+ @response_expected[FUNCTION_GET_RED] = RESPONSE_EXPECTED_ALWAYS_TRUE
71
+ @response_expected[FUNCTION_SET_GREEN] = RESPONSE_EXPECTED_FALSE
72
+ @response_expected[FUNCTION_GET_GREEN] = RESPONSE_EXPECTED_ALWAYS_TRUE
73
+ @response_expected[FUNCTION_SET_BLUE] = RESPONSE_EXPECTED_FALSE
74
+ @response_expected[FUNCTION_GET_BLUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
75
+ @response_expected[FUNCTION_SET_FRAME_DURATION] = RESPONSE_EXPECTED_FALSE
76
+ @response_expected[FUNCTION_GET_FRAME_DURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
77
+ @response_expected[FUNCTION_DRAW_FRAME] = RESPONSE_EXPECTED_FALSE
78
+ @response_expected[FUNCTION_GET_SUPPLY_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
79
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
81
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
83
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
85
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
87
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
88
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
89
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
91
+
92
+ @callback_formats[CALLBACK_FRAME_STARTED] = 'L'
93
+
94
+ end
95
+
96
+ # Sets the 64 red LED values of the matrix.
97
+ def set_red(red)
98
+ send_request FUNCTION_SET_RED, [red], 'C64', 0, ''
99
+ end
100
+
101
+ # Returns the red LED values as set by BrickletRGBLEDMatrix#set_red.
102
+ def get_red
103
+ send_request FUNCTION_GET_RED, [], '', 64, 'C64'
104
+ end
105
+
106
+ # Sets the 64 green LED values of the matrix.
107
+ def set_green(green)
108
+ send_request FUNCTION_SET_GREEN, [green], 'C64', 0, ''
109
+ end
110
+
111
+ # Returns the green LED values as set by BrickletRGBLEDMatrix#set_green.
112
+ def get_green
113
+ send_request FUNCTION_GET_GREEN, [], '', 64, 'C64'
114
+ end
115
+
116
+ # Sets the 64 blue LED values of the matrix.
117
+ def set_blue(blue)
118
+ send_request FUNCTION_SET_BLUE, [blue], 'C64', 0, ''
119
+ end
120
+
121
+ # Returns the blue LED values as set by BrickletRGBLEDMatrix#set_blue.
122
+ def get_blue
123
+ send_request FUNCTION_GET_BLUE, [], '', 64, 'C64'
124
+ end
125
+
126
+ # Sets the frame duration in ms.
127
+ #
128
+ # Example: If you want to achieve 20 frames per second, you should
129
+ # set the frame duration to 50ms (50ms * 20 = 1 second).
130
+ #
131
+ # Set this value to 0 to turn the automatic frame write mechanism off.
132
+ #
133
+ # Approach:
134
+ #
135
+ # * Call BrickletRGBLEDMatrix#set_frame_duration with value > 0.
136
+ # * Set LED values for first frame with BrickletRGBLEDMatrix#set_red, BrickletRGBLEDMatrix#set_green, BrickletRGBLEDMatrix#set_blue.
137
+ # * Wait for CALLBACK_FRAME_STARTED callback.
138
+ # * Set LED values for second frame with BrickletRGBLEDMatrix#set_red, BrickletRGBLEDMatrix#set_green, BrickletRGBLEDMatrix#set_blue.
139
+ # * Wait for CALLBACK_FRAME_STARTED callback.
140
+ # * and so on.
141
+ #
142
+ # For frame duration of 0 see BrickletRGBLEDMatrix#draw_frame.
143
+ #
144
+ # Default value: 0 = off.
145
+ def set_frame_duration(frame_duration)
146
+ send_request FUNCTION_SET_FRAME_DURATION, [frame_duration], 'S', 0, ''
147
+ end
148
+
149
+ # Returns the frame duration in ms as set by BrickletRGBLEDMatrix#set_frame_duration.
150
+ def get_frame_duration
151
+ send_request FUNCTION_GET_FRAME_DURATION, [], '', 2, 'S'
152
+ end
153
+
154
+ # If you set the frame duration to 0 (see BrickletRGBLEDMatrix#set_frame_duration), you can use this
155
+ # function to transfer the frame to the matrix.
156
+ #
157
+ # Approach:
158
+ #
159
+ # * Call BrickletRGBLEDMatrix#set_frame_duration with 0.
160
+ # * Set LED values for first frame with BrickletRGBLEDMatrix#set_red, BrickletRGBLEDMatrix#set_green, BrickletRGBLEDMatrix#set_blue.
161
+ # * Call BrickletRGBLEDMatrix#draw_frame.
162
+ # * Wait for CALLBACK_FRAME_STARTED callback.
163
+ # * Set LED values for second frame with BrickletRGBLEDMatrix#set_red, BrickletRGBLEDMatrix#set_green, BrickletRGBLEDMatrix#set_blue.
164
+ # * Call BrickletRGBLEDMatrix#draw_frame.
165
+ # * Wait for CALLBACK_FRAME_STARTED callback.
166
+ # * and so on.
167
+ def draw_frame
168
+ send_request FUNCTION_DRAW_FRAME, [], '', 0, ''
169
+ end
170
+
171
+ # Returns the current supply voltage of the Bricklet. The voltage is given in mV.
172
+ def get_supply_voltage
173
+ send_request FUNCTION_GET_SUPPLY_VOLTAGE, [], '', 2, 'S'
174
+ end
175
+
176
+ # Returns the error count for the communication between Brick and Bricklet.
177
+ #
178
+ # The errors are divided into
179
+ #
180
+ # * ack checksum errors,
181
+ # * message checksum errors,
182
+ # * frameing errors and
183
+ # * overflow errors.
184
+ #
185
+ # The errors counts are for errors that occur on the Bricklet side. All
186
+ # Bricks have a similar function that returns the errors on the Brick side.
187
+ def get_spitfp_error_count
188
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
189
+ end
190
+
191
+ # Sets the bootloader mode and returns the status after the requested
192
+ # mode change was instigated.
193
+ #
194
+ # You can change from bootloader mode to firmware mode and vice versa. A change
195
+ # from bootloader mode to firmware mode will only take place if the entry function,
196
+ # device identifier und crc are present and correct.
197
+ #
198
+ # This function is used by Brick Viewer during flashing. It should not be
199
+ # necessary to call it in a normal user program.
200
+ def set_bootloader_mode(mode)
201
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
202
+ end
203
+
204
+ # Returns the current bootloader mode, see BrickletRGBLEDMatrix#set_bootloader_mode.
205
+ def get_bootloader_mode
206
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
207
+ end
208
+
209
+ # Sets the firmware pointer for BrickletRGBLEDMatrix#write_firmware. The pointer has
210
+ # to be increased by chunks of size 64. The data is written to flash
211
+ # every 4 chunks (which equals to one page of size 256).
212
+ #
213
+ # This function is used by Brick Viewer during flashing. It should not be
214
+ # necessary to call it in a normal user program.
215
+ def set_write_firmware_pointer(pointer)
216
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
217
+ end
218
+
219
+ # Writes 64 Bytes of firmware at the position as written by
220
+ # BrickletRGBLEDMatrix#set_write_firmware_pointer before. The firmware is written
221
+ # to flash every 4 chunks.
222
+ #
223
+ # You can only write firmware in bootloader mode.
224
+ #
225
+ # This function is used by Brick Viewer during flashing. It should not be
226
+ # necessary to call it in a normal user program.
227
+ def write_firmware(data)
228
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
229
+ end
230
+
231
+ # Sets the status LED configuration. By default the LED shows
232
+ # communication traffic between Brick and Bricklet, it flickers once
233
+ # for every 10 received data packets.
234
+ #
235
+ # You can also turn the LED permanently on/off or show a heartbeat.
236
+ #
237
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
238
+ def set_status_led_config(config)
239
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
240
+ end
241
+
242
+ # Returns the configuration as set by BrickletRGBLEDMatrix#set_status_led_config
243
+ def get_status_led_config
244
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
245
+ end
246
+
247
+ # Returns the temperature in °C as measured inside the microcontroller. The
248
+ # value returned is not the ambient temperature!
249
+ #
250
+ # The temperature is only proportional to the real temperature and it has bad
251
+ # accuracy. Practically it is only useful as an indicator for
252
+ # temperature changes.
253
+ def get_chip_temperature
254
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
255
+ end
256
+
257
+ # Calling this function will reset the Bricklet. All configurations
258
+ # will be lost.
259
+ #
260
+ # After a reset you have to create new device objects,
261
+ # calling functions on the existing ones will result in
262
+ # undefined behavior!
263
+ def reset
264
+ send_request FUNCTION_RESET, [], '', 0, ''
265
+ end
266
+
267
+ # Writes a new UID into flash. If you want to set a new UID
268
+ # you have to decode the Base58 encoded UID string into an
269
+ # integer first.
270
+ #
271
+ # We recommend that you use Brick Viewer to change the UID.
272
+ def write_uid(uid)
273
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
274
+ end
275
+
276
+ # Returns the current UID as an integer. Encode as
277
+ # Base58 to get the usual string version.
278
+ def read_uid
279
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
280
+ end
281
+
282
+ # Returns the UID, the UID where the Bricklet is connected to,
283
+ # the position, the hardware and firmware version as well as the
284
+ # device identifier.
285
+ #
286
+ # The position can be 'a', 'b', 'c' or 'd'.
287
+ #
288
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
289
+ # |device_identifier_constant|
290
+ def get_identity
291
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
292
+ end
293
+
294
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
295
+ def register_callback(id, &block)
296
+ callback = block
297
+ @registered_callbacks[id] = callback
298
+ end
299
+ end
300
+ end