tinkerforge 2.1.17 → 2.1.18

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.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +6 -6
  3. data/lib/tinkerforge/brick_imu.rb +6 -6
  4. data/lib/tinkerforge/brick_imu_v2.rb +13 -6
  5. data/lib/tinkerforge/brick_master.rb +6 -6
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +9 -7
  8. data/lib/tinkerforge/brick_silent_stepper.rb +13 -13
  9. data/lib/tinkerforge/brick_stepper.rb +6 -6
  10. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  11. data/lib/tinkerforge/bricklet_air_quality.rb +514 -0
  12. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  13. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
  14. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  15. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  16. data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -5
  17. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  18. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  19. data/lib/tinkerforge/bricklet_analog_out_v3.rb +210 -0
  20. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  21. data/lib/tinkerforge/bricklet_barometer_v2.rb +497 -0
  22. data/lib/tinkerforge/bricklet_can.rb +2 -2
  23. data/lib/tinkerforge/bricklet_can_v2.rb +5 -5
  24. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  25. data/lib/tinkerforge/bricklet_color.rb +2 -2
  26. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  27. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  28. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  29. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +398 -0
  30. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  31. data/lib/tinkerforge/bricklet_dmx.rb +7 -5
  32. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  33. data/lib/tinkerforge/bricklet_dual_button_v2.rb +283 -0
  34. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  35. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  36. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  37. data/lib/tinkerforge/bricklet_gps_v2.rb +6 -6
  38. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  39. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  40. data/lib/tinkerforge/bricklet_humidity_v2.rb +5 -5
  41. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  42. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +336 -0
  43. data/lib/tinkerforge/bricklet_industrial_counter.rb +12 -12
  44. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  45. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +7 -7
  46. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  47. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +302 -0
  48. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  49. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +382 -0
  50. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  51. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +374 -0
  52. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +5 -5
  53. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  54. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +11 -11
  55. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  56. data/lib/tinkerforge/bricklet_io16_v2.rb +418 -0
  57. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  58. data/lib/tinkerforge/bricklet_io4_v2.rb +6 -6
  59. data/lib/tinkerforge/bricklet_isolator.rb +282 -0
  60. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  61. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  62. data/lib/tinkerforge/bricklet_lcd_128x64.rb +486 -0
  63. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  64. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  65. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  66. data/lib/tinkerforge/bricklet_led_strip_v2.rb +8 -8
  67. data/lib/tinkerforge/bricklet_line.rb +2 -2
  68. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  69. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  70. data/lib/tinkerforge/bricklet_load_cell_v2.rb +5 -5
  71. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  72. data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
  73. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +6 -6
  74. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -5
  75. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  76. data/lib/tinkerforge/bricklet_nfc.rb +6 -6
  77. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  78. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  79. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +387 -0
  80. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  81. data/lib/tinkerforge/bricklet_one_wire.rb +305 -0
  82. data/lib/tinkerforge/bricklet_outdoor_weather.rb +5 -5
  83. data/lib/tinkerforge/bricklet_particulate_matter.rb +5 -5
  84. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  85. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  86. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  87. data/lib/tinkerforge/bricklet_ptc_v2.rb +5 -5
  88. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  89. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +5 -5
  90. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  91. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +5 -5
  92. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  93. data/lib/tinkerforge/bricklet_rgb_led_button.rb +5 -5
  94. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +5 -5
  95. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  96. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +5 -5
  97. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  98. data/lib/tinkerforge/bricklet_rs232.rb +2 -2
  99. data/lib/tinkerforge/bricklet_rs232_v2.rb +5 -5
  100. data/lib/tinkerforge/bricklet_rs485.rb +5 -5
  101. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  102. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  103. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +5 -5
  104. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  105. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +9 -9
  106. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  107. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  108. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +5 -5
  109. data/lib/tinkerforge/bricklet_temperature_v2.rb +278 -0
  110. data/lib/tinkerforge/bricklet_thermal_imaging.rb +5 -5
  111. data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
  112. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +5 -5
  113. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  114. data/lib/tinkerforge/bricklet_uv_light.rb +6 -5
  115. data/lib/tinkerforge/bricklet_uv_light_v2.rb +430 -0
  116. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  117. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  118. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +5 -5
  119. data/lib/tinkerforge/version.rb +1 -1
  120. metadata +18 -2
