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