FutabaMDM166AA.h
author StephaneLenclud
Thu, 05 Feb 2015 15:09:48 +0100
changeset 30 7f649078cb52
parent 29 9b44c6e1651c
child 31 0a2b658e0d56
permissions -rw-r--r--
MDM166AA: Clock is now synchronized at the second.
StephaneLenclud@25
     1
//
StephaneLenclud@25
     2
//
StephaneLenclud@25
     3
//
StephaneLenclud@25
     4
StephaneLenclud@25
     5
#ifndef FUTABA_MDM166AA_H
StephaneLenclud@25
     6
#define FUTABA_MDM166AA_H
StephaneLenclud@25
     7
StephaneLenclud@25
     8
#include "FutabaVfd.h"
StephaneLenclud@25
     9
StephaneLenclud@25
    10
StephaneLenclud@25
    11
const int KMDM166AAWidthInPixels = 96;
StephaneLenclud@25
    12
const int KMDM166AAHeightInPixels = 16;
StephaneLenclud@25
    13
const int KMDM166AAPixelsPerByte = 8;
StephaneLenclud@25
    14
const int KMDM166AAFrameBufferSizeInBytes = KMDM166AAWidthInPixels*KMDM166AAHeightInPixels/KMDM166AAPixelsPerByte; //96*16/8=192
StephaneLenclud@25
    15
const int KMDM166AAFrameBufferPixelCount = KMDM166AAWidthInPixels*KMDM166AAHeightInPixels;
StephaneLenclud@25
    16
StephaneLenclud@25
    17
StephaneLenclud@25
    18
/**
StephaneLenclud@25
    19
MDM166AA is a graphic display module using a FUTABA 96x16dots VFD.
StephaneLenclud@25
    20
*/
StephaneLenclud@25
    21
class MDM166AA : public FutabaGraphicDisplay
StephaneLenclud@25
    22
	{
StephaneLenclud@25
    23
public:
StephaneLenclud@25
    24
    MDM166AA();
StephaneLenclud@25
    25
    ~MDM166AA();
StephaneLenclud@25
    26
StephaneLenclud@25
    27
	//From DisplayBase
StephaneLenclud@25
    28
	virtual int Open();
StephaneLenclud@25
    29
	virtual void SwapBuffers();
StephaneLenclud@25
    30
		//Brightness support
StephaneLenclud@25
    31
    virtual int MinBrightness() const {return 0;}
StephaneLenclud@25
    32
    virtual int MaxBrightness() const {return 2;}
StephaneLenclud@25
    33
	virtual void SetBrightness(int aBrightness);
StephaneLenclud@25
    34
		//Clock support
StephaneLenclud@25
    35
	virtual void ShowClock();
StephaneLenclud@25
    36
	virtual void HideClock();
StephaneLenclud@25
    37
	virtual bool SupportClock(){return true;}
StephaneLenclud@25
    38
StephaneLenclud@25
    39
	//From GraphicDisplay
StephaneLenclud@25
    40
    virtual int WidthInPixels() const {return KMDM166AAWidthInPixels;}
StephaneLenclud@25
    41
    virtual int HeightInPixels() const {return KMDM166AAHeightInPixels;}
StephaneLenclud@25
    42
StephaneLenclud@25
    43
	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel);
StephaneLenclud@25
    44
	virtual void SetAllPixels(unsigned char aPattern);
StephaneLenclud@25
    45
    virtual int FrameBufferSizeInBytes() const {return KMDM166AAFrameBufferSizeInBytes;}	
StephaneLenclud@25
    46
	virtual void Clear();
StephaneLenclud@25
    47
	virtual void Fill();
StephaneLenclud@25
    48
	virtual void Request(TMiniDisplayRequest aRequest);
StephaneLenclud@25
    49
		
StephaneLenclud@25
    50
	//
StephaneLenclud@25
    51
	void ToggleOffScreenMode();
StephaneLenclud@25
    52
    void SetOffScreenMode(bool aOn);
StephaneLenclud@25
    53
    bool OffScreenMode() const {return iOffScreenMode;}
StephaneLenclud@25
    54
StephaneLenclud@25
    55
private:
StephaneLenclud@25
    56
StephaneLenclud@25
    57
	enum TClockFormat
StephaneLenclud@28
    58
		{
StephaneLenclud@25
    59
		EClock12	=	0x00,
StephaneLenclud@25
    60
		EClock24	=	0x01,
StephaneLenclud@28
    61
		};
StephaneLenclud@25
    62
StephaneLenclud@25
    63
	enum TClockSize
StephaneLenclud@28
    64
		{
StephaneLenclud@25
    65
		EClockSmall		=	0x01,
StephaneLenclud@25
    66
		EClockLarge		=	0x02
StephaneLenclud@28
    67
		};
StephaneLenclud@25
    68
	
StephaneLenclud@25
    69
StephaneLenclud@25
    70
private:
StephaneLenclud@25
    71
	//Specific to MDM166AA
StephaneLenclud@25
    72
	//General setting command
StephaneLenclud@25
    73
	void SendCommandClear();
StephaneLenclud@25
    74
	void SendCommandReset();
StephaneLenclud@25
    75
	//
StephaneLenclud@25
    76
	//Clock commands
StephaneLenclud@28
    77
	void SendCommandSetClockData(unsigned char aHour, unsigned char aMinute);
StephaneLenclud@25
    78
	void SendCommandClockDisplay(TClockSize aClockSize, TClockFormat aClockFormat);	
StephaneLenclud@30
    79
	void AttemptClockSynchronization();
StephaneLenclud@25
    80
StephaneLenclud@27
    81
	//Graphics commands
StephaneLenclud@27
    82
	void SendCommandSetAddressCounter(unsigned char aAddressCounter);
StephaneLenclud@27
    83
	void SendCommandWriteGraphicData(int aSize, unsigned char* aPixels);
StephaneLenclud@27
    84
StephaneLenclud@25
    85
    void RequestDeviceId();
StephaneLenclud@25
    86
    void RequestFirmwareRevision();
StephaneLenclud@25
    87
    void RequestPowerSupplyStatus();
StephaneLenclud@25
    88
	//
StephaneLenclud@28
    89
	void SetClockData();
StephaneLenclud@30
    90
	//
StephaneLenclud@25
    91
	void ResetBuffers();
StephaneLenclud@25
    92
StephaneLenclud@25
    93
private:
StephaneLenclud@25
    94
	///Off screen mode is the recommended default settings to avoid tearing.
StephaneLenclud@25
    95
	///Though turning it off can be useful for debugging
StephaneLenclud@25
    96
	bool iOffScreenMode;
StephaneLenclud@30
    97
	///We use this flag to align display clock seconds with system time
StephaneLenclud@30
    98
	bool iNeedAccurateClockData;
StephaneLenclud@28
    99
    //
StephaneLenclud@28
   100
	BitArrayLow* iFrameNext;
StephaneLenclud@25
   101
    BitArrayLow* iFrameCurrent;
StephaneLenclud@25
   102
    BitArrayLow* iFramePrevious;
StephaneLenclud@25
   103
    //
StephaneLenclud@28
   104
    BitArrayLow* iFrameAlpha; //owned
StephaneLenclud@28
   105
    BitArrayLow* iFrameBeta;  //owned
StephaneLenclud@28
   106
    BitArrayLow* iFrameGamma; //owned
StephaneLenclud@25
   107
	};
StephaneLenclud@25
   108
StephaneLenclud@25
   109
StephaneLenclud@25
   110
StephaneLenclud@25
   111
#endif