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