FutabaGP1212A02.h
author StephaneLenclud
Mon, 22 Sep 2014 22:03:28 +0200
changeset 23 e63ba12d7a18
parent 21 fa7c9f9140aa
child 25 3fa4007c0b19
permissions -rw-r--r--
HTPC documentation and optimization for GP1212A02.
     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, unsigned int aPixel);
    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 TFontSizeLogical
   110 	{
   111 		EFontTiny		=	0x30,
   112 		EFontSmall		=	0x31,
   113 		EFontMedium	=	0x32,
   114 		EFontLarge		=	0x33
   115 	};
   116 
   117 	enum TFontSize
   118 	{
   119 		EFont6x8	= 0x30,
   120 		EFont8x16	= 0x31,
   121 		EFont12x24	= 0x32,
   122 		EFont16x32	= 0x33,
   123 		EFont16x16	= 0x34,
   124 		EFont24x24	= 0x35,
   125 		EFont32x32	= 0x36
   126 	};
   127 
   128 	enum TFontAction
   129 	{
   130 		EFontStore		= 0x30,
   131 		EFontTransfer	= 0x31,
   132 		EFontDelete		= 0x32
   133 	};
   134 
   135 
   136 private:
   137 	//Specific to GP1212A02A
   138 	//General setting command
   139 	void SendCommandClear();
   140 	void SendCommandReset();
   141 	//
   142 	void BmpDataInput(TTarget aTarget, unsigned short aAddress, TDirection aDirection, unsigned short aSize, unsigned char* aPixels);
   143 	//
   144 	void SendCommandPower(TPowerStatus aPowerStatus);
   145 	//Clock commands
   146 	void SendCommandClockSetting(TWeekDay aWeekDay, unsigned char aHour, unsigned char aMinute);
   147 	void SendCommandClockDisplay(TClockFormat aClockFormat, unsigned short aAddress, TFontSizeLogical aSize);	
   148 	void SendCommandClockCancel();
   149 	//Font commands
   150 	void SendCommandDefineCharacter(TFontSize aFontSize, unsigned short aCharacterCode, unsigned char* aPixelData);
   151 	void SendCommandFontAction(TFontAction aFontAction);
   152 	void SendCommandSelectFontSize(TFontSizeLogical aFontSoze);
   153 
   154 
   155 	//BMP box
   156 	void BmpBoxSetting(TBmpBoxId aBoxId, unsigned short aAddress, int aWidth, int aHeight);
   157 	void BmpBoxSelect(TBmpBoxId aBoxId);
   158 	void BmpBoxDataMemoryTransfer(unsigned short aAddress);
   159 	void BmpBoxDataInput(unsigned short aSize, unsigned char* aPixels);
   160 
   161 	//Clock utilities
   162 	int ClockCharCount(TClockFormat aFormat);
   163 	int ClockCharWidthInPixels(TFontSizeLogical aSize);
   164 	int ClockCharHeightInPixels(TFontSizeLogical aSize);
   165 	unsigned short ClockCenterAddress(TClockFormat aFormat, TFontSizeLogical aSize);
   166 	//Font utilities
   167 	int CharacterSizeInBytes(TFontSize aFontSize);
   168 
   169 private:
   170     void RequestDeviceId();
   171     void RequestFirmwareRevision();
   172     void RequestPowerSupplyStatus();
   173 	//
   174 	void SetClockSetting();
   175 
   176 
   177 private:
   178 	unsigned char OffScreenY() const;	
   179 	void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
   180 	void ResetBuffers();
   181 
   182 private:
   183 	unsigned char iDisplayPositionX;
   184 	unsigned char iDisplayPositionY;
   185 	///Off screen mode is the recommended default settings to avoid tearing.
   186 	///Though turning it off can be useful for debugging
   187 	bool iOffScreenMode;
   188     ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
   189     bool iUseFrameDifferencing;
   190 	///
   191 	//FutabaVfdReport iReport;
   192 	///
   193 	//unsigned char iFrameBuffer[256*64];
   194     BitArrayLow* iFrameNext;
   195     BitArrayLow* iFrameCurrent;
   196     BitArrayLow* iFramePrevious;
   197     //
   198     BitArrayLow* iFrameAlpha;
   199     BitArrayLow* iFrameBeta;
   200     BitArrayLow* iFrameGamma;
   201     //
   202     int iNeedFullFrameUpdate;
   203 	//unsigned char iFrameBeta[256*64];
   204 	//unsigned char *iFrontBuffer;
   205 	//unsigned char *iBackBuffer;
   206     FutabaVfdReport iInputReport;
   207 	//
   208 	char iDeviceId[KFutabaMaxHidReportSize];
   209 	char iFirmwareRevision[KFutabaMaxHidReportSize];
   210     bool iPowerOn;
   211 	//
   212 	unsigned short iNextFrameAddress;
   213 	};
   214 
   215 
   216 
   217 #endif