tinderfridge 0.4.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinderfridge/device.rb +67 -3
  3. data/lib/tinderfridge/device_collection.rb +52 -0
  4. data/lib/tinderfridge/device_info.txt +3 -0
  5. data/lib/tinderfridge/devices/brick_hat/brick_hat.json +11 -0
  6. data/lib/tinderfridge/devices/{brick_hat.rb → brick_hat/brick_hat.rb} +0 -0
  7. data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.json +11 -0
  8. data/lib/tinderfridge/devices/{brick_hat_zero.rb → brick_hat_zero/brick_hat_zero.rb} +0 -0
  9. data/lib/tinderfridge/devices/bricklet_accelerometer_v2/bricklet_accelerometer_v2.json +11 -0
  10. data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json +11 -0
  11. data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.rb +20 -0
  12. data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.json +10 -0
  13. data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb +19 -0
  14. data/lib/tinderfridge/devices/bricklet_analog_in_v3/bricklet_analog_in_v3.json +10 -0
  15. data/lib/tinderfridge/devices/bricklet_analog_out_v3/bricklet_analog_out_v3.json +11 -0
  16. data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json +11 -0
  17. data/lib/tinderfridge/devices/bricklet_can_v2/bricklet_can_v2.json +11 -0
  18. data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json +10 -0
  19. data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json +10 -0
  20. data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.rb +31 -0
  21. data/lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json +10 -0
  22. data/lib/tinderfridge/devices/bricklet_dc_v2/bricklet_dc_v2.json +11 -0
  23. data/lib/tinderfridge/devices/bricklet_distance_ir_v2/bricklet_distance_ir_v2.json +11 -0
  24. data/lib/tinderfridge/devices/bricklet_distance_us_v2/bricklet_distance_us_v2.json +10 -0
  25. data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.json +10 -0
  26. data/lib/tinderfridge/devices/{bricklet_dmx.rb → bricklet_dmx/bricklet_dmx.rb} +0 -0
  27. data/lib/tinderfridge/devices/bricklet_dual_button_v2/bricklet_dual_button_v2.json +11 -0
  28. data/lib/tinderfridge/devices/bricklet_e_paper_296x128/bricklet_e_paper_296x128.json +10 -0
  29. data/lib/tinderfridge/devices/bricklet_energy_monitor/bricklet_energy_monitor.json +10 -0
  30. data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.json +10 -0
  31. data/lib/tinderfridge/devices/{bricklet_gps_v2.rb → bricklet_gps_v2/bricklet_gps_v2.rb} +0 -0
  32. data/lib/tinderfridge/devices/bricklet_hall_effect_v2/bricklet_hall_effect_v2.json +10 -0
  33. data/lib/tinderfridge/devices/bricklet_humidity_v2/bricklet_humidity_v2.json +10 -0
  34. data/lib/tinderfridge/devices/bricklet_imu_v3/bricklet_imu_v3.json +10 -0
  35. data/lib/tinderfridge/devices/bricklet_industrial_analog_out_v2/bricklet_industrial_analog_out_v2.json +11 -0
  36. data/lib/tinderfridge/devices/bricklet_industrial_counter/bricklet_industrial_counter.json +11 -0
  37. data/lib/tinderfridge/devices/bricklet_industrial_digital_in_4_v2/bricklet_industrial_digital_in_4_v2.json +11 -0
  38. data/lib/tinderfridge/devices/bricklet_industrial_digital_out_4_v2/bricklet_industrial_digital_out_4_v2.json +11 -0
  39. data/lib/tinderfridge/devices/bricklet_industrial_dual_0_20ma_v2/bricklet_industrial_dual_0_20ma_v2.json +11 -0
  40. data/lib/tinderfridge/devices/bricklet_industrial_dual_ac_relay/bricklet_industrial_dual_ac_relay.json +11 -0
  41. data/lib/tinderfridge/devices/bricklet_industrial_dual_analog_in_v2/bricklet_industrial_dual_analog_in_v2.json +11 -0
  42. data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.json +10 -0
  43. data/lib/tinderfridge/devices/{bricklet_industrial_dual_relay.rb → bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb} +0 -0
  44. data/lib/tinderfridge/devices/bricklet_industrial_ptc/bricklet_industrial_ptc.json +11 -0
  45. data/lib/tinderfridge/devices/bricklet_industrial_quad_relay_v2/bricklet_industrial_quad_relay_v2.json +11 -0
  46. data/lib/tinderfridge/devices/bricklet_io16_v2/bricklet_io16_v2.json +11 -0
  47. data/lib/tinderfridge/devices/bricklet_io4_v2/bricklet_io4_v2.json +11 -0
  48. data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.json +10 -0
  49. data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.rb +17 -0
  50. data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.json +10 -0
  51. data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.rb +15 -0
  52. data/lib/tinderfridge/devices/bricklet_laser_range_finder_v2/bricklet_laser_range_finder_v2.json +10 -0
  53. data/lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.json +10 -0
  54. data/lib/tinderfridge/devices/{bricklet_lcd_128x64.rb → bricklet_lcd_128x64/bricklet_lcd_128x64.rb} +0 -0
  55. data/lib/tinderfridge/devices/bricklet_led_strip_v2/bricklet_led_strip_v2.json +11 -0
  56. data/lib/tinderfridge/devices/{bricklet_led_strip_v2.rb → bricklet_led_strip_v2/bricklet_led_strip_v2.rb} +0 -0
  57. data/lib/tinderfridge/devices/bricklet_linear_poti_v2/bricklet_linear_poti_v2.json +10 -0
  58. data/lib/tinderfridge/devices/bricklet_load_cell_v2/bricklet_load_cell_v2.json +11 -0
  59. data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.json +10 -0
  60. data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.rb +22 -0
  61. data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.json +10 -0
  62. data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb +42 -0
  63. data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.json +10 -0
  64. data/lib/tinderfridge/devices/{bricklet_multi_touch_v2.rb → bricklet_multi_touch_v2/bricklet_multi_touch_v2.rb} +0 -0
  65. data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.json +10 -0
  66. data/lib/tinderfridge/devices/{bricklet_nfc.rb → bricklet_nfc/bricklet_nfc.rb} +0 -0
  67. data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.json +11 -0
  68. data/lib/tinderfridge/devices/bricklet_one_wire/bricklet_one_wire.json +11 -0
  69. data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.json +10 -0
  70. data/lib/tinderfridge/devices/{bricklet_outdoor_weather.rb → bricklet_outdoor_weather/bricklet_outdoor_weather.rb} +0 -0
  71. data/lib/tinderfridge/devices/bricklet_particulate_matter/bricklet_particulate_matter.json +11 -0
  72. data/lib/tinderfridge/devices/bricklet_performance_dc/bricklet_performance_dc.json +11 -0
  73. data/lib/tinderfridge/devices/bricklet_piezo_speaker_v2/bricklet_piezo_speaker_v2.json +10 -0
  74. data/lib/tinderfridge/devices/bricklet_ptc_v2/bricklet_ptc_v2.json +11 -0
  75. data/lib/tinderfridge/devices/bricklet_real_time_clock_v2/bricklet_real_time_clock_v2.json +10 -0
  76. data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.json +10 -0
  77. data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.rb +15 -0
  78. data/lib/tinderfridge/devices/bricklet_rgb_led_button/bricklet_rgb_led_button.json +10 -0
  79. data/lib/tinderfridge/devices/{bricklet_rgb_led_button.rb → bricklet_rgb_led_button/bricklet_rgb_led_button.rb} +9 -0
  80. data/lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.json +10 -0
  81. data/lib/tinderfridge/devices/{bricklet_rgb_led_v2.rb → bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb} +7 -0
  82. data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.json +10 -0
  83. data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.rb +20 -0
  84. data/lib/tinderfridge/devices/bricklet_rotary_poti_v2/bricklet_rotary_poti_v2.json +10 -0
  85. data/lib/tinderfridge/devices/bricklet_rs232_v2/bricklet_rs232_v2.json +11 -0
  86. data/lib/tinderfridge/devices/bricklet_rs485/bricklet_rs485.json +11 -0
  87. data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.json +11 -0
  88. data/lib/tinderfridge/devices/{bricklet_segment_display_4x7_v2.rb → bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb} +23 -1
  89. data/lib/tinderfridge/devices/bricklet_servo_v2/bricklet_servo_v2.json +11 -0
  90. data/lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json +11 -0
  91. data/lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.json +11 -0
  92. data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json +10 -0
  93. data/lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json +10 -0
  94. data/lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.json +10 -0
  95. data/lib/tinderfridge/devices/bricklet_thermal_imaging/bricklet_thermal_imaging.json +10 -0
  96. data/lib/tinderfridge/devices/bricklet_thermocouple_v2/bricklet_thermocouple_v2.json +10 -0
  97. data/lib/tinderfridge/devices/bricklet_uv_light_v2/bricklet_uv_light_v2.json +10 -0
  98. data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.json +10 -0
  99. data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.rb +18 -0
  100. data/lib/tinderfridge/devices/bricklet_xmc1400_breakout/bricklet_xmc1400_breakout.json +10 -0
  101. data/lib/tinderfridge/ip_connection.rb +56 -4
  102. data/lib/tinderfridge/tinkerforge.rb +3 -0
  103. data/lib/tinderfridge/version.rb +1 -1
  104. metadata +106 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f7d7c9860d6aa8495eef63beeca7be8d7122205b562c49d560d513bdd780c7f
