tinderfridge 0.5.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinderfridge/device.rb +101 -6
  3. data/lib/tinderfridge/device_collection.rb +19 -1
  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/brick_master/brick_master.json +11 -0
  10. data/lib/tinderfridge/devices/brick_master/brick_master.rb +11 -0
  11. data/lib/tinderfridge/devices/bricklet_accelerometer_v2/bricklet_accelerometer_v2.json +11 -0
  12. data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json +11 -0
  13. data/lib/tinderfridge/devices/{bricklet_air_quality.rb → bricklet_air_quality/bricklet_air_quality.rb} +0 -0
  14. data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.json +11 -0
  15. data/lib/tinderfridge/devices/{bricklet_ambient_light_v3.rb → bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb} +0 -0
  16. data/lib/tinderfridge/devices/bricklet_analog_in_v3/bricklet_analog_in_v3.json +10 -0
  17. data/lib/tinderfridge/devices/bricklet_analog_out_v3/bricklet_analog_out_v3.json +11 -0
  18. data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json +11 -0
  19. data/lib/tinderfridge/devices/bricklet_can_v2/bricklet_can_v2.json +11 -0
  20. data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json +11 -0
  21. data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.rb +19 -0
  22. data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json +11 -0
  23. data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.rb +31 -0
  24. data/lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json +11 -0
  25. data/lib/tinderfridge/devices/bricklet_dc_v2/bricklet_dc_v2.json +11 -0
  26. data/lib/tinderfridge/devices/bricklet_distance_ir_v2/bricklet_distance_ir_v2.json +11 -0
  27. data/lib/tinderfridge/devices/bricklet_distance_us_v2/bricklet_distance_us_v2.json +10 -0
  28. data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.json +10 -0
  29. data/lib/tinderfridge/devices/{bricklet_dmx.rb → bricklet_dmx/bricklet_dmx.rb} +0 -0
  30. data/lib/tinderfridge/devices/bricklet_dual_button_v2/bricklet_dual_button_v2.json +11 -0
  31. data/lib/tinderfridge/devices/bricklet_e_paper_296x128/bricklet_e_paper_296x128.json +10 -0
  32. data/lib/tinderfridge/devices/bricklet_energy_monitor/bricklet_energy_monitor.json +10 -0
  33. data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.json +11 -0
  34. data/lib/tinderfridge/devices/{bricklet_gps_v2.rb → bricklet_gps_v2/bricklet_gps_v2.rb} +14 -1
  35. data/lib/tinderfridge/devices/bricklet_hall_effect_v2/bricklet_hall_effect_v2.json +10 -0
  36. data/lib/tinderfridge/devices/bricklet_humidity_v2/bricklet_humidity_v2.json +10 -0
  37. data/lib/tinderfridge/devices/bricklet_imu_v3/bricklet_imu_v3.json +10 -0
  38. data/lib/tinderfridge/devices/bricklet_industrial_analog_out_v2/bricklet_industrial_analog_out_v2.json +11 -0
  39. data/lib/tinderfridge/devices/bricklet_industrial_counter/bricklet_industrial_counter.json +11 -0
  40. data/lib/tinderfridge/devices/bricklet_industrial_digital_in_4_v2/bricklet_industrial_digital_in_4_v2.json +11 -0
  41. data/lib/tinderfridge/devices/bricklet_industrial_digital_out_4_v2/bricklet_industrial_digital_out_4_v2.json +11 -0
  42. data/lib/tinderfridge/devices/bricklet_industrial_dual_0_20ma_v2/bricklet_industrial_dual_0_20ma_v2.json +11 -0
  43. data/lib/tinderfridge/devices/bricklet_industrial_dual_ac_relay/bricklet_industrial_dual_ac_relay.json +11 -0
  44. data/lib/tinderfridge/devices/bricklet_industrial_dual_analog_in_v2/bricklet_industrial_dual_analog_in_v2.json +11 -0
  45. data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.json +10 -0
  46. data/lib/tinderfridge/devices/{bricklet_industrial_dual_relay.rb → bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb} +0 -0
  47. data/lib/tinderfridge/devices/bricklet_industrial_ptc/bricklet_industrial_ptc.json +11 -0
  48. data/lib/tinderfridge/devices/bricklet_industrial_quad_relay_v2/bricklet_industrial_quad_relay_v2.json +11 -0
  49. data/lib/tinderfridge/devices/bricklet_io16_v2/bricklet_io16_v2.json +11 -0
  50. data/lib/tinderfridge/devices/bricklet_io4_v2/bricklet_io4_v2.json +11 -0
  51. data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.json +10 -0
  52. data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.rb +17 -0
  53. data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.json +10 -0
  54. data/lib/tinderfridge/devices/{bricklet_joystick_v2.rb → bricklet_joystick_v2/bricklet_joystick_v2.rb} +0 -0
  55. data/lib/tinderfridge/devices/bricklet_laser_range_finder_v2/bricklet_laser_range_finder_v2.json +10 -0
  56. data/lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.json +10 -0
  57. data/lib/tinderfridge/devices/{bricklet_lcd_128x64.rb → bricklet_lcd_128x64/bricklet_lcd_128x64.rb} +0 -0
  58. data/lib/tinderfridge/devices/bricklet_led_strip_v2/bricklet_led_strip_v2.json +11 -0
  59. data/lib/tinderfridge/devices/{bricklet_led_strip_v2.rb → bricklet_led_strip_v2/bricklet_led_strip_v2.rb} +0 -0
  60. data/lib/tinderfridge/devices/bricklet_linear_poti_v2/bricklet_linear_poti_v2.json +10 -0
  61. data/lib/tinderfridge/devices/bricklet_load_cell_v2/bricklet_load_cell_v2.json +11 -0
  62. data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.json +11 -0
  63. data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.rb +22 -0
  64. data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.json +10 -0
  65. data/lib/tinderfridge/devices/{bricklet_motorized_linear_poti.rb → bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb} +0 -0
  66. data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.json +11 -0
  67. data/lib/tinderfridge/devices/{bricklet_multi_touch_v2.rb → bricklet_multi_touch_v2/bricklet_multi_touch_v2.rb} +0 -0
  68. data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.json +10 -0
  69. data/lib/tinderfridge/devices/{bricklet_nfc.rb → bricklet_nfc/bricklet_nfc.rb} +0 -0
  70. data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.json +11 -0
  71. data/lib/tinderfridge/devices/bricklet_one_wire/bricklet_one_wire.json +11 -0
  72. data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.json +10 -0
  73. data/lib/tinderfridge/devices/{bricklet_outdoor_weather.rb → bricklet_outdoor_weather/bricklet_outdoor_weather.rb} +0 -0
  74. data/lib/tinderfridge/devices/bricklet_particulate_matter/bricklet_particulate_matter.json +11 -0
  75. data/lib/tinderfridge/devices/bricklet_performance_dc/bricklet_performance_dc.json +11 -0
  76. data/lib/tinderfridge/devices/bricklet_piezo_speaker_v2/bricklet_piezo_speaker_v2.json +10 -0
  77. data/lib/tinderfridge/devices/bricklet_ptc_v2/bricklet_ptc_v2.json +11 -0
  78. data/lib/tinderfridge/devices/bricklet_real_time_clock_v2/bricklet_real_time_clock_v2.json +10 -0
  79. data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.json +11 -0
  80. data/lib/tinderfridge/devices/{bricklet_remote_switch_v2.rb → bricklet_remote_switch_v2/bricklet_remote_switch_v2.rb} +0 -0
  81. data/lib/tinderfridge/devices/bricklet_rgb_led_button/bricklet_rgb_led_button.json +10 -0
  82. data/lib/tinderfridge/devices/{bricklet_rgb_led_button.rb → bricklet_rgb_led_button/bricklet_rgb_led_button.rb} +1 -1
  83. data/lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.json +10 -0
  84. data/lib/tinderfridge/devices/{bricklet_rgb_led_v2.rb → bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb} +0 -0
  85. data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.json +10 -0
  86. data/lib/tinderfridge/devices/{bricklet_rotary_encoder_v2.rb → bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.rb} +0 -0
  87. data/lib/tinderfridge/devices/bricklet_rotary_poti_v2/bricklet_rotary_poti_v2.json +10 -0
  88. data/lib/tinderfridge/devices/bricklet_rs232_v2/bricklet_rs232_v2.json +11 -0
  89. data/lib/tinderfridge/devices/bricklet_rs485/bricklet_rs485.json +11 -0
  90. data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.json +11 -0
  91. data/lib/tinderfridge/devices/{bricklet_segment_display_4x7_v2.rb → bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb} +25 -1
  92. data/lib/tinderfridge/devices/bricklet_servo_v2/bricklet_servo_v2.json +11 -0
  93. data/lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json +11 -0
  94. data/lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.json +11 -0
  95. data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json +11 -0
  96. data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.rb +20 -0
  97. data/lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json +10 -0
  98. data/lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.json +10 -0
  99. data/lib/tinderfridge/devices/bricklet_thermal_imaging/bricklet_thermal_imaging.json +10 -0
  100. data/lib/tinderfridge/devices/bricklet_thermocouple_v2/bricklet_thermocouple_v2.json +10 -0
  101. data/lib/tinderfridge/devices/bricklet_uv_light_v2/bricklet_uv_light_v2.json +10 -0
  102. data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.json +10 -0
  103. data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.rb +18 -0
  104. data/lib/tinderfridge/devices/bricklet_xmc1400_breakout/bricklet_xmc1400_breakout.json +10 -0
  105. data/lib/tinderfridge/ip_connection.rb +51 -4
  106. data/lib/tinderfridge/tinkerforge.rb +3 -0
  107. data/lib/tinderfridge/version.rb +1 -1
  108. metadata +110 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7b851b2ea04d7ab8385d6ca4f11cece38721b4cb09dd7afbd449e84d9e4e2a7
