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