tinkerforge 2.1.21 → 2.1.22

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 (134) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +2 -2
  3. data/lib/tinkerforge/brick_hat.rb +256 -0
  4. data/lib/tinkerforge/brick_hat_zero.rb +196 -0
  5. data/lib/tinkerforge/brick_imu.rb +2 -2
  6. data/lib/tinkerforge/brick_imu_v2.rb +2 -2
  7. data/lib/tinkerforge/brick_master.rb +12 -9
  8. data/lib/tinkerforge/brick_red.rb +2 -2
  9. data/lib/tinkerforge/brick_servo.rb +2 -2
  10. data/lib/tinkerforge/brick_silent_stepper.rb +2 -2
  11. data/lib/tinkerforge/brick_stepper.rb +2 -2
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +16 -6
  14. data/lib/tinkerforge/bricklet_air_quality.rb +59 -3
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +3 -3
  18. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +2 -2
  21. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +2 -2
  24. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +2 -2
  26. data/lib/tinkerforge/bricklet_can.rb +2 -2
  27. data/lib/tinkerforge/bricklet_can_v2.rb +2 -2
  28. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +479 -0
  30. data/lib/tinkerforge/bricklet_color.rb +2 -2
  31. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  32. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  33. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  34. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +3 -3
  35. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  36. data/lib/tinkerforge/bricklet_dmx.rb +2 -2
  37. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  38. data/lib/tinkerforge/bricklet_dual_button_v2.rb +2 -2
  39. data/lib/tinkerforge/bricklet_dual_relay.rb +5 -3
  40. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  41. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +600 -0
  42. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  43. data/lib/tinkerforge/bricklet_gps_v2.rb +2 -2
  44. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  45. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +333 -0
  46. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  47. data/lib/tinkerforge/bricklet_humidity_v2.rb +2 -2
  48. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  49. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +2 -2
  50. data/lib/tinkerforge/bricklet_industrial_counter.rb +2 -2
  51. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +3 -3
  52. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +2 -2
  53. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +9 -4
  54. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +12 -2
  55. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  56. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +2 -2
  57. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  58. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +2 -2
  59. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +6 -3
  60. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +9 -4
  61. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +7 -2
  62. data/lib/tinkerforge/bricklet_io16.rb +11 -2
  63. data/lib/tinkerforge/bricklet_io16_v2.rb +10 -2
  64. data/lib/tinkerforge/bricklet_io4.rb +10 -2
  65. data/lib/tinkerforge/bricklet_io4_v2.rb +15 -2
  66. data/lib/tinkerforge/bricklet_isolator.rb +2 -2
  67. data/lib/tinkerforge/bricklet_joystick.rb +9 -9
  68. data/lib/tinkerforge/bricklet_joystick_v2.rb +294 -0
  69. data/lib/tinkerforge/bricklet_laser_range_finder.rb +3 -3
  70. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +447 -0
  71. data/lib/tinkerforge/bricklet_lcd_128x64.rb +2 -2
  72. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  73. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  74. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  75. data/lib/tinkerforge/bricklet_led_strip_v2.rb +2 -2
  76. data/lib/tinkerforge/bricklet_line.rb +2 -2
  77. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  78. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +259 -0
  79. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  80. data/lib/tinkerforge/bricklet_load_cell_v2.rb +2 -2
  81. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  82. data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
  83. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +5 -7
  84. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
  85. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  86. data/lib/tinkerforge/bricklet_nfc.rb +2 -2
  87. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  88. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  89. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +2 -2
  90. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  91. data/lib/tinkerforge/bricklet_one_wire.rb +2 -2
  92. data/lib/tinkerforge/bricklet_outdoor_weather.rb +14 -2
  93. data/lib/tinkerforge/bricklet_particulate_matter.rb +2 -2
  94. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  95. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  96. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +311 -0
  97. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  98. data/lib/tinkerforge/bricklet_ptc_v2.rb +2 -2
  99. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  100. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +2 -2
  101. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  102. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +3 -3
  103. data/lib/tinkerforge/bricklet_rgb_led.rb +4 -4
  104. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  105. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  106. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +203 -0
  107. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  108. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +2 -2
  109. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  110. data/lib/tinkerforge/bricklet_rs232.rb +2 -2
  111. data/lib/tinkerforge/bricklet_rs232_v2.rb +2 -2
  112. data/lib/tinkerforge/bricklet_rs485.rb +2 -2
  113. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  114. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +309 -0
  115. data/lib/tinkerforge/bricklet_solid_state_relay.rb +3 -3
  116. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
  117. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  118. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +2 -2
  119. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  120. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  121. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +5 -2
  122. data/lib/tinkerforge/bricklet_temperature_v2.rb +2 -2
  123. data/lib/tinkerforge/bricklet_thermal_imaging.rb +4 -4
  124. data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
  125. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +2 -2
  126. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  127. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  128. data/lib/tinkerforge/bricklet_uv_light_v2.rb +2 -2
  129. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  130. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  131. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +2 -2
  132. data/lib/tinkerforge/ip_connection.rb +21 -4
  133. data/lib/tinkerforge/version.rb +1 -1
  134. metadata +14 -3
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-01-29. #
3
+ # This file was automatically generated on 2019-05-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.21 #
5
+ # Ruby Bindings Version 2.1.22 #
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 2019-01-29. #
3
+ # This file was automatically generated on 2019-05-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.21 #
5
+ # Ruby Bindings Version 2.1.22 #
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 2019-01-29. #
3
+ # This file was automatically generated on 2019-05-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.21 #
5
+ # Ruby Bindings Version 2.1.22 #
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 2019-01-29. #
3
+ # This file was automatically generated on 2019-05-21. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.21 #
5
+ # Ruby Bindings Version 2.1.22 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -0,0 +1,479 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2019-05-21. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.22 #
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
+ # Measures CO2 concentration, temperature and humidity
14
+ class BrickletCO2V2 < Device
15
+ DEVICE_IDENTIFIER = 2147 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'CO2 Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered periodically according to the configuration set by
19
+ # BrickletCO2V2#set_all_values_callback_configuration.
20
+ #
21
+ # The parameters are the same as BrickletCO2V2#get_all_values.
22
+ CALLBACK_ALL_VALUES = 8
23
+
24
+ # This callback is triggered periodically according to the configuration set by
25
+ # BrickletCO2V2#set_co2_concentration_callback_configuration.
26
+ #
27
+ # The parameter is the same as BrickletCO2V2#get_co2_concentration.
28
+ CALLBACK_CO2_CONCENTRATION = 12
29
+
30
+ # This callback is triggered periodically according to the configuration set by
31
+ # BrickletCO2V2#set_temperature_callback_configuration.
32
+ #
33
+ # The parameter is the same as BrickletCO2V2#get_temperature.
34
+ CALLBACK_TEMPERATURE = 16
35
+
36
+ # This callback is triggered periodically according to the configuration set by
37
+ # BrickletCO2V2#set_humidity_callback_configuration.
38
+ #
39
+ # The parameter is the same as BrickletCO2V2#get_humidity.
40
+ CALLBACK_HUMIDITY = 20
41
+
42
+ FUNCTION_GET_ALL_VALUES = 1 # :nodoc:
43
+ FUNCTION_SET_AIR_PRESSURE = 2 # :nodoc:
44
+ FUNCTION_GET_AIR_PRESSURE = 3 # :nodoc:
45
+ FUNCTION_SET_TEMPERATURE_OFFSET = 4 # :nodoc:
46
+ FUNCTION_GET_TEMPERATURE_OFFSET = 5 # :nodoc:
47
+ FUNCTION_SET_ALL_VALUES_CALLBACK_CONFIGURATION = 6 # :nodoc:
48
+ FUNCTION_GET_ALL_VALUES_CALLBACK_CONFIGURATION = 7 # :nodoc:
49
+ FUNCTION_GET_CO2_CONCENTRATION = 9 # :nodoc:
50
+ FUNCTION_SET_CO2_CONCENTRATION_CALLBACK_CONFIGURATION = 10 # :nodoc:
51
+ FUNCTION_GET_CO2_CONCENTRATION_CALLBACK_CONFIGURATION = 11 # :nodoc:
52
+ FUNCTION_GET_TEMPERATURE = 13 # :nodoc:
53
+ FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION = 14 # :nodoc:
54
+ FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION = 15 # :nodoc:
55
+ FUNCTION_GET_HUMIDITY = 17 # :nodoc:
56
+ FUNCTION_SET_HUMIDITY_CALLBACK_CONFIGURATION = 18 # :nodoc:
57
+ FUNCTION_GET_HUMIDITY_CALLBACK_CONFIGURATION = 19 # :nodoc:
58
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
59
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
60
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
61
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
62
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
63
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
64
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
65
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
66
+ FUNCTION_RESET = 243 # :nodoc:
67
+ FUNCTION_WRITE_UID = 248 # :nodoc:
68
+ FUNCTION_READ_UID = 249 # :nodoc:
69
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
70
+
71
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
72
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
73
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
74
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
75
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
76
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
77
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
78
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
79
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
80
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
81
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
82
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
83
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
84
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
85
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
86
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
87
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
88
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
89
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
90
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
91
+
92
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
93
+ # the IP Connection <tt>ipcon</tt>.
94
+ def initialize(uid, ipcon)
95
+ super uid, ipcon
96
+
97
+ @api_version = [2, 0, 0]
98
+
99
+ @response_expected[FUNCTION_GET_ALL_VALUES] = RESPONSE_EXPECTED_ALWAYS_TRUE
100
+ @response_expected[FUNCTION_SET_AIR_PRESSURE] = RESPONSE_EXPECTED_FALSE
101
+ @response_expected[FUNCTION_GET_AIR_PRESSURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
102
+ @response_expected[FUNCTION_SET_TEMPERATURE_OFFSET] = RESPONSE_EXPECTED_FALSE
103
+ @response_expected[FUNCTION_GET_TEMPERATURE_OFFSET] = RESPONSE_EXPECTED_ALWAYS_TRUE
104
+ @response_expected[FUNCTION_SET_ALL_VALUES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
105
+ @response_expected[FUNCTION_GET_ALL_VALUES_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
106
+ @response_expected[FUNCTION_GET_CO2_CONCENTRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
107
+ @response_expected[FUNCTION_SET_CO2_CONCENTRATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
108
+ @response_expected[FUNCTION_GET_CO2_CONCENTRATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
109
+ @response_expected[FUNCTION_GET_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
110
+ @response_expected[FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
111
+ @response_expected[FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
112
+ @response_expected[FUNCTION_GET_HUMIDITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
+ @response_expected[FUNCTION_SET_HUMIDITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
114
+ @response_expected[FUNCTION_GET_HUMIDITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
116
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
117
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
118
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
119
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
120
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
121
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
122
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
124
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
125
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
126
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
127
+
128
+ @callback_formats[CALLBACK_ALL_VALUES] = 'S s S'
129
+ @callback_formats[CALLBACK_CO2_CONCENTRATION] = 'S'
130
+ @callback_formats[CALLBACK_TEMPERATURE] = 's'
131
+ @callback_formats[CALLBACK_HUMIDITY] = 'S'
132
+
133
+ end
134
+
135
+ # Returns all values measured by the CO2 Bricklet 2.0. The values are
136
+ # CO2 concentration (in ppm), temperature (in 0.01 °C)
137
+ # and humidity (in 0.01 %RH).
138
+ #
139
+ # If you want to get the values periodically, it is recommended to use the
140
+ # CALLBACK_ALL_VALUES callback. You can set the callback configuration
141
+ # with BrickletCO2V2#set_all_values_callback_configuration.
142
+ def get_all_values
143
+ send_request FUNCTION_GET_ALL_VALUES, [], '', 6, 'S s S'
144
+ end
145
+
146
+ # The CO2 concentration (among other things) depends on the ambient air pressure.
147
+ #
148
+ # To increase the accuracy of the CO2 Bricklet 2.0 you can set the current air pressure.
149
+ # You use the :ref:`Barometer Bricklet 2.0 <barometer_v2_bricklet>` or the
150
+ # :ref:`Air Quality Bricklet <air_quality_bricklet>` to get the current air pressure.
151
+ #
152
+ # The expected unit of the ambient air pressure value is mbar.
153
+ #
154
+ # By default air pressure compensation is disabled. Once you set a value it
155
+ # will be used for compensation. You can turn the compensation off again by
156
+ # setting the value to 0.
157
+ #
158
+ # It is sufficient to update the value every few minutes.
159
+ def set_air_pressure(air_pressure)
160
+ send_request FUNCTION_SET_AIR_PRESSURE, [air_pressure], 'S', 0, ''
161
+ end
162
+
163
+ # Returns the ambient air pressure as set by BrickletCO2V2#set_air_pressure.
164
+ def get_air_pressure
165
+ send_request FUNCTION_GET_AIR_PRESSURE, [], '', 2, 'S'
166
+ end
167
+
168
+ # Sets a temperature offset with resolution 1/100°C. A offset of 10 will decrease
169
+ # the measured temperature by 0.1°C.
170
+ #
171
+ # If you install this Bricklet into an enclosure and you want to measure the ambient
172
+ # temperature, you may have to decrease the measured temperature by some value to
173
+ # compensate for the error because of the heating inside of the enclosure.
174
+ #
175
+ # We recommend that you leave the parts in the enclosure running for at least
176
+ # 24 hours such that a temperature equilibrium can be reached. After that you can measure
177
+ # the temperature directly outside of enclosure and set the difference as offset.
178
+ #
179
+ # This temperature offset is used to calculate the relative humidity and
180
+ # CO2 concentration. In case the Bricklet is installed in an enclosure, we
181
+ # recommend to measure and set the temperature offset to improve the accuracy of
182
+ # the measurements.
183
+ #
184
+ # It is sufficient to set the temperature offset once. The offset is saved in
185
+ # non-volatile memory and is applied again after a power loss.
186
+ def set_temperature_offset(offset)
187
+ send_request FUNCTION_SET_TEMPERATURE_OFFSET, [offset], 'S', 0, ''
188
+ end
189
+
190
+ # Returns the temperature offset as set by
191
+ # BrickletCO2V2#set_temperature_offset.
192
+ def get_temperature_offset
193
+ send_request FUNCTION_GET_TEMPERATURE_OFFSET, [], '', 2, 'S'
194
+ end
195
+
196
+ # The period in ms is the period with which the CALLBACK_ALL_VALUES
197
+ # callback is triggered periodically. A value of 0 turns the callback off.
198
+ #
199
+ # If the `value has to change`-parameter is set to true, the callback is only
200
+ # triggered after at least one of the values has changed. If the values didn't
201
+ # change within the period, the callback is triggered immediately on change.
202
+ #
203
+ # If it is set to false, the callback is continuously triggered with the period,
204
+ # independent of the value.
205
+ #
206
+ # The default value is (0, false).
207
+ def set_all_values_callback_configuration(period, value_has_to_change)
208
+ send_request FUNCTION_SET_ALL_VALUES_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
209
+ end
210
+
211
+ # Returns the callback configuration as set by
212
+ # BrickletCO2V2#set_all_values_callback_configuration.
213
+ def get_all_values_callback_configuration
214
+ send_request FUNCTION_GET_ALL_VALUES_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
215
+ end
216
+
217
+ # Returns CO2 concentration in ppm.
218
+ #
219
+ #
220
+ # If you want to get the value periodically, it is recommended to use the
221
+ # CALLBACK_CO2_CONCENTRATION callback. You can set the callback configuration
222
+ # with BrickletCO2V2#set_co2_concentration_callback_configuration.
223
+ def get_co2_concentration
224
+ send_request FUNCTION_GET_CO2_CONCENTRATION, [], '', 2, 'S'
225
+ end
226
+
227
+ # The period in ms is the period with which the CALLBACK_CO2_CONCENTRATION callback is triggered
228
+ # periodically. A value of 0 turns the callback off.
229
+ #
230
+ # If the `value has to change`-parameter is set to true, the callback is only
231
+ # triggered after the value has changed. If the value didn't change
232
+ # within the period, the callback is triggered immediately on change.
233
+ #
234
+ # If it is set to false, the callback is continuously triggered with the period,
235
+ # independent of the value.
236
+ #
237
+ # It is furthermore possible to constrain the callback with thresholds.
238
+ #
239
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_CO2_CONCENTRATION callback.
240
+ #
241
+ # The following options are possible:
242
+ #
243
+ # "Option", "Description"
244
+ #
245
+ # "'x'", "Threshold is turned off"
246
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
247
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
248
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
249
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
250
+ #
251
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
252
+ #
253
+ # The default value is (0, false, 'x', 0, 0).
254
+ def set_co2_concentration_callback_configuration(period, value_has_to_change, option, min, max)
255
+ send_request FUNCTION_SET_CO2_CONCENTRATION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
256
+ end
257
+
258
+ # Returns the callback configuration as set by BrickletCO2V2#set_co2_concentration_callback_configuration.
259
+ def get_co2_concentration_callback_configuration
260
+ send_request FUNCTION_GET_CO2_CONCENTRATION_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
261
+ end
262
+
263
+ # Returns temperature in steps of 0.01 °C.
264
+ #
265
+ #
266
+ # If you want to get the value periodically, it is recommended to use the
267
+ # CALLBACK_TEMPERATURE callback. You can set the callback configuration
268
+ # with BrickletCO2V2#set_temperature_callback_configuration.
269
+ def get_temperature
270
+ send_request FUNCTION_GET_TEMPERATURE, [], '', 2, 's'
271
+ end
272
+
273
+ # The period in ms is the period with which the CALLBACK_TEMPERATURE callback is triggered
274
+ # periodically. A value of 0 turns the callback off.
275
+ #
276
+ # If the `value has to change`-parameter is set to true, the callback is only
277
+ # triggered after the value has changed. If the value didn't change
278
+ # within the period, the callback is triggered immediately on change.
279
+ #
280
+ # If it is set to false, the callback is continuously triggered with the period,
281
+ # independent of the value.
282
+ #
283
+ # It is furthermore possible to constrain the callback with thresholds.
284
+ #
285
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_TEMPERATURE callback.
286
+ #
287
+ # The following options are possible:
288
+ #
289
+ # "Option", "Description"
290
+ #
291
+ # "'x'", "Threshold is turned off"
292
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
293
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
294
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
295
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
296
+ #
297
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
298
+ #
299
+ # The default value is (0, false, 'x', 0, 0).
300
+ def set_temperature_callback_configuration(period, value_has_to_change, option, min, max)
301
+ send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
302
+ end
303
+
304
+ # Returns the callback configuration as set by BrickletCO2V2#set_temperature_callback_configuration.
305
+ def get_temperature_callback_configuration
306
+ send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
307
+ end
308
+
309
+ # Returns relative humidity in steps of 0.01 %RH.
310
+ #
311
+ #
312
+ # If you want to get the value periodically, it is recommended to use the
313
+ # CALLBACK_HUMIDITY callback. You can set the callback configuration
314
+ # with BrickletCO2V2#set_humidity_callback_configuration.
315
+ def get_humidity
316
+ send_request FUNCTION_GET_HUMIDITY, [], '', 2, 'S'
317
+ end
318
+
319
+ # The period in ms is the period with which the CALLBACK_HUMIDITY callback is triggered
320
+ # periodically. A value of 0 turns the callback off.
321
+ #
322
+ # If the `value has to change`-parameter is set to true, the callback is only
323
+ # triggered after the value has changed. If the value didn't change
324
+ # within the period, the callback is triggered immediately on change.
325
+ #
326
+ # If it is set to false, the callback is continuously triggered with the period,
327
+ # independent of the value.
328
+ #
329
+ # It is furthermore possible to constrain the callback with thresholds.
330
+ #
331
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_HUMIDITY callback.
332
+ #
333
+ # The following options are possible:
334
+ #
335
+ # "Option", "Description"
336
+ #
337
+ # "'x'", "Threshold is turned off"
338
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
339
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
340
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
341
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
342
+ #
343
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
344
+ #
345
+ # The default value is (0, false, 'x', 0, 0).
346
+ def set_humidity_callback_configuration(period, value_has_to_change, option, min, max)
347
+ send_request FUNCTION_SET_HUMIDITY_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
348
+ end
349
+
350
+ # Returns the callback configuration as set by BrickletCO2V2#set_humidity_callback_configuration.
351
+ def get_humidity_callback_configuration
352
+ send_request FUNCTION_GET_HUMIDITY_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
353
+ end
354
+
355
+ # Returns the error count for the communication between Brick and Bricklet.
356
+ #
357
+ # The errors are divided into
358
+ #
359
+ # * ACK checksum errors,
360
+ # * message checksum errors,
361
+ # * framing errors and
362
+ # * overflow errors.
363
+ #
364
+ # The errors counts are for errors that occur on the Bricklet side. All
365
+ # Bricks have a similar function that returns the errors on the Brick side.
366
+ def get_spitfp_error_count
367
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
368
+ end
369
+
370
+ # Sets the bootloader mode and returns the status after the requested
371
+ # mode change was instigated.
372
+ #
373
+ # You can change from bootloader mode to firmware mode and vice versa. A change
374
+ # from bootloader mode to firmware mode will only take place if the entry function,
375
+ # device identifier and CRC are present and correct.
376
+ #
377
+ # This function is used by Brick Viewer during flashing. It should not be
378
+ # necessary to call it in a normal user program.
379
+ def set_bootloader_mode(mode)
380
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
381
+ end
382
+
383
+ # Returns the current bootloader mode, see BrickletCO2V2#set_bootloader_mode.
384
+ def get_bootloader_mode
385
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
386
+ end
387
+
388
+ # Sets the firmware pointer for BrickletCO2V2#write_firmware. The pointer has
389
+ # to be increased by chunks of size 64. The data is written to flash
390
+ # every 4 chunks (which equals to one page of size 256).
391
+ #
392
+ # This function is used by Brick Viewer during flashing. It should not be
393
+ # necessary to call it in a normal user program.
394
+ def set_write_firmware_pointer(pointer)
395
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
396
+ end
397
+
398
+ # Writes 64 Bytes of firmware at the position as written by
399
+ # BrickletCO2V2#set_write_firmware_pointer before. The firmware is written
400
+ # to flash every 4 chunks.
401
+ #
402
+ # You can only write firmware in bootloader mode.
403
+ #
404
+ # This function is used by Brick Viewer during flashing. It should not be
405
+ # necessary to call it in a normal user program.
406
+ def write_firmware(data)
407
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
408
+ end
409
+
410
+ # Sets the status LED configuration. By default the LED shows
411
+ # communication traffic between Brick and Bricklet, it flickers once
412
+ # for every 10 received data packets.
413
+ #
414
+ # You can also turn the LED permanently on/off or show a heartbeat.
415
+ #
416
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
417
+ def set_status_led_config(config)
418
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
419
+ end
420
+
421
+ # Returns the configuration as set by BrickletCO2V2#set_status_led_config
422
+ def get_status_led_config
423
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
424
+ end
425
+
426
+ # Returns the temperature in °C as measured inside the microcontroller. The
427
+ # value returned is not the ambient temperature!
428
+ #
429
+ # The temperature is only proportional to the real temperature and it has bad
430
+ # accuracy. Practically it is only useful as an indicator for
431
+ # temperature changes.
432
+ def get_chip_temperature
433
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
434
+ end
435
+
436
+ # Calling this function will reset the Bricklet. All configurations
437
+ # will be lost.
438
+ #
439
+ # After a reset you have to create new device objects,
440
+ # calling functions on the existing ones will result in
441
+ # undefined behavior!
442
+ def reset
443
+ send_request FUNCTION_RESET, [], '', 0, ''
444
+ end
445
+
446
+ # Writes a new UID into flash. If you want to set a new UID
447
+ # you have to decode the Base58 encoded UID string into an
448
+ # integer first.
449
+ #
450
+ # We recommend that you use Brick Viewer to change the UID.
451
+ def write_uid(uid)
452
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
453
+ end
454
+
455
+ # Returns the current UID as an integer. Encode as
456
+ # Base58 to get the usual string version.
457
+ def read_uid
458
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
459
+ end
460
+
461
+ # Returns the UID, the UID where the Bricklet is connected to,
462
+ # the position, the hardware and firmware version as well as the
463
+ # device identifier.
464
+ #
465
+ # The position can be 'a', 'b', 'c' or 'd'.
466
+ #
467
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
468
+ # |device_identifier_constant|
469
+ def get_identity
470
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
471
+ end
472
+
473
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
474
+ def register_callback(id, &block)
475
+ callback = block
476
+ @registered_callbacks[id] = callback
477
+ end
478
+ end
479
+ end