NAME
Device::Spektrum::Packet - Represent a packet of Spektrum data
SYNOPSIS
use Device::Spektrum::Packet;
my $packet = Device::Spektrum::Packet->new({
throttle => 170,
aileron => 200,
elevator => 250,
rudder => 800,
gear => SPEKTRUM_LOW,
aux1 => SPEKTRUM_MIDDLE,
aux2 => SPEKTRUM_HIGH,
# Optional; may correct problems with buggy implementations
field_order => [qw(
throttle
aileron
elevator
rudder
gear
aux1
aux2
)],
});
my $encoded_packet = $packet->encode_packet;
DESCRIPTION
Represents a single packet of Spektrum data.
ATTRIBUTES
throttle
aileron
elevator
rudder
gear
aux1
aux2
Each attribute takes an integer. These are typically in between 170 (exported as SPEKTRUM_LOW
) and 853 (SPEKTRUM_HIGH
). The protocol is technically capable of values between 0 and 1023, but servos and flight controllers may not be well-behaved outside the typical range.
There is also a field_order
parameter, which shouldn't be necessary, because the protocol uses a few identifier bits for each channel. However, some implementations out there hardcode the channel order to what common Spektrum recievers put out, so you may need to work around them with this parameter.
METHODS
encode_packet
Return a byte string containing the encoded packet.
LICENSE
Copyright (c) 2015, Timm Murray All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.