tinderfridge 0.2.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinderfridge/device.rb +95 -1
  3. data/lib/tinderfridge/device_collection.rb +69 -0
  4. data/lib/tinderfridge/device_info.txt +5 -0
  5. data/lib/tinderfridge/devices/brick_hat/brick_hat.json +11 -0
  6. data/lib/tinderfridge/devices/brick_hat/brick_hat.rb +18 -0
  7. data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.json +11 -0
  8. data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.rb +14 -0
  9. data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json +10 -0
  10. data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.rb +20 -0
  11. data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.json +10 -0
  12. data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb +19 -0
  13. data/lib/tinderfridge/devices/bricklet_analog_in_v3/bricklet_analog_in_v3.json +10 -0
  14. data/lib/tinderfridge/devices/bricklet_analog_out_v3/bricklet_analog_out_v3.json +10 -0
  15. data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json +10 -0
  16. data/lib/tinderfridge/devices/bricklet_can_v2/bricklet_can_v2.json +11 -0
  17. data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json +10 -0
  18. data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json +10 -0
  19. data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.rb +31 -0
  20. data/lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json +10 -0
  21. data/lib/tinderfridge/devices/bricklet_dc_v2/bricklet_dc_v2.json +11 -0
  22. data/lib/tinderfridge/devices/bricklet_distance_us_v2/bricklet_distance_us_v2.json +10 -0
  23. data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.json +10 -0
  24. data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.rb +18 -0
  25. data/lib/tinderfridge/devices/bricklet_e_paper_296x128/bricklet_e_paper_296x128.json +10 -0
  26. data/lib/tinderfridge/devices/bricklet_energy_monitor/bricklet_energy_monitor.json +10 -0
  27. data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.json +10 -0
  28. data/lib/tinderfridge/devices/{bricklet_gps_v2.rb → bricklet_gps_v2/bricklet_gps_v2.rb} +0 -0
  29. data/lib/tinderfridge/devices/bricklet_hall_effect_v2/bricklet_hall_effect_v2.json +10 -0
  30. data/lib/tinderfridge/devices/bricklet_humidity_v2/bricklet_humidity_v2.json +10 -0
  31. data/lib/tinderfridge/devices/bricklet_imu_v3/bricklet_imu_v3.json +10 -0
  32. data/lib/tinderfridge/devices/bricklet_industrial_counter/bricklet_industrial_counter.json +11 -0
  33. data/lib/tinderfridge/devices/bricklet_industrial_digital_in_4_v2/bricklet_industrial_digital_in_4_v2.json +11 -0
  34. data/lib/tinderfridge/devices/bricklet_industrial_digital_out_4_v2/bricklet_industrial_digital_out_4_v2.json +11 -0
  35. data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.json +10 -0
  36. data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb +20 -0
  37. data/lib/tinderfridge/devices/bricklet_industrial_ptc/bricklet_industrial_ptc.json +11 -0
  38. data/lib/tinderfridge/devices/bricklet_industrial_quad_relay_v2/bricklet_industrial_quad_relay_v2.json +11 -0
  39. data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.json +10 -0
  40. data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.rb +17 -0
  41. data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.json +10 -0
  42. data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.rb +15 -0
  43. data/lib/tinderfridge/devices/bricklet_laser_range_finder_v2/bricklet_laser_range_finder_v2.json +10 -0
  44. data/lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.json +10 -0
  45. data/lib/tinderfridge/devices/{bricklet_lcd_128x64.rb → bricklet_lcd_128x64/bricklet_lcd_128x64.rb} +0 -0
  46. data/lib/tinderfridge/devices/bricklet_led_strip_v2/bricklet_led_strip_v2.json +10 -0
  47. data/lib/tinderfridge/devices/{bricklet_led_strip_v2.rb → bricklet_led_strip_v2/bricklet_led_strip_v2.rb} +12 -0
  48. data/lib/tinderfridge/devices/bricklet_linear_poti_v2/bricklet_linear_poti_v2.json +10 -0
  49. data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.json +10 -0
  50. data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.rb +22 -0
  51. data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.json +10 -0
  52. data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb +42 -0
  53. data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.json +10 -0
  54. data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.rb +16 -0
  55. data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.json +10 -0
  56. data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.rb +16 -0
  57. data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.json +11 -0
  58. data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.json +10 -0
  59. data/lib/tinderfridge/devices/{bricklet_outdoor_weather.rb → bricklet_outdoor_weather/bricklet_outdoor_weather.rb} +0 -0
  60. data/lib/tinderfridge/devices/bricklet_performance_dc/bricklet_performance_dc.json +11 -0
  61. data/lib/tinderfridge/devices/bricklet_piezo_speaker_v2/bricklet_piezo_speaker_v2.json +10 -0
  62. data/lib/tinderfridge/devices/bricklet_real_time_clock_v2/bricklet_real_time_clock_v2.json +10 -0
  63. data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.json +10 -0
  64. data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.rb +15 -0
  65. data/lib/tinderfridge/devices/bricklet_rgb_led_button/bricklet_rgb_led_button.json +10 -0
  66. data/lib/tinderfridge/devices/{bricklet_rgb_led_button.rb → bricklet_rgb_led_button/bricklet_rgb_led_button.rb} +9 -0
  67. data/lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.json +10 -0
  68. data/lib/tinderfridge/devices/{bricklet_rgb_led_v2.rb → bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb} +7 -0
  69. data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.json +10 -0
  70. data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.rb +20 -0
  71. data/lib/tinderfridge/devices/bricklet_rotary_poti_v2/bricklet_rotary_poti_v2.json +10 -0
  72. data/lib/tinderfridge/devices/bricklet_rs232_v2/bricklet_rs232_v2.json +11 -0
  73. data/lib/tinderfridge/devices/bricklet_rs485/bricklet_rs485.json +11 -0
  74. data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.json +10 -0
  75. data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +128 -0
  76. data/lib/tinderfridge/devices/bricklet_servo_v2/bricklet_servo_v2.json +11 -0
  77. data/lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json +11 -0
  78. data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json +10 -0
  79. data/lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json +10 -0
  80. data/lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.json +10 -0
  81. data/lib/tinderfridge/devices/bricklet_thermal_imaging/bricklet_thermal_imaging.json +10 -0
  82. data/lib/tinderfridge/devices/bricklet_thermocouple_v2/bricklet_thermocouple_v2.json +10 -0
  83. data/lib/tinderfridge/devices/bricklet_uv_light_v2/bricklet_uv_light_v2.json +10 -0
  84. data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.json +10 -0
  85. data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.rb +18 -0
  86. data/lib/tinderfridge/devices/bricklet_xmc1400_breakout/bricklet_xmc1400_breakout.json +10 -0
  87. data/lib/tinderfridge/ip_connection.rb +66 -10
  88. data/lib/tinderfridge/tinkerforge.rb +3 -0
  89. data/lib/tinderfridge/version.rb +1 -1
  90. metadata +98 -17
  91. data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a1a23e33e307a89386dbf4d61f3a9852e000e3382ec3c61de5b1c45c0335f11