4
- data.tar.gz: efc7ec85867758066b96df1ceccf63ff5b32eee7f0a29b7060560a2236cfe365
3
+ metadata.gz: c1f848437f1877596a58521fdbe213042f6561b42a91c91b60eca2fd3ab1a690
4
+ data.tar.gz: '09c7adcf40fabf6eae5ca89316428aeb6cabfa5f4abccbaaf27bd3901535afca'
5
5
  SHA512:
6
- metadata.gz: 8de0db5c9d6dc68b3f2fd18b434191e7b23c7bdff389b71918308846637e23fdc80b4880c3ee15b0f83b97e358a6751364c73795a1071bfe2e3ed0a99aeecf74
7
- data.tar.gz: 640bee0f79ea37182229abed010480cedbd079de16a3920623c5a6ee4cfca393482bb82d64924485a9b7b651afc194394c40bf76a787fbea8bf21e119b491f3d
6
+ metadata.gz: a84bc2687015ef1c65dd61cac031a7b6e6ff57e22a811784e6160dd5b002badf5f55f11c3883ffa754a6f42d0b5a6e5a085a4c930700c899956d06ec8f533d98
7
+ data.tar.gz: c12dcf3ef70b1111f665a3098ab213a75819c2953b3c7cb2ebc020bd00b016588ec70ca0bebbdf72666a84edcc4be345f7aaa67c8ee4f8841262c1fc4afb80a7
@@ -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
@@ -66,20 +67,42 @@ module Tinkerforge
66
67
  # Returns the device's IPConnection object.
