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 #
@@ -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 #
@@ -125,6 +125,9 @@ module Tinkerforge
125
125
  # that have been seen since the startup of the Bricklet.
126
126
  #
127
127
  # Each station gives itself a random identifier on first startup.
128
+ #
129
+ # Since firmware version 2.0.2 a station is removed from the list if no data was received for
130
+ # 12 hours.
128
131
  def get_station_identifiers_low_level
129
132
  send_request FUNCTION_GET_STATION_IDENTIFIERS_LOW_LEVEL, [], '', 64, 'S S C60'
130
133
  end
@@ -134,6 +137,9 @@ module Tinkerforge
134
137
  # that have been seen since the startup of the Bricklet.
135
138
  #
136
139
  # Each sensor gives itself a random identifier on first startup.
140
+ #
141
+ # Since firmware version 2.0.2 a sensor is removed from the list if no data was received for
142
+ # 12 hours.
137
143
  def get_sensor_identifiers_low_level
138
144
  send_request FUNCTION_GET_SENSOR_IDENTIFIERS_LOW_LEVEL, [], '', 64, 'S S C60'
139
145
  end
@@ -310,6 +316,9 @@ module Tinkerforge
310
316
  # that have been seen since the startup of the Bricklet.
311
317
  #
312
318
  # Each station gives itself a random identifier on first startup.
319
+ #
320
+ # Since firmware version 2.0.2 a station is removed from the list if no data was received for
321
+ # 12 hours.
313
322
  def get_station_identifiers
314
323
  identifiers_length = nil # assigned in block
315
324
  identifiers_data = nil # assigned in block
@@ -348,6 +357,9 @@ module Tinkerforge
348
357
  # that have been seen since the startup of the Bricklet.
349
358
  #
350
359
  # Each sensor gives itself a random identifier on first startup.
360
+ #
361
+ # Since firmware version 2.0.2 a sensor is removed from the list if no data was received for
362
+ # 12 hours.
351
363
  def get_sensor_identifiers
352
364
  identifiers_length = nil # assigned in block
353
365
  identifiers_data = nil # assigned in block