4
- data.tar.gz: 4261d085ad57d3205da9b27fcd38d74bd3bb47e482f0fbcfb391918e4abac268
3
+ metadata.gz: 61c196b035feb056ef219545b4fb18b0d31143ec45dce191fd24abba736c6c06
4
+ data.tar.gz: b8f7e262293e0c1f42648f57360818bc160bef744d3bf4e1424c31f81658fe84
5
5
  SHA512:
6
- metadata.gz: 12677e84815ddad014bf40df64798fbb05c46be764106143e16d2964a73d71a402bfb9d66bbc6f1422ec83766628ec0f6e2ddf9817fb64e38988523f9b4c3479
7
- data.tar.gz: '0749d1e2bf1b022313bbe807c08836df740d223d1b5d81efd5bb388693c84c707d436e5dc35f9fe827518dcf6ce97db70e9f8c948a5d3b0e64f75b4780f722f5'
6
+ metadata.gz: 68b64abcf925c879f4962b505c4ae06b9cdf3d4fad9964c34e1d33cbe1dc72fffee805a7a1651fe9b4d0cdc3c2c93a53a593dafdc0ad28f8fea93e20a3fc2c0b
7
+ data.tar.gz: b3a2980b1f8d21b9044b59b8e40b62bf148fc5a18505b3391f1c7047796df5139e2782e50872cac01acf1a29bb8b52cfe14fea0fca8b706c9a6fb3d120ebbfc5
@@ -1,6 +1,7 @@
1
1
  require 'tinkerforge/ip_connection'
2
2
 
3
3
  module Tinkerforge
4
+
4
5
  class Device
