FutabaGP1212A02.h
author sl
Sat, 06 Sep 2014 15:54:51 +0200
changeset 20 3b7acc7fb64b
parent 17 591e9f922c63
child 21 fa7c9f9140aa
permissions -rw-r--r--
GP1212A02: Implement commands for: font char update, font action and hard reset.
     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 	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, TClockSize aSize);	
   148 	void SendCommandClockCancel();
   149 	//Font commands
   150 	void SendCommandDefineCharacter(TFontSize aFontSize, unsigned short aCharacterCode, unsigned char* aPixelData);
   151 	void SendCommandFontAction(TFontAction aFontAction);
   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(TClockSize aSize);
   163 	int ClockCharHeightInPixels(TClockSize aSize);
   164 	unsigned short ClockCenterAddress(TClockFormat aFormat, TClockSize 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 	//unsigned char iFrameBeta[256*64];
   203 	//unsigned char *iFrontBuffer;
   204 	//unsigned char *iBackBuffer;
   205     FutabaVfdReport iInputReport;
   206 	//
   207 	char iDeviceId[KFutabaMaxHidReportSize];
   208 	char iFirmwareRevision[KFutabaMaxHidReportSize];
   209     bool iPowerOn;
   210 	//
   211 	unsigned short iNextFrameAddress;
   212 	};
   213 
   214 
   215 
   216 #endif