tinkerforge 2.1.24 → 2.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +155 -74
  3. data/lib/tinkerforge/brick_hat.rb +70 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +56 -22
  5. data/lib/tinkerforge/brick_imu.rb +184 -77
  6. data/lib/tinkerforge/brick_imu_v2.rb +208 -105
  7. data/lib/tinkerforge/brick_master.rb +484 -182
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +185 -101
  10. data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
  11. data/lib/tinkerforge/brick_stepper.rb +210 -98
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
  18. data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +66 -26
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -18
  27. data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +34 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
  30. data/lib/tinkerforge/bricklet_color.rb +69 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +78 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +58 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +58 -24
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
  37. data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
  39. data/lib/tinkerforge/bricklet_dmx.rb +88 -34
  40. data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
  46. data/lib/tinkerforge/bricklet_gps.rb +64 -26
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
  50. data/lib/tinkerforge/bricklet_humidity.rb +51 -21
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
  52. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
  53. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
  54. data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
  55. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
  57. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
  59. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
  62. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
  64. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
  65. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
  66. data/lib/tinkerforge/bricklet_io16.rb +55 -21
  67. data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
  68. data/lib/tinkerforge/bricklet_io4.rb +55 -23
  69. data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
  70. data/lib/tinkerforge/bricklet_isolator.rb +72 -28
  71. data/lib/tinkerforge/bricklet_joystick.rb +59 -25
  72. data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
  73. data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
  74. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
  75. data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
  76. data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
  77. data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
  78. data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
  79. data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
  80. data/lib/tinkerforge/bricklet_line.rb +34 -14
  81. data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
  82. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
  83. data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
  84. data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
  85. data/lib/tinkerforge/bricklet_moisture.rb +40 -16
  86. data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
  87. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
  88. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
  89. data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
  90. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
  91. data/lib/tinkerforge/bricklet_nfc.rb +123 -58
  92. data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
  93. data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
  94. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
  95. data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
  96. data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
  97. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
  98. data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
  99. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
  100. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
  101. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
  102. data/lib/tinkerforge/bricklet_ptc.rb +74 -42
  103. data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
  104. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
  105. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
  106. data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
  107. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
  108. data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
  109. data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
  110. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
  111. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
  112. data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
  113. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
  114. data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
  115. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
  116. data/lib/tinkerforge/bricklet_rs232.rb +90 -28
  117. data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
  118. data/lib/tinkerforge/bricklet_rs485.rb +223 -95
  119. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
  120. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
  121. data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
  122. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
  123. data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
  124. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
  125. data/lib/tinkerforge/bricklet_temperature.rb +40 -16
  126. data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
  127. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
  128. data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
  129. data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
  130. data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
  131. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
  132. data/lib/tinkerforge/bricklet_tilt.rb +24 -10
  133. data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
  134. data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
  135. data/lib/tinkerforge/bricklet_voltage.rb +52 -28
  136. data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
  137. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
  138. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
  139. data/lib/tinkerforge/device_display_names.rb +163 -0
  140. data/lib/tinkerforge/ip_connection.rb +151 -32
  141. data/lib/tinkerforge/version.rb +1 -1
  142. metadata +3 -2
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Reads and writes NFC and RFID tags
14
16
  class BrickletNFCRFID < Device
@@ -52,7 +54,7 @@ module Tinkerforge
52
54
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
53
55
  # the IP Connection <tt>ipcon</tt>.
54
56
  def initialize(uid, ipcon)
55
- super uid, ipcon
57
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
56
58
 
57
59
  @api_version = [2, 0, 0]
58
60
 
