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