Class: Spektrum::Log::GPSRecord2

Inherits:
Record
  • Object
show all
Defined in:
lib/spektrum/log/records.rb

Instance Attribute Summary

Attributes inherited from Record

#timestamp

Instance Method Summary collapse

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(timestamp, raw_data)
  super timestamp, raw_data
end

Instance Method Details

#satellitesInteger

Note:

This conversion has been verified via Spektrum STi

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

Returns:

  • (Integer)

    number of active satellites



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.

Parameters:

  • unit (defaults to: :knots)

    one of :knots, :mph, :kph to define desired unit

Returns:

  • (Float)

    speed in the 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

#timeString

Note:

This conversion has been verified via Spektrum STi

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

Returns:

  • (String)

    UTC 24-hour time



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