FutabaMDM166AA.h
author StephaneLenclud
Sat, 26 Sep 2015 11:45:26 +0200
changeset 39 c32f4955c166
parent 33 fc42477ae80b
permissions -rw-r--r--
More fixes to our NuGet package targets file.
     1 //
     2 // Copyright (C) 2014-2015 Stéphane Lenclud.
     3 //
     4 // This file is part of MiniDisplay.
     5 //
     6 // MiniDisplay is free software: you can redistribute it and/or modify
     7 // it under the terms of the GNU General Public License as published by
     8 // the Free Software Foundation, either version 3 of the License, or
     9 // (at your option) any later version.
    10 //
    11 // MiniDisplay is distributed in the hope that it will be useful,
    12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 // GNU General Public License for more details.
    15 //
    16 // You should have received a copy of the GNU General Public License
    17 // along with MiniDisplay.  If not, see <http://www.gnu.org/licenses/>.
    18 //
    19 
    20 #ifndef FUTABA_MDM166AA_H
    21 #define FUTABA_MDM166AA_H
    22 
    23 #include "FutabaVfd.h"
    24 
    25 
    26 const int KMDM166AAWidthInPixels = 96;
    27 const int KMDM166AAHeightInPixels = 16;
    28 const int KMDM166AAPixelsPerByte = 8;
    29 const int KMDM166AAFrameBufferSizeInBytes = KMDM166AAWidthInPixels*KMDM166AAHeightInPixels/KMDM166AAPixelsPerByte; //96*16/8=192
    30 const int KMDM166AAFrameBufferPixelCount = KMDM166AAWidthInPixels*KMDM166AAHeightInPixels;
    31 
    32 
    33 /**
    34 MDM166AA is a graphic display module using a FUTABA 96x16dots VFD.
    35 */
    36 class MDM166AA : public FutabaGraphicDisplay
    37 	{
    38 public:
    39     MDM166AA();
    40     ~MDM166AA();
    41 
    42 	//From DisplayBase
    43 	virtual int Open();
    44 	virtual void SwapBuffers();
    45 		//Brightness support
    46     virtual int MinBrightness() const {return 0;}
    47     virtual int MaxBrightness() const {return 2;}
    48 	virtual void SetBrightness(int aBrightness);
    49 		//Clock support
    50 	virtual void ShowClock();
    51 	virtual void HideClock();
    52 	virtual bool SupportClock(){return true;}
    53 		//Icons
    54 	virtual int IconCount(TMiniDisplayIconType aIcon);
    55 	virtual int IconStatusCount(TMiniDisplayIconType aIcon);
    56 	virtual void SetIconStatus(TMiniDisplayIconType aIcon, int aIndex, int aStatus);
    57 
    58 	//From GraphicDisplay
    59     virtual int WidthInPixels() const {return KMDM166AAWidthInPixels;}
    60     virtual int HeightInPixels() const {return KMDM166AAHeightInPixels;}
    61 
    62 	virtual void SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel);
    63 	virtual void SetAllPixels(unsigned char aPattern);
    64     virtual int FrameBufferSizeInBytes() const {return KMDM166AAFrameBufferSizeInBytes;}	
    65 	virtual void Clear();
    66 	virtual void Fill();
    67 	virtual void Request(TMiniDisplayRequest aRequest);
    68 		
    69 	//
    70 	void ToggleOffScreenMode();
    71     void SetOffScreenMode(bool aOn);
    72     bool OffScreenMode() const {return iOffScreenMode;}
    73 
    74 		//Icon specific
    75 	void SetIconNetworkSignal(int aIndex, int aStatus);
    76 	void SetIconInternet(int aIndex, int aStatus);
    77 	void SetIconEmail(int aIndex, int aStatus);
    78 	void SetIconMute(int aIndex, int aStatus);
    79 	void SetIconVolumeLabel(int aIndex, int aStatus);
    80 	void SetIconVolume(int aIndex, int aStatus);
    81 	void SetIconPlay(int aIndex, int aStatus);
    82 	void SetIconPause(int aIndex, int aStatus);
    83 	void SetIconRecording(int aIndex, int aStatus);
    84 
    85 
    86 private:
    87 
    88 	enum TClockFormat
    89 		{
    90 		EClock12	=	0x00,
    91 		EClock24	=	0x01,
    92 		};
    93 
    94 	enum TClockSize
    95 		{
    96 		EClockSmall		=	0x01,
    97 		EClockLarge		=	0x02
    98 		};
    99 	
   100 	enum TIconId
   101 		{		
   102 		EIconPlay				=	0x00,
   103 		EIconPause				=	0x01,
   104 		EIconRecording			=	0x02,
   105 		EIconEnvelop			=	0x03,
   106 		EIconAt					=	0x04,
   107 		EIconMute				=	0x05,
   108 		EIconNetworkMast		=   0x06,
   109 		EIconNetworkSignalLow	=   0x07,
   110 		EIconNetworkSignalMid	=   0x08,
   111 		EIconNetworkSignalHigh	=   0x09,
   112 		EIconVolumeLabel		=   0x0A,
   113 		EIconVolumeLevel01		=   0x0B,
   114 		EIconVolumeLevel02		=   0x0C,
   115 		EIconVolumeLevel03		=   0x0D,
   116 		EIconVolumeLevel04		=   0x0E,
   117 		EIconVolumeLevel05		=   0x0F,
   118 		EIconVolumeLevel06		=   0x10,
   119 		EIconVolumeLevel07		=   0x11,
   120 		EIconVolumeLevel08		=   0x12,
   121 		EIconVolumeLevel09		=   0x13,
   122 		EIconVolumeLevel10		=   0x14,
   123 		EIconVolumeLevel11		=   0x15,
   124 		EIconVolumeLevel12		=   0x16,
   125 		EIconVolumeLevel13		=   0x17,
   126 		EIconVolumeLevel14		=   0x18,
   127 		EIconFirst				=   EIconPlay,
   128 		EIconLast				=	EIconVolumeLevel14,		
   129 		};
   130 
   131 	enum TIconStatus
   132 		{
   133 		EIconOff		=	0x00,
   134 		EIconFaded		=	0x01,
   135 		EIconOn			=	0x02
   136 		};
   137 	
   138 
   139 private:
   140 	//Testing
   141 	void SetAllIcons(TIconStatus aStatus);
   142 
   143 	//Specific to MDM166AA
   144 	//General setting command
   145 	void SendCommandClear();
   146 	void SendCommandReset();
   147 	//
   148 	//Clock commands
   149 	void SendCommandSetClockData(unsigned char aHour, unsigned char aMinute);
   150 	void SendCommandClockDisplay(TClockSize aClockSize, TClockFormat aClockFormat);	
   151 	void AttemptClockSynchronization();
   152 
   153 	//Graphics commands
   154 	void SendCommandSetAddressCounter(unsigned char aAddressCounter);
   155 	void SendCommandWriteGraphicData(int aSize, unsigned char* aPixels);
   156 
   157 	//Icon/Symbol command
   158 	void SendCommandSymbolControl(TIconId aIconId, TIconStatus aStatus);
   159 
   160     void RequestDeviceId();
   161     void RequestFirmwareRevision();
   162     void RequestPowerSupplyStatus();
   163 	//
   164 	void SetClockData();
   165 	//
   166 	void ResetBuffers();
   167 
   168 private:
   169 	///Off screen mode is the recommended default settings to avoid tearing.
   170 	///Though turning it off can be useful for debugging
   171 	bool iOffScreenMode;
   172 	///We use this flag to align display clock seconds with system time
   173 	bool iNeedAccurateClockData;
   174     //
   175 	BitArrayLow* iFrameNext;
   176     BitArrayLow* iFrameCurrent;
   177     BitArrayLow* iFramePrevious;
   178     //
   179     BitArrayLow* iFrameAlpha; //owned
   180     BitArrayLow* iFrameBeta;  //owned
   181     BitArrayLow* iFrameGamma; //owned
   182 	};
   183 
   184 
   185 
   186 #endif