#pragma once

#include "data/config/SamplingConfig.h"

namespace inertia
{

/** ADCChannel */
enum ADCChannel {
	ADCchannelA2VBAT = 0,
	ADCchannelA0,
	ADCchannelA1,
	ADCchannelA3,
	ADCchannelA4,
	ADCchannelA5,
	ADCchannelA6,
	ADCchannelA7,
	ADCChannelNone // nothing selected
};

struct INERTIA_API ADCConfig
	: SamplingConfig
{
	bool adoptOffset;
	bool adoptScale;
	bool asGPIO[2];
	float scale[2];
	int16_t offset[2];

	/** each of the 8 bits select different ADC channels.
	* Only 2 channels can be active at once (others will be ignored).
	* The lowest selected bit will be the first value of the ADC sample.
	* bit 0. Channel 2 (A2 on MSP - VBAT on P3D).
	* bit 1. Channel 0 (A0).
	* bit 2. Channel 1 (A1).
	* bit 3. Channel 3 (A3).
	* bit 4. Channel 4 (A4).
	* bit 5. Channel 5 (A5).
	* bit 6. Channel 6 (A6).
	* bit 7. Channel 7 (A7)
	*/
	uint8_t ADCchannelMap;

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

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

	void Set(const ADCChannel channel1, const ADCChannel channel2);
	void Get(ADCChannel &channel1, ADCChannel &channel2) const;
	static unsigned GetLength();
	void GetBytes(std::vector<uint8_t>& out) const override;
	ConfigType GetConfigType() const override;
	const std::wstring ToString() const override;
};

}
