FutabaMDM166AA.h
author StephaneLenclud
Thu, 05 Feb 2015 11:41:19 +0100
changeset 27 949be5444c57
parent 25 3fa4007c0b19
child 28 0d426caeaefe
permissions -rw-r--r--
MDM166AA swap buffers now working.
     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 
    25     MDM166AA();
    26     ~MDM166AA();
    27 
    28 	//From DisplayBase
    29 	virtual int Open();
    30 	virtual void SwapBuffers();
    31 		//Brightness support
    32     virtual int MinBrightness() const {return 0;}
    33     virtual int MaxBrightness() const {return 2;}
    34 	virtual void SetBrightness(int aBrightness);
    35 		//Clock support
    36 	virtual void ShowClock();
    37 	virtual void HideClock();
    38 	virtual bool SupportClock(){return true;}
    39 
    40 	//From GraphicDisplay
    41     virtual int WidthInPixels() const {return KMDM166AAWidthInPixels;}
    42     virtual int HeightInPixels() const {return KMDM166AAHeightInPixels;}
    43 
    44 	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel);
    45 	virtual void SetAllPixels(unsigned char aPattern);
    46     virtual int FrameBufferSizeInBytes() const {return KMDM166AAFrameBufferSizeInBytes;}	
    47 	virtual void Clear();
    48 	virtual void Fill();
    49 	virtual void Request(TMiniDisplayRequest aRequest);
    50 		
    51 	//
    52 	void ToggleOffScreenMode();
    53     void SetOffScreenMode(bool aOn);
    54     bool OffScreenMode() const {return iOffScreenMode;}
    55     //
    56     void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;}
    57     bool FrameDifferencing() const {return iUseFrameDifferencing;}
    58     //    
    59     TMiniDisplayRequest AttemptRequestCompletion();
    60     FutabaVfdReport& InputReport() {return iInputReport;}
    61     bool IsPowerOn();
    62 	char* DeviceId();
    63 	char* FirmwareRevision();
    64 
    65 private:
    66 
    67 	enum TClockFormat
    68 	{
    69 		EClock12	=	0x00,
    70 		EClock24	=	0x01,
    71 	};
    72 
    73 	enum TClockSize
    74 	{
    75 		EClockSmall		=	0x01,
    76 		EClockLarge		=	0x02
    77 	};
    78 	
    79 
    80 private:
    81 	//Specific to MDM166AA
    82 	//General setting command
    83 	void SendCommandClear();
    84 	void SendCommandReset();
    85 	//
    86 	//Clock commands
    87 	void SendCommandClockSetting(unsigned char aHour, unsigned char aMinute);
    88 	void SendCommandClockDisplay(TClockSize aClockSize, TClockFormat aClockFormat);	
    89 
    90 	//Graphics commands
    91 	void SendCommandSetAddressCounter(unsigned char aAddressCounter);
    92 	void SendCommandWriteGraphicData(int aSize, unsigned char* aPixels);
    93 
    94 
    95 private:
    96     void RequestDeviceId();
    97     void RequestFirmwareRevision();
    98     void RequestPowerSupplyStatus();
    99 	//
   100 	void SetClockSetting();
   101 
   102 
   103 private:
   104 	unsigned char OffScreenY() const;	
   105 	void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
   106 	void ResetBuffers();
   107 
   108 private:
   109 	unsigned char iDisplayPositionX;
   110 	unsigned char iDisplayPositionY;
   111 	///Off screen mode is the recommended default settings to avoid tearing.
   112 	///Though turning it off can be useful for debugging
   113 	bool iOffScreenMode;
   114     ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
   115     bool iUseFrameDifferencing;
   116 	///
   117 	//FutabaVfdReport iReport;
   118 	///
   119 	//unsigned char iFrameBuffer[256*64];
   120     BitArrayLow* iFrameNext;
   121     BitArrayLow* iFrameCurrent;
   122     BitArrayLow* iFramePrevious;
   123     //
   124     BitArrayLow* iFrameAlpha;
   125     BitArrayLow* iFrameBeta;
   126     BitArrayLow* iFrameGamma;
   127     //
   128     int iNeedFullFrameUpdate;
   129 	//unsigned char iFrameBeta[256*64];
   130 	//unsigned char *iFrontBuffer;
   131 	//unsigned char *iBackBuffer;
   132     FutabaVfdReport iInputReport;
   133 	//
   134 	char iDeviceId[KFutabaMaxHidReportSize];
   135 	char iFirmwareRevision[KFutabaMaxHidReportSize];
   136     bool iPowerOn;
   137 	};
   138 
   139 
   140 
   141 #endif