FutabaGP1212A02.h
author StephaneLenclud
Thu, 05 Feb 2015 11:41:19 +0100
changeset 27 949be5444c57
parent 22 ea9ccfdb5563
child 29 9b44c6e1651c
permissions -rw-r--r--
MDM166AA swap buffers now working.
     1 //
     2 //
     3 //
     4 
     5 #ifndef FUTABA_GP1212A02_H
     6 #define FUTABA_GP1212A02_H
     7 
     8 #include "FutabaGP1212.h"
     9 #include "FutabaVfd.h"
    10 
    11 /**
    12 GP1212A02A is a graphic display module using a FUTABA 256x64dots VFD.
    13 The module will support the interface of I2C, RS-232C and USB2.0 communications.
    14 The module include flash ROM (4Mbyte), the customer will definable the BMP data and download
    15 character.
    16 It realizes displaying a Japanese font (refer to Table-24) and BMP by I2C, RS-232C or USB2.0
    17 communications. Other font tables (ex. Chinese, Korean, European and custom font) can be appended to
    18 flash ROM.
    19 Since a DC/DC converter is included, 5V power source is required to operate the module.
    20 */
    21 class GP1212A02A : public GP1212XXXX
    22 	{
    23 public:
    24 
    25     GP1212A02A();
    26     ~GP1212A02A();
    27 
    28 	//From DisplayBase
    29 	int Open();
    30 	virtual void SwapBuffers();
    31 	virtual void TurnPowerOn();
    32 	virtual void TurnPowerOff();
    33 	virtual bool SupportPowerOnOff(){return true;}
    34 	virtual void ShowClock();
    35 	virtual void HideClock();
    36 	virtual bool SupportClock(){return true;}
    37 
    38 
    39 
    40 	//From GraphicDisplay
    41 	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel);
    42 	virtual void SetAllPixels(unsigned char aPattern);
    43     virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}
    44 	virtual void SetBrightness(int aBrightness);
    45 	virtual void Clear();
    46 	virtual void Fill();
    47 	virtual void Request(TMiniDisplayRequest aRequest);
    48 
    49 	
    50 		
    51 	//
    52 	void ToggleOffScreenMode();
    53     void SetOffScreenMode(bool aOn);
    54     bool OffScreenMode() const {return iOffScreenMode;}
    55     //
    56     void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;}
    57     bool FrameDifferencing() const {return iUseFrameDifferencing;}
    58     //    
    59     TMiniDisplayRequest AttemptRequestCompletion();
    60     FutabaVfdReport& InputReport() {return iInputReport;}
    61     bool IsPowerOn();
    62 	char* DeviceId();
    63 	char* FirmwareRevision();
    64 
    65 private:
    66 
    67 	enum TBmpBoxId
    68 	{
    69 		EBmpBoxIdNull=0x30,
    70 		EBmpBoxIdOne=0x31,
    71 		EBmpBoxIdTwo=0x32,
    72 		EBmpBoxIdThree=0x33
    73 	};
    74 
    75 	enum TTarget
    76 	{
    77 		ETargetDisplayWindow=0x30,
    78 		ETargetDataMemory=0x31
    79 	};
    80 
    81 	enum TDirection
    82 	{
    83 		EDirectionY=0x30,
    84 		EDirectionX=0x31
    85 	};
    86 
    87 	enum TPowerStatus
    88 	{
    89 		EPowerOff=0x30,
    90 		EPowerOn=0x31
    91 	};
    92 
    93 	enum TWeekDay
    94 	{
    95 		ESunday		=	0x00,
    96 		EMonday		=	0x01,
    97 		ETuesday	=	0x02,
    98 		EWednesday	=	0x03,
    99 		EThrusday	=	0x04,
   100 		EFriday		=	0x05,
   101 		ESaturday	=	0x06
   102 	};
   103 
   104 	enum TClockFormat
   105 	{
   106 		EClock24	=	0x00,
   107 		EClockDay24	=	0x01,
   108 		EClock12	=	0x10,
   109 		EClockDay12	=	0x11
   110 	};
   111 
   112 	enum TFontSizeLogical
   113 	{
   114 		EFontTiny		=	0x30,
   115 		EFontSmall		=	0x31,
   116 		EFontMedium	=	0x32,
   117 		EFontLarge		=	0x33
   118 	};
   119 
   120 	enum TFontSize
   121 	{
   122 		EFont6x8	= 0x30,
   123 		EFont8x16	= 0x31,
   124 		EFont12x24	= 0x32,
   125 		EFont16x32	= 0x33,
   126 		EFont16x16	= 0x34,
   127 		EFont24x24	= 0x35,
   128 		EFont32x32	= 0x36
   129 	};
   130 
   131 	enum TFontAction
   132 	{
   133 		EFontStore		= 0x30,
   134 		EFontTransfer	= 0x31,
   135 		EFontDelete		= 0x32
   136 	};
   137 
   138 
   139 private:
   140 	//Specific to GP1212A02A
   141 	//General setting command
   142 	void SendCommandClear();
   143 	void SendCommandReset();
   144 	//
   145 	void BmpDataInput(TTarget aTarget, unsigned short aAddress, TDirection aDirection, unsigned short aSize, unsigned char* aPixels);
   146 	//
   147 	void SendCommandPower(TPowerStatus aPowerStatus);
   148 	//Clock commands
   149 	void SendCommandClockSetting(TWeekDay aWeekDay, unsigned char aHour, unsigned char aMinute);
   150 	void SendCommandClockDisplay(TClockFormat aClockFormat, unsigned short aAddress, TFontSizeLogical aSize);	
   151 	void SendCommandClockCancel();
   152 	//Font commands
   153 	void SendCommandDefineCharacter(TFontSize aFontSize, unsigned short aCharacterCode, unsigned char* aPixelData);
   154 	void SendCommandFontAction(TFontAction aFontAction);
   155 	void SendCommandSelectFontSize(TFontSizeLogical aFontSoze);
   156 
   157 
   158 	//BMP box
   159 	void BmpBoxSetting(TBmpBoxId aBoxId, unsigned short aAddress, int aWidth, int aHeight);
   160 	void BmpBoxSelect(TBmpBoxId aBoxId);
   161 	void BmpBoxDataMemoryTransfer(unsigned short aAddress);
   162 	void BmpBoxDataInput(unsigned short aSize, unsigned char* aPixels);
   163 
   164 	//Clock utilities
   165 	int ClockCharCount(TClockFormat aFormat);
   166 	int ClockCharWidthInPixels(TFontSizeLogical aSize);
   167 	int ClockCharHeightInPixels(TFontSizeLogical aSize);
   168 	unsigned short ClockCenterAddress(TClockFormat aFormat, TFontSizeLogical aSize);
   169 	//Font utilities
   170 	int CharacterSizeInBytes(TFontSize aFontSize);
   171 
   172 private:
   173     void RequestDeviceId();
   174     void RequestFirmwareRevision();
   175     void RequestPowerSupplyStatus();
   176 	//
   177 	void SetClockSetting();
   178 
   179 
   180 private:
   181 	unsigned char OffScreenY() const;	
   182 	void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
   183 	void ResetBuffers();
   184 
   185 private:
   186 	unsigned char iDisplayPositionX;
   187 	unsigned char iDisplayPositionY;
   188 	///Off screen mode is the recommended default settings to avoid tearing.
   189 	///Though turning it off can be useful for debugging
   190 	bool iOffScreenMode;
   191     ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
   192     bool iUseFrameDifferencing;
   193 	///
   194 	//FutabaVfdReport iReport;
   195 	///
   196 	//unsigned char iFrameBuffer[256*64];
   197     BitArrayLow* iFrameNext;
   198     BitArrayLow* iFrameCurrent;
   199     BitArrayLow* iFramePrevious;
   200     //
   201     BitArrayLow* iFrameAlpha;
   202     BitArrayLow* iFrameBeta;
   203     BitArrayLow* iFrameGamma;
   204     //
   205     int iNeedFullFrameUpdate;
   206 	//unsigned char iFrameBeta[256*64];
   207 	//unsigned char *iFrontBuffer;
   208 	//unsigned char *iBackBuffer;
   209     FutabaVfdReport iInputReport;
   210 	//
   211 	char iDeviceId[KFutabaMaxHidReportSize];
   212 	char iFirmwareRevision[KFutabaMaxHidReportSize];
   213     bool iPowerOn;
   214 	//
   215 	unsigned short iNextFrameAddress;
   216 	};
   217 
   218 
   219 
   220 #endif