#ifndef ANSI_H
#define ANSI_H


#if defined(MCU_PLATFORM_STM32)
   #include <lepto/signal.h>
   #include <lepto/string.h>
   #include <lepto/mockQt.hpp>
#else
   #define  CString  QString
   #define  CByteArray  QByteArray
   #include <QString>
   #include <QByteArray>
#endif

bool isAscii(int i);

enum EAnsiState
{
   eAnsiStateNone,
   eAnsiStateEscaped,
   eAnsiStateCsi,
   eAnsiStateTelegram,
};


class CAnsi
{
   private:
      int   current;
      EAnsiState eAnsiState;
      CString telegram;

   public:
      CAnsi();
      int digest(signed char c);
   #ifdef NO_QT
      CSignal<void, CByteArray &> newTelegram;
   #else
   public: // signals:
      void newTelegram(CByteArray &);
   #endif

   public: // slots:
      void slotSendTelegram(CByteArray &);
};

#endif // ANSI_H