@@ -0,0 +1,486 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2018-09-28. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.18 #
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
+ # LCD with 128x64 pixel
14
+ class BrickletLCD128x64 < Device
15
+ DEVICE_IDENTIFIER = 298 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'LCD 128x64 Bricklet' # :nodoc:
17
+
18
+ # This callback is triggered periodically with the period that is set by
19
+ # BrickletLCD128x64#set_touch_position_callback_configuration. The parameters are the
20
+ # same as for BrickletLCD128x64#get_touch_position.
21
+ CALLBACK_TOUCH_POSITION = 11
22
+
23
+ # This callback is triggered periodically with the period that is set by
24
+ # BrickletLCD128x64#set_touch_gesture_callback_configuration. The parameters are the
25
+ # same as for BrickletLCD128x64#get_touch_gesture.
26
+ CALLBACK_TOUCH_GESTURE = 15
27
+
28
+ FUNCTION_WRITE_PIXELS_LOW_LEVEL = 1 # :nodoc:
29
+ FUNCTION_READ_PIXELS_LOW_LEVEL = 2 # :nodoc:
30
+ FUNCTION_CLEAR_DISPLAY = 3 # :nodoc:
31
+ FUNCTION_SET_DISPLAY_CONFIGURATION = 4 # :nodoc:
32
+ FUNCTION_GET_DISPLAY_CONFIGURATION = 5 # :nodoc:
33
+ FUNCTION_WRITE_LINE = 6 # :nodoc:
34
+ FUNCTION_DRAW_BUFFERED_FRAME = 7 # :nodoc:
35
+ FUNCTION_GET_TOUCH_POSITION = 8 # :nodoc:
36
+ FUNCTION_SET_TOUCH_POSITION_CALLBACK_CONFIGURATION = 9 # :nodoc:
37
+ FUNCTION_GET_TOUCH_POSITION_CALLBACK_CONFIGURATION = 10 # :nodoc:
38
+ FUNCTION_GET_TOUCH_GESTURE = 12 # :nodoc:
39
+ FUNCTION_SET_TOUCH_GESTURE_CALLBACK_CONFIGURATION = 13 # :nodoc:
40
+ FUNCTION_GET_TOUCH_GESTURE_CALLBACK_CONFIGURATION = 14 # :nodoc:
41
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
42
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
43
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
44
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
45
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
46
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
47
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
48
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
49
+ FUNCTION_RESET = 243 # :nodoc:
50
+ FUNCTION_WRITE_UID = 248 # :nodoc:
51
+ FUNCTION_READ_UID = 249 # :nodoc:
52
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
53
+
54
+ GESTURE_LEFT_TO_RIGHT = 0 # :nodoc:
55
+ GESTURE_RIGHT_TO_LEFT = 1 # :nodoc:
56
+ GESTURE_TOP_TO_BOTTOM = 2 # :nodoc:
57
+ GESTURE_BOTTOM_TO_TOP = 3 # :nodoc:
58
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
59
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
60
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
61
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
62
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
63
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
64
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
65
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
66
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
67
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
68
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
69
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
70
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
71
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
72
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
73
+
74
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
75
+ # the IP Connection <tt>ipcon</tt>.
76
+ def initialize(uid, ipcon)
77
+ super uid, ipcon
78
+
79
+ @api_version = [2, 0, 0]
80
+
81
+ @response_expected[FUNCTION_WRITE_PIXELS_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
82
+ @response_expected[FUNCTION_READ_PIXELS_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
+ @response_expected[FUNCTION_CLEAR_DISPLAY] = RESPONSE_EXPECTED_FALSE
84
+ @response_expected[FUNCTION_SET_DISPLAY_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
85
+ @response_expected[FUNCTION_GET_DISPLAY_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
+ @response_expected[FUNCTION_WRITE_LINE] = RESPONSE_EXPECTED_FALSE
87
+ @response_expected[FUNCTION_DRAW_BUFFERED_FRAME] = RESPONSE_EXPECTED_FALSE
88
+ @response_expected[FUNCTION_GET_TOUCH_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
+ @response_expected[FUNCTION_SET_TOUCH_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
90
+ @response_expected[FUNCTION_GET_TOUCH_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
91
+ @response_expected[FUNCTION_GET_TOUCH_GESTURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
92
+ @response_expected[FUNCTION_SET_TOUCH_GESTURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
93
+ @response_expected[FUNCTION_GET_TOUCH_GESTURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
94
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
95
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
96
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
97
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
98
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
99
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
100
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
101
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
102
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
103
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
104
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
106
+
107
+ @callback_formats[CALLBACK_TOUCH_POSITION] = 'S S S L'
108
+ @callback_formats[CALLBACK_TOUCH_GESTURE] = 'C L S S S S S L'
109
+
110
+ end
111
+
112
+ # Writes pixels to the specified window.
113
+ #
114
+ # The x-axis goes from 0 to 127 and the y-axis from 0 to 63. The pixels are written
115
+ # into the window line by line top to bottom and each line is written from left to
116
+ # right.
117
+ #
118
+ # If automatic draw is enabled (default) the pixels are directly written to
119
+ # the screen. Only pixels that have actually changed are updated on the screen,
120
+ # the rest stays the same.
121
+ #
122
+ # If automatic draw is disabled the pixels are written to an internal buffer and
123
+ # the buffer is transferred to the display only after BrickletLCD128x64#draw_buffered_frame
124
+ # is called. This can be used to avoid flicker when drawing a complex frame in
125
+ # multiple steps.
126
+ #
127
+ # Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
128
+ # function.
129
+ def write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data)
130
+ send_request FUNCTION_WRITE_PIXELS_LOW_LEVEL, [x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data], 'C C C C S S ?448', 0, ''
131
+ end
132
+
133
+ # Reads pixels from the specified window.
134
+ #
135
+ # The x-axis goes from 0 to 127 and the y-axis from 0 to 63. The pixels are read
136
+ # from the window line by line top to bottom and each line is read from left to
137
+ # right.
138
+ #
139
+ # If automatic draw is enabled (default) the pixels that are read are always the
140
+ # same that are shown on the display.
141
+ #
142
+ # If automatic draw is disabled the pixels are read from the internal buffer
143
+ # (see BrickletLCD128x64#draw_buffered_frame).
144
+ #
145
+ # Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
146
+ # function.
147
+ def read_pixels_low_level(x_start, y_start, x_end, y_end)
148
+ send_request FUNCTION_READ_PIXELS_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'C C C C', 484, 'S S ?480'
149
+ end
150
+
151
+ # Clears the complete content of the display.
152
+ def clear_display
153
+ send_request FUNCTION_CLEAR_DISPLAY, [], '', 0, ''
154
+ end
155
+
156
+ # Sets the configuration of the display.
157
+ #
158
+ # You can set a contrast value from 0 to 63, a backlight intensity value
159
+ # from 0 to 100 and you can invert the color (white/black) of the display.
160
+ #
161
+ # If automatic draw is set to *true*, the display is automatically updated with every
162
+ # call of BrickletLCD128x64#write_pixels and BrickletLCD128x64#write_line. If it is set to false, the
163
+ # changes are written into an internal buffer and only shown on the display after
164
+ # a call of BrickletLCD128x64#draw_buffered_frame.
165
+ #
166
+ # The default values are contrast 14, backlight intensity 100, inverting off
167
+ # and automatic draw on.
168
+ def set_display_configuration(contrast, backlight, invert, automatic_draw)
169
+ send_request FUNCTION_SET_DISPLAY_CONFIGURATION, [contrast, backlight, invert, automatic_draw], 'C C ? ?', 0, ''
170
+ end
171
+
172
+ # Returns the configuration as set by BrickletLCD128x64#set_display_configuration.
173
+ def get_display_configuration
174
+ send_request FUNCTION_GET_DISPLAY_CONFIGURATION, [], '', 4, 'C C ? ?'
175
+ end
176
+
177
+ # Writes text to a specific line (0 to 7) with a specific position
178
+ # (0 to 21). The text can have a maximum of 22 characters.
179
+ #
180
+ # For example: (1, 10, "Hello") will write *Hello* in the middle of the
181
+ # second line of the display.
182
+ #
183
+ # The display uses a special 5x7 pixel charset. You can view the characters
184
+ # of the charset in Brick Viewer.
185
+ def write_line(line, position, text)
186
+ send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z22', 0, ''
187
+ end
188
+
189
+ # Draws the currently buffered frame. Normally each call of BrickletLCD128x64#write_pixels and
190
+ # BrickletLCD128x64#write_line draws directly onto the display. If you turn automatic draw off
191
+ # (BrickletLCD128x64#set_display_configuration), the data is written in an internal buffer and
192
+ # only transferred to the display by calling this function. This can be used to
193
+ # avoid flicker when drawing a complex frame in multiple steps.
194
+ #
195
+ # Set the `force complete redraw` to *true* to redraw the whole display
196
+ # instead of only the changed parts. Normally it should not be necessary to set this to
197
+ # *true*. It may only become necessary in case of stuck pixels because of errors.
198
+ def draw_buffered_frame(force_complete_redraw)
199
+ send_request FUNCTION_DRAW_BUFFERED_FRAME, [force_complete_redraw], '?', 0, ''
200
+ end
201
+
202
+ # Returns the last valid touch position:
203
+ #
204
+ # * Pressure: Amount of pressure applied by the user (0-300)
205
+ # * X: Touch position on x-axis (0-127)
206
+ # * Y: Touch position on y-axis (0-63)
207
+ # * Age: Age of touch press in ms (how long ago it was)
208
+ def get_touch_position
209
+ send_request FUNCTION_GET_TOUCH_POSITION, [], '', 10, 'S S S L'
210
+ end
211
+
212
+ # The period in ms is the period with which the CALLBACK_TOUCH_POSITION callback
213
+ # is triggered periodically. A value of 0 turns the callback off.
214
+ #
215
+ # If the `value has to change`-parameter is set to true, the callback is only
216
+ # triggered after the value has changed. If the value didn't change within the
217
+ # period, the callback is triggered immediately on change.
218
+ #
219
+ # If it is set to false, the callback is continuously triggered with the period,
220
+ # independent of the value.
221
+ #
222
+ # The default value is (0, false).
223
+ def set_touch_position_callback_configuration(period, value_has_to_change)
224
+ send_request FUNCTION_SET_TOUCH_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
225
+ end
226
+
227
+ # Returns the callback configuration as set by
228
+ # BrickletLCD128x64#set_touch_position_callback_configuration.
229
+ def get_touch_position_callback_configuration
230
+ send_request FUNCTION_GET_TOUCH_POSITION_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
231
+ end
232
+
233
+ # Returns one of four touch gestures that can be automatically detected by the Bricklet.
234
+ #
235
+ # The gestures are swipes from left to right, right to left, top to bottom and bottom to top.
236
+ #
237
+ # Additionally to the gestures a vector with a start and end position of the gesture is
238
+ # provided. You can use this vector do determine a more exact location of the gesture (e.g.
239
+ # the swipe from top to bottom was on the left or right part of the screen).
240
+ #
241
+ # The age parameter corresponds to the age of gesture in ms (how long ago it was).
242
+ def get_touch_gesture
243
+ send_request FUNCTION_GET_TOUCH_GESTURE, [], '', 19, 'C L S S S S S L'
244
+ end
245
+
246
+ # The period in ms is the period with which the CALLBACK_TOUCH_GESTURE callback
247
+ # is triggered periodically. A value of 0 turns the callback off.
248
+ #
249
+ # If the `value has to change`-parameter is set to true, the callback is only
250
+ # triggered after the value has changed. If the value didn't change within the
251
+ # period, the callback is triggered immediately on change.
252
+ #
253
+ # If it is set to false, the callback is continuously triggered with the period,
254
+ # independent of the value.
255
+ #
256
+ # The default value is (0, false).
257
+ def set_touch_gesture_callback_configuration(period, value_has_to_change)
258
+ send_request FUNCTION_SET_TOUCH_GESTURE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
259
+ end
260
+
261
+ # Returns the callback configuration as set by
262
+ # BrickletLCD128x64#set_touch_gesture_callback_configuration.
263
+ def get_touch_gesture_callback_configuration
264
+ send_request FUNCTION_GET_TOUCH_GESTURE_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
265
+ end
266
+
267
+ # Returns the error count for the communication between Brick and Bricklet.
268
+ #
269
+ # The errors are divided into
270
+ #
271
+ # * ACK checksum errors,
272
+ # * message checksum errors,
273
+ # * framing errors and
274
+ # * overflow errors.
275
+ #
276
+ # The errors counts are for errors that occur on the Bricklet side. All
277
+ # Bricks have a similar function that returns the errors on the Brick side.
278
+ def get_spitfp_error_count
279
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
280
+ end
281
+
282
+ # Sets the bootloader mode and returns the status after the requested
283
+ # mode change was instigated.
284
+ #
285
+ # You can change from bootloader mode to firmware mode and vice versa. A change
286
+ # from bootloader mode to firmware mode will only take place if the entry function,
287
+ # device identifier and CRC are present and correct.
288
+ #
289
+ # This function is used by Brick Viewer during flashing. It should not be
290
+ # necessary to call it in a normal user program.
291
+ def set_bootloader_mode(mode)
292
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
293
+ end
294
+
295
+ # Returns the current bootloader mode, see BrickletLCD128x64#set_bootloader_mode.
296
+ def get_bootloader_mode
297
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
298
+ end
299
+
300
+ # Sets the firmware pointer for BrickletLCD128x64#write_firmware. The pointer has
301
+ # to be increased by chunks of size 64. The data is written to flash
302
+ # every 4 chunks (which equals to one page of size 256).
303
+ #
304
+ # This function is used by Brick Viewer during flashing. It should not be
305
+ # necessary to call it in a normal user program.
306
+ def set_write_firmware_pointer(pointer)
307
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
308
+ end
309
+
310
+ # Writes 64 Bytes of firmware at the position as written by
311
+ # BrickletLCD128x64#set_write_firmware_pointer before. The firmware is written
312
+ # to flash every 4 chunks.
313
+ #
314
+ # You can only write firmware in bootloader mode.
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 write_firmware(data)
319
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
320
+ end
321
+
322
+ # Sets the status LED configuration. By default the LED shows
323
+ # communication traffic between Brick and Bricklet, it flickers once
324
+ # for every 10 received data packets.
325
+ #
326
+ # You can also turn the LED permanently on/off or show a heartbeat.
327
+ #
328
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
329
+ def set_status_led_config(config)
330
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
331
+ end
332
+
333
+ # Returns the configuration as set by BrickletLCD128x64#set_status_led_config
334
+ def get_status_led_config
335
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
336
+ end
337
+
338
+ # Returns the temperature in °C as measured inside the microcontroller. The
339
+ # value returned is not the ambient temperature!
340
+ #
341
+ # The temperature is only proportional to the real temperature and it has bad
342
+ # accuracy. Practically it is only useful as an indicator for
343
+ # temperature changes.
344
+ def get_chip_temperature
345
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
346
+ end
347
+
348
+ # Calling this function will reset the Bricklet. All configurations
349
+ # will be lost.
350
+ #
351
+ # After a reset you have to create new device objects,
352
+ # calling functions on the existing ones will result in
353
+ # undefined behavior!
354
+ def reset
355
+ send_request FUNCTION_RESET, [], '', 0, ''
356
+ end
357
+
358
+ # Writes a new UID into flash. If you want to set a new UID
359
+ # you have to decode the Base58 encoded UID string into an
360
+ # integer first.
361
+ #
362
+ # We recommend that you use Brick Viewer to change the UID.
363
+ def write_uid(uid)
364
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
365
+ end
366
+
367
+ # Returns the current UID as an integer. Encode as
368
+ # Base58 to get the usual string version.
369
+ def read_uid
370
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
371
+ end
372
+
373
+ # Returns the UID, the UID where the Bricklet is connected to,
374
+ # the position, the hardware and firmware version as well as the
375
+ # device identifier.
376
+ #
377
+ # The position can be 'a', 'b', 'c' or 'd'.
378
+ #
379
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
380
+ # |device_identifier_constant|
381
+ def get_identity
382
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
383
+ end
384
+
385
+ # Writes pixels to the specified window.
386
+ #
387
+ # The x-axis goes from 0 to 127 and the y-axis from 0 to 63. The pixels are written
388
+ # into the window line by line top to bottom and each line is written from left to
389
+ # right.
390
+ #
391
+ # If automatic draw is enabled (default) the pixels are directly written to
392
+ # the screen. Only pixels that have actually changed are updated on the screen,
393
+ # the rest stays the same.
394
+ #
395
+ # If automatic draw is disabled the pixels are written to an internal buffer and
396
+ # the buffer is transferred to the display only after BrickletLCD128x64#draw_buffered_frame
397
+ # is called. This can be used to avoid flicker when drawing a complex frame in
398
+ # multiple steps.
399
+ #
400
+ # Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
401
+ # function.
402
+ def write_pixels(x_start, y_start, x_end, y_end, pixels)
403
+ if pixels.length > 65535
404
+ raise ArgumentError, 'Pixels can be at most 65535 items long'
405
+ end
406
+
407
+ pixels_length = pixels.length
408
+ pixels_chunk_offset = 0
409
+
410
+ if pixels_length == 0
411
+ pixels_chunk_data = [false] * 448
412
+ ret = write_pixels_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data
413
+ else
414
+ ret = nil # assigned in block
415
+
416
+ @stream_mutex.synchronize {
417
+ while pixels_chunk_offset < pixels_length
418
+ pixels_chunk_data = pixels[pixels_chunk_offset, 448]
419
+
420
+ if pixels_chunk_data.length < 448
421
+ pixels_chunk_data += [false] * (448 - pixels_chunk_data.length)
422
+ end
423
+
424
+ ret = write_pixels_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data
425
+ pixels_chunk_offset += 448
426
+ end
427
+ }
428
+ end
429
+
430
+ ret
431
+ end
432
+
433
+ # Reads pixels from the specified window.
434
+ #
435
+ # The x-axis goes from 0 to 127 and the y-axis from 0 to 63. The pixels are read
436
+ # from the window line by line top to bottom and each line is read from left to
437
+ # right.
438
+ #
439
+ # If automatic draw is enabled (default) the pixels that are read are always the
440
+ # same that are shown on the display.
441
+ #
442
+ # If automatic draw is disabled the pixels are read from the internal buffer
443
+ # (see BrickletLCD128x64#draw_buffered_frame).
444
+ #
445
+ # Automatic draw can be configured with the BrickletLCD128x64#set_display_configuration
446
+ # function.
447
+ def read_pixels(x_start, y_start, x_end, y_end)
448
+ pixels_length = nil # assigned in block
449
+ pixels_data = nil # assigned in block
450
+
451
+ @stream_mutex.synchronize {
452
+ ret = read_pixels_low_level x_start, y_start, x_end, y_end
453
+ pixels_length = ret[0]
454
+ pixels_chunk_offset = ret[1]
455
+ pixels_out_of_sync = pixels_chunk_offset != 0
456
+ pixels_data = ret[2]
457
+
458
+ while not pixels_out_of_sync and pixels_data.length < pixels_length
459
+ ret = read_pixels_low_level x_start, y_start, x_end, y_end
460
+ pixels_length = ret[0]
461
+ pixels_chunk_offset = ret[1]
462
+ pixels_out_of_sync = pixels_chunk_offset != pixels_data.length
463
+ pixels_data += ret[2]
464
+ end
465
+
466
+ if pixels_out_of_sync # discard remaining stream to bring it back in-sync
467
+ while pixels_chunk_offset + 480 < pixels_length
468
+ ret = read_pixels_low_level x_start, y_start, x_end, y_end
469
+ pixels_length = ret[0]
470
+ pixels_chunk_offset = ret[1]
471
+ end
472
+
473
+ raise StreamOutOfSyncException, 'Pixels stream is out-of-sync'
474
+ end
475
+ }
476
+
477
+ pixels_data[0, pixels_length]
478
+ end
479
+
480
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
481
+ def register_callback(id, &block)
482
+ callback = block
483
+ @registered_callbacks[id] = callback
484
+ end
485
+ end
486
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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 #
@@ -242,9 +242,9 @@ module Tinkerforge
242
242
  # If the mapping has 4 colors, the function BrickletLEDStripV2#set_led_values expects 4
243
243
  # values per pixel and if the mapping has 3 colors it expects 3 values per pixel.
244
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
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
248
  # the APA102 chips typically use WBGR order.
249
249
  #
250
250
  # The APA102 chips are special. They have three 8-bit channels for RGB
@@ -280,9 +280,9 @@ module Tinkerforge
280
280
  #
281
281
  # The errors are divided into
282
282
  #
283
- # * ack checksum errors,
283
+ # * ACK checksum errors,
284
284
  # * message checksum errors,
285
- # * frameing errors and
285
+ # * framing errors and
286
286
  # * overflow errors.
287
287
  #
288
288
  # The errors counts are for errors that occur on the Bricklet side. All
@@ -296,7 +296,7 @@ module Tinkerforge
296
296
  #
297
297
  # You can change from bootloader mode to firmware mode and vice versa. A change
298
298
  # from bootloader mode to firmware mode will only take place if the entry function,
299
- # device identifier und crc are present and correct.
299
+ # device identifier and CRC are present and correct.
300
300
  #
301
301
  # This function is used by Brick Viewer during flashing. It should not be
302
302
  # necessary to call it in a normal user program.
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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 #
@@ -231,9 +231,9 @@ module Tinkerforge
231
231
  #
232
232
  # The errors are divided into
233
233
  #
234
- # * ack checksum errors,
234
+ # * ACK checksum errors,
235
235
  # * message checksum errors,
236
- # * frameing errors and
236
+ # * framing errors and
237
237
  # * overflow errors.
238
238
  #
239
239
  # The errors counts are for errors that occur on the Bricklet side. All
@@ -247,7 +247,7 @@ module Tinkerforge
247
247
  #
248
248
  # You can change from bootloader mode to firmware mode and vice versa. A change
249
249
  # from bootloader mode to firmware mode will only take place if the entry function,
250
- # device identifier und crc are present and correct.
250
+ # device identifier and CRC are present and correct.
251
251
  #
252
252
  # This function is used by Brick Viewer during flashing. It should not be
253
253
  # necessary to call it in a normal user program.
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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-06-08. #
3
+ # This file was automatically generated on 2018-09-28. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.17 #
5
+ # Ruby Bindings Version 2.1.18 #
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 #