4
- data.tar.gz: 19e264699bc41886fe56fa954339d04b118994d39990cb0e834d7a8b5fb1f0e2
3
+ metadata.gz: 26a171ddfc01502cca8300d445d498c960b8cfb1304e1b60fddc5d33ad0a68ba
4
+ data.tar.gz: ebf5e97bd0fe072375c6a548615baff3e42ef77432b96373035571a41897ba8a
5
5
  SHA512:
6
- metadata.gz: 7694f3b62443011a1658034d015a50485f491cee038ce87f820b58e35bf017ce857a21a25a8aae33b92602164100e04a50fc5094679da1164a0592a845852b5b
7
- data.tar.gz: fd7b21aac321ae3b25be1857da5e6c91cbc26d7f3bc839fd5934774de35dd9730a5bdfa13ed103f8d4d3bfb4f533d87a325f01f20ec6db30991a24511a0f6e7d
6
+ metadata.gz: e5a6e8d3f54c3955afbbce8d48c1ded48ea46535dd078cc6118d207bf988634c7e04fbcab178a5b440ea5ff55798287df53f94465a06e0971a5d0282876f532f
7
+ data.tar.gz: 31d5cbea577e5b98279279193301e2a95062db29d7150149c3035ecb639f4301ce739854927f018fa922a9630bea7217c76dfb0329ccc5e88359b73f7c4fc7fe
@@ -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
@@ -81,32 +82,85 @@ module Tinkerforge
81
82
  "%s (%s@%s:%s)" % [self.class, @uid_string, ipcon.host, ipcon.port]
