Skip to content

Commit

Permalink
Tarot v1.50 support
Browse files Browse the repository at this point in the history
  • Loading branch information
cemizm committed Jul 7, 2016
1 parent e4e461d commit fca4e32
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 63 deletions.
7 changes: 0 additions & 7 deletions Firmware/Bootloader/.project
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>libs/spiffs</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/shared/Middleware/spiffs</locationURI>
</link>
</linkedResources>
</projectDescription>
2 changes: 1 addition & 1 deletion Firmware/Pro/include/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <Timer.h>
#include <I2C.h>

#define FIRMWARE_VERSION 0x02020100
#define FIRMWARE_VERSION 0x02020200
#define HARDWARE_VERSION 0x01

namespace Board
Expand Down
Binary file modified Firmware/Releases/AnySensePro.bin
Binary file not shown.
85 changes: 47 additions & 38 deletions Firmware/shared/Application/include/FCTarot.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,62 +30,69 @@ class FCTarot: public FCAdapter, public HAL::InterruptHandler

enum PaketType
{
GPS = 1,
RC = 2,
HomeData = 3,
RC = 1, GPS = 2, Battery = 3, Time = 4,
};

struct GPSType
struct RCType //Paket 1
{
int32_t Longitude;
int32_t Latitude;
int16_t Altitude;
int16_t Speed;
int16_t Speed2;
int16_t Climb;
uint8_t unk1[2];
uint16_t Voltage;
uint8_t unk2[9];
uint8_t Failsafe;
uint8_t Flightmode;
uint8_t unk3[2];
uint8_t Satellites;
uint8_t unk4[4];
}__attribute__((packed, aligned(1)));

struct RCType
{
int16_t GyroX;
int16_t GyroY;
int16_t GyroZ;
int16_t AccX;
int16_t AccY;
int16_t AccZ;
int16_t Altitude;
int8_t Aileron;
int8_t Elevator;
int8_t Throttle;
int8_t Rudder;
int8_t Mode;
int8_t unk1;
int8_t unused;
int8_t GoHome;
int8_t IOC;
int8_t Gear;
int8_t GimbalTilt;
int8_t CamSwitch;
int8_t InfoSwitch;
int8_t unk2[4];
uint8_t RCConnected;
uint8_t unk1[15];
uint8_t Armed;
uint8_t unk3[6];
uint8_t Failsafe;
uint8_t unk2;
uint8_t Flightmode;
uint8_t unk3[2];
uint8_t Satellites;
uint8_t unk4[4];
}__attribute__((packed, aligned(1)));

struct HomeDataType
struct GPSType //Paket 2
{
int32_t HomeLongitude;
int32_t HomeLatitude;
int16_t HomeAltitude;
int32_t Longitude;
int32_t Latitude;
int16_t Altitude;
uint8_t unk1[28];
int16_t Speed;
int16_t Speed2;
int16_t Climb;

int16_t GyroX;
int16_t GyroY;
int16_t GyroZ;
int16_t AccX;
int16_t AccY;
int16_t AccZ;

}__attribute__((packed, aligned(1)));

struct BatteryType
{
uint8_t unk1[18];
int16_t RawAltitude1;
uint8_t unk2[2];
int16_t Voltage;
int16_t RawAltitude2;
uint8_t unk3[12];
}__attribute__((packed, aligned(1)));

struct TimeType
{
uint32_t Time;
uint16_t unk2;
uint8_t unk1[32];
}__attribute__((packed, aligned(1)));

struct Paket
Expand All @@ -107,7 +114,8 @@ class FCTarot: public FCAdapter, public HAL::InterruptHandler
uint8_t ContentData[PacketContentSize];
GPSType GPS;
RCType RC;
HomeDataType HomeData;
BatteryType Battery;
TimeType Time;
};
uint16_t CRC;
}__attribute__((packed, aligned(1)));
Expand All @@ -121,9 +129,10 @@ class FCTarot: public FCAdapter, public HAL::InterruptHandler
uint8_t m_processIndex;

void Process(Paket& paket);
void Process(GPSType& data);
void Process(RCType& data);
void Process(HomeDataType& data);
void Process(GPSType& data);
void Process(BatteryType& data);
void Process(TimeType& data);

