/*
 * fe_takeover.h
 *
 */

#ifndef FE_TAKEOVER_H_
#define FE_TAKEOVER_H_

#include <stdint.h>

struct flying_engineer_takeover_t
{
	enum takeover_flags_t
	{
		//to_enable=(1<<0),
#if 0
		to_cursor=(1<<1),

		to_mode=(1<<2),
		to_scale=(1<<3),
		to_width=(1<<4),
		to_ifgain=(1<<5),
		to_antenna_abs=(1<<6),
		to_antenna_rel=(1<<7),
#endif
		//to_obs=(1<<16),	//enable observer
		to_marker=0x544B4F56U  //"TKOV"
	};

	uint32_t takeover_marker;
	uint32_t takeover_update;
	uint32_t takeover_size;
	uint32_t takeover_version;

	//uint32_t takeover_flags;//see takeover_flags_t
	int32_t fe_enable;
	int32_t obs_enable;
	int32_t to_enable;

    int crs_ovr;
	uint32_t crs_x;
	uint32_t crs_y;

	uint32_t evn;

	int mode_ovr;

	int32_t mode;
	int32_t submode;

	int32_t scale_ovr;
	int32_t scale;
	int32_t width;

	int32_t if_gain_ovr;
	int32_t if_gain;

	int32_t ant_ovr;
	int32_t ant_evn;
        float antenna_az;
        float antenna_el;

	int32_t bars;

        int32_t spoi_control;   //0=no, 1..3: attach to waypoint as bull's eye
        float spoi_lat;
        float spoi_lon;
        float spoi_alt;
        int32_t crs_zero;

        uint32_t spare[16-5];
};

struct flying_engineer_observer_t
{
    enum flags_t
    {
        obs_marker=0x544B4F57U
    };
    uint32_t marker;
	uint32_t pending;
	uint32_t updated;

	uint32_t date;
	uint32_t time;

	uint32_t mode;
	uint32_t map;
	uint32_t scale;

	uint32_t map_ref_valid;
	float map_refeference;
	float ptaz;
	float magnetic_heading;
	float true_heading;

	float latitude;
	float longitude;

	uint32_t frame_center_updated;
	float frame_center;

	uint32_t if_gain;
	uint32_t ts_mode;
	uint32_t width;
	uint32_t bars;

	float ground_track_angle;
	float baro_altitude;

	uint32_t spare[25];
};

extern const flying_engineer_takeover_t* b1553_flying_engineer_takeover();

extern void b1553_flying_engineer_takeover_rx(int msgid, void* buffer);
extern void b1553_flying_engineer_takeover_tx(int msgid, void* buffer);

#endif /* FE_TAKEOVER_H_ */