5
6
 
6
7
  #----------------------------------------------------------------------#
@@ -41,7 +42,7 @@ module Tinkerforge
41
42
  def inherited(klass)
42
43
  if info = Tinkerforge.device_info(klass)
43
44
  begin
44
- require("tinderfridge/devices/#{info[2][1]}")
45
+ require("tinderfridge/devices/#{info[2][1]}/#{info[2][1]}")
45
46
  rescue LoadError
46
47
  # No extension found for this device
47
48
  end
@@ -54,14 +55,80 @@ module Tinkerforge
54
55
  # Instance Methods #
55
56
  #----------------------------------------------------------------------#
56
57
 
58
+ # Returns the device's UID. Not to be confused with #uid, which returns the numeric UID.
59
+ attr_reader :uid_string
60
+
61
+ # Returns the device's numeric Device Identifier.
62
+ attr_reader :device_identifier
63
+
64
+ # Returns the device's Display Name.
65
+ attr_reader :device_display_name
66
+
57
67
  # Returns the device's IPConnection object.
58
68
  attr_reader :ipcon
59
69
 
70
+ # Returns device information.
71
+ #
72
+ # Device information is an array:
73
+ # - 0 : Device Identifier
74
+ # - 1 : Device Display Name
75
+ # - 2 : Associated class name and source file
76
+ def device_info
77
+ Tinkerforge.device_info device_identifier
78
+ end
79
+
60
80
  # Returns a programmer-friendly representation of the device.
61
81
  def inspect
62
82
  "%s (%s@%s:%s)" % [self.class, @uid_string, ipcon.host, ipcon.port]
63
83
  end
64
84
 
85
+ # Returns the device's properties.
86
+ def properties
87
+ @properties ||= {
88
+ 'device_identifier' => device_identifier,
89
+ 'device_display_name' => device_display_name,
90
+ }.merge load_properties
91
+ end
92
+
93
+ alias props properties
94
+
95
+ # Returns the device's state.
96
+ def state
97
+
98
+ # BrickDaemon inherits from Device, but has no #get_identity.
99
+ return {} unless respond_to? 'get_identity'
100
+
101
+ identity = get_identity
102
+
103
+ [
104
+ [ 'uid' , uid_string ],
105
+ [ 'update_time' , Time.now.gmtime ],
106
+ [ 'firmware_version' , identity[4].join('.') ],
107
+
108
+ [ 'connected', { 'uid' => identity[1], 'position' => identity[2] } ],
109
+ [ 'ipcon' , { 'host' => ipcon.host , 'port' => ipcon.port } ],
110
+
111
+ respond_to?('get_chip_temperature' ) ? [ 'chip_temperature' , get_chip_temperature ] : nil,
112
+ respond_to?('get_spitfp_error_count') ? [ 'spitfp_error_count', get_spitfp_error_count ] : nil,
113
+ respond_to?('get_status_led_config' ) ? [ 'status_led_config' , get_status_led_config ] : nil,
114
+
115
+ ].compact.to_h
116
+ end
117
+
118
+ # Opens the online documentation for the device (Mac OS only).
119
+ #
120
+ # When the URL for the documentation is not known, does nothing.
121
+ def open_documentation
122
+ if properties['documentation_en_url'] and ( RUBY_PLATFORM =~ /darwin/ )
123
+ `open #{properties['documentation_en_url']}`
124
+ properties['documentation_en_url']
125
+ else
126
+ nil
127
+ end
128
+ end
129
+
130
+ alias doc open_documentation
131
+
65
132
  # Identifies a Tinkerforge device by blinking its status led.
66
133
  #
67
134
  # Supports recent devices. When invoked on older devices, does nothing.
@@ -82,5 +149,32 @@ module Tinkerforge
82
149
  end
83
150
  end
84
151
 
152
+ private
153
+
154
+ def load_properties
155
+ if device_info
156
+ properties_file = File.join(
157
+ File.dirname(__FILE__),
158
+ 'devices',
159
+ device_info[2][1],
160
+ device_info[2][1],
161
+ ) + '.json'
162
+
163
+ if File.readable? properties_file
164
+ begin
165
+ require 'json'
166
+ JSON.load File.read properties_file
167
+ rescue
168
+ {}
169
+ end
170
+ else
171
+ {}
172
+ end
173
+ else
174
+ {}
175
+ end
176
+ end
177
+
85
178
  end
