FutabaGP1212A02.h
author StephaneLenclud
Sun, 31 Aug 2014 22:57:32 +0200
changeset 18 96c013c63595
parent 16 42ba42be810d
child 20 3b7acc7fb64b
permissions -rw-r--r--
Display auto detect implementation.
     1 //
     2 //
     3 //
     4 
     5 #ifndef FUTABA_GP1212A02_H
     6 #define FUTABA_GP1212A02_H
     7 
     8 #include "FutabaGP1212.h"
     9 
    10 #include "FutabaGP1212.h"
    11 #include "FutabaVfd.h"
    12 
    13 /**
    14 GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD.
    15 The module do not include character ROM, the customer will compile the character
    16 by themselves (from main system). 
    17 */
    18 class GP1212A02A : public GP1212XXXX
    19 	{
    20 public:
    21 
    22     GP1212A02A();
    23     ~GP1212A02A();
    24 
    25 	//From DisplayBase
    26 	int Open();
    27 	virtual void SwapBuffers();
    28 	virtual void TurnPowerOn();
    29 	virtual void TurnPowerOff();
    30 	virtual bool SupportPowerOnOff(){return true;}
    31 	virtual void ShowClock();
    32 	virtual void HideClock();
    33 	virtual bool SupportClock(){return true;}
    34 
    35 
    36 
    37 	//From GraphicDisplay
    38 	virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn);
    39 	virtual void SetAllPixels(unsigned char aPattern);
    40     virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}
    41 	virtual void SetBrightness(int aBrightness);
    42 	virtual void Clear();
    43 	virtual void Fill();
    44 	virtual void Request(TMiniDisplayRequest aRequest);
    45 
    46 	
    47 		
    48 	//
    49 	void ToggleOffScreenMode();
    50     void SetOffScreenMode(bool aOn);
    51     bool OffScreenMode() const {return iOffScreenMode;}
    52     //
    53     void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;}
    54     bool FrameDifferencing() const {return iUseFrameDifferencing;}
    55     //    
    56     TMiniDisplayRequest AttemptRequestCompletion();
    57     FutabaVfdReport& InputReport() {return iInputReport;}
    58     bool IsPowerOn();
    59 	char* DeviceId();
    60 	char* FirmwareRevision();
    61 
    62 private:
    63 
    64 	enum TBmpBoxId
    65 	{
    66 		EBmpBoxIdNull=0x30,
    67 		EBmpBoxIdOne=0x31,
    68 		EBmpBoxIdTwo=0x32,
    69 		EBmpBoxIdThree=0x33
    70 	};
    71 
    72 	enum TTarget
    73 	{
    74 		ETargetDisplayWindow=0x30,
    75 		ETargetDataMemory=0x31
    76 	};
    77 
    78 	enum TDirection
    79 	{
    80 		EDirectionY=0x30,
    81 		EDirectionX=0x31
    82 	};
    83 
    84 	enum TPowerStatus
    85 	{
    86 		EPowerOff=0x30,
    87 		EPowerOn=0x31
    88 	};
    89 
    90 	enum TWeekDay
    91 	{
    92 		ESunday		=	0x00,
    93 		EMonday		=	0x01,
    94 		ETuesday	=	0x02,
    95 		EWednesday	=	0x03,
    96 		EThrusday	=	0x04,
    97 		EFriday		=	0x05,
    98 		ESaturday	=	0x06
    99 	};
   100 
   101 	enum TClockFormat
   102 	{
   103 		EClock24	=	0x00,
   104 		EClockDay24	=	0x01,
   105 		EClock12	=	0x10,
   106 		EClockDay12	=	0x11
   107 	};
   108 
   109 	enum TClockSize
   110 	{
   111 		EClockTiny		=	0x30,
   112 		EClockSmall		=	0x31,
   113 		EClockMedium	=	0x32,
   114 		EClockLarge		=	0x33
   115 	};
   116 
   117 
   118 private:
   119 	//Specific to GP1212A02A
   120 	//General setting command
   121 	void SendCommandClear();
   122 	//
   123 	void BmpDataInput(TTarget aTarget, unsigned short aAddress, TDirection aDirection, unsigned short aSize, unsigned char* aPixels);
   124 	//
   125 	void SendCommandPower(TPowerStatus aPowerStatus);
   126 	//Clock commands
   127 	void SendCommandClockSetting(TWeekDay aWeekDay, unsigned char aHour, unsigned char aMinute);
   128 	void SendCommandClockDisplay(TClockFormat aClockFormat, unsigned short aAddress, TClockSize aSize);
   129 	void SendCommandClockCancel();
   130 
   131 
   132 	//BMP box
   133 	void BmpBoxSetting(TBmpBoxId aBoxId, unsigned short aAddress, int aWidth, int aHeight);
   134 	void BmpBoxSelect(TBmpBoxId aBoxId);
   135 	void BmpBoxDataMemoryTransfer(unsigned short aAddress);
   136 	void BmpBoxDataInput(unsigned short aSize, unsigned char* aPixels);
   137 
   138 	//Clock utilities
   139 	int ClockCharCount(TClockFormat aFormat);
   140 	int ClockCharWidthInPixels(TClockSize aSize);
   141 	int ClockCharHeightInPixels(TClockSize aSize);
   142 	unsigned short ClockCenterAddress(TClockFormat aFormat, TClockSize aSize);
   143 
   144 private:
   145     void RequestDeviceId();
   146     void RequestFirmwareRevision();
   147     void RequestPowerSupplyStatus();
   148 	//
   149 	void SetClockSetting();
   150 
   151 
   152 private:
   153 	unsigned char OffScreenY() const;	
   154 	void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
   155 	void ResetBuffers();
   156 
   157 private:
   158 	unsigned char iDisplayPositionX;
   159 	unsigned char iDisplayPositionY;
   160 	///Off screen mode is the recommended default settings to avoid tearing.
   161 	///Though turning it off can be useful for debugging
   162 	bool iOffScreenMode;
   163     ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
   164     bool iUseFrameDifferencing;
   165 	///
   166 	//FutabaVfdReport iReport;
   167 	///
   168 	//unsigned char iFrameBuffer[256*64];
   169     BitArrayLow* iFrameNext;
   170     BitArrayLow* iFrameCurrent;
   171     BitArrayLow* iFramePrevious;
   172     //
   173     BitArrayLow* iFrameAlpha;
   174     BitArrayLow* iFrameBeta;
   175     BitArrayLow* iFrameGamma;
   176     //
   177     int iNeedFullFrameUpdate;
   178 	//unsigned char iFrameBeta[256*64];
   179 	//unsigned char *iFrontBuffer;
   180 	//unsigned char *iBackBuffer;
   181     FutabaVfdReport iInputReport;
   182 	//
   183 	char iDeviceId[KFutabaMaxHidReportSize];
   184 	char iFirmwareRevision[KFutabaMaxHidReportSize];
   185     bool iPowerOn;
   186 	//
   187 	unsigned short iNextFrameAddress;
   188 	};
   189 
   190 
   191 
   192 #endif