FutabaGP1212A02.h
author StephaneLenclud
Sat, 07 Feb 2015 13:50:11 +0100
changeset 32 2c844ef1ff4b
parent 25 3fa4007c0b19
child 35 638eb0763e20
permissions -rw-r--r--
MDM166AA: Improved icon APIs.
     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 	virtual 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 	virtual void SetBrightness(int aBrightness);
    38 	virtual void Clear();
    39 	virtual void Fill();
    40     virtual TMiniDisplayRequest AttemptRequestCompletion();
    41 	virtual void Request(TMiniDisplayRequest aRequest);
    42 
    43 
    44 
    45 	//From GraphicDisplay
    46 	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel);
    47 	virtual void SetAllPixels(unsigned char aPattern);
    48     virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}
    49 	
    50 
    51 		
    52 	//
    53 	void ToggleOffScreenMode();
    54     void SetOffScreenMode(bool aOn);
    55     bool OffScreenMode() const {return iOffScreenMode;}
    56     //
    57     void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;}
    58     bool FrameDifferencing() const {return iUseFrameDifferencing;}
    59     FutabaVfdReport& InputReport() {return iInputReport;}
    60 
    61 private:
    62 
    63 	enum TBmpBoxId
    64 	{
    65 		EBmpBoxIdNull=0x30,
    66 		EBmpBoxIdOne=0x31,
    67 		EBmpBoxIdTwo=0x32,
    68 		EBmpBoxIdThree=0x33
    69 	};
    70 
    71 	enum TTarget
    72 	{
    73 		ETargetDisplayWindow=0x30,
    74 		ETargetDataMemory=0x31
    75 	};
    76 
    77 	enum TDirection
    78 	{
    79 		EDirectionY=0x30,
    80 		EDirectionX=0x31
    81 	};
    82 
    83 	enum TPowerStatus
    84 	{
    85 		EPowerOff=0x30,
    86 		EPowerOn=0x31
    87 	};
    88 
    89 	enum TWeekDay
    90 	{
    91 		ESunday		=	0x00,
    92 		EMonday		=	0x01,
    93 		ETuesday	=	0x02,
    94 		EWednesday	=	0x03,
    95 		EThrusday	=	0x04,
    96 		EFriday		=	0x05,
    97 		ESaturday	=	0x06
    98 	};
    99 
   100 	enum TClockFormat
   101 	{
   102 		EClock24	=	0x00,
   103 		EClockDay24	=	0x01,
   104 		EClock12	=	0x10,
   105 		EClockDay12	=	0x11
   106 	};
   107 
   108 	enum TFontSizeLogical
   109 	{
   110 		EFontTiny		=	0x30,
   111 		EFontSmall		=	0x31,
   112 		EFontMedium	=	0x32,
   113 		EFontLarge		=	0x33
   114 	};
   115 
   116 	enum TFontSize
   117 	{
   118 		EFont6x8	= 0x30,
   119 		EFont8x16	= 0x31,
   120 		EFont12x24	= 0x32,
   121 		EFont16x32	= 0x33,
   122 		EFont16x16	= 0x34,
   123 		EFont24x24	= 0x35,
   124 		EFont32x32	= 0x36
   125 	};
   126 
   127 	enum TFontAction
   128 	{
   129 		EFontStore		= 0x30,
   130 		EFontTransfer	= 0x31,
   131 		EFontDelete		= 0x32
   132 	};
   133 
   134 
   135 private:
   136 	//Specific to GP1212A02A
   137 	//General setting command
   138 	void SendCommandClear();
   139 	void SendCommandReset();
   140 	//
   141 	void BmpDataInput(TTarget aTarget, unsigned short aAddress, TDirection aDirection, unsigned short aSize, unsigned char* aPixels);
   142 	//
   143 	void SendCommandPower(TPowerStatus aPowerStatus);
   144 	//Clock commands
   145 	void SendCommandClockSetting(TWeekDay aWeekDay, unsigned char aHour, unsigned char aMinute);
   146 	void SendCommandClockDisplay(TClockFormat aClockFormat, unsigned short aAddress, TFontSizeLogical aSize);	
   147 	void SendCommandClockCancel();
   148 	//Font commands
   149 	void SendCommandDefineCharacter(TFontSize aFontSize, unsigned short aCharacterCode, unsigned char* aPixelData);
   150 	void SendCommandFontAction(TFontAction aFontAction);
   151 	void SendCommandSelectFontSize(TFontSizeLogical aFontSoze);
   152 
   153 
   154 	//BMP box
   155 	void BmpBoxSetting(TBmpBoxId aBoxId, unsigned short aAddress, int aWidth, int aHeight);
   156 	void BmpBoxSelect(TBmpBoxId aBoxId);
   157 	void BmpBoxDataMemoryTransfer(unsigned short aAddress);
   158 	void BmpBoxDataInput(unsigned short aSize, unsigned char* aPixels);
   159 
   160 	//Clock utilities
   161 	int ClockCharCount(TClockFormat aFormat);
   162 	int ClockCharWidthInPixels(TFontSizeLogical aSize);
   163 	int ClockCharHeightInPixels(TFontSizeLogical aSize);
   164 	unsigned short ClockCenterAddress(TClockFormat aFormat, TFontSizeLogical aSize);
   165 	//Font utilities
   166 	int CharacterSizeInBytes(TFontSize aFontSize);
   167 
   168 private:
   169     void RequestDeviceId();
   170     void RequestFirmwareRevision();
   171     void RequestPowerSupplyStatus();
   172 	//
   173 	void SetClockSetting();
   174 
   175 
   176 private:
   177 	unsigned char OffScreenY() const;	
   178 	void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
   179 	void ResetBuffers();
   180 
   181 private:
   182 	unsigned char iDisplayPositionX;
   183 	unsigned char iDisplayPositionY;
   184 	///Off screen mode is the recommended default settings to avoid tearing.
   185 	///Though turning it off can be useful for debugging
   186 	bool iOffScreenMode;
   187     ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
   188     bool iUseFrameDifferencing;
   189 	///
   190 	//FutabaVfdReport iReport;
   191 	///
   192 	//unsigned char iFrameBuffer[256*64];
   193     BitArrayLow* iFrameNext;
   194     BitArrayLow* iFrameCurrent;
   195     BitArrayLow* iFramePrevious;
   196     //
   197     BitArrayLow* iFrameAlpha;
   198     BitArrayLow* iFrameBeta;
   199     BitArrayLow* iFrameGamma;
   200     //
   201     int iNeedFullFrameUpdate;
   202 	//
   203     FutabaVfdReport iInputReport;
   204 	//
   205 	unsigned short iNextFrameAddress;
   206 	};
   207 
   208 
   209 
   210 #endif