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


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


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

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

class CSpi;
typedef struct
{
   uint8_t     command, len;
   uint8_t     data[4];
} TCommandData;


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


class CGraphicDisplayNh
         :public CGraphicDisplay
{

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

   public:

      CGraphicDisplayNh( CSpi &_spi,
            EGpioPeripheral eGpioPeripheralCs, EGpioPin eGpioPinCs,
            EGpioPeripheral eGpioPeripheralDc, EGpioPin eGpioPinDc
            );
      ~CGraphicDisplayNh();
      void reset();
      void resetDisplay();
      void sendNibble (char data);
      void writeIns (const uint8_t data, int delayValue =0 );
      void writeInsArray(const TCommandData *pData);
      void writeData (char data);
      void writeData (const char *pData, int len);
      void CheckBusy();
      void putString(const char *string);
      void putChar(const char ch);
      void enableCs();
      void disableCs();
      void checkBusy();
      void clear();
      void drawMatrix(int x, int y, const char *matrix);
      int width()
      {
         return(64);
      }
      void clear(TRgb color);
      void drawPixel( const TRgb color );
      void gotoxy(int x, int y);
      virtual void gotoxyHw();
      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 void drawPixels( const TRgb *pixels, int count) override;

      /*
      COutput &getOutput()
      {
         return(output);
      }
      */
};


//---fin----------------------------------------------------------------------
#endif // ? ! _GRAPHIC_DISPLAY_NH_H_
