#pragma once

#include "data/config/InertialConfig.h"

namespace inertia
{

// compass overflow (-4096 situation from HMC5843 is received as 32767 independent of scaling & offset)
#define COMPASS_OVERFLOW 32767

/** CompassRate */
enum CompassRate {
	COMPASS_RATE_0 = 0,
	COMPASS_RATE_1 = 1,
	COMPASS_RATE_2 = 2,
	COMPASS_RATE_3 = 3,
	COMPASS_RATE_4 = 4,
	COMPASS_RATE_5 = 5,
	COMPASS_RATE_6 = 6
};

/** CompassGain */
enum CompassGain {
	COMPASS_GAIN_0 = 0,
	COMPASS_GAIN_1 = 1,
	COMPASS_GAIN_2 = 2,
	COMPASS_GAIN_3 = 3,
	COMPASS_GAIN_4 = 4,
	COMPASS_GAIN_5 = 5,
	COMPASS_GAIN_6 = 6,
	COMPASS_GAIN_7 = 7
};

/** CompassType */
enum CompassType {
	COMPASS_HMC5843 = 0,
	COMPASS_HMC5883L = 1,
	COMPASS_RESERVED = 2,
	COMPASS_RESERVED2 = 3
};


struct INERTIA_API CompassConfig
	: InertialConfig
{
	CompassRate	hardwareRate;
	CompassGain	hardwareGain;
	CompassType hardwareType;

	CompassConfig();
	CompassConfig(uint8_t const* in);
	CompassConfig(std::wstring const& argString);

#ifdef WITH_BOOST_PROGRAM_OPTIONS
	static const po::options_description GetOptionDescription();
#endif

	static unsigned GetLength();
	void GetBytes(std::vector<uint8_t>& out) const override;
	ConfigType GetConfigType() const override;
	const std::wstring ToString() const override;
	const std::wstring ToSimpleString(uint16_t const globalRate) const;
	double GetRangeFactor() const override;
	uint16_t GetMaxRate() const override;
};

}