179
+
86
180
  end
@@ -63,6 +63,75 @@ module Tinkerforge
63
63
  end.size
64
64
  end
65
65
 
66
+ # Returns the properties of devices in the collection.
67
+ def properties
68
+ smap 'properties'
69
+ end
70
+
71
+ alias props properties
72
+
73
+ # Returns the state of devices in the collection.
74
+ def state
75
+ smap 'state'
76
+ end
77
+
78
+ # Opens the online documentation for the devices in the collection (Mac OS only).
79
+ #
80
+ # When the URL for a device's documentation is not known, does nothing.
81
+ def open_documentation
82
+ smap 'open_documentation'
83
+ end
84
+
85
+ alias doc open_documentation
86
+
87
+ # Turns off light sources such as screens and RGB LEDs for devices in the collection.
88
+ #
89
+ # Ignores devices that do not support the blackout method.
90
+ def blackout
91
+ smap 'blackout'
92
+ end
93
+
94
+ # Returns a list of unique IP Connections used by devices in the collection.
95
+ def ipcons
96
+ smap('ipcon').values.compact.uniq
97
+ end
98
+
99
+ # Returns an array of devices in the collection matching the selector.
100
+ #
101
+ # Selector argument can be:
102
+ # - Device Identifier
103
+ # - Class name or Device Display Name (Regexp)
104
+ # Selection by regular expression is case-insensitive by default.
105
+ #
106
+ # @example Select by class name and Device Display Name
107
+ # # All 'analog' devices
108
+ # tf = Tinkerforge.connect.discover(1)
109
+ # tf.find_all /analog/
110
+ def find_all(selector)
111
+ case selector
112
+ when Integer
113
+ values.select { |v| v.device_identifier == selector}
114
+ when Regexp
115
+ r = Regexp.new selector.source, Regexp::IGNORECASE
116
+ values.select { |v| v.class.to_s.split('::').last =~ r || v.device_display_name =~ r }
117
+ end
118
+ end
119
+
120
+ # Returns the first device in the collection matching the selector.
121
+ #
122
+ # Selector argument can be:
123
+ # - Device Identifier
124
+ # - Class name or Device Display Name (Regexp)
125
+ # Selection by regular expression is case-insensitive by default.
126
+ #
127
+ # @example Select by Device Identifier
128
+ # # Remote Switch Bricklet 2.0
129
+ # tf = Tinkerforge.connect('myhost.local').discover(1)
130
+ # tf.find 289
131
+ def find(selector)
132
+ find_all(selector).first
133
+ end
134
+
66
135
  private
67
136
 
68
137
  def smap(m)
@@ -135,5 +135,10 @@
135
135
  2147 CO2 Bricklet 2.0 Tinkerforge::BrickletCO2V2 bricklet_co2_v2
136
136
  2152 Energy Monitor Bricklet Tinkerforge::BrickletEnergyMonitor bricklet_energy_monitor
137
137
  2153 Compass Bricklet Tinkerforge::BrickletCompass bricklet_compass
138
+ 2156 Performance DC Bricklet Tinkerforge::BrickletPerformanceDC bricklet_performance_dc
139
+ 2157 Servo Bricklet 2.0 Tinkerforge::BrickletServoV2 bricklet_servo_v2
138
140
  2161 IMU Bricklet 3.0 Tinkerforge::BrickletIMUV3 bricklet_imu_v3
139
141
  2162 Industrial Dual AC Relay Bricklet Tinkerforge::BrickletIndustrialDualACRelay bricklet_industrial_dual_ac_relay
