MiniDisplay.cpp
author sl
Sat, 06 Sep 2014 18:39:49 +0200
changeset 21 fa7c9f9140aa
parent 18 96c013c63595
child 22 ea9ccfdb5563
permissions -rw-r--r--
GP1212A02: Adding select font size command.
     1 
     2 #include "MiniDisplay.h"
     3 #include "FutabaGP1212A01.h"
     4 #include "FutabaGP1212A02.h"
     5 
     6 
     7 MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType, bool aAutoDetect)
     8 	{
     9 	GraphicDisplay* device=NULL;
    10 
    11 	switch (aType)
    12 		{
    13 	case EMiniDisplayAutoDetect:
    14 	case EMiniDisplayFutabaGP1212A01:
    15 		device=new GP1212A01A();
    16 		break;
    17 		
    18 	case EMiniDisplayFutabaGP1212A02:
    19 		device=new GP1212A02A();
    20 		break;
    21 
    22 	case EMiniDisplayAutoDetectFailed:
    23 		//Auto detect sequence failed
    24 		return NULL;
    25 		break;
    26 		};
    27 
    28 	int success = device->Open();
    29 	if (!success)
    30 		{
    31 		delete device;
    32 		device=NULL;
    33 		if (aAutoDetect)
    34 			{
    35 			//Go recursive for auto detect
    36 			int typeValue=(int)aType;
    37 			typeValue++;
    38 			TMiniDisplayType nextType=(TMiniDisplayType)typeValue;
    39 			return MiniDisplayOpen(nextType,aAutoDetect);
    40 			}
    41 		}
    42 
    43 	return device;
    44 	}
    45 
    46 
    47 //Open & Close functions
    48 MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType)
    49 	{
    50 	bool autoDetect=aType==EMiniDisplayAutoDetect;
    51 	//If we want auto detect we need to pass in our first display type
    52 	//If we don't want auto detect we just pass in the given display type. 
    53 	return MiniDisplayOpen((autoDetect?EMiniDisplayFutabaGP1212A01:aType),autoDetect);
    54 	}
    55 
    56 
    57 
    58 
    59 //
    60 
    61 void MiniDisplayClose(MiniDisplayDevice aDevice)
    62 	{
    63 	delete ((GraphicDisplay*)aDevice);
    64 	}
    65 
    66 
    67 void MiniDisplayClear(MiniDisplayDevice aDevice)
    68 	{
    69 	if (!aDevice)
    70 		{
    71 		return;
    72 		}
    73 
    74 	((GraphicDisplay*)aDevice)->Clear();
    75 	}
    76 
    77 
    78 void MiniDisplayFill(MiniDisplayDevice aDevice)
    79 	{
    80 	if (!aDevice)
    81 		{
    82 		return;
    83 		}
    84 
    85 	((GraphicDisplay*)aDevice)->Fill();
    86 	}
    87 
    88 
    89 void MiniDisplaySwapBuffers(MiniDisplayDevice aDevice)
    90 	{
    91 	if (!aDevice)
    92 		{
    93 		return;
    94 		}
    95 
    96 	((GraphicDisplay*)aDevice)->SwapBuffers();
    97 	}
    98 
    99 //-------------------------------------------------------------
   100 int MiniDisplayMaxBrightness(MiniDisplayDevice aDevice)
   101 	{
   102 	if (!aDevice)
   103 		{
   104 		return 0;
   105 		}
   106 
   107 	return ((GraphicDisplay*)aDevice)->MaxBrightness();
   108 	}
   109 
   110 //-------------------------------------------------------------
   111 int MiniDisplayMinBrightness(MiniDisplayDevice aDevice)
   112 	{
   113 	if (!aDevice)
   114 		{
   115 		return 0;
   116 		}
   117 
   118 	return ((GraphicDisplay*)aDevice)->MinBrightness();
   119 	}
   120 
   121 //-------------------------------------------------------------
   122 void MiniDisplaySetBrightness(MiniDisplayDevice aDevice, int aBrightness)
   123 	{
   124 	if (!aDevice)
   125 		{
   126 		return;
   127 		}
   128 
   129 	((GraphicDisplay*)aDevice)->SetBrightness(aBrightness);
   130 	}
   131 
   132 //-------------------------------------------------------------
   133 int MiniDisplayWidthInPixels(MiniDisplayDevice aDevice)
   134 	{
   135 	if (!aDevice)
   136 		{
   137 		return 0;
   138 		}
   139 
   140 	return ((GraphicDisplay*)aDevice)->WidthInPixels();
   141 	}
   142 
   143 //-------------------------------------------------------------
   144 int MiniDisplayHeightInPixels(MiniDisplayDevice aDevice)
   145 	{
   146 	if (!aDevice)
   147 		{
   148 		return 0;
   149 		}
   150 
   151 	return ((GraphicDisplay*)aDevice)->HeightInPixels();
   152 	}
   153 
   154 //-------------------------------------------------------------
   155 void MiniDisplaySetPixel(MiniDisplayDevice aDevice, int aX, int aY, int aValue)
   156 	{
   157 	//aValue&=0x00FFFFFF; //Filter out alpha component
   158 	return ((GraphicDisplay*)aDevice)->SetPixel(aX,aY,aValue);
   159 	}
   160 
   161 //-------------------------------------------------------------
   162 wchar_t* MiniDisplayVendor(MiniDisplayDevice aDevice)
   163     {
   164     return ((GraphicDisplay*)aDevice)->Vendor();
   165     }
   166 
   167 //-------------------------------------------------------------
   168 wchar_t* MiniDisplayProduct(MiniDisplayDevice aDevice)
   169     {
   170     return ((GraphicDisplay*)aDevice)->Product();
   171     }
   172 
   173 //-------------------------------------------------------------
   174 wchar_t* MiniDisplaySerialNumber(MiniDisplayDevice aDevice)
   175     {
   176     return ((GraphicDisplay*)aDevice)->SerialNumber();
   177     }
   178 
   179 //-------------------------------------------------------------
   180 void MiniDisplayRequest(MiniDisplayDevice aDevice, TMiniDisplayRequest aRequest)
   181     {
   182     ((GraphicDisplay*)aDevice)->Request(aRequest);
   183     }
   184 
   185 //-------------------------------------------------------------
   186 bool MiniDisplayRequestPending(MiniDisplayDevice aDevice)
   187     {
   188     return ((GraphicDisplay*)aDevice)->RequestPending();
   189     }
   190 
   191 //-------------------------------------------------------------
   192 TMiniDisplayRequest MiniDisplayCurrentRequest(MiniDisplayDevice aDevice)
   193     {
   194     return ((GraphicDisplay*)aDevice)->CurrentRequest();
   195     }
   196 
   197 //-------------------------------------------------------------
   198 void MiniDisplayCancelRequest(MiniDisplayDevice aDevice)
   199     {
   200     ((GraphicDisplay*)aDevice)->CancelRequest();
   201     }
   202 
   203 //-------------------------------------------------------------
   204 TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(MiniDisplayDevice aDevice)
   205 	{
   206 	return ((GraphicDisplay*)aDevice)->AttemptRequestCompletion();
   207 	}
   208 
   209 //-------------------------------------------------------------
   210 char* MiniDisplayDeviceId(MiniDisplayDevice aDevice)
   211 	{
   212 	return ((GraphicDisplay*)aDevice)->DeviceId();
   213 	}
   214 
   215 //-------------------------------------------------------------
   216 char* MiniDisplayFirmwareRevision(MiniDisplayDevice aDevice)
   217 	{
   218 	return ((GraphicDisplay*)aDevice)->FirmwareRevision();
   219 	}
   220 
   221 //-------------------------------------------------------------
   222 bool MiniDisplayPowerSupplyStatus(MiniDisplayDevice aDevice)
   223 	{
   224 	return ((GraphicDisplay*)aDevice)->IsPowerOn();
   225 	}
   226 
   227 //-------------------------------------------------------------
   228 void MiniDisplayPowerOn(MiniDisplayDevice aDevice)
   229     {
   230     ((GraphicDisplay*)aDevice)->TurnPowerOn();
   231     }
   232 
   233 //-------------------------------------------------------------
   234 void MiniDisplayPowerOff(MiniDisplayDevice aDevice)
   235     {
   236     ((GraphicDisplay*)aDevice)->TurnPowerOff();
   237     }
   238 
   239 //-------------------------------------------------------------
   240 bool MiniDisplaySupportPowerOnOff(MiniDisplayDevice aDevice)
   241     {
   242     return ((GraphicDisplay*)aDevice)->SupportPowerOnOff();
   243     }
   244 
   245 //-------------------------------------------------------------
   246 void MiniDisplayShowClock(MiniDisplayDevice aDevice)
   247     {
   248     ((GraphicDisplay*)aDevice)->ShowClock();
   249     }
   250 
   251 //-------------------------------------------------------------
   252 void MiniDisplayHideClock(MiniDisplayDevice aDevice)
   253     {
   254     ((GraphicDisplay*)aDevice)->HideClock();
   255     }
   256 
   257 //-------------------------------------------------------------
   258 bool MiniDisplaySupportClock(MiniDisplayDevice aDevice)
   259     {
   260     return ((GraphicDisplay*)aDevice)->SupportClock();
   261     }