#ifndef _GRAPHIC_DISPLAY_DEM_H_
#define _GRAPHIC_DISPLAY_DEM_H_
//----------------------------------------------------------------------------
///
/// \brief  Display Eleltronik Display
///
///         See implementation files for further information.
///
/// \date   20181027
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


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


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

#include <biwak/output.hpp>
#include <biwak/gdisplay.h>

class CSpi;

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


class CGraphicDisplayDem
         :public CGraphicDisplay
{

   private:
      CSpi &spi;
      COutput outCs;
      COutput outDc;
      int busyCounter;
      bool m_drawMode;

   public:
      typedef struct
      {
         //uint8_t     command, len;
         uint8_t     command, data;
         //uint8_t     data[4];
      } TCommandData;

      CGraphicDisplayDem( CSpi &_spi,
            EGpioPeripheral eGpioPeripheralCs, EGpioPin eGpioPinCs,
            EGpioPeripheral eGpioPeripheralDc, EGpioPin eGpioPinDc
            );
      ~CGraphicDisplayDem();
      void reset();
      void resetDisplay();
      void sendNibble (char data);

      void writeCommand (const char command);
      void writeData (const char data);
      void writeRegister (const char reg, const char data);
      void writeInsArray(const TCommandData *pData);
      int readRegister (const char reg);
      int readData ();
      void dumpId();

      void CheckBusy();
      void putString(const char *string);
      void putChar(const char ch);
      void enableCs();
      void disableCs();
      void checkBusy();
      void clear();

      void setWindow(int x1, int y1, int x2, int y2);
      void enableDrawMode();
      void disableDrawMode();

      void drawMatrix(int x, int y, const char *matrix);
      int width()
      {
         return(64);
      }
      void clear(TRgb color);
      void drawPixel( TRgb color );
      virtual void gotoxyHw() override;
      virtual void setFrame(int x1, int y1, int x2, int y2) override
      {
         return;
      }
      // void drawText(int x, int y, const char *text);
      void setFg( TRgb color ){ fg = color; };
      void setBg( TRgb color ){ bg = color; };
      void setDrawBackground(bool _drawBackground)
      {
         drawBackground=_drawBackground;
      }
      void drawBar(int x1, int y1, int x2, int y2, TRgb startColor, TRgb endColor);
      virtual bool setRotation(bool rot) override;

      virtual void drawPixels( const TRgb *pixels, int count) override;
};


//---fin----------------------------------------------------------------------
#endif // ? ! _GRAPHIC_DISPLAY_DEM_H_
