spektrum-log 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c52d0345d2a7d9f48430b3a68cee624fcaacd8c2
4
- data.tar.gz: fbf6b7ebec0feb0a04320cc02537145f6334be51
3
+ metadata.gz: 2d30cad8f6f6191ef4faa750cba19e147da9cf40
4
+ data.tar.gz: 8bdcb97ee0a0d330aa66decf6a03d2f234693d65
5
5
  SHA512:
6
- metadata.gz: ddf724bdbd0bb8129cc90edae12fb393a853f75172f2002484905ffa342010cceeac239173baba2a9f7f2def987a4167a1d2813a21088b6f60ee462f3688d4ca
7
- data.tar.gz: 7808def78f5ddee8bf6a0782dbf75703047800a69b030fc2c157819c35a8d96de715d3fe71879ba931b61ef66420d0cafb03b046b261508ed282a6161874cd3f
6
+ metadata.gz: 23fd531279aa135335a98809ab1cfb7c699587ea834bf7d8e8836c1e8f0ad745a948bb4ec4b50a0b50c72fc7cbbe20a076f7963799df4772580b38ace59831e9
7
+ data.tar.gz: 9e3d46610b18f52760f362150dc3d9d2a600659c03f984435b0cadc82bef010aad53dcca7355b800e8abb914f43644f85a545037b55a4e5f051e8ceae2051e55
@@ -83,10 +83,17 @@ module Spektrum
83
83
  raw_rpm != 0xFFFF
84
84
  end
85
85
 
86
+ # Gets the flight pack voltage data.
87
+ #
88
+ # @return [Float] flight voltage data, in volts
89
+ # @note This conversion has been verified via Spektrum STi
86
90
  def voltage
87
91
  raw_voltage / 100.0
88
92
  end
89
93
 
94
+ # Determines if there is flight voltage data contained within.
95
+ #
96
+ # @return [Boolean] true if there is flight voltage data, false otherwise
90
97
  def voltage?
91
98
  raw_voltage != 0xFFFF
92
99
  end
@@ -128,6 +135,7 @@ module Spektrum
128
135
  # Gets the receiver pack voltage data.
129
136
  #
130
137
  # @return [Float] rx voltage data, in volts
138
+ # @note This conversion has been verified via Spektrum STi
131
139
  def rx_voltage
132
140
  raw_rx_voltage / 100.0
133
141
  end
@@ -315,24 +323,38 @@ module Spektrum
315
323
 
316
324
  end
317
325
 
318
- class MysteryRecord < Record
326
+ class SpeedRecord < Record
319
327
 
320
328
  def initialize timestamp, raw_data
321
329
  super timestamp, raw_data
322
330
  end
323
331
 
332
+ # Gets the speed, in desired unit.
333
+ #
334
+ # @param unit one of :knots, :mph, :kph to define desired unit
335
+ # @return [Float] speed in the desired unit
336
+ def speed(unit = :knots)
337
+ @speed ||= two_byte_field(2..3)
338
+ case unit
339
+ when :knots
340
+ @speed * 0.539957
341
+ when :mph
342
+ @speed * 0.621371
343
+ when :kph
344
+ @speed
345
+ else
346
+ @speed
347
+ end
348
+ end
349
+
324
350
  end
325
351
 
326
- class SpeedRecord < Record
352
+ class MysteryRecord < Record
327
353
 
328
354
  def initialize timestamp, raw_data
329
355
  super timestamp, raw_data
330
356
  end
331
357
 
332
- def speed
333
- @speed ||= two_byte_field(2..3)
334
- end
335
-
336
358
  end
337
359
 
338
360
  class Records
@@ -1,5 +1,5 @@
1
1
  module Spektrum
2
2
  module Log
3
- VERSION = "0.0.19"
3
+ VERSION = "0.0.20"
4
4
  end
5
5
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spektrum::Log::SpeedRecord do
4
+
5
+ let(:timestamp) { 0xC67C0FE2 }
6
+
7
+ let(:raw_data) { ["1100010501F900000000000000000000"].pack('H*') }
8
+
9
+ subject { Spektrum::Log::SpeedRecord.new(timestamp, raw_data) }
10
+
11
+ its(:timestamp) { should eql(0xC67C0FE2) }
12
+
13
+ it 'should have a speed in mph' do
14
+ subject.speed(:mph).should be_within(0.1).of(162.2)
15
+ end
16
+
17
+ it 'should have a speed in kph' do
18
+ subject.speed(:kph).should be_within(0.1).of(261)
19
+ end
20
+
21
+ its(:speed) { should be_within(0.1).of(140.9) }
22
+
23
+ it 'should have a speed in knots' do
24
+ subject.speed(:knots).should be_within(0.1).of(140.9)
25
+ end
26
+
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spektrum-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-14 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -188,6 +188,7 @@ files:
188
188
  - spec/gps_record1_spec.rb
189
189
  - spec/gps_record2_spec.rb
190
190
  - spec/spec_helper.rb
191
+ - spec/speed_record_spec.rb
191
192
  - spektrum-log.gemspec
192
193
  homepage: ''
193
194
  licenses:
@@ -246,3 +247,4 @@ test_files:
246
247
  - spec/gps_record1_spec.rb
247
248
  - spec/gps_record2_spec.rb
248
249
  - spec/spec_helper.rb
250
+ - spec/speed_record_spec.rb