#ifndef _IRINPUT_H_
#define _IRINPUT_H_
//----------------------------------------------------------------------------
///
/// \brief  NEC infrared input
///
///         See implementation for further information.
///
/// \date   20141102
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


//---Own------------------------------

#include <lepto/ring.h>
#include <biwak/input.h>
#include <biwak/input_decoder.h>
#include <biwak/timer.h>


//---Declaration--------------------------------------------------------------


enum EKeyMode
{
   eKeyModeinvalid,
   eKeyModePress,
   eKeyModeRepeat,
};


typedef struct
{
   uint8_t  address;
   uint8_t  command;
} TIrKey;


class CIrDecoder
         : public CInputDecoderRecorder
{
   private:
      EKeyMode eKeyMode;

   public:
      CIrDecoder();
      virtual void slope(bool value) override;
      void decodeKey();
      int decodeData(int startSlope, int bites, int &data);
      int decodeStop(int startSlope);
      virtual void sink(uint8_t address, uint8_t command)
      {};
};


class CIrInput
         :public CInput
         ,public CIrDecoder
         ,public CRing <TIrKey>
{

    private:

    public:
        CIrInput(EGpioPeripheral _eGpioPeripheral, EGpioPin _eGpioPin);
        ~CIrInput();
        virtual void sink(uint8_t address, uint8_t command) override
        {
            putEntry( TIrKey{address, command} );
        };

};


//---fin----------------------------------------------------------------------
#endif // ? ! _IRINPUT_H_