82
83
  end
83
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
+
84
95
  # Returns the device's state.
85
96
  def state
97
+
98
+ # BrickDaemon inherits from Device, but has no #get_identity.
99
+ return {} unless respond_to? 'get_identity'
100
+
86
101
  identity = get_identity
87
102
 
88
103
  [
89
104
  [ 'uid' , uid_string ],
90
105
  [ 'update_time' , Time.now.gmtime ],
91
- [ 'device_identifier' , device_identifier ],
92
- [ 'device_display_name', device_display_name ],
93
106
  [ 'firmware_version' , identity[4].join('.') ],
94
107
 
95
108
  [ 'connected', { 'uid' => identity[1], 'position' => identity[2] } ],
96
109
  [ 'ipcon' , { 'host' => ipcon.host , 'port' => ipcon.port } ],
97
110
 
98
111
  respond_to?('get_chip_temperature' ) ? [ 'chip_temperature' , get_chip_temperature ] : nil,
99
- respond_to?('get_spitfp_error_count') ? [ 'spitfp_error_count', get_spitfp_error_count ] : nil,
112
+
113
+ if respond_to?('get_spitfp_error_count') and (method(:get_spitfp_error_count).arity == 0)
114
+ [ 'spitfp_error_count', get_spitfp_error_count ]
115
+ else
116
+ nil
117
+ end,
118
+
100
119
  respond_to?('get_status_led_config' ) ? [ 'status_led_config' , get_status_led_config ] : nil,
101
120
 
102
121
  ].compact.to_h
103
122
  end
104
123
 
124
+ # Opens the online documentation for the device (Mac OS only).
125
+ #
126
+ # When the URL for the documentation is not known, does nothing.
127
+ def open_documentation
128
+ if properties['documentation_en_url'] and ( RUBY_PLATFORM =~ /darwin/ )
129
+ `open #{properties['documentation_en_url']}`
130
+ properties['documentation_en_url']
131
+ else
132
+ nil
133
+ end
134
+ end
135
+
136
+ alias doc open_documentation
137
+
105
138
  # Identifies a Tinkerforge device by blinking its status led.