67
68
  attr_reader :ipcon
68
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
+
69
80
  # Returns a programmer-friendly representation of the device.
70
81
  def inspect
71
82
  "%s (%s@%s:%s)" % [self.class, @uid_string, ipcon.host, ipcon.port]
72
83
  end
73
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
+
74
95
  # Returns the device's state.
75
96
  def state
97
+
98
+ # BrickDaemon inherits from Device, but has no #get_identity.
99
+ return {} unless respond_to? 'get_identity'
100
+
76
101
  identity = get_identity
77
102
 
78
103
  [
79
104
  [ 'uid' , uid_string ],
80
105
  [ 'update_time' , Time.now.gmtime ],
81
- [ 'device_identifier' , device_identifier ],
82
- [ 'device_display_name', device_display_name ],
83
106
  [ 'firmware_version' , identity[4].join('.') ],
84
107
 
85
108
  [ 'connected', { 'uid' => identity[1], 'position' => identity[2] } ],
@@ -92,6 +115,20 @@ module Tinkerforge
92
115
  ].compact.to_h
93
116
  end
94
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
+
95
132
  # Identifies a Tinkerforge device by blinking its status led.
96
133
  #
97
134
  # Supports recent devices. When invoked on older devices, does nothing.
@@ -112,5 +149,32 @@ module Tinkerforge
112
149
  end
113
150
  end
114
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
+
115
178
  end
179
+
116
180
  end
@@ -63,11 +63,27 @@ 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
+
66
73
  # Returns the state of devices in the collection.
67
74
  def state
68
75
  smap 'state'
69
76
  end
70
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
+
71
87
  # Turns off light sources such as screens and RGB LEDs for devices in the collection.
72
88
  #
73
89
  # Ignores devices that do not support the blackout method.
@@ -80,6 +96,42 @@ module Tinkerforge
80
96
  smap('ipcon').values.compact.uniq
81
97
  end
82
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
+
83
135
  private
84
136
 
85
137
  def smap(m)
@@ -139,3 +139,6 @@
139
139
  2157 Servo Bricklet 2.0 Tinkerforge::BrickletServoV2 bricklet_servo_v2
140
140
  2161 IMU Bricklet 3.0 Tinkerforge::BrickletIMUV3 bricklet_imu_v3
141
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,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,11 @@
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/Accelerometer_V2.html",
9
+ "versions_identifier": "bricklets:accelerometer_v2",
10
+ "released": "2019-01-29"
11
+ }
@@ -0,0 +1,11 @@
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
+ "released": "2018-09-27"
11
+ }
@@ -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,11 @@
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
+ "released": "2018-09-27"
11
+ }
@@ -0,0 +1,11 @@
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
+ "released": "2018-09-27"
11
+ }
@@ -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
@@ -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/Compass.html",
9
+ "versions_identifier": "bricklets:compass"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 40,
4
+ 40,
5
+ 15
6
+ ],
7
+ "weight": 12,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/DC_V2.html",
9
+ "versions_identifier": "bricklets:dc_v2",
10
+ "released": "2021-05-04"
11
+ }