tinkerforge 2.1.16 → 2.1.17

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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +3 -3
  3. data/lib/tinkerforge/brick_imu.rb +3 -3
  4. data/lib/tinkerforge/brick_imu_v2.rb +3 -3
  5. data/lib/tinkerforge/brick_master.rb +3 -3
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +3 -3
  8. data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
  9. data/lib/tinkerforge/brick_stepper.rb +3 -3
  10. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  11. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  12. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
  13. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  14. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  15. data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -6
  16. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  17. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  18. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  19. data/lib/tinkerforge/bricklet_can.rb +3 -3
  20. data/lib/tinkerforge/bricklet_can_v2.rb +770 -0
  21. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  22. data/lib/tinkerforge/bricklet_color.rb +2 -2
  23. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  24. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  25. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  26. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  27. data/lib/tinkerforge/bricklet_dmx.rb +3 -3
  28. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  29. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  30. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  31. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  32. data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
  33. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  34. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  35. data/lib/tinkerforge/bricklet_humidity_v2.rb +11 -13
  36. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  37. data/lib/tinkerforge/bricklet_industrial_counter.rb +445 -0
  38. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  39. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +342 -0
  40. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  41. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  42. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  43. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +263 -0
  44. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  45. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +281 -0
  46. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  47. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  48. data/lib/tinkerforge/bricklet_io4_v2.rb +437 -0
  49. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  50. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  51. data/lib/tinkerforge/bricklet_lcd_16x2.rb +3 -3
  52. data/lib/tinkerforge/bricklet_lcd_20x4.rb +3 -3
  53. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  54. data/lib/tinkerforge/bricklet_led_strip_v2.rb +493 -0
  55. data/lib/tinkerforge/bricklet_line.rb +2 -2
  56. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  57. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  58. data/lib/tinkerforge/bricklet_load_cell_v2.rb +354 -0
  59. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  60. data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
  61. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
  62. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -6
  63. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  64. data/lib/tinkerforge/bricklet_nfc.rb +39 -3
  65. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  66. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  67. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  68. data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
  69. data/lib/tinkerforge/bricklet_particulate_matter.rb +320 -0
  70. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  71. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  72. data/lib/tinkerforge/bricklet_ptc.rb +33 -3
  73. data/lib/tinkerforge/bricklet_ptc_v2.rb +433 -0
  74. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  75. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +353 -0
  76. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  77. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
  78. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  79. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  80. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  81. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  82. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +8 -9
  83. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  84. data/lib/tinkerforge/bricklet_rs232.rb +3 -3
  85. data/lib/tinkerforge/bricklet_rs232_v2.rb +421 -0
  86. data/lib/tinkerforge/bricklet_rs485.rb +6 -6
  87. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  88. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  89. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
  90. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  91. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +420 -0
  92. data/lib/tinkerforge/bricklet_temperature.rb +3 -3
  93. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  94. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +13 -15
  95. data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
  96. data/lib/tinkerforge/bricklet_thermocouple.rb +4 -4
  97. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +340 -0
  98. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  99. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  100. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  101. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  102. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +453 -0
  103. data/lib/tinkerforge/ip_connection.rb +4 -4
  104. data/lib/tinkerforge/version.rb +1 -1
  105. metadata +17 -2
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
5
+ # Ruby Bindings Version 2.1.17 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -47,6 +47,14 @@ module Tinkerforge
47
47
  # with the period as set by BrickletPTC#set_debounce_period.
48
48
  CALLBACK_RESISTANCE_REACHED = 16
49
49
 
50
+ # This callback is triggered periodically according to the configuration set by
51
+ # BrickletPTC#set_sensor_connected_callback_configuration.
52
+ #
53
+ # The parameter is the same as BrickletPTC#is_sensor_connected.
54
+ #
55
+ # .. versionadded:: 2.0.2$nbsp;(Plugin)
56
+ CALLBACK_SENSOR_CONNECTED = 24
57
+
50
58
  FUNCTION_GET_TEMPERATURE = 1 # :nodoc:
51
59
  FUNCTION_GET_RESISTANCE = 2 # :nodoc:
52
60
  FUNCTION_SET_TEMPERATURE_CALLBACK_PERIOD = 3 # :nodoc:
@@ -64,6 +72,8 @@ module Tinkerforge
64
72
  FUNCTION_IS_SENSOR_CONNECTED = 19 # :nodoc:
65
73
  FUNCTION_SET_WIRE_MODE = 20 # :nodoc:
66
74
  FUNCTION_GET_WIRE_MODE = 21 # :nodoc:
75
+ FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION = 22 # :nodoc:
76
+ FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION = 23 # :nodoc:
67
77
  FUNCTION_GET_IDENTITY = 255 # :nodoc:
68
78
 
69
79
  THRESHOLD_OPTION_OFF = 'x' # :nodoc:
@@ -82,7 +92,7 @@ module Tinkerforge
82
92
  def initialize(uid, ipcon)
83
93
  super uid, ipcon
84
94
 
85
- @api_version = [2, 0, 0]
95
+ @api_version = [2, 0, 1]
86
96
 
87
97
  @response_expected[FUNCTION_GET_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
98
  @response_expected[FUNCTION_GET_RESISTANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -101,12 +111,15 @@ module Tinkerforge
101
111
  @response_expected[FUNCTION_IS_SENSOR_CONNECTED] = RESPONSE_EXPECTED_ALWAYS_TRUE
102
112
  @response_expected[FUNCTION_SET_WIRE_MODE] = RESPONSE_EXPECTED_FALSE
103
113
  @response_expected[FUNCTION_GET_WIRE_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
+ @response_expected[FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
115
+ @response_expected[FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
104
116
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
117
 
106
118
  @callback_formats[CALLBACK_TEMPERATURE] = 'l'
107
119
  @callback_formats[CALLBACK_TEMPERATURE_REACHED] = 'l'
108
120
  @callback_formats[CALLBACK_RESISTANCE] = 'l'
109
121
  @callback_formats[CALLBACK_RESISTANCE_REACHED] = 'l'
122
+ @callback_formats[CALLBACK_SENSOR_CONNECTED] = '?'
110
123
 
111
124
  end
112
125
 
@@ -272,6 +285,23 @@ module Tinkerforge
272
285
  send_request FUNCTION_GET_WIRE_MODE, [], '', 1, 'C'
273
286
  end
274
287
 
288
+ # If you enable this callback, the CALLBACK_SENSOR_CONNECTED callback is triggered
289
+ # every time a Pt sensor is connected/disconnected.
290
+ #
291
+ # By default this callback is disabled.
292
+ #
293
+ # .. versionadded:: 2.0.2$nbsp;(Plugin)
294
+ def set_sensor_connected_callback_configuration(enabled)
295
+ send_request FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION, [enabled], '?', 0, ''
296
+ end
297
+
298
+ # Returns the configuration as set by BrickletPTC#set_sensor_connected_callback_configuration.
299
+ #
300
+ # .. versionadded:: 2.0.2$nbsp;(Plugin)
301
+ def get_sensor_connected_callback_configuration
302
+ send_request FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION, [], '', 1, '?'
303
+ end
304
+
275
305
  # Returns the UID, the UID where the Bricklet is connected to,
276
306
  # the position, the hardware and firmware version as well as the
277
307
  # device identifier.
@@ -0,0 +1,433 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2018-06-08. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.17 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Reads temperatures from Pt100 und Pt1000 sensors
14
+ class BrickletPTCV2 < Device
15
+ DEVICE_IDENTIFIER = 2101 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'PTC Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered periodically according to the configuration set by
19
+ # BrickletPTCV2#set_temperature_callback_configuration.
20
+ #
21
+ # The parameter is the same as BrickletPTCV2#get_temperature.
22
+ CALLBACK_TEMPERATURE = 4
23
+
24
+ # This callback is triggered periodically according to the configuration set by
25
+ # BrickletPTCV2#set_resistance_callback_configuration.
26
+ #
27
+ # The parameter is the same as BrickletPTCV2#get_resistance.
28
+ CALLBACK_RESISTANCE = 8
29
+
30
+ # This callback is triggered periodically according to the configuration set by
31
+ # BrickletPTCV2#set_sensor_connected_callback_configuration.
32
+ #
33
+ # The parameter is the same as BrickletPTCV2#is_sensor_connected.
34
+ CALLBACK_SENSOR_CONNECTED = 18
35
+
36
+ FUNCTION_GET_TEMPERATURE = 1 # :nodoc:
37
+ FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION = 2 # :nodoc:
38
+ FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION = 3 # :nodoc:
39
+ FUNCTION_GET_RESISTANCE = 5 # :nodoc:
40
+ FUNCTION_SET_RESISTANCE_CALLBACK_CONFIGURATION = 6 # :nodoc:
41
+ FUNCTION_GET_RESISTANCE_CALLBACK_CONFIGURATION = 7 # :nodoc:
42
+ FUNCTION_SET_NOISE_REJECTION_FILTER = 9 # :nodoc:
43
+ FUNCTION_GET_NOISE_REJECTION_FILTER = 10 # :nodoc:
44
+ FUNCTION_IS_SENSOR_CONNECTED = 11 # :nodoc:
45
+ FUNCTION_SET_WIRE_MODE = 12 # :nodoc:
46
+ FUNCTION_GET_WIRE_MODE = 13 # :nodoc:
47
+ FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION = 14 # :nodoc:
48
+ FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION = 15 # :nodoc:
49
+ FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION = 16 # :nodoc:
50
+ FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION = 17 # :nodoc:
51
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
52
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
53
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
54
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
55
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
56
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
57
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
58
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
59
+ FUNCTION_RESET = 243 # :nodoc:
60
+ FUNCTION_WRITE_UID = 248 # :nodoc:
61
+ FUNCTION_READ_UID = 249 # :nodoc:
62
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
63
+
64
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
65
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
66
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
67
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
68
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
69
+ FILTER_OPTION_50HZ = 0 # :nodoc:
70
+ FILTER_OPTION_60HZ = 1 # :nodoc:
71
+ WIRE_MODE_2 = 2 # :nodoc:
72
+ WIRE_MODE_3 = 3 # :nodoc:
73
+ WIRE_MODE_4 = 4 # :nodoc:
74
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
75
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
76
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
77
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
78
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
79
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
80
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
81
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
82
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
83
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
84
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
85
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
86
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
87
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
88
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
89
+
90
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
91
+ # the IP Connection <tt>ipcon</tt>.
92
+ def initialize(uid, ipcon)
93
+ super uid, ipcon
94
+
95
+ @api_version = [2, 0, 0]
96
+
97
+ @response_expected[FUNCTION_GET_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
98
+ @response_expected[FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
99
+ @response_expected[FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
100
+ @response_expected[FUNCTION_GET_RESISTANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
101
+ @response_expected[FUNCTION_SET_RESISTANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
102
+ @response_expected[FUNCTION_GET_RESISTANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
103
+ @response_expected[FUNCTION_SET_NOISE_REJECTION_FILTER] = RESPONSE_EXPECTED_FALSE
104
+ @response_expected[FUNCTION_GET_NOISE_REJECTION_FILTER] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
+ @response_expected[FUNCTION_IS_SENSOR_CONNECTED] = RESPONSE_EXPECTED_ALWAYS_TRUE
106
+ @response_expected[FUNCTION_SET_WIRE_MODE] = RESPONSE_EXPECTED_FALSE
107
+ @response_expected[FUNCTION_GET_WIRE_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
108
+ @response_expected[FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
109
+ @response_expected[FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
110
+ @response_expected[FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
111
+ @response_expected[FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
112
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
116
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
117
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
118
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
119
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
120
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
121
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
122
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+
125
+ @callback_formats[CALLBACK_TEMPERATURE] = 'l'
126
+ @callback_formats[CALLBACK_RESISTANCE] = 'l'
127
+ @callback_formats[CALLBACK_SENSOR_CONNECTED] = '?'
128
+
129
+ end
130
+
131
+ # Returns the temperature of the connected sensor. The value
132
+ # has a range of -246 to 849 °C and is given in °C/100,
133
+ # e.g. a value of 4223 means that a temperature of 42.23 °C is measured.
134
+ #
135
+ #
136
+ # If you want to get the value periodically, it is recommended to use the
137
+ # CALLBACK_TEMPERATURE callback. You can set the callback configuration
138
+ # with BrickletPTCV2#set_temperature_callback_configuration.
139
+ def get_temperature
140
+ send_request FUNCTION_GET_TEMPERATURE, [], '', 4, 'l'
141
+ end
142
+
143
+ # The period in ms is the period with which the CALLBACK_TEMPERATURE callback is triggered
144
+ # periodically. A value of 0 turns the callback off.
145
+ #
146
+ # If the `value has to change`-parameter is set to true, the callback is only
147
+ # triggered after the value has changed. If the value didn't change
148
+ # within the period, the callback is triggered immediately on change.
149
+ #
150
+ # If it is set to false, the callback is continuously triggered with the period,
151
+ # independent of the value.
152
+ #
153
+ # It is furthermore possible to constrain the callback with thresholds.
154
+ #
155
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_TEMPERATURE callback.
156
+ #
157
+ # The following options are possible:
158
+ #
159
+ # "Option", "Description"
160
+ #
161
+ # "'x'", "Threshold is turned off"
162
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
163
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
164
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
165
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
166
+ #
167
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
168
+ #
169
+ # The default value is (0, false, 'x', 0, 0).
170
+ def set_temperature_callback_configuration(period, value_has_to_change, option, min, max)
171
+ send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
172
+ end
173
+
174
+ # Returns the callback configuration as set by BrickletPTCV2#set_temperature_callback_configuration.
175
+ def get_temperature_callback_configuration
176
+ send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
177
+ end
178
+
179
+ # Returns the value as measured by the MAX31865 precision delta-sigma ADC.
180
+ #
181
+ # The value can be converted with the following formulas:
182
+ #
183
+ # * Pt100: resistance = (value * 390) / 32768
184
+ # * Pt1000: resistance = (value * 3900) / 32768
185
+ #
186
+ #
187
+ # If you want to get the value periodically, it is recommended to use the
188
+ # CALLBACK_RESISTANCE callback. You can set the callback configuration
189
+ # with BrickletPTCV2#set_resistance_callback_configuration.
190
+ def get_resistance
191
+ send_request FUNCTION_GET_RESISTANCE, [], '', 4, 'l'
192
+ end
193
+
194
+ # The period in ms is the period with which the CALLBACK_RESISTANCE callback is triggered
195
+ # periodically. A value of 0 turns the callback off.
196
+ #
197
+ # If the `value has to change`-parameter is set to true, the callback is only
198
+ # triggered after the value has changed. If the value didn't change
199
+ # within the period, the callback is triggered immediately on change.
200
+ #
201
+ # If it is set to false, the callback is continuously triggered with the period,
202
+ # independent of the value.
203
+ #
204
+ # It is furthermore possible to constrain the callback with thresholds.
205
+ #
206
+ # The `option`-parameter together with min/max sets a threshold for the CALLBACK_RESISTANCE callback.
207
+ #
208
+ # The following options are possible:
209
+ #
210
+ # "Option", "Description"
211
+ #
212
+ # "'x'", "Threshold is turned off"
213
+ # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
214
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
215
+ # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
216
+ # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
217
+ #
218
+ # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
219
+ #
220
+ # The default value is (0, false, 'x', 0, 0).
221
+ def set_resistance_callback_configuration(period, value_has_to_change, option, min, max)
222
+ send_request FUNCTION_SET_RESISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 0, ''
223
+ end
224
+
225
+ # Returns the callback configuration as set by BrickletPTCV2#set_resistance_callback_configuration.
226
+ def get_resistance_callback_configuration
227
+ send_request FUNCTION_GET_RESISTANCE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k l l'
228
+ end
229
+
230
+ # Sets the noise rejection filter to either 50Hz (0) or 60Hz (1).
231
+ # Noise from 50Hz or 60Hz power sources (including
232
+ # harmonics of the AC power's fundamental frequency) is
233
+ # attenuated by 82dB.
234
+ #
235
+ # Default value is 0 = 50Hz.
236
+ def set_noise_rejection_filter(filter)
237
+ send_request FUNCTION_SET_NOISE_REJECTION_FILTER, [filter], 'C', 0, ''
238
+ end
239
+
240
+ # Returns the noise rejection filter option as set by
241
+ # BrickletPTCV2#set_noise_rejection_filter
242
+ def get_noise_rejection_filter
243
+ send_request FUNCTION_GET_NOISE_REJECTION_FILTER, [], '', 1, 'C'
244
+ end
245
+
246
+ # Returns *true* if the sensor is connected correctly.
247
+ #
248
+ # If this function
249
+ # returns *false*, there is either no Pt100 or Pt1000 sensor connected,
250
+ # the sensor is connected incorrectly or the sensor itself is faulty.
251
+ #
252
+ # If you want to get the status automatically, it is recommended to use the
253
+ # CALLBACK_SENSOR_CONNECTED callback. You can set the callback configuration
254
+ # with BrickletPTCV2#set_sensor_connected_callback_configuration.
255
+ def is_sensor_connected
256
+ send_request FUNCTION_IS_SENSOR_CONNECTED, [], '', 1, '?'
257
+ end
258
+
259
+ # Sets the wire mode of the sensor. Possible values are 2, 3 and 4 which
260
+ # correspond to 2-, 3- and 4-wire sensors. The value has to match the jumper
261
+ # configuration on the Bricklet.
262
+ #
263
+ # The default value is 2 = 2-wire.
264
+ def set_wire_mode(mode)
265
+ send_request FUNCTION_SET_WIRE_MODE, [mode], 'C', 0, ''
266
+ end
267
+
268
+ # Returns the wire mode as set by BrickletPTCV2#set_wire_mode
269
+ def get_wire_mode
270
+ send_request FUNCTION_GET_WIRE_MODE, [], '', 1, 'C'
271
+ end
272
+
273
+ # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
274
+ # for the resistance and temperature.
275
+ #
276
+ # Setting the length to 1 will turn the averaging off. With less
277
+ # averaging, there is more noise on the data.
278
+ #
279
+ # The range for the averaging is 1-1000.
280
+ #
281
+ # New data is gathered every 20ms. With a moving average of length 1000 the resulting
282
+ # averaging window has a length of 20s. If you want to do long term measurements the longest
283
+ # moving average will give the cleanest results.
284
+ #
285
+ # The default value is 1 for resistance and 40 for temperature. The default values match
286
+ # the non-changeable averaging settings of the old PTC Bricklet 1.0
287
+ def set_moving_average_configuration(moving_average_length_resistance, moving_average_length_temperature)
288
+ send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length_resistance, moving_average_length_temperature], 'S S', 0, ''
289
+ end
290
+
291
+ # Returns the moving average configuration as set by BrickletPTCV2#set_moving_average_configuration.
292
+ def get_moving_average_configuration
293
+ send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 4, 'S S'
294
+ end
295
+
296
+ # If you enable this callback, the CALLBACK_SENSOR_CONNECTED callback is triggered
297
+ # every time a Pt sensor is connected/disconnected.
298
+ #
299
+ # By default this callback is disabled.
300
+ def set_sensor_connected_callback_configuration(enabled)
301
+ send_request FUNCTION_SET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION, [enabled], '?', 0, ''
302
+ end
303
+
304
+ # Returns the configuration as set by BrickletPTCV2#set_sensor_connected_callback_configuration.
305
+ def get_sensor_connected_callback_configuration
306
+ send_request FUNCTION_GET_SENSOR_CONNECTED_CALLBACK_CONFIGURATION, [], '', 1, '?'
307
+ end
308
+
309
+ # Returns the error count for the communication between Brick and Bricklet.
310
+ #
311
+ # The errors are divided into
312
+ #
313
+ # * ack checksum errors,
314
+ # * message checksum errors,
315
+ # * frameing errors and
316
+ # * overflow errors.
317
+ #
318
+ # The errors counts are for errors that occur on the Bricklet side. All
319
+ # Bricks have a similar function that returns the errors on the Brick side.
320
+ def get_spitfp_error_count
321
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
322
+ end
323
+
324
+ # Sets the bootloader mode and returns the status after the requested
325
+ # mode change was instigated.
326
+ #
327
+ # You can change from bootloader mode to firmware mode and vice versa. A change
328
+ # from bootloader mode to firmware mode will only take place if the entry function,
329
+ # device identifier und crc are present and correct.
330
+ #
331
+ # This function is used by Brick Viewer during flashing. It should not be
332
+ # necessary to call it in a normal user program.
333
+ def set_bootloader_mode(mode)
334
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
335
+ end
336
+
337
+ # Returns the current bootloader mode, see BrickletPTCV2#set_bootloader_mode.
338
+ def get_bootloader_mode
339
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
340
+ end
341
+
342
+ # Sets the firmware pointer for BrickletPTCV2#write_firmware. The pointer has
343
+ # to be increased by chunks of size 64. The data is written to flash
344
+ # every 4 chunks (which equals to one page of size 256).
345
+ #
346
+ # This function is used by Brick Viewer during flashing. It should not be
347
+ # necessary to call it in a normal user program.
348
+ def set_write_firmware_pointer(pointer)
349
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
350
+ end
351
+
352
+ # Writes 64 Bytes of firmware at the position as written by
353
+ # BrickletPTCV2#set_write_firmware_pointer before. The firmware is written
354
+ # to flash every 4 chunks.
355
+ #
356
+ # You can only write firmware in bootloader mode.
357
+ #
358
+ # This function is used by Brick Viewer during flashing. It should not be
359
+ # necessary to call it in a normal user program.
360
+ def write_firmware(data)
361
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
362
+ end
363
+
364
+ # Sets the status LED configuration. By default the LED shows
365
+ # communication traffic between Brick and Bricklet, it flickers once
366
+ # for every 10 received data packets.
367
+ #
368
+ # You can also turn the LED permanently on/off or show a heartbeat.
369
+ #
370
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
371
+ def set_status_led_config(config)
372
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
373
+ end
374
+
375
+ # Returns the configuration as set by BrickletPTCV2#set_status_led_config
376
+ def get_status_led_config
377
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
378
+ end
379
+
380
+ # Returns the temperature in °C as measured inside the microcontroller. The
381
+ # value returned is not the ambient temperature!
382
+ #
383
+ # The temperature is only proportional to the real temperature and it has bad
384
+ # accuracy. Practically it is only useful as an indicator for
385
+ # temperature changes.
386
+ def get_chip_temperature
387
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
388
+ end
389
+
390
+ # Calling this function will reset the Bricklet. All configurations
391
+ # will be lost.
392
+ #
393
+ # After a reset you have to create new device objects,
394
+ # calling functions on the existing ones will result in
395
+ # undefined behavior!
396
+ def reset
397
+ send_request FUNCTION_RESET, [], '', 0, ''
398
+ end
399
+
400
+ # Writes a new UID into flash. If you want to set a new UID
401
+ # you have to decode the Base58 encoded UID string into an
402
+ # integer first.
403
+ #
404
+ # We recommend that you use Brick Viewer to change the UID.
405
+ def write_uid(uid)
406
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
407
+ end
408
+
409
+ # Returns the current UID as an integer. Encode as
410
+ # Base58 to get the usual string version.
411
+ def read_uid
412
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
413
+ end
414
+
415
+ # Returns the UID, the UID where the Bricklet is connected to,
416
+ # the position, the hardware and firmware version as well as the
417
+ # device identifier.
418
+ #
419
+ # The position can be 'a', 'b', 'c' or 'd'.
420
+ #
421
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
422
+ # |device_identifier_constant|
423
+ def get_identity
424
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
425
+ end
426
+
427
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
428
+ def register_callback(id, &block)
429
+ callback = block
430
+ @registered_callbacks[id] = callback
431
+ end
432
+ end
433
+ end