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