FutabaMDM166AA.h
author StephaneLenclud
Thu, 05 Feb 2015 14:02:27 +0100
changeset 28 0d426caeaefe
parent 27 949be5444c57
child 29 9b44c6e1651c
permissions -rw-r--r--
MDM166AA: more accurate time setting and cleanup.
     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     TMiniDisplayRequest AttemptRequestCompletion();
    56 
    57 
    58 private:
    59 
    60 	enum TClockFormat
    61 		{
    62 		EClock12	=	0x00,
    63 		EClock24	=	0x01,
    64 		};
    65 
    66 	enum TClockSize
    67 		{
    68 		EClockSmall		=	0x01,
    69 		EClockLarge		=	0x02
    70 		};
    71 	
    72 
    73 private:
    74 	//Specific to MDM166AA
    75 	//General setting command
    76 	void SendCommandClear();
    77 	void SendCommandReset();
    78 	//
    79 	//Clock commands
    80 	void SendCommandSetClockData(unsigned char aHour, unsigned char aMinute);
    81 	void SendCommandClockDisplay(TClockSize aClockSize, TClockFormat aClockFormat);	
    82 
    83 	//Graphics commands
    84 	void SendCommandSetAddressCounter(unsigned char aAddressCounter);
    85 	void SendCommandWriteGraphicData(int aSize, unsigned char* aPixels);
    86 
    87 private:
    88     void RequestDeviceId();
    89     void RequestFirmwareRevision();
    90     void RequestPowerSupplyStatus();
    91 	//
    92 	void SetClockData();
    93 
    94 private:
    95 	void ResetBuffers();
    96 
    97 private:
    98 	///Off screen mode is the recommended default settings to avoid tearing.
    99 	///Though turning it off can be useful for debugging
   100 	bool iOffScreenMode;
   101     //
   102 	BitArrayLow* iFrameNext;
   103     BitArrayLow* iFrameCurrent;
   104     BitArrayLow* iFramePrevious;
   105     //
   106     BitArrayLow* iFrameAlpha; //owned
   107     BitArrayLow* iFrameBeta;  //owned
   108     BitArrayLow* iFrameGamma; //owned
   109 	};
   110 
   111 
   112 
   113 #endif