MDM166AA: Adding icon support.
authorStephaneLenclud
Thu, 05 Feb 2015 22:26:15 +0100
changeset 310a2b658e0d56
parent 30 7f649078cb52
child 32 2c844ef1ff4b
MDM166AA: Adding icon support.
Display.h
FutabaMDM166AA.cpp
FutabaMDM166AA.h
MiniDisplay.cpp
MiniDisplay.h
     1.1 --- a/Display.h	Thu Feb 05 15:09:48 2015 +0100
     1.2 +++ b/Display.h	Thu Feb 05 22:26:15 2015 +0100
     1.3 @@ -55,6 +55,24 @@
     1.4  	virtual void HideClock(){}
     1.5  	virtual bool SupportClock(){return false;}
     1.6  
     1.7 +	//Icon management
     1.8 +	//Icon support queries return the number of segments an icon supports.
     1.9 +	virtual int IconNetworkCount(){return 0;}
    1.10 +	virtual int IconEmailCount(){return 0;}
    1.11 +	virtual int IconMuteCount(){return 0;}
    1.12 +	virtual int IconVolumeCount(){return 0;}
    1.13 +	virtual int IconPlayCount(){return 0;}
    1.14 +	virtual int IconPauseCount(){return 0;}
    1.15 +	virtual int IconRecordingCount(){return 0;}
    1.16 +	//
    1.17 +	virtual void SetIconNetwork(int /*aIndex*/, int /*aStatus*/){}
    1.18 +	virtual void SetIconEmail(int /*aIndex*/, int /*aStatus*/){}
    1.19 +	virtual void SetIconMute(int /*aIndex*/, int /*aStatus*/){}
    1.20 +	virtual void SetIconVolume(int /*aIndex*/, int /*aStatus*/){}
    1.21 +	virtual void SetIconPlay(int /*aIndex*/, int /*aStatus*/){}
    1.22 +	virtual void SetIconPause(int /*aIndex*/, int /*aStatus*/){}
    1.23 +	virtual void SetIconRecording(int /*aIndex*/, int /*aStatus*/){}
    1.24 +
    1.25  protected:
    1.26  	void SetRequest(TMiniDisplayRequest aRequest) { iRequest=aRequest; }
    1.27  
     2.1 --- a/FutabaMDM166AA.cpp	Thu Feb 05 15:09:48 2015 +0100
     2.2 +++ b/FutabaMDM166AA.cpp	Thu Feb 05 22:26:15 2015 +0100
     2.3 @@ -86,6 +86,13 @@
     2.4  		//We don't set clock data here as it turns on clock display too and cause an unpleasant clock flash
     2.5  		//Only side effect from not doing this here is that for at most one minute the first time you cold boot your display the time should be wrong.
     2.6  		//SetClockData();
     2.7 +
     2.8 +		//Turns mast ON
     2.9 +		//SetIconNetwork(0,EIconOn);
    2.10 +		//Show volume label
    2.11 +		//SendCommandSymbolControl(EIconVolumeLabel,EIconOn);
    2.12 +		//Icon checks
    2.13 +		//SetAllIcons(EIconOn);
    2.14  		}
    2.15  	return success;
    2.16  	}
    2.17 @@ -128,6 +135,7 @@
    2.18      {
    2.19  	//That one also clear the symbols
    2.20      SetAllPixels(0x00);
    2.21 +	SendCommandClear(); //Clear icons too
    2.22      }
    2.23  
    2.24  /**
    2.25 @@ -381,6 +389,136 @@
    2.26  
    2.27  
    2.28  /**
    2.29 +*/
    2.30 +void MDM166AA::SetIconNetwork(int aIndex, int aStatus)
    2.31 +	{
    2.32 +	if (aIndex<0||aIndex>=IconNetworkCount())
    2.33 +		{
    2.34 +		//Out of range
    2.35 +		return;
    2.36 +		}
    2.37 +
    2.38 +	SendCommandSymbolControl((TIconId)(aIndex+EIconNetworkMast),(aStatus==0?EIconOff:EIconOn));
    2.39 +	}
    2.40 +
    2.41 +/**
    2.42 +*/
    2.43 +void MDM166AA::SetIconEmail(int aIndex, int aStatus)
    2.44 +	{
    2.45 +	if (aIndex<0||aIndex>=IconEmailCount())
    2.46 +		{
    2.47 +		//Out of range
    2.48 +		return;
    2.49 +		}
    2.50 +
    2.51 +	SendCommandSymbolControl((TIconId)(aIndex+EIconEnvelop),(aStatus==0?EIconOff:EIconOn));
    2.52 +	}
    2.53 +
    2.54 +/**
    2.55 +*/
    2.56 +void MDM166AA::SetIconMute(int aIndex, int aStatus)
    2.57 +	{
    2.58 +	if (aIndex<0||aIndex>=IconMuteCount())
    2.59 +		{
    2.60 +		//Out of range
    2.61 +		return;
    2.62 +		}
    2.63 +
    2.64 +	SendCommandSymbolControl((TIconId)(aIndex+EIconMute),(aStatus==0?EIconOff:EIconOn));
    2.65 +	}
    2.66 +
    2.67 +/**
    2.68 +*/
    2.69 +void MDM166AA::SetIconVolume(int aIndex, int aStatus)
    2.70 +	{
    2.71 +	if (aIndex<0||aIndex>=IconVolumeCount())
    2.72 +		{
    2.73 +		//Out of range
    2.74 +		return;
    2.75 +		}
    2.76 +
    2.77 +	if (aStatus<EIconOff||aStatus>EIconOn)
    2.78 +		{
    2.79 +		//Out of range
    2.80 +		return;
    2.81 +		}
    2.82 +
    2.83 +	SendCommandSymbolControl((TIconId)(aIndex+EIconVolumeLevel01),(TIconStatus)aStatus);
    2.84 +	}
    2.85 +
    2.86 +
    2.87 +/**
    2.88 +*/
    2.89 +void MDM166AA::SetIconPlay(int aIndex, int aStatus)
    2.90 +	{
    2.91 +	if (aIndex<0||aIndex>=IconPlayCount())
    2.92 +		{
    2.93 +		//Out of range
    2.94 +		return;
    2.95 +		}
    2.96 +
    2.97 +	SendCommandSymbolControl((TIconId)(aIndex+EIconPlay),(aStatus==0?EIconOff:EIconOn));
    2.98 +	}
    2.99 +
   2.100 +
   2.101 +/**
   2.102 +*/
   2.103 +void MDM166AA::SetIconPause(int aIndex, int aStatus)
   2.104 +	{
   2.105 +	if (aIndex<0||aIndex>=IconPauseCount())
   2.106 +		{
   2.107 +		//Out of range
   2.108 +		return;
   2.109 +		}
   2.110 +
   2.111 +	SendCommandSymbolControl((TIconId)(aIndex+EIconPause),(aStatus==0?EIconOff:EIconOn));
   2.112 +	}
   2.113 +
   2.114 +
   2.115 +/**
   2.116 +*/
   2.117 +void MDM166AA::SetIconRecording(int aIndex, int aStatus)
   2.118 +	{
   2.119 +	if (aIndex<0||aIndex>=IconRecordingCount())
   2.120 +		{
   2.121 +		//Out of range
   2.122 +		return;
   2.123 +		}
   2.124 +
   2.125 +	SendCommandSymbolControl((TIconId)(aIndex+EIconRecording),(aStatus==0?EIconOff:EIconOn));
   2.126 +	}
   2.127 +
   2.128 +/**
   2.129 +Set all our icons to the corresponding status.
   2.130 +*/
   2.131 +void MDM166AA::SetAllIcons(TIconStatus aStatus)
   2.132 +	{
   2.133 +	for (int i=EIconFirst;i<=EIconLast;i++)
   2.134 +		{
   2.135 +		SendCommandSymbolControl((TIconId)i,aStatus);
   2.136 +		}
   2.137 +	}
   2.138 +
   2.139 +/**
   2.140 +Symbols control
   2.141 +Segment On/Off and Grayscale/Brightness
   2.142 +[Code]1BH,30H,Ps,Pb
   2.143 +*/
   2.144 +void MDM166AA::SendCommandSymbolControl(TIconId aIconId, TIconStatus aStatus)
   2.145 +	{
   2.146 +	FutabaVfdReport report;
   2.147 +    report[0]=0x00; //Report ID
   2.148 +    report[1]=0x04; //Report size
   2.149 +    report[2]=0x1B; //Command ID
   2.150 +    report[3]=0x30; //Command ID
   2.151 +	report[4]=aIconId;
   2.152 +	report[5]=aStatus;
   2.153 +
   2.154 +    Write(report);
   2.155 +	}
   2.156 +
   2.157 +
   2.158 +/**
   2.159  Clock setting 
   2.160  [Code]1BH,00H,Pm,Ph 
   2.161  [Function]Setting the clock data. The setting data is cleared, if the Reset command is input or power is turned off.
   2.162 @@ -404,7 +542,6 @@
   2.163      Write(report);
   2.164  	}
   2.165  
   2.166 -
   2.167  /**
   2.168  Set display clock data according to local system time.
   2.169  This will only provide 30s accuracy.
   2.170 @@ -467,6 +604,7 @@
   2.171  Display RAM filled with 00H.
   2.172  Address Counter is set by 00H.
   2.173  Dimming is set to 50%.
   2.174 +Turn off all icons segments.
   2.175  */
   2.176  void MDM166AA::SendCommandReset()
   2.177  	{
   2.178 @@ -475,8 +613,6 @@
   2.179  	report[1]=0x01; //Report length.
   2.180  	report[2]=0x1F; //Command ID
   2.181  	Write(report);
   2.182 -	//Wait until reset is done. Is that needed?
   2.183 -	//sleep(2000);
   2.184  	}
   2.185  
   2.186  
     3.1 --- a/FutabaMDM166AA.h	Thu Feb 05 15:09:48 2015 +0100
     3.2 +++ b/FutabaMDM166AA.h	Thu Feb 05 22:26:15 2015 +0100
     3.3 @@ -35,6 +35,22 @@
     3.4  	virtual void ShowClock();
     3.5  	virtual void HideClock();
     3.6  	virtual bool SupportClock(){return true;}
     3.7 +		//Icons
     3.8 +	virtual int IconNetworkCount(){return 4;}
     3.9 +	virtual int IconEmailCount(){return 2;}
    3.10 +	virtual int IconMuteCount(){return 1;}
    3.11 +	virtual int IconVolumeCount(){return 14;} //TODO: What do we do with "VOL."
    3.12 +	virtual int IconPlayCount(){return 1;}
    3.13 +	virtual int IconPauseCount(){return 1;}
    3.14 +	virtual int IconRecordingCount(){return 1;}
    3.15 +	//
    3.16 +	virtual void SetIconNetwork(int aIndex, int aStatus);
    3.17 +	virtual void SetIconEmail(int aIndex, int aStatus);
    3.18 +	virtual void SetIconMute(int aIndex, int aStatus);
    3.19 +	virtual void SetIconVolume(int aIndex, int aStatus);
    3.20 +	virtual void SetIconPlay(int aIndex, int aStatus);
    3.21 +	virtual void SetIconPause(int aIndex, int aStatus);
    3.22 +	virtual void SetIconRecording(int aIndex, int aStatus);
    3.23  
    3.24  	//From GraphicDisplay
    3.25      virtual int WidthInPixels() const {return KMDM166AAWidthInPixels;}
    3.26 @@ -66,8 +82,49 @@
    3.27  		EClockLarge		=	0x02
    3.28  		};
    3.29  	
    3.30 +	enum TIconId
    3.31 +		{		
    3.32 +		EIconPlay				=	0x00,
    3.33 +		EIconPause				=	0x01,
    3.34 +		EIconRecording			=	0x02,
    3.35 +		EIconEnvelop			=	0x03,
    3.36 +		EIconAt					=	0x04,
    3.37 +		EIconMute				=	0x05,
    3.38 +		EIconNetworkMast		=   0x06,
    3.39 +		EIconNetworkSignalLow	=   0x07,
    3.40 +		EIconNetworkSignalMid	=   0x08,
    3.41 +		EIconNetworkSignalHigh	=   0x09,
    3.42 +		EIconVolumeLabel		=   0x0A,
    3.43 +		EIconVolumeLevel01		=   0x0B,
    3.44 +		EIconVolumeLevel02		=   0x0C,
    3.45 +		EIconVolumeLevel03		=   0x0D,
    3.46 +		EIconVolumeLevel04		=   0x0E,
    3.47 +		EIconVolumeLevel05		=   0x0F,
    3.48 +		EIconVolumeLevel06		=   0x10,
    3.49 +		EIconVolumeLevel07		=   0x11,
    3.50 +		EIconVolumeLevel08		=   0x12,
    3.51 +		EIconVolumeLevel09		=   0x13,
    3.52 +		EIconVolumeLevel10		=   0x14,
    3.53 +		EIconVolumeLevel11		=   0x15,
    3.54 +		EIconVolumeLevel12		=   0x16,
    3.55 +		EIconVolumeLevel13		=   0x17,
    3.56 +		EIconVolumeLevel14		=   0x18,
    3.57 +		EIconFirst				=   EIconPlay,
    3.58 +		EIconLast				=	EIconVolumeLevel14,		
    3.59 +		};
    3.60 +
    3.61 +	enum TIconStatus
    3.62 +		{
    3.63 +		EIconOff		=	0x00,
    3.64 +		EIconFaded		=	0x01,
    3.65 +		EIconOn			=	0x02
    3.66 +		};
    3.67 +	
    3.68  
    3.69  private:
    3.70 +	//Testing
    3.71 +	void SetAllIcons(TIconStatus aStatus);
    3.72 +
    3.73  	//Specific to MDM166AA
    3.74  	//General setting command
    3.75  	void SendCommandClear();
    3.76 @@ -82,6 +139,9 @@
    3.77  	void SendCommandSetAddressCounter(unsigned char aAddressCounter);
    3.78  	void SendCommandWriteGraphicData(int aSize, unsigned char* aPixels);
    3.79  
    3.80 +	//Icon/Symbol command
    3.81 +	void SendCommandSymbolControl(TIconId aIconId, TIconStatus aStatus);
    3.82 +
    3.83      void RequestDeviceId();
    3.84      void RequestFirmwareRevision();
    3.85      void RequestPowerSupplyStatus();
     4.1 --- a/MiniDisplay.cpp	Thu Feb 05 15:09:48 2015 +0100
     4.2 +++ b/MiniDisplay.cpp	Thu Feb 05 22:26:15 2015 +0100
     4.3 @@ -290,4 +290,88 @@
     4.4  bool MiniDisplaySupportClock(MiniDisplayDevice aDevice)
     4.5      {
     4.6      return ((GraphicDisplay*)aDevice)->SupportClock();
     4.7 -    }
     4.8 \ No newline at end of file
     4.9 +    }
    4.10 +
    4.11 +//-------------------------------------------------------------
    4.12 +int MiniDisplayIconNetworkCount(MiniDisplayDevice aDevice)
    4.13 +	{
    4.14 +    return ((GraphicDisplay*)aDevice)->IconNetworkCount();
    4.15 +    }
    4.16 +
    4.17 +//-------------------------------------------------------------
    4.18 +int MiniDisplayIconEmailCount(MiniDisplayDevice aDevice)
    4.19 +	{
    4.20 +    return ((GraphicDisplay*)aDevice)->IconEmailCount();
    4.21 +    }
    4.22 +
    4.23 +//-------------------------------------------------------------
    4.24 +int MiniDisplayIconMuteCount(MiniDisplayDevice aDevice)
    4.25 +	{
    4.26 +    return ((GraphicDisplay*)aDevice)->IconMuteCount();
    4.27 +    }
    4.28 +
    4.29 +//-------------------------------------------------------------
    4.30 +int MiniDisplayIconVolumeCount(MiniDisplayDevice aDevice)
    4.31 +	{
    4.32 +    return ((GraphicDisplay*)aDevice)->IconVolumeCount();
    4.33 +    }
    4.34 +
    4.35 +//-------------------------------------------------------------
    4.36 +int MiniDisplayIconPlayCount(MiniDisplayDevice aDevice)
    4.37 +	{
    4.38 +    return ((GraphicDisplay*)aDevice)->IconPlayCount();
    4.39 +    }
    4.40 +
    4.41 +//-------------------------------------------------------------
    4.42 +int MiniDisplayIconPauseCount(MiniDisplayDevice aDevice)
    4.43 +	{
    4.44 +    return ((GraphicDisplay*)aDevice)->IconPauseCount();
    4.45 +    }
    4.46 +
    4.47 +//-------------------------------------------------------------
    4.48 +int MiniDisplayIconRecordingCount(MiniDisplayDevice aDevice)
    4.49 +	{
    4.50 +    return ((GraphicDisplay*)aDevice)->IconRecordingCount();
    4.51 +    }
    4.52 +
    4.53 +//-------------------------------------------------------------
    4.54 +void MiniDisplaySetIconNetwork(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.55 +    {
    4.56 +    ((GraphicDisplay*)aDevice)->SetIconNetwork(aIndex,aStatus);
    4.57 +    }
    4.58 +
    4.59 +//-------------------------------------------------------------
    4.60 +void MiniDisplaySetIconEmail(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.61 +    {
    4.62 +    ((GraphicDisplay*)aDevice)->SetIconEmail(aIndex,aStatus);
    4.63 +    }
    4.64 +
    4.65 +//-------------------------------------------------------------
    4.66 +void MiniDisplaySetIconMute(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.67 +    {
    4.68 +    ((GraphicDisplay*)aDevice)->SetIconMute(aIndex,aStatus);
    4.69 +    }
    4.70 +
    4.71 +//-------------------------------------------------------------
    4.72 +void MiniDisplaySetIconVolume(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.73 +    {
    4.74 +    ((GraphicDisplay*)aDevice)->SetIconVolume(aIndex,aStatus);
    4.75 +    }
    4.76 +
    4.77 +//-------------------------------------------------------------
    4.78 +void MiniDisplaySetIconPlay(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.79 +    {
    4.80 +    ((GraphicDisplay*)aDevice)->SetIconPlay(aIndex,aStatus);
    4.81 +    }
    4.82 +
    4.83 +//-------------------------------------------------------------
    4.84 +void MiniDisplaySetIconPause(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.85 +    {
    4.86 +    ((GraphicDisplay*)aDevice)->SetIconPause(aIndex,aStatus);
    4.87 +    }
    4.88 +
    4.89 +//-------------------------------------------------------------
    4.90 +void MiniDisplaySetIconRecording(MiniDisplayDevice aDevice, int aIndex, int aStatus)
    4.91 +    {
    4.92 +    ((GraphicDisplay*)aDevice)->SetIconRecording(aIndex,aStatus);
    4.93 +    }
     5.1 --- a/MiniDisplay.h	Thu Feb 05 15:09:48 2015 +0100
     5.2 +++ b/MiniDisplay.h	Thu Feb 05 22:26:15 2015 +0100
     5.3 @@ -253,5 +253,22 @@
     5.4  extern "C" MDAPI bool MiniDisplaySupportClock(MiniDisplayDevice aDevice);
     5.5  
     5.6  
     5.7 +extern "C" MDAPI int MiniDisplayIconNetworkCount(MiniDisplayDevice aDevice);
     5.8 +extern "C" MDAPI int MiniDisplayIconEmailCount(MiniDisplayDevice aDevice);
     5.9 +extern "C" MDAPI int MiniDisplayIconMuteCount(MiniDisplayDevice aDevice);
    5.10 +extern "C" MDAPI int MiniDisplayIconVolumeCount(MiniDisplayDevice aDevice);
    5.11 +extern "C" MDAPI int MiniDisplayIconPlayCount(MiniDisplayDevice aDevice);
    5.12 +extern "C" MDAPI int MiniDisplayIconPauseCount(MiniDisplayDevice aDevice);
    5.13 +extern "C" MDAPI int MiniDisplayIconRecordingCount(MiniDisplayDevice aDevice);
    5.14 +//
    5.15 +extern "C" MDAPI void MiniDisplaySetIconNetwork(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.16 +extern "C" MDAPI void MiniDisplaySetIconEmail(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.17 +extern "C" MDAPI void MiniDisplaySetIconMute(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.18 +extern "C" MDAPI void MiniDisplaySetIconVolume(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.19 +extern "C" MDAPI void MiniDisplaySetIconPlay(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.20 +extern "C" MDAPI void MiniDisplaySetIconPause(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.21 +extern "C" MDAPI void MiniDisplaySetIconRecording(MiniDisplayDevice aDevice, int aIndex, int aStatus);
    5.22 +
    5.23 +
    5.24  #endif
    5.25