106
139
  #
107
- # Supports recent devices. When invoked on older devices, does nothing.
140
+ # Supports recent devices. When invoked on some older devices, does nothing.
108
141
  def identify(seconds=10)
109
- if (respond_to? 'get_status_led_config') and (respond_to? 'set_status_led_config')
142
+ case status_led_api_variety
143
+ when 1
144
+ seconds = seconds.to_i
145
+ state = is_status_led_enabled
146
+
147
+ (seconds*2).times do |n|
148
+ if n.even?
149
+ disable_status_led
150
+ else
151
+ enable_status_led
152
+ end
153
+ sleep 0.5
154
+ end
155
+
156
+ if state
157
+ enable_status_led
158
+ else
159
+ disable_status_led
160
+ end
161
+
162
+ seconds
163
+ when 2
110
164
  seconds = seconds.to_i
111
165
  state = get_status_led_config
112
166
 
@@ -122,5 +176,46 @@ module Tinkerforge
122
176
  end
123
177
  end
124
178
 
179
+ private
180
+
181
+ def load_properties
182
+ if device_info
183
+ properties_file = File.join(
184
+ File.dirname(__FILE__),
185
+ 'devices',
186
+ device_info[2][1],
187
+ device_info[2][1],
188
+ ) + '.json'
189
+
190
+ if File.readable? properties_file
191
+ begin
192
+ require 'json'
193
+ JSON.load File.read properties_file
194
+ rescue
195
+ {}
196
+ end
197
+ else
198
+ {}
199
+ end
200
+ else
201
+ {}
202
+ end
203
+ end
204
+
205
+ def status_led_api_variety
206
+ @status_led_api_variety ||=
207
+ if ( respond_to?('get_status_led_config') &&
208
+ respond_to?('set_status_led_config') )
209
+ 2
210
+ elsif ( respond_to?('is_status_led_enabled') &&
211
+ respond_to?('enable_status_led') &&
212
+ respond_to?('disable_status_led') )
213
+ 1
214
+ else
215
+ nil
216
+ end
217
+ end
218
+
125
219
  end
220
+
126
221
  end
@@ -5,6 +5,8 @@ module Tinkerforge
5
5
  # Returns the temperatures as measured inside the microcontrollers of devices in the collection.
6
6
  #
7
7
  # Nil for devices that do not support the get_chip_temperature method.
8
+ #
9
+ # Note: most devices return temperature in °C, but a few return temperature in 1/10 °C.
8
10
  def get_chip_temperature
9
11
  smap 'get_chip_temperature'
10
12
  end
@@ -63,11 +65,27 @@ module Tinkerforge
63
65
  end.size
64
66
  end
65
67
 
68
+ # Returns the properties of devices in the collection.
69
+ def properties
70
+ smap 'properties'
71
+ end
72
+
73
+ alias props properties
74
+
66
75
  # Returns the state of devices in the collection.
67
76
  def state
68
77
  smap 'state'
69
78
  end
70
79
 
80
+ # Opens the online documentation for the devices in the collection (Mac OS only).
81
+ #
82
+ # When the URL for a device's documentation is not known, does nothing.
83
+ def open_documentation
84
+ smap 'open_documentation'
85
+ end
86
+
87
+ alias doc open_documentation
88
+
71
89
  # Turns off light sources such as screens and RGB LEDs for devices in the collection.
72
90
  #
73
91
  # Ignores devices that do not support the blackout method.
@@ -119,7 +137,7 @@ module Tinkerforge
119
137
  private
120
138
 
121
139
  def smap(m)
122
- map { |k,d| [ k, d.respond_to?(m) ? d.send(m) : nil ] }.to_h
140
+ map { |k,d| [ k, ( d.respond_to?(m) and (d.method(m).arity == 0) ) ? d.send(m) : nil ] }.to_h
123
141
  end
124
142
 
125
143
  end