@@ -65,8 +67,9 @@ module Tinkerforge
65
67
  @response_expected[FUNCTION_GET_PAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
66
68
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
67
69
 
68
- @callback_formats[CALLBACK_STATE_CHANGED] = 'C ?'
70
+ @callback_formats[CALLBACK_STATE_CHANGED] = [10, 'C ?']
69
71
 
72
+ @ipcon.add_device self
70
73
  end
71
74
 
72
75
  # To read or write a tag that is in proximity of the NFC/RFID Bricklet you
@@ -98,7 +101,9 @@ module Tinkerforge
98
101
  # In case of any *Error* state the selection is lost and you have to
99
102
  # start again by calling BrickletNFCRFID#request_tag_id.
100
103
  def request_tag_id(tag_type)
101
- send_request FUNCTION_REQUEST_TAG_ID, [tag_type], 'C', 0, ''
104
+ check_validity
105
+
106
+ send_request FUNCTION_REQUEST_TAG_ID, [tag_type], 'C', 8, ''
102
107
  end
103
108
 
104
109
  # Returns the tag type, tag ID and the length of the tag ID
@@ -113,7 +118,9 @@ module Tinkerforge
113
118
  # CALLBACK_STATE_CHANGED callback)
114
119
  # 3. Call BrickletNFCRFID#get_tag_id
115
120
  def get_tag_id
116
- send_request FUNCTION_GET_TAG_ID, [], '', 9, 'C C C7'
121
+ check_validity
122
+
123
+ send_request FUNCTION_GET_TAG_ID, [], '', 17, 'C C C7'
117
124
  end
118
125
 
119
126
  # Returns the current state of the NFC/RFID Bricklet.
@@ -131,7 +138,9 @@ module Tinkerforge
131
138
  #
132
139
  # The same approach is used analogously for the other API functions.
133
140
  def get_state
134
- send_request FUNCTION_GET_STATE, [], '', 2, 'C ?'
141
+ check_validity
142
+
143
+ send_request FUNCTION_GET_STATE, [], '', 10, 'C ?'
135
144
  end
136
145
 
137
146
  # Mifare Classic tags use authentication. If you want to read from or write to
@@ -153,7 +162,9 @@ module Tinkerforge
153
162
  # BrickletNFCRFID#get_state or CALLBACK_STATE_CHANGED callback)
154
163
  # 6. Call BrickletNFCRFID#request_page or BrickletNFCRFID#write_page to read/write page
155
164
  def authenticate_mifare_classic_page(page, key_number, key)
156
- send_request FUNCTION_AUTHENTICATE_MIFARE_CLASSIC_PAGE, [page, key_number, key], 'S C C6', 0, ''
165
+ check_validity
166
+
167
+ send_request FUNCTION_AUTHENTICATE_MIFARE_CLASSIC_PAGE, [page, key_number, key], 'S C C6', 8, ''
157
168
  end
158
169
 
159
170
  # Writes 16 bytes starting from the given page. How many pages are written
@@ -177,7 +188,9 @@ module Tinkerforge
177
188
  # If you use a Mifare Classic tag you have to authenticate a page before you
178
189
  # can write to it. See BrickletNFCRFID#authenticate_mifare_classic_page.
179
190
  def write_page(page, data)
180
- send_request FUNCTION_WRITE_PAGE, [page, data], 'S C16', 0, ''
191
+ check_validity
192
+
193
+ send_request FUNCTION_WRITE_PAGE, [page, data], 'S C16', 8, ''
181
194
  end
182
195
 
183
196
  # Reads 16 bytes starting from the given page and stores them into a buffer.
@@ -204,25 +217,32 @@ module Tinkerforge
204
217
  # If you use a Mifare Classic tag you have to authenticate a page before you
205
218
  # can read it. See BrickletNFCRFID#authenticate_mifare_classic_page.
206
219
  def request_page(page)
207
- send_request FUNCTION_REQUEST_PAGE, [page], 'S', 0, ''
220
+ check_validity
221
+
222
+ send_request FUNCTION_REQUEST_PAGE, [page], 'S', 8, ''
208
223
  end
209
224
 
210
225
  # Returns 16 bytes of data from an internal buffer. To fill the buffer
211
226
  # with specific pages you have to call BrickletNFCRFID#request_page beforehand.
212
227
  def get_page
213
- send_request FUNCTION_GET_PAGE, [], '', 16, 'C16'
228
+ check_validity
229
+
230
+ send_request FUNCTION_GET_PAGE, [], '', 24, 'C16'
214
231
  end
215
232
 
216
233
  # Returns the UID, the UID where the Bricklet is connected to,
217
234
  # the position, the hardware and firmware version as well as the
218
235
  # device identifier.
219
236
  #
220
- # The position can be 'a', 'b', 'c' or 'd'.
237
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
238
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
239
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
240
+ # position 'z'.
221
241
  #
222
242
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
223
243
  # |device_identifier_constant|
224
244
  def get_identity
225
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
245
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
226
246
  end
227
247
 
228
248
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # 3.3cm (1.3") OLED display with 128x64 pixels
14
16
  class BrickletOLED128x64 < Device
@@ -27,7 +29,7 @@ module Tinkerforge
27
29
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
28
30
  # the IP Connection <tt>ipcon</tt>.
29
31
  def initialize(uid, ipcon)
30
- super uid, ipcon
32
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
31
33
 
32
34
  @api_version = [2, 0, 0]
33
35
 
@@ -40,6 +42,7 @@ module Tinkerforge
40
42
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
41
43
 
42
44
 
45
+ @ipcon.add_device self
43
46
  end
44
47
 
45
48
  # Appends 64 byte of data to the window as set by BrickletOLED128x64#new_window.
@@ -63,18 +66,24 @@ module Tinkerforge
63
66
  # and the next two the second row and so on. To fill the whole display
64
67
  # you need to call BrickletOLED128x64#write 16 times.
65
68
  def write(data)
66
- send_request FUNCTION_WRITE, [data], 'C64', 0, ''
69
+ check_validity
70
+
71
+ send_request FUNCTION_WRITE, [data], 'C64', 8, ''
67
72
  end
68
73
 
69
74
  # Sets the window in which you can write with BrickletOLED128x64#write. One row
70
75
  # has a height of 8 pixels.
71
76
  def new_window(column_from, column_to, row_from, row_to)
72
- send_request FUNCTION_NEW_WINDOW, [column_from, column_to, row_from, row_to], 'C C C C', 0, ''
77
+ check_validity
78
+
79
+ send_request FUNCTION_NEW_WINDOW, [column_from, column_to, row_from, row_to], 'C C C C', 8, ''
73
80
  end
74
81
 
75
82
  # Clears the current content of the window as set by BrickletOLED128x64#new_window.
76
83
  def clear_display
77
- send_request FUNCTION_CLEAR_DISPLAY, [], '', 0, ''
84
+ check_validity
85
+
86
+ send_request FUNCTION_CLEAR_DISPLAY, [], '', 8, ''
78
87
  end
79
88
 
80
89
  # Sets the configuration of the display.
@@ -82,12 +91,16 @@ module Tinkerforge
82
91
  # You can set a contrast value from 0 to 255 and you can invert the color
83
92
  # (black/white) of the display.
84
93
  def set_display_configuration(contrast, invert)
85
- send_request FUNCTION_SET_DISPLAY_CONFIGURATION, [contrast, invert], 'C ?', 0, ''
94
+ check_validity
95
+
96
+ send_request FUNCTION_SET_DISPLAY_CONFIGURATION, [contrast, invert], 'C ?', 8, ''
86
97
  end
87
98
 
88
99
  # Returns the configuration as set by BrickletOLED128x64#set_display_configuration.
89
100
  def get_display_configuration
90
- send_request FUNCTION_GET_DISPLAY_CONFIGURATION, [], '', 2, 'C ?'
101
+ check_validity
102
+
103
+ send_request FUNCTION_GET_DISPLAY_CONFIGURATION, [], '', 10, 'C ?'
91
104
  end
92
105
 
93
106
  # Writes text to a specific line with a specific position.
@@ -102,19 +115,24 @@ module Tinkerforge
102
115
  # The display uses a special 5x7 pixel charset. You can view the characters
103
116
  # of the charset in Brick Viewer.
104
117
  def write_line(line, position, text)
105
- send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z26', 0, ''
118
+ check_validity
119
+
120
+ send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z26', 8, ''
106
121
  end
107
122
 
108
123
  # Returns the UID, the UID where the Bricklet is connected to,
109
124
  # the position, the hardware and firmware version as well as the
110
125
  # device identifier.
111
126
  #
112
- # The position can be 'a', 'b', 'c' or 'd'.
127
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
128
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
129
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
130
+ # position 'z'.
113
131
  #
114
132
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
115
133
  # |device_identifier_constant|
116
134
  def get_identity
117
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
135
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
118
136
  end
119
137
 
120
138
  end
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # 3.3cm (1.3") OLED display with 128x64 pixels
14
16
  class BrickletOLED128x64V2 < Device
@@ -54,7 +56,7 @@ module Tinkerforge
54
56
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
55
57
  # the IP Connection <tt>ipcon</tt>.
56
58
  def initialize(uid, ipcon)
57
- super uid, ipcon
59
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
58
60
 
59
61
  @api_version = [2, 0, 0]
60
62
 
@@ -79,6 +81,7 @@ module Tinkerforge
79
81
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
82
 
81
83
 
84
+ @ipcon.add_device self
82
85
  end
83
86
 
84
87
  # Writes pixels to the specified window.
@@ -98,7 +101,9 @@ module Tinkerforge
98
101
  # Automatic draw can be configured with the BrickletOLED128x64V2#set_display_configuration
99
102
  # function.
100
103
  def write_pixels_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data)