uint16_t calculateChecksum(const uint8_t* data, uint8_t size);

Expand Down
45 changes: 30 additions & 15 deletions Firmware/shared/Application/source/FCTarot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ void FCTarot::Init()
{
static_assert (sizeof(FCTarot::GPSType) == FCTarot::PacketContentSize, "Tarot GPS PaketSize does not match!");
static_assert (sizeof(FCTarot::RCType) == FCTarot::PacketContentSize, "Tarot RC PaketSize does not match!");
static_assert (sizeof(FCTarot::HomeDataType) == FCTarot::PacketContentSize, "Tarot HomeData PaketSize does not match!");
static_assert (sizeof(FCTarot::BatteryType) == FCTarot::PacketContentSize, "Tarot Battery PaketSize does not match!");
static_assert (sizeof(FCTarot::TimeType) == FCTarot::PacketContentSize, "Tarot Time PaketSize does not match!");

static_assert (sizeof(FCTarot::Paket) == FCTarot::PaketSize, "Tarot PaketSize does not match!");

Expand Down Expand Up @@ -117,18 +118,20 @@ void FCTarot::Process(Paket& paket)
case PaketType::RC:
Process(paket.RC);
break;
case PaketType::HomeData:
Process(paket.HomeData);
case PaketType::Battery:
Process(paket.Battery);
break;
case PaketType::Time:
Process(paket.Time);
break;
}
}

void FCTarot::Process(GPSType& data)
void FCTarot::Process(RCType& data)
{
SensorData.SetPositionCurrent(data.Latitude / 10000000.f, data.Longitude / 10000000.f);
SensorData.SetAltitude(data.Altitude / 10.f);
SensorData.SetSpeed(data.Speed / 10.f);
SensorData.SetVerticalSpeed(data.Climb / 10.f);
SensorData.SetBattery(data.Voltage * 10);
SensorData.SetThrottle(data.Throttle * 10);

SensorData.SetArmed(data.Armed);

if (data.Failsafe != 0)
SensorData.SetFlightMode(FlightMode::Failsafe);
Expand All @@ -142,18 +145,30 @@ void FCTarot::Process(GPSType& data)
SensorData.SetSatellites(data.Satellites);
SensorData.SetFixType(data.Satellites == 0 ? GPSFixType::FixNo : data.Satellites < 4 ? GPSFixType::Fix2D : GPSFixType::Fix3D);

//TODO: Set RC Channels
}

void FCTarot::Process(RCType& data)
void FCTarot::Process(GPSType& data)
{
SensorData.SetArmed(data.Armed);
//TODO: Set RC Channels
SensorData.SetPositionHome(data.HomeLatitude / 10000000.f, data.HomeLongitude / 10000000.f);
SensorData.SetHomeAltitude(data.HomeAltitude / 10.f);

SensorData.SetPositionCurrent(data.Latitude / 10000000.f, data.Longitude / 10000000.f);
SensorData.SetAltitude(data.Altitude / 10.f);

SensorData.SetSpeed(data.Speed / 10.f);
SensorData.SetVerticalSpeed(data.Climb / 10.f);
}

void FCTarot::Process(BatteryType& data)
{
SensorData.SetBattery(data.Voltage * 10);
}

void FCTarot::Process(HomeDataType& data)
void FCTarot::Process(TimeType& data)
{
SensorData.SetHomeAltitude(data.Altitude / 10.f);
SensorData.SetPositionHome(data.Latitude / 10000000.f, data.Longitude / 10000000.f);
Utils::DateTime dt = Utils::DateTime(1467504000 + data.Time / 1000);
SensorData.SetDateTime(dt);
}

uint16_t FCTarot::calculateChecksum(const uint8_t* data, uint8_t size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>2.2.1.%2a</ApplicationVersion>
<ApplicationVersion>2.2.2.1</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace xeniC.AnySense.Library.Devices
{
public class AnySensePro : DeviceModelBase
{
private const UInt32 LatestVersion = 0x02020100;
private const UInt32 LatestVersion = 0x02020200;

public AnySensePro(BaseMavlinkLayer mv, UInt32 version)
: base(mv, version)
Expand Down

0 comments on commit fca4e32

Please sign in to comment.