FutabaMDM166AA.h
author StephaneLenclud
Sat, 07 Feb 2015 13:50:11 +0100
changeset 32 2c844ef1ff4b
parent 31 0a2b658e0d56
child 33 fc42477ae80b
permissions -rw-r--r--
MDM166AA: Improved icon APIs.
     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 		//Icons
    39 	virtual int IconCount(TMiniDisplayIconType aIcon);
    40 	virtual int IconStatusCount(TMiniDisplayIconType aIcon);
    41 	virtual void SetIconStatus(TMiniDisplayIconType aIcon, int aIndex, int aStatus);
    42 
    43 	//From GraphicDisplay
    44     virtual int WidthInPixels() const {return KMDM166AAWidthInPixels;}
    45     virtual int HeightInPixels() const {return KMDM166AAHeightInPixels;}
    46 
    47 	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel);
    48 	virtual void SetAllPixels(unsigned char aPattern);
    49     virtual int FrameBufferSizeInBytes() const {return KMDM166AAFrameBufferSizeInBytes;}	
    50 	virtual void Clear();
    51 	virtual void Fill();
    52 	virtual void Request(TMiniDisplayRequest aRequest);
    53 		
    54 	//
    55 	void ToggleOffScreenMode();
    56     void SetOffScreenMode(bool aOn);
    57     bool OffScreenMode() const {return iOffScreenMode;}
    58 
    59 		//Icon specific
    60 	void SetIconNetwork(int aIndex, int aStatus);
    61 	void SetIconEmail(int aIndex, int aStatus);
    62 	void SetIconMute(int aIndex, int aStatus);
    63 	void SetIconVolumeLabel(int aIndex, int aStatus);
    64 	void SetIconVolume(int aIndex, int aStatus);
    65 	void SetIconPlay(int aIndex, int aStatus);
    66 	void SetIconPause(int aIndex, int aStatus);
    67 	void SetIconRecording(int aIndex, int aStatus);
    68 
    69 
    70 private:
    71 
    72 	enum TClockFormat
    73 		{
    74 		EClock12	=	0x00,
    75 		EClock24	=	0x01,
    76 		};
    77 
    78 	enum TClockSize
    79 		{
    80 		EClockSmall		=	0x01,
    81 		EClockLarge		=	0x02
    82 		};
    83 	
    84 	enum TIconId
    85 		{		
    86 		EIconPlay				=	0x00,
    87 		EIconPause				=	0x01,
    88 		EIconRecording			=	0x02,
    89 		EIconEnvelop			=	0x03,
    90 		EIconAt					=	0x04,
    91 		EIconMute				=	0x05,
    92 		EIconNetworkMast		=   0x06,
    93 		EIconNetworkSignalLow	=   0x07,
    94 		EIconNetworkSignalMid	=   0x08,
    95 		EIconNetworkSignalHigh	=   0x09,
    96 		EIconVolumeLabel		=   0x0A,
    97 		EIconVolumeLevel01		=   0x0B,
    98 		EIconVolumeLevel02		=   0x0C,
    99 		EIconVolumeLevel03		=   0x0D,
   100 		EIconVolumeLevel04		=   0x0E,
   101 		EIconVolumeLevel05		=   0x0F,
   102 		EIconVolumeLevel06		=   0x10,
   103 		EIconVolumeLevel07		=   0x11,
   104 		EIconVolumeLevel08		=   0x12,
   105 		EIconVolumeLevel09		=   0x13,
   106 		EIconVolumeLevel10		=   0x14,
   107 		EIconVolumeLevel11		=   0x15,
   108 		EIconVolumeLevel12		=   0x16,
   109 		EIconVolumeLevel13		=   0x17,
   110 		EIconVolumeLevel14		=   0x18,
   111 		EIconFirst				=   EIconPlay,
   112 		EIconLast				=	EIconVolumeLevel14,		
   113 		};
   114 
   115 	enum TIconStatus
   116 		{
   117 		EIconOff		=	0x00,
   118 		EIconFaded		=	0x01,
   119 		EIconOn			=	0x02
   120 		};
   121 	
   122 
   123 private:
   124 	//Testing
   125 	void SetAllIcons(TIconStatus aStatus);
   126 
   127 	//Specific to MDM166AA
   128 	//General setting command
   129 	void SendCommandClear();
   130 	void SendCommandReset();
   131 	//
   132 	//Clock commands
   133 	void SendCommandSetClockData(unsigned char aHour, unsigned char aMinute);
   134 	void SendCommandClockDisplay(TClockSize aClockSize, TClockFormat aClockFormat);	
   135 	void AttemptClockSynchronization();
   136 
   137 	//Graphics commands
   138 	void SendCommandSetAddressCounter(unsigned char aAddressCounter);
   139 	void SendCommandWriteGraphicData(int aSize, unsigned char* aPixels);
   140 
   141 	//Icon/Symbol command
   142 	void SendCommandSymbolControl(TIconId aIconId, TIconStatus aStatus);
   143 
   144     void RequestDeviceId();
   145     void RequestFirmwareRevision();
   146     void RequestPowerSupplyStatus();
   147 	//
   148 	void SetClockData();
   149 	//
   150 	void ResetBuffers();
   151 
   152 private:
   153 	///Off screen mode is the recommended default settings to avoid tearing.
   154 	///Though turning it off can be useful for debugging
   155 	bool iOffScreenMode;
   156 	///We use this flag to align display clock seconds with system time
   157 	bool iNeedAccurateClockData;
   158     //
   159 	BitArrayLow* iFrameNext;
   160     BitArrayLow* iFrameCurrent;
   161     BitArrayLow* iFramePrevious;
   162     //
   163     BitArrayLow* iFrameAlpha; //owned
   164     BitArrayLow* iFrameBeta;  //owned
   165     BitArrayLow* iFrameGamma; //owned
   166 	};
   167 
   168 
   169 
   170 #endif