101
- 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, ''
104
+ check_validity
105
+
106
+ 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', 8, ''
102
107
  end
103
108
 
104
109
  # Reads pixels from the specified window.
@@ -115,7 +120,9 @@ module Tinkerforge
115
120
  # Automatic draw can be configured with the BrickletOLED128x64V2#set_display_configuration
116
121
  # function.
117
122
  def read_pixels_low_level(x_start, y_start, x_end, y_end)
118
- send_request FUNCTION_READ_PIXELS_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'C C C C', 484, 'S S ?480'
123
+ check_validity
124
+
125
+ send_request FUNCTION_READ_PIXELS_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'C C C C', 72, 'S S ?480'
119
126
  end
120
127
 
121
128
  # Clears the complete content of the display.
@@ -130,7 +137,9 @@ module Tinkerforge
130
137
  # Automatic draw can be configured with the BrickletOLED128x64V2#set_display_configuration
131
138
  # function.
132
139
  def clear_display
133
- send_request FUNCTION_CLEAR_DISPLAY, [], '', 0, ''
140
+ check_validity
141
+
142
+ send_request FUNCTION_CLEAR_DISPLAY, [], '', 8, ''
134
143
  end
135
144
 
136
145
  # Sets the configuration of the display.
@@ -143,12 +152,16 @@ module Tinkerforge
143
152
  # changes are written into an internal buffer and only shown on the display after
