class Spektrum::Log::GPSRecord2

Public Class Methods

new(timestamp, raw_data) click to toggle source
Calls superclass method Spektrum::Log::Record::new
# File lib/spektrum/log/records.rb, line 284
def initialize(timestamp, raw_data)
  super timestamp, raw_data
end

Public Instance Methods

satellites() click to toggle source

Gets the number of satellites currently visible and in-use.

@return [Integer] number of active satellites @note This conversion has been verified via Spektrum STi

# File lib/spektrum/log/records.rb, line 319
def satellites
  @satellites ||= hex_byte_field(8)
end
speed(unit = :knots) click to toggle source

Gets the speed, in desired unit.

@param unit one of :knots, :mph, :kph to define desired unit @return [Float] speed in the desired unit @note This conversion has been verified via Spektrum STi

# 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() click to toggle source

Gets the UTC 24-hour time. In the format: 'HH:MM:SS:CS' (CS=centiseconds).

@return [String] UTC 24-hour time @note This conversion has been verified via Spektrum STi

# 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