tinkerforge 2.1.22 → 2.1.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +3 -3
  3. data/lib/tinkerforge/brick_hat.rb +11 -7
  4. data/lib/tinkerforge/brick_hat_zero.rb +2 -2
  5. data/lib/tinkerforge/brick_imu.rb +3 -3
  6. data/lib/tinkerforge/brick_imu_v2.rb +3 -3
  7. data/lib/tinkerforge/brick_master.rb +5 -5
  8. data/lib/tinkerforge/brick_red.rb +2 -2
  9. data/lib/tinkerforge/brick_servo.rb +3 -3
  10. data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
  11. data/lib/tinkerforge/brick_stepper.rb +4 -4
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +81 -6
  14. data/lib/tinkerforge/bricklet_air_quality.rb +2 -2
  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 +2 -2
  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 +2 -2
  30. data/lib/tinkerforge/bricklet_color.rb +4 -4
  31. data/lib/tinkerforge/bricklet_color_v2.rb +449 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +356 -0
  33. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  34. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +2 -2
  37. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +300 -0
  39. data/lib/tinkerforge/bricklet_dmx.rb +2 -2
  40. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +2 -2
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +2 -2
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +375 -0
  46. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +2 -2
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +2 -2
  50. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +2 -2
  52. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  53. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +2 -2
  54. data/lib/tinkerforge/bricklet_industrial_counter.rb +2 -2
  55. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +2 -2
  57. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +2 -2
  59. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +2 -2
  61. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  62. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +2 -2
  63. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +2 -2
  64. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  65. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +2 -2
  66. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  67. data/lib/tinkerforge/bricklet_io16_v2.rb +2 -2
  68. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  69. data/lib/tinkerforge/bricklet_io4_v2.rb +2 -2
  70. data/lib/tinkerforge/bricklet_isolator.rb +2 -2
  71. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  72. data/lib/tinkerforge/bricklet_joystick_v2.rb +2 -2
  73. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  74. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +5 -5
  75. data/lib/tinkerforge/bricklet_lcd_128x64.rb +24 -2
  76. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  77. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  78. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  79. data/lib/tinkerforge/bricklet_led_strip_v2.rb +2 -2
  80. data/lib/tinkerforge/bricklet_line.rb +2 -2
  81. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  82. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +2 -2
  83. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  84. data/lib/tinkerforge/bricklet_load_cell_v2.rb +2 -2
  85. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  86. data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
  87. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
  88. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
  89. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  90. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +334 -0
  91. data/lib/tinkerforge/bricklet_nfc.rb +2 -2
  92. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  93. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  94. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +24 -2
  95. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  96. data/lib/tinkerforge/bricklet_one_wire.rb +2 -2
  97. data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
  98. data/lib/tinkerforge/bricklet_particulate_matter.rb +2 -2
  99. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  100. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  101. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +2 -2
  102. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  103. data/lib/tinkerforge/bricklet_ptc_v2.rb +2 -2
  104. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  105. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +2 -2
  106. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  107. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
  108. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  109. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  110. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  111. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +2 -2
  112. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  113. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +2 -2
  114. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  115. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +259 -0
  116. data/lib/tinkerforge/bricklet_rs232.rb +2 -2
  117. data/lib/tinkerforge/bricklet_rs232_v2.rb +2 -2
  118. data/lib/tinkerforge/bricklet_rs485.rb +70 -60
  119. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  120. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +2 -2
  121. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  122. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +2 -2
  123. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  124. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +2 -2
  125. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  126. data/lib/tinkerforge/bricklet_temperature_ir.rb +5 -3
  127. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +3 -11
  128. data/lib/tinkerforge/bricklet_temperature_v2.rb +2 -2
  129. data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
  130. data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
  131. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +2 -2
  132. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  133. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  134. data/lib/tinkerforge/bricklet_uv_light_v2.rb +2 -2
  135. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  136. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  137. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +13 -2
  138. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +365 -0
  139. data/lib/tinkerforge/ip_connection.rb +1 -1
  140. data/lib/tinkerforge/version.rb +1 -1
  141. metadata +10 -3
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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,375 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2019-08-23. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.23 #
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 Voltage, Current, Energy, Real/Apparent/Reactive Power, Power Factor and Frequency
14
+ class BrickletEnergyMonitor < Device
15
+ DEVICE_IDENTIFIER = 2152 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Energy Monitor Bricklet' # :nodoc:
17
+
18
+ # This callback is triggered periodically according to the configuration set by
19
+ # BrickletEnergyMonitor#set_energy_data_callback_configuration.
20
+ #
21
+ # The parameters are the same as BrickletEnergyMonitor#get_energy_data.
22
+ CALLBACK_ENERGY_DATA = 10
23
+
24
+ FUNCTION_GET_ENERGY_DATA = 1 # :nodoc:
25
+ FUNCTION_RESET_ENERGY = 2 # :nodoc:
26
+ FUNCTION_GET_WAVEFORM_LOW_LEVEL = 3 # :nodoc:
27
+ FUNCTION_GET_TRANSFORMER_STATUS = 4 # :nodoc:
28
+ FUNCTION_SET_TRANSFORMER_CALIBRATION = 5 # :nodoc:
29
+ FUNCTION_GET_TRANSFORMER_CALIBRATION = 6 # :nodoc:
30
+ FUNCTION_CALIBRATE_OFFSET = 7 # :nodoc:
31
+ FUNCTION_SET_ENERGY_DATA_CALLBACK_CONFIGURATION = 8 # :nodoc:
32
+ FUNCTION_GET_ENERGY_DATA_CALLBACK_CONFIGURATION = 9 # :nodoc:
33
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
34
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
35
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
36
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
37
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
38
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
39
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
40
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
41
+ FUNCTION_RESET = 243 # :nodoc:
42
+ FUNCTION_WRITE_UID = 248 # :nodoc:
43
+ FUNCTION_READ_UID = 249 # :nodoc:
44
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
45
+
46
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
47
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
48
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
49
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
50
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
51
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
52
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
53
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
54
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
55
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
56
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
57
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
58
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
59
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
60
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
61
+
62
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
63
+ # the IP Connection <tt>ipcon</tt>.
64
+ def initialize(uid, ipcon)
65
+ super uid, ipcon
66
+
67
+ @api_version = [2, 0, 0]
68
+
69
+ @response_expected[FUNCTION_GET_ENERGY_DATA] = RESPONSE_EXPECTED_ALWAYS_TRUE
70
+ @response_expected[FUNCTION_RESET_ENERGY] = RESPONSE_EXPECTED_FALSE
71
+ @response_expected[FUNCTION_GET_WAVEFORM_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
72
+ @response_expected[FUNCTION_GET_TRANSFORMER_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
73
+ @response_expected[FUNCTION_SET_TRANSFORMER_CALIBRATION] = RESPONSE_EXPECTED_FALSE
74
+ @response_expected[FUNCTION_GET_TRANSFORMER_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
75
+ @response_expected[FUNCTION_CALIBRATE_OFFSET] = RESPONSE_EXPECTED_FALSE
76
+ @response_expected[FUNCTION_SET_ENERGY_DATA_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
77
+ @response_expected[FUNCTION_GET_ENERGY_DATA_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
78
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
79
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
81
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
82
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
84
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
85
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
87
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
88
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
+
91
+ @callback_formats[CALLBACK_ENERGY_DATA] = 'l l l l l l S S'
92
+
93
+ end
94
+
95
+ # Returns all of the measurements that are done by the Energy Monitor Bricklet.
96
+ #
97
+ # * Voltage (V): Voltage RMS with a resolution of 10mV (example: 230.05V = 23005)
98
+ # * Current (A): Current RMS with a resolution of 10mA (example: 1.42A = 142)
99
+ # * Energy (Wh): Energy (integrated over time) with a resolution of 10mWh (example: 1.1kWh = 110000)
100
+ # * Real Power (W): Real Power with a resolution of 10mW (example: 1234.56W = 123456)
101
+ # * Apparent Power (VA): Apparent Power with a resolution of 10mVA (example: 1234.56VA = 123456)
102
+ # * Reactive Power (VAR): Reactive Power with a resolution of 10mVAR (example: 1234.56VAR = 123456)
103
+ # * Power Factor: Power Factor with a resolution of 1/1000 (example: PF 0.995 = 995)
104
+ # * Frequency (Hz): AC Frequency of the mains voltage with a resolution of 1/100 Hz (example: 50Hz = 5000)
105
+ #
106
+ # The frequency is recalculated every 6 seconds.
107
+ #
108
+ # All other values are integrated over 10 zero-crossings of the voltage sine wave.
109
+ # With a standard AC mains voltage frequency of 50Hz this results in a 5 measurements
110
+ # per second (or an integration time of 200ms per measurement).
111
+ #
112
+ # If no voltage transformer is connected, the Bricklet will use the current waveform
113
+ # to calculate the frequency and it will use an integration time of
114
+ # 10 zero-crossings of the current waveform.
115
+ def get_energy_data
116
+ send_request FUNCTION_GET_ENERGY_DATA, [], '', 28, 'l l l l l l S S'
117
+ end
118
+
119
+ # Sets the energy value (see BrickletEnergyMonitor#get_energy_data) back to 0Wh.
120
+ def reset_energy
121
+ send_request FUNCTION_RESET_ENERGY, [], '', 0, ''
122
+ end
123
+
124
+ # Returns a snapshot of the voltage and current waveform. The values
125
+ # in the returned array alternate between voltage and current. The data from
126
+ # one getter call contains 768 data points for voltage and current, which
127
+ # correspond to about 3 full sine waves.
128
+ #
129
+ # The voltage is given with a resolution of 100mV and the current is given
130
+ # with a resolution of 10mA.
131
+ #
132
+ # This data is meant to be used for a non-realtime graphical representation of
133
+ # the voltage and current waveforms.
134
+ def get_waveform_low_level
135
+ send_request FUNCTION_GET_WAVEFORM_LOW_LEVEL, [], '', 62, 'S s30'
136
+ end
137
+
138
+ # Returns *true* if a voltage/current transformer is connected to the Bricklet.
139
+ def get_transformer_status
140
+ send_request FUNCTION_GET_TRANSFORMER_STATUS, [], '', 2, '? ?'
141
+ end
142
+
143
+ # Sets the transformer ratio for the voltage and current transformer in 1/100 form.
144
+ #
145
+ # Example: If your mains voltage is 230V, you use 9V voltage transformer and a
146
+ # 1V:30A current clamp your voltage ratio is 230/9 = 25.56 and your current ratio
147
+ # is 30/1 = 30.
148
+ #
149
+ # In this case you have to set the values 2556 and 3000 for voltage ratio and current
150
+ # ratio.
151
+ #
152
+ # The calibration is saved in non-volatile memory, you only have to set it once.
153
+ #
154
+ # By default the voltage ratio is set to 1923 and the current ratio is set to 3000.
155
+ #
156
+ # Set the phase shift to 0. It is for future use and currently not supported by the Bricklet.
157
+ def set_transformer_calibration(voltage_ratio, current_ratio, phase_shift)
158
+ send_request FUNCTION_SET_TRANSFORMER_CALIBRATION, [voltage_ratio, current_ratio, phase_shift], 'S S s', 0, ''
159
+ end
160
+
161
+ # Returns the transformer calibration as set by BrickletEnergyMonitor#set_transformer_calibration.
162
+ def get_transformer_calibration
163
+ send_request FUNCTION_GET_TRANSFORMER_CALIBRATION, [], '', 6, 'S S s'
164
+ end
165
+
166
+ # Calling this function will start an offset calibration. The offset calibration will
167
+ # integrate the voltage and current waveform over a longer time period to find the 0
168
+ # transition point in the sine wave.
169
+ #
170
+ # The Bricklet comes with a factory-calibrated offset value, you should not have to
171
+ # call this function.
172
+ #
173
+ # If you want to re-calibrate the offset we recommend that you connect a load that
174
+ # has a smooth sinusoidal voltage and current waveform. Alternatively you can also
175
+ # short both inputs.
176
+ #
177
+ # The calibration is saved in non-volatile memory, you only have to set it once.
178
+ def calibrate_offset
179
+ send_request FUNCTION_CALIBRATE_OFFSET, [], '', 0, ''
180
+ end
181
+
182
+ # The period in ms is the period with which the CALLBACK_ENERGY_DATA
183
+ # callback is triggered periodically. A value of 0 turns the callback off.
184
+ #
185
+ # If the `value has to change`-parameter is set to true, the callback is only
186
+ # triggered after the value has changed. If the value didn't change within the
187
+ # period, the callback is triggered immediately on change.
188
+ #
189
+ # If it is set to false, the callback is continuously triggered with the period,
190
+ # independent of the value.
191
+ #
192
+ # The default value is (0, false).
193
+ def set_energy_data_callback_configuration(period, value_has_to_change)
194
+ send_request FUNCTION_SET_ENERGY_DATA_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
195
+ end
196
+
197
+ # Returns the callback configuration as set by
198
+ # BrickletEnergyMonitor#set_energy_data_callback_configuration.
199
+ def get_energy_data_callback_configuration
200
+ send_request FUNCTION_GET_ENERGY_DATA_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
201
+ end
202
+
203
+ # Returns the error count for the communication between Brick and Bricklet.
204
+ #
205
+ # The errors are divided into
206
+ #
207
+ # * ACK checksum errors,
208
+ # * message checksum errors,
209
+ # * framing errors and
210
+ # * overflow errors.
211
+ #
212
+ # The errors counts are for errors that occur on the Bricklet side. All
213
+ # Bricks have a similar function that returns the errors on the Brick side.
214
+ def get_spitfp_error_count
215
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
216
+ end
217
+
218
+ # Sets the bootloader mode and returns the status after the requested
219
+ # mode change was instigated.
220
+ #
221
+ # You can change from bootloader mode to firmware mode and vice versa. A change
222
+ # from bootloader mode to firmware mode will only take place if the entry function,
223
+ # device identifier and CRC are present and correct.
224
+ #
225
+ # This function is used by Brick Viewer during flashing. It should not be
226
+ # necessary to call it in a normal user program.
227
+ def set_bootloader_mode(mode)
228
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
229
+ end
230
+
231
+ # Returns the current bootloader mode, see BrickletEnergyMonitor#set_bootloader_mode.
232
+ def get_bootloader_mode
233
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
234
+ end
235
+
236
+ # Sets the firmware pointer for BrickletEnergyMonitor#write_firmware. The pointer has
237
+ # to be increased by chunks of size 64. The data is written to flash
238
+ # every 4 chunks (which equals to one page of size 256).
239
+ #
240
+ # This function is used by Brick Viewer during flashing. It should not be
241
+ # necessary to call it in a normal user program.
242
+ def set_write_firmware_pointer(pointer)
243
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
244
+ end
245
+
246
+ # Writes 64 Bytes of firmware at the position as written by
247
+ # BrickletEnergyMonitor#set_write_firmware_pointer before. The firmware is written
248
+ # to flash every 4 chunks.
249
+ #
250
+ # You can only write firmware in bootloader mode.
251
+ #
252
+ # This function is used by Brick Viewer during flashing. It should not be
253
+ # necessary to call it in a normal user program.
254
+ def write_firmware(data)
255
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
256
+ end
257
+
258
+ # Sets the status LED configuration. By default the LED shows
259
+ # communication traffic between Brick and Bricklet, it flickers once
260
+ # for every 10 received data packets.
261
+ #
262
+ # You can also turn the LED permanently on/off or show a heartbeat.
263
+ #
264
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
265
+ def set_status_led_config(config)
266
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
267
+ end
268
+
269
+ # Returns the configuration as set by BrickletEnergyMonitor#set_status_led_config
270
+ def get_status_led_config
271
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
272
+ end
273
+
274
+ # Returns the temperature in °C as measured inside the microcontroller. The
275
+ # value returned is not the ambient temperature!
276
+ #
277
+ # The temperature is only proportional to the real temperature and it has bad
278
+ # accuracy. Practically it is only useful as an indicator for
279
+ # temperature changes.
280
+ def get_chip_temperature
281
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
282
+ end
283
+
284
+ # Calling this function will reset the Bricklet. All configurations
285
+ # will be lost.
286
+ #
287
+ # After a reset you have to create new device objects,
288
+ # calling functions on the existing ones will result in
289
+ # undefined behavior!
290
+ def reset
291
+ send_request FUNCTION_RESET, [], '', 0, ''
292
+ end
293
+
294
+ # Writes a new UID into flash. If you want to set a new UID
295
+ # you have to decode the Base58 encoded UID string into an
296
+ # integer first.
297
+ #
298
+ # We recommend that you use Brick Viewer to change the UID.
299
+ def write_uid(uid)
300
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
301
+ end
302
+
303
+ # Returns the current UID as an integer. Encode as
304
+ # Base58 to get the usual string version.
305
+ def read_uid
306
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
307
+ end
308
+
309
+ # Returns the UID, the UID where the Bricklet is connected to,
310
+ # the position, the hardware and firmware version as well as the
311
+ # device identifier.
312
+ #
313
+ # The position can be 'a', 'b', 'c' or 'd'.
314
+ #
315
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
316
+ # |device_identifier_constant|
317
+ def get_identity
318
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
319
+ end
320
+
321
+ # Returns a snapshot of the voltage and current waveform. The values
322
+ # in the returned array alternate between voltage and current. The data from
323
+ # one getter call contains 768 data points for voltage and current, which
324
+ # correspond to about 3 full sine waves.
325
+ #
326
+ # The voltage is given with a resolution of 100mV and the current is given
327
+ # with a resolution of 10mA.
328
+ #
329
+ # This data is meant to be used for a non-realtime graphical representation of
330
+ # the voltage and current waveforms.
331
+ def get_waveform
332
+ waveform_length = 1536
333
+ waveform_data = nil # assigned in block
334
+
335
+ @stream_mutex.synchronize {
336
+ ret = get_waveform_low_level
337
+ waveform_chunk_offset = ret[0]
338
+
339
+ if waveform_chunk_offset == (1 << 16) - 1 # maximum chunk offset -> stream has no data
340
+ waveform_length = 0
341
+ waveform_chunk_offset = 0
342
+ waveform_out_of_sync = false
343
+ waveform_data = []
344
+ else
345
+ waveform_out_of_sync = waveform_chunk_offset != 0
346
+ waveform_data = ret[1]
347
+ end
348
+
349
+ while not waveform_out_of_sync and waveform_data.length < waveform_length
350
+ ret = get_waveform_low_level
351
+ waveform_chunk_offset = ret[0]
352
+ waveform_out_of_sync = waveform_chunk_offset != waveform_data.length
353
+ waveform_data += ret[1]
354
+ end
355
+
356
+ if waveform_out_of_sync # discard remaining stream to bring it back in-sync
357
+ while waveform_chunk_offset + 30 < waveform_length
358
+ ret = get_waveform_low_level
359
+ waveform_chunk_offset = ret[0]
360
+ end
361
+
362
+ raise StreamOutOfSyncException, 'Waveform stream is out-of-sync'
363
+ end
364
+ }
365
+
366
+ waveform_data[0, waveform_length]
367
+ end
368
+
369
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
370
+ def register_callback(id, &block)
371
+ callback = block
372
+ @registered_callbacks[id] = callback
373
+ end
374
+ end
375
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2019-08-23. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.23 #
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 #