144
153
  # a call of BrickletOLED128x64V2#draw_buffered_frame.
145
154
  def set_display_configuration(contrast, invert, automatic_draw)
146
- send_request FUNCTION_SET_DISPLAY_CONFIGURATION, [contrast, invert, automatic_draw], 'C ? ?', 0, ''
155
+ check_validity
156
+
157
+ send_request FUNCTION_SET_DISPLAY_CONFIGURATION, [contrast, invert, automatic_draw], 'C ? ?', 8, ''
147
158
  end
148
159
 
149
160
  # Returns the configuration as set by BrickletOLED128x64V2#set_display_configuration.
150
161
  def get_display_configuration
151
- send_request FUNCTION_GET_DISPLAY_CONFIGURATION, [], '', 3, 'C ? ?'
162
+ check_validity
163
+
164
+ send_request FUNCTION_GET_DISPLAY_CONFIGURATION, [], '', 11, 'C ? ?'
152
165
  end
153
166
 
154
167
  # Writes text to a specific line with a specific position.
@@ -172,7 +185,9 @@ module Tinkerforge
172
185
  # Automatic draw can be configured with the BrickletOLED128x64V2#set_display_configuration
173
186
  # function.
174
187
  def write_line(line, position, text)
175
- send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z22', 0, ''
188
+ check_validity
189
+
190
+ send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z22', 8, ''
176
191
  end
177
192
 
178
193
  # Draws the currently buffered frame. Normally each call of BrickletOLED128x64V2#write_pixels and
@@ -185,7 +200,9 @@ module Tinkerforge
185
200
  # instead of only the changed parts. Normally it should not be necessary to set this to
186
201
  # *true*. It may only become necessary in case of stuck pixels because of errors.
187
202
  def draw_buffered_frame(force_complete_redraw)
188
- send_request FUNCTION_DRAW_BUFFERED_FRAME, [force_complete_redraw], '?', 0, ''
203
+ check_validity
204
+
205
+ send_request FUNCTION_DRAW_BUFFERED_FRAME, [force_complete_redraw], '?', 8, ''
189
206
  end
190
207
 
191
208
  # Returns the error count for the communication between Brick and Bricklet.
