Class: Spektrum::Log::GPSRecord2
- Defined in:
- lib/spektrum/log/records.rb
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
-
#initialize(timestamp, raw_data) ⇒ GPSRecord2
constructor
A new instance of GPSRecord2.
-
#satellites ⇒ Integer
Gets the number of satellites currently visible and in-use.
-
#speed(unit = :knots) ⇒ Float
Gets the speed, in desired unit.
-
#time ⇒ String
Gets the UTC 24-hour time.
Methods inherited from Record
#raw_hex_string, #type, #valid?
Constructor Details
#initialize(timestamp, raw_data) ⇒ GPSRecord2
Returns a new instance of GPSRecord2.
284 285 286 |
# File 'lib/spektrum/log/records.rb', line 284 def initialize(, raw_data) super , raw_data end |
Instance Method Details
#satellites ⇒ Integer
Note:
This conversion has been verified via Spektrum STi
Gets the number of satellites currently visible and in-use.
319 320 321 |
# File 'lib/spektrum/log/records.rb', line 319 def satellites @satellites ||= hex_byte_field(8) end |
#speed(unit = :knots) ⇒ Float
Note:
This conversion has been verified via Spektrum STi
Gets the speed, in desired unit.
293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/spektrum/log/records.rb', line 293 def speed(unit = :knots) @speed ||= (hex_byte_field(3) * 100) + hex_byte_field(2) case unit when :knots @speed / 10.0 when :mph @speed * 0.115078 when :kph @speed * 0.1852 else @speed end end |
#time ⇒ String
Note:
This conversion has been verified via Spektrum STi
Gets the UTC 24-hour time. In the format: ‘HH:MM:SS:CS’ (CS=centiseconds).
311 312 313 |
# File 'lib/spektrum/log/records.rb', line 311 def time @time ||= '%.2i:%.2i:%.2i.%.2i' % 7.downto(4).map { |i| hex_byte_field(i) } end |