142
+ 2164 Industrial PTC Bricklet Tinkerforge::BrickletIndustrialPTC bricklet_industrial_ptc
143
+ 2165 DC Bricklet 2.0 Tinkerforge::BrickletDCV2 bricklet_dc_v2
144
+ 2166 Silent Stepper Bricklet 2.0 Tinkerforge::BrickletSilentStepperV2 bricklet_silent_stepper_v2
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 65,
4
+ 56,
5
+ 25
6
+ ],
7
+ "weight": 30,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricks/HAT_Brick.html",
9
+ "versions_identifier": "bricklets:hat",
10
+ "released": "2019-05-21"
11
+ }
@@ -0,0 +1,18 @@
1
+ module Tinkerforge
2
+
3
+ class BrickHAT
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ volts = get_voltages
8
+ super.merge(
9
+ 'bricklet_power' => get_bricklet_power,
10
+ 'usb_voltage' => volts[0],
11
+ 'dc_voltage' => volts[1],
12
+ 'sleep_mode' => get_sleep_mode,
13
+ )
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 65,
4
+ 30,
5
+ 5
6
+ ],
7
+ "weight": 12,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricks/HAT_Zero_Brick.html",
9
+ "versions_identifier": "bricklets:hat_zero",
10
+ "released": "2019-05-21"
11
+ }
@@ -0,0 +1,14 @@
1
+ module Tinkerforge
2
+
3
+ class BrickHATZero
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'usb_voltage' => get_usb_voltage,
9
+ )
10
+ end
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 25,
4
+ 20,
5
+ 5
6
+ ],
7
+ "weight": 2.1,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Air_Quality.html",
9
+ "versions_identifier": "bricklets:air_quality"
10
+ }
@@ -0,0 +1,20 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletAirQuality
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ av = get_all_values
8
+ super.merge(
9
+ 'iaq_index' => av[0],
10
+ 'iaq_index_accuracy' => av[1],
11
+ 'temperature' => av[2],
12
+ 'temperature_offset' => get_temperature_offset,
13
+ 'humidity' => av[3],
14
+ 'air_pressure' => av[4],
15
+ )
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 25,
4
+ 15,
5
+ 5
6
+ ],
7
+ "weight": 2,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Ambient_Light_V3.html",
9
+ "versions_identifier": "bricklets:ambient_light_v3"
10
+ }
@@ -0,0 +1,19 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletAmbientLightV3
4
+
5
+ ILLUMINANCE_RANGES = [ 64000, 32000, 16000, 8000, 1300, 600, 100000 ]
6
+
7
+ # Returns the device's state.
8
+ def state
9
+ super.merge(
10
+ 'configuration' => conf = get_configuration,
11
+ 'illuminance_range' => ILLUMINANCE_RANGES[ conf[0] ],
12
+ 'integration_time' => 50 + conf[1] * 50,
13
+ 'illuminance_raw' => get_illuminance,
14
+ )
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 35,
4
+ 30,
5
+ 14
6
+ ],
7
+ "weight": 8,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Analog_In_V3.html",
9
+ "versions_identifier": "bricklets:analog_in_v3"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 35,
4
+ 30,
5
+ 14
6
+ ],
7
+ "weight": 8,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Analog_Out_V3.html",
9
+ "versions_identifier": "bricklets:analog_out_v3"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 25,
4
+ 15,
5
+ 5
6
+ ],
7
+ "weight": 1.6,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Barometer_V2.html",
9
+ "versions_identifier": "bricklets:barometer_v2"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 45,
4
+ 35,
5
+ 14
6
+ ],
7
+ "weight": 8.6,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/CAN_V2.html",
9
+ "versions_identifier": "bricklets:can_v2",
10
+ "released": "2018-06-07"
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 35,
4
+ 40,
5
+ 18
6
+ ],
7
+ "weight": 9,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/CO2_V2.html",
9
+ "versions_identifier": "bricklets:co2_v2"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 25,
4
+ 20,
5
+ 5
6
+ ],
7
+ "weight": 2,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Color_V2.html",
9
+ "versions_identifier": "bricklets:color_v2"
10
+ }
@@ -0,0 +1,31 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletColorV2
4
+
5
+ GAINS = [1, 4, 16, 60]
6
+ INTEGRATION_TIMES = [2.4, 24, 101, 154, 700]
7
+
8
+ # Switches off the Bricklet's white LED.
9
+ def blackout
10
+ set_light false
11
+ true
12
+ end
13
+
14
+ # Returns the device's state.
15
+ def state
16
+ super.merge(
17
+ 'configuration' => config = get_configuration,
18
+ 'gain' => GAINS[ config[0] ],
19
+ 'integration_time' => INTEGRATION_TIMES[ config[1] ],
20
+ 'color_rgbc' => color = get_color,
21
+ 'illuminance_raw' => illum = get_illuminance,
22
+ 'illuminance' => illum * 700.0 / GAINS[ config[0] ] / INTEGRATION_TIMES[ config[1] ],
23
+ 'color_temperature' => get_color_temperature,
24
+ 'saturated' => color[0,3].include?(65535),
25
+ 'light' => get_light,
26
+ )
27
+ end
28
+
29
+ end
30
+
31
+ end