@@ -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
+ 40,
4
+ 40,
5
+ 16
6
+ ],
7
+ "weight": 12,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricks/Master_Brick.html",
9
+ "versions_identifier": "bricks:master",
10
+ "released": ""
11
+ }
@@ -0,0 +1,11 @@
1
+ module Tinkerforge
2
+
3
+ class BrickMaster
4
+
5
+ # Unit returned by #get_chip_temperature. Master Bricks return temperature as 1/10 °C.
6
+ CHIP_TEMPERATURE_UNIT = 0.1
7
+ # REVIEW: This should ideally be part of base Tinkerforge.
8
+
9
+ end
10
+
11
+ end
@@ -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,11 @@
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
+ "released": "2019-01-29"
11
+ }
@@ -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,11 @@
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
+ "released": "2019-05-20"
11
+ }
@@ -0,0 +1,19 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletCO2V2
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ av = get_all_values
8
+ super.merge(
9
+ 'co2_concentration' => av[0],
10
+ 'temperature' => av[1],
11
+ 'temperature_offset' => get_temperature_offset,
12
+ 'humidity' => av[2],
13
+ 'air_pressure' => get_air_pressure,
14
+ )
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -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/Color_V2.html",
9
+ "versions_identifier": "bricklets:color_v2",
10
+ "released": "2019-08-22"
11
+ }
@@ -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,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/Compass.html",
9
+ "versions_identifier": "bricklets:compass",
10
+ "released": "2019-08-22"
11
+ }
@@ -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
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 45,
4
+ 13,
5
+ 5
6
+ ],
7
+ "weight": 8,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Distance_IR_V2.html",
9
+ "versions_identifier": "bricklets:distance_ir_v2",
10
+ "released": "2018-09-27"
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 35,
4
+ 35,
5
+ 20
6
+ ],
7
+ "weight": 9,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Distance_US_V2.html",
9
+ "versions_identifier": "bricklets:distance_us_v2"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 60,
4
+ 50,
5
+ 30
6
+ ],
7
+ "weight": 30,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/DMX.html",
9
+ "versions_identifier": "bricklets:dmx"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 45,
4
+ 20,
5
+ 10
6
+ ],
7
+ "weight": 5.5,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Dual_Button_V2.html",
9
+ "versions_identifier": "bricklets:dual_button_v2",
10
+ "released": "2018-09-27"
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 100,
4
+ 40,
5
+ 6
6
+ ],
7
+ "weight": 20,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/EPaper_296x128.html",
9
+ "versions_identifier": "bricklets:e_paper_296x128"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 40,
4
+ 40,
5
+ 5
6
+ ],
7
+ "weight": 7,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Energy_Monitor.html",
9
+ "versions_identifier": "bricklets:energy_monitor"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 40,
4
+ 35,
5
+ 12
6
+ ],
7
+ "weight": 20,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/GPS_V2.html",
9
+ "versions_identifier": "bricklets:gps_v2",
10
+ "released": "2017-05-11"
11
+ }
@@ -2,11 +2,24 @@ module Tinkerforge
2
2
 
3
3
  class BrickletGPSV2
4
4
 
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'fix_led_config' => get_fix_led_config,
9
+ 'fix' => fix?,
10
+ )
11
+ end
12
+
13
+ # Returns true if a fix is available.
14
+ def fix?
15
+ get_status[0]
16
+ end
17
+
5
18
  # Returns latitude and longitude as reported by the GPS Bricklet.
6
19
  #
7
20
  # Nil when there is no fix (position not determined).
8
21
  def coordinates
9
- if get_status[0]
22
+ if fix?
10
23
  c = get_coordinates
11
24
  [
12
25
  c[0] / (c[1] == 'N' ? 1000000.0 : -1000000.0),
@@ -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/Hall_Effect_V2.html",
9
+ "versions_identifier": "bricklets:hall_effect_v2"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 25,
4
+ 15,
5
+ 5
6
+ ],
7
+ "weight": 3,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Humidity_V2.html",
9
+ "versions_identifier": "bricklets:humidity_v2"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "dimensions": [
3
+ 25,
4
+ 25,
5
+ 5
6
+ ],
7
+ "weight": 3,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/IMU_V3.html",
9
+ "versions_identifier": "bricklets:imu_v3"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 40,
4
+ 40,
5
+ 11
6
+ ],
7
+ "weight": 9,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_Analog_Out_V2.html",
9
+ "versions_identifier": "bricklets:industrial_analog_out_v2",
10
+ "released": "2018-09-27"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 40,
4
+ 40,
5
+ 11
6
+ ],
7
+ "weight": 8.4,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_Counter.html",
9
+ "versions_identifier": "bricklets:industrial_counter",
10
+ "released": "2018-06-07"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "dimensions": [
3
+ 40,
4
+ 40,
5
+ 11
6
+ ],
7
+ "weight": 8.6,
8
+ "documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_Digital_In_4_V2.html",
9
+ "versions_identifier": "bricklets:industrial_digital_in_4_v2",
10
+ "released": "2018-06-07"
11
+ }