Class: Spektrum::Log::BasicDataRecord

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) ⇒ BasicDataRecord

Returns a new instance of BasicDataRecord.



74
75
76
# File 'lib/spektrum/log/records.rb', line 74

def initialize(timestamp, raw_data)
  super timestamp, raw_data
end

Instance Method Details

#rpm(pole_count) ⇒ Object



78
79
80
# File 'lib/spektrum/log/records.rb', line 78

def rpm(pole_count)
  raw_rpm * pole_count
end

#rpm?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/spektrum/log/records.rb', line 82

def rpm?
  raw_rpm != 0xFFFF
end

#temperature(unit = :f) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/spektrum/log/records.rb', line 101

def temperature(unit = :f)
  @temperature ||= two_byte_field(6..7)
  case unit
  when :f
    @temperature
  when :c
    (@temperature - 32) * (5.0 / 9.0)
  else
    @temperature
  end
end

#temperature?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/spektrum/log/records.rb', line 113

def temperature?
  self.temperature != 0x7FFF
end

#voltageFloat

Note:

This conversion has been verified via Spektrum STi

Gets the flight pack voltage data.

Returns:

  • (Float)

    flight voltage data, in volts



90
91
92
# File 'lib/spektrum/log/records.rb', line 90

def voltage
  raw_voltage / 100.0
end

#voltage?Boolean

Determines if there is flight voltage data contained within.

Returns:

  • (Boolean)

    true if there is flight voltage data, false otherwise



97
98
99
# File 'lib/spektrum/log/records.rb', line 97

def voltage?
  raw_voltage != 0xFFFF
end