@@ -200,7 +217,9 @@ module Tinkerforge
200
217
  # The errors counts are for errors that occur on the Bricklet side. All
201
218
  # Bricks have a similar function that returns the errors on the Brick side.
202
219
  def get_spitfp_error_count
203
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
220
+ check_validity
221
+
222
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
204
223
  end
205
224
 
206
225
  # Sets the bootloader mode and returns the status after the requested
@@ -213,12 +232,16 @@ module Tinkerforge
213
232
  # This function is used by Brick Viewer during flashing. It should not be
214
233
  # necessary to call it in a normal user program.
215
234
  def set_bootloader_mode(mode)
216
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
235
+ check_validity
236
+
237
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
217
238
  end
218
239
 
219
240
  # Returns the current bootloader mode, see BrickletOLED128x64V2#set_bootloader_mode.
220
241
  def get_bootloader_mode
221
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
242
+ check_validity
243
+
244
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
222
245
  end
223
246
 
224
247
  # Sets the firmware pointer for BrickletOLED128x64V2#write_firmware. The pointer has
@@ -228,7 +251,9 @@ module Tinkerforge
228
251
  # This function is used by Brick Viewer during flashing. It should not be
229
252
  # necessary to call it in a normal user program.
230
253
  def set_write_firmware_pointer(pointer)
231
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
254
+ check_validity
255
+
256
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
232
257
  end
233
258
 
234
259
  # Writes 64 Bytes of firmware at the position as written by
@@ -240,7 +265,9 @@ module Tinkerforge
240
265
  # This function is used by Brick Viewer during flashing. It should not be
241
266
  # necessary to call it in a normal user program.
242
267
  def write_firmware(data)
243
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
268
+ check_validity
269
+
270
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
244
271
  end
245
272
 
246
273
  # Sets the status LED configuration. By default the LED shows
@@ -251,22 +278,28 @@ module Tinkerforge
251
278
  #
252
279
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
253
280
  def set_status_led_config(config)
254
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
281
+ check_validity
282
+
283
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
255
284
  end
256
285
 
257
286
  # Returns the configuration as set by BrickletOLED128x64V2#set_status_led_config
258
287
  def get_status_led_config
259
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
288
+ check_validity
289
+
290
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
260
291
  end
261
292
 
262
- # Returns the temperature in °C as measured inside the microcontroller. The
293
+ # Returns the temperature as measured inside the microcontroller. The
263
294
  # value returned is not the ambient temperature!
264
295
  #
265
296
  # The temperature is only proportional to the real temperature and it has bad
266
297
  # accuracy. Practically it is only useful as an indicator for
267
298
  # temperature changes.
268
299
  def get_chip_temperature
269
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
300
+ check_validity
301
+
302
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
270
303
  end
271
304
 
272
305
  # Calling this function will reset the Bricklet. All configurations
@@ -276,7 +309,9 @@ module Tinkerforge
276
309
  # calling functions on the existing ones will result in
277
310
  # undefined behavior!
278
311
  def reset
279
- send_request FUNCTION_RESET, [], '', 0, ''
312
+ check_validity
313
+
314
+ send_request FUNCTION_RESET, [], '', 8, ''
280
315
  end
281
316
 
282
317
  # Writes a new UID into flash. If you want to set a new UID
@@ -285,25 +320,32 @@ module Tinkerforge
285
320
  #
286
321
  # We recommend that you use Brick Viewer to change the UID.
287
322
  def write_uid(uid)
288
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
323
+ check_validity
324
+
325
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
289
326
  end
290
327
 
291
328
  # Returns the current UID as an integer. Encode as
292
329
  # Base58 to get the usual string version.
293
330
  def read_uid
294
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
331
+ check_validity
332
+
333
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
295
334
  end
296
335
 
297
336
  # Returns the UID, the UID where the Bricklet is connected to,
298
337
  # the position, the hardware and firmware version as well as the
299
338
  # device identifier.
300
339
  #
301
- # The position can be 'a', 'b', 'c' or 'd'.
340
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
341
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
342
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
343
+ # position 'z'.
302
344
  #
303
345
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
304
346
  # |device_identifier_constant|
305
347
  def get_identity
306
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
348
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
307
349
  end
308
350
 
309
351
  # Writes pixels to the specified window.