@@ -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,311 @@
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
+ # Creates beep and alarm with configurable volume and frequency
14
+ class BrickletPiezoSpeakerV2 < Device
15
+ DEVICE_IDENTIFIER = 2145 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Piezo Speaker Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered if a beep set by BrickletPiezoSpeakerV2#set_beep is finished
19
+ CALLBACK_BEEP_FINISHED = 7
20
+
21
+ # This callback is triggered if a alarm set by BrickletPiezoSpeakerV2#set_alarm is finished
22
+ CALLBACK_ALARM_FINISHED = 8
23
+
24
+ FUNCTION_SET_BEEP = 1 # :nodoc:
25
+ FUNCTION_GET_BEEP = 2 # :nodoc:
26
+ FUNCTION_SET_ALARM = 3 # :nodoc:
27
+ FUNCTION_GET_ALARM = 4 # :nodoc:
28
+ FUNCTION_UPDATE_VOLUME = 5 # :nodoc:
29
+ FUNCTION_UPDATE_FREQUENCY = 6 # :nodoc:
30
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
31
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
32
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
33
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
34
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
35
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
36
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
37
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
38
+ FUNCTION_RESET = 243 # :nodoc:
39
+ FUNCTION_WRITE_UID = 248 # :nodoc:
40
+ FUNCTION_READ_UID = 249 # :nodoc:
41
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
42
+
43
+ BEEP_DURATION_OFF = 0 # :nodoc:
44
+ BEEP_DURATION_INFINITE = 4294967295 # :nodoc:
45
+ ALARM_DURATION_OFF = 0 # :nodoc:
46
+ ALARM_DURATION_INFINITE = 4294967295 # :nodoc:
47
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
48
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
49
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
50
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
51
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
52
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
53
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
54
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
55
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
56
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
57
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
58
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
59
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
60
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
61
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
62
+
63
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
64
+ # the IP Connection <tt>ipcon</tt>.
65
+ def initialize(uid, ipcon)
66
+ super uid, ipcon
67
+
68
+ @api_version = [2, 0, 0]
69
+
70
+ @response_expected[FUNCTION_SET_BEEP] = RESPONSE_EXPECTED_FALSE
71
+ @response_expected[FUNCTION_GET_BEEP] = RESPONSE_EXPECTED_ALWAYS_TRUE
72
+ @response_expected[FUNCTION_SET_ALARM] = RESPONSE_EXPECTED_FALSE
73
+ @response_expected[FUNCTION_GET_ALARM] = RESPONSE_EXPECTED_ALWAYS_TRUE
74
+ @response_expected[FUNCTION_UPDATE_VOLUME] = RESPONSE_EXPECTED_FALSE
75
+ @response_expected[FUNCTION_UPDATE_FREQUENCY] = RESPONSE_EXPECTED_FALSE
76
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
77
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
78
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
79
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
80
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
81
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
82
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
85
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
86
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
87
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
+
89
+ @callback_formats[CALLBACK_BEEP_FINISHED] = ''
90
+ @callback_formats[CALLBACK_ALARM_FINISHED] = ''
91
+
92
+ end
93
+
94
+ # Beeps with the given frequency and volume for the duration in ms.
95
+ #
96
+ # For example: If you set a duration of 1000, with a volume of 10 and a frequency
97
+ # value of 2000 the piezo buzzer will beep with maximum loudness for one
98
+ # second with a frequency of 2 kHz.
99
+ #
100
+ # A duration of 0 stops the current beep if any is ongoing.
101
+ # A duration of 4294967295 results in an infinite beep.
102
+ #
103
+ # The ranges are:
104
+ #
105
+ # * Frequency: 50Hz - 15000Hz
106
+ # * Volume: 0 - 10
107
+ # * Duration: 0ms - 4294967295ms
108
+ def set_beep(frequency, volume, duration)
109
+ send_request FUNCTION_SET_BEEP, [frequency, volume, duration], 'S C L', 0, ''
110
+ end
111
+
112
+ # Returns the last beep settings as set by BrickletPiezoSpeakerV2#set_beep. If a beep is currently
113
+ # running it also returns the remaining duration of the beep in ms.
114
+ #
115
+ # If the frequency or volume is updated during a beep (with BrickletPiezoSpeakerV2#update_frequency
116
+ # or BrickletPiezoSpeakerV2#update_volume) this function returns the updated value.
117
+ def get_beep
118
+ send_request FUNCTION_GET_BEEP, [], '', 11, 'S C L L'
119
+ end
120
+
121
+ # Creates an alarm (a tone that goes back and force between two specified frequencies).
122
+ #
123
+ # The following parameters can be set:
124
+ #
125
+ # * Start Frequency: Start frequency of the alarm in Hz.
126
+ # * End Frequency: End frequency of the alarm in Hz.
127
+ # * Step Size: Size of one step of the sweep between the start/end frequencies in Hz.
128
+ # * Step Delay: Delay between two steps (duration of time that one tone is used in a sweep) in ms.
129
+ # * Duration: Duration of the alarm in ms.
130
+ #
131
+ # A duration of 0 stops the current alarm if any is ongoing.
132
+ # A duration of 4294967295 results in an infinite alarm.
133
+ #
134
+ # Below you can find two sets of example settings that you can try out. You can use
135
+ # these as a starting point to find an alarm signal that suits your application.
136
+ #
137
+ # Example 1: 10 seconds of loud annoying fast alarm
138
+ #
139
+ # * Start Frequency = 800
140
+ # * End Frequency = 2000
141
+ # * Step Size = 10
142
+ # * Step Delay = 1
143
+ # * Volume = 10
144
+ # * Duration = 10000
145
+ #
146
+ # Example 2: 10 seconds of soft siren sound with slow build-up
147
+ #
148
+ # * Start Frequency = 250
149
+ # * End Frequency = 750
150
+ # * Step Size = 1
151
+ # * Step Delay = 5
152
+ # * Volume = 0
153
+ # * Duration = 10000
154
+ #
155
+ # The ranges are:
156
+ #
157
+ # * Start Frequency: 50Hz - 14999Hz (has to be smaller than end frequency)
158
+ # * End Frequency: 51Hz - 15000Hz (has to be bigger than start frequency)
159
+ # * Step Size: 1Hz - 65535Hz (has to be small enough to fit into the frequency range)
160
+ # * Step Delay: 1ms - 65535ms (has to be small enough to fit into the duration)
161
+ # * Volume: 0 - 10
162
+ # * Duration: 0ms - 4294967295ms
163
+ def set_alarm(start_frequency, end_frequency, step_size, step_delay, volume, duration)
164
+ send_request FUNCTION_SET_ALARM, [start_frequency, end_frequency, step_size, step_delay, volume, duration], 'S S S S C L', 0, ''
165
+ end
166
+
167
+ # Returns the last alarm settings as set by BrickletPiezoSpeakerV2#set_alarm. If an alarm is currently
168
+ # running it also returns the remaining duration of the alarm in ms as well as the
169
+ # current frequency of the alarm in Hz.
170
+ #
171
+ # If the volume is updated during a beep (with BrickletPiezoSpeakerV2#update_volume)
172
+ # this function returns the updated value.
173
+ def get_alarm
174
+ send_request FUNCTION_GET_ALARM, [], '', 19, 'S S S S C L L S'
175
+ end
176
+
177
+ # Updates the volume of an ongoing beep or alarm. The range of the volume is 0 to 10.
178
+ def update_volume(volume)
179
+ send_request FUNCTION_UPDATE_VOLUME, [volume], 'C', 0, ''
180
+ end
181
+
182
+ # Updates the frequency of an ongoing beep. The range of the frequency is 50Hz to 15000Hz.
183
+ def update_frequency(frequency)
184
+ send_request FUNCTION_UPDATE_FREQUENCY, [frequency], 'S', 0, ''
185
+ end
186
+
187
+ # Returns the error count for the communication between Brick and Bricklet.
188
+ #
189
+ # The errors are divided into
190
+ #
191
+ # * ACK checksum errors,
192
+ # * message checksum errors,
193
+ # * framing errors and
194
+ # * overflow errors.
195
+ #
196
+ # The errors counts are for errors that occur on the Bricklet side. All
197
+ # Bricks have a similar function that returns the errors on the Brick side.
198
+ def get_spitfp_error_count
199
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
200
+ end
201
+
202
+ # Sets the bootloader mode and returns the status after the requested
203
+ # mode change was instigated.
204
+ #
205
+ # You can change from bootloader mode to firmware mode and vice versa. A change
206
+ # from bootloader mode to firmware mode will only take place if the entry function,
207
+ # device identifier and CRC are present and correct.
208
+ #
209
+ # This function is used by Brick Viewer during flashing. It should not be
210
+ # necessary to call it in a normal user program.
211
+ def set_bootloader_mode(mode)
212
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
213
+ end
214
+
215
+ # Returns the current bootloader mode, see BrickletPiezoSpeakerV2#set_bootloader_mode.
216
+ def get_bootloader_mode
217
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
218
+ end
219
+
220
+ # Sets the firmware pointer for BrickletPiezoSpeakerV2#write_firmware. The pointer has
221
+ # to be increased by chunks of size 64. The data is written to flash
222
+ # every 4 chunks (which equals to one page of size 256).
223
+ #
224
+ # This function is used by Brick Viewer during flashing. It should not be
225
+ # necessary to call it in a normal user program.
226
+ def set_write_firmware_pointer(pointer)
227
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
228
+ end
229
+
230
+ # Writes 64 Bytes of firmware at the position as written by
231
+ # BrickletPiezoSpeakerV2#set_write_firmware_pointer before. The firmware is written
232
+ # to flash every 4 chunks.
233
+ #
234
+ # You can only write firmware in bootloader mode.
235
+ #
236
+ # This function is used by Brick Viewer during flashing. It should not be
237
+ # necessary to call it in a normal user program.
238
+ def write_firmware(data)
239
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
240
+ end
241
+
242
+ # Sets the status LED configuration. By default the LED shows
243
+ # communication traffic between Brick and Bricklet, it flickers once
244
+ # for every 10 received data packets.
245
+ #
246
+ # You can also turn the LED permanently on/off or show a heartbeat.
247
+ #
248
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
249
+ def set_status_led_config(config)
250
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
251
+ end
252
+
253
+ # Returns the configuration as set by BrickletPiezoSpeakerV2#set_status_led_config
254
+ def get_status_led_config
255
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
256
+ end
257
+
258
+ # Returns the temperature in °C as measured inside the microcontroller. The
259
+ # value returned is not the ambient temperature!
260
+ #
261
+ # The temperature is only proportional to the real temperature and it has bad
262
+ # accuracy. Practically it is only useful as an indicator for
263
+ # temperature changes.
264
+ def get_chip_temperature
265
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
266
+ end
267
+
268
+ # Calling this function will reset the Bricklet. All configurations
269
+ # will be lost.
270
+ #
271
+ # After a reset you have to create new device objects,
272
+ # calling functions on the existing ones will result in
273
+ # undefined behavior!
274
+ def reset
275
+ send_request FUNCTION_RESET, [], '', 0, ''
276
+ end
277
+
278
+ # Writes a new UID into flash. If you want to set a new UID
279
+ # you have to decode the Base58 encoded UID string into an
280
+ # integer first.
281
+ #
282
+ # We recommend that you use Brick Viewer to change the UID.
283
+ def write_uid(uid)
284
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
285
+ end
286
+
287
+ # Returns the current UID as an integer. Encode as
288
+ # Base58 to get the usual string version.
289
+ def read_uid
290
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
291
+ end
292
+
293
+ # Returns the UID, the UID where the Bricklet is connected to,
294
+ # the position, the hardware and firmware version as well as the
295
+ # device identifier.
296
+ #
297
+ # The position can be 'a', 'b', 'c' or 'd'.
298
+ #
299
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
300
+ # |device_identifier_constant|
301
+ def get_identity
302
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
303
+ end
304
+
305
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
306
+ def register_callback(id, &block)
307
+ callback = block
308
+ @registered_callbacks[id] = callback
309
+ end
310
+ end
311
+ end