#ifndef BTA_FRAME_H_INCLUDED
#define BTA_FRAME_H_INCLUDED

#include <bta_status.h>
#include <stdint.h>


/**     @brief Enumerator with valid frame modes to be passed with BTAsetFrameMode        */
typedef enum {
    BTA_FrameModeCurrentConfig    = 0,    //<<< The sensors settings are not changed and data is passed through
    BTA_FrameModeDistAmp          = 1,
    BTA_FrameModeDistAmpFlags     = 2,
    BTA_FrameModeXYZ              = 3,
    BTA_FrameModeXYZAmp           = 4
} BTA_FrameMode;

typedef enum {
    BTA_ChannelIdUnknown             = 0x0,
    BTA_ChannelIdDistance            = 0x1,
    BTA_ChannelIdAmplitude           = 0x2,
    BTA_ChannelIdX                   = 0x4,
    BTA_ChannelIdY                   = 0x8,
    BTA_ChannelIdZ                   = 0x10,
    BTA_ChannelIdConfidence          = 0x20,         //<<< in percent
    BTA_ChannelIdFlags               = 0x40,         //<<< additional pixel-wise sensor specific information
    BTA_ChannelIdPhase0              = 0x80,
    BTA_ChannelIdPhase90             = 0x100,
    BTA_ChannelIdPhase180            = 0x200,
    BTA_ChannelIdPhase270            = 0x400,
    BTA_ChannelIdTest                = 0x800
} BTA_ChannelId;


typedef enum {
    // the lowbyte stands for width (number of bytes)
    // the highbyte stands for type (continuous numbering)
    BTA_DataFormatUnknown         = 0x0,
    BTA_DataFormatUInt8           = 0x11,
    BTA_DataFormatUInt16          = 0x12,
    BTA_DataFormatUInt24          = 0x13,
    BTA_DataFormatUInt32          = 0x14,
    BTA_DataFormatSInt8           = 0x21,
    BTA_DataFormatSInt16          = 0x22,
    BTA_DataFormatSInt24          = 0x23,
    BTA_DataFormatSInt32          = 0x24,
    BTA_DataFormatFloat8          = 0x31,
    BTA_DataFormatFloat16         = 0x32,
    BTA_DataFormatFloat24         = 0x33,
    BTA_DataFormatFloat32         = 0x34
} BTA_DataFormat;


typedef enum {
    BTA_UnitUnitLess        = 0,
    BTA_UnitMeter           = 1,
    BTA_UnitCentimeter      = 2,
    BTA_UnitMillimeter      = 3,
    BTA_UnitPercent         = 4
} BTA_Unit;


typedef struct {
    BTA_ChannelId id;                 //<<< Type of data in this channel
    uint16_t xRes;                    //<<< Number of columns
    uint16_t yRes;                    //<<< Number of rows
    BTA_DataFormat dataFormat;        //<<< The bytestream in data needs to be casted to this format
    BTA_Unit unit;                    //<<< Informative, for easier interpretation of the data
    uint32_t integrationTime;         //<<< Integration time at which the frame was captured in [us]
    uint32_t modulationFrequency;     //<<< Modulation frequency at which the frame was captured in [Hz]
    uint8_t *data;                    //<<< Pixels starting with upper left pixel. For nofBytesPerPixel > 1 the first byte is the lowbyte
} BTA_Channel;


typedef struct {
    //BTA_Status status;              //<<< Status of frame (can also be an empty frame with faulty status code)
    uint8_t firmwareVersionNonFunc;   //<<< Firmware version non functional
    uint8_t firmwareVersionMinor;     //<<< Firmware version minor
    uint8_t firmwareVersionMajor;     //<<< Firmware version major
    float mainTemp;                   //<<< Main-board/processor temperature sensor in degree Celcius
    float ledTemp;                    //<<< Led-board temperature sensor in degree Celcius
    float genericTemp;                //<<< Additional Generic temperature sensor in degree Celcius
    uint32_t frameCounter;            //<<< Consecutive numbering of frames
    uint32_t timeStamp;               //<<< Time-stamp at which the frame was captured (unit define by library)
    BTA_Channel **channels;           //<<< Data containing ucNofChannels Channel structs
    uint8_t channelsLen;
} BTA_Frame;

#endif
