Trying to sort out our interop nicely.
2 // Copyright (C) 2014-2015 Stéphane Lenclud.
4 // This file is part of MiniDisplay.
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.
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.
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/>.
20 #include "MiniDisplay.h"
21 #include "FutabaGP1212A01.h"
22 #include "FutabaGP1212A02.h"
23 #include "FutabaMDM166AA.h"
26 Make sure you update this list when adding a new display.
27 The order has to match the one from TMiniDisplayType.
29 wchar_t* KDisplayNames[]=
35 L"Unknown display device"
38 MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType, bool aAutoDetect)
40 GraphicDisplay* device=NULL;
44 case EMiniDisplayAutoDetect:
45 case EMiniDisplayFutabaGP1212A01:
46 device=new GP1212A01A();
49 case EMiniDisplayFutabaGP1212A02:
50 device=new GP1212A02A();
53 case EMiniDisplayFutabaMDM166AA:
54 device=new MDM166AA();
57 case EMiniDisplayAutoDetectFailed:
58 //Auto detect sequence failed
63 int success = device->Open();
70 //Go recursive for auto detect
71 int typeValue=(int)aType;
73 TMiniDisplayType nextType=(TMiniDisplayType)typeValue;
74 return MiniDisplayOpen(nextType,aAutoDetect);
82 //Open & Close functions
83 MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType)
85 bool autoDetect=aType==EMiniDisplayAutoDetect;
86 //If we want auto detect we need to pass in our first display type
87 //If we don't want auto detect we just pass in the given display type.
88 return MiniDisplayOpen((autoDetect?EMiniDisplayFutabaGP1212A01:aType),autoDetect);
94 void MiniDisplayClose(MiniDisplayDevice aDevice)
96 delete ((GraphicDisplay*)aDevice);
100 int MiniDisplayTypeCount()
102 return EMiniDisplayAutoDetectFailed;
106 wchar_t* MiniDisplayTypeName(TMiniDisplayType aType)
108 if (aType>=EMiniDisplayAutoDetectFailed)
110 return KDisplayNames[EMiniDisplayAutoDetectFailed];
113 return KDisplayNames[aType];
117 void MiniDisplayClear(MiniDisplayDevice aDevice)
124 ((GraphicDisplay*)aDevice)->Clear();
128 void MiniDisplayFill(MiniDisplayDevice aDevice)
135 ((GraphicDisplay*)aDevice)->Fill();
139 void MiniDisplaySwapBuffers(MiniDisplayDevice aDevice)
146 ((GraphicDisplay*)aDevice)->SwapBuffers();
149 //-------------------------------------------------------------
150 int MiniDisplayMaxBrightness(MiniDisplayDevice aDevice)
157 return ((GraphicDisplay*)aDevice)->MaxBrightness();
160 //-------------------------------------------------------------
161 int MiniDisplayMinBrightness(MiniDisplayDevice aDevice)
168 return ((GraphicDisplay*)aDevice)->MinBrightness();
171 //-------------------------------------------------------------
172 void MiniDisplaySetBrightness(MiniDisplayDevice aDevice, int aBrightness)
179 ((GraphicDisplay*)aDevice)->SetBrightness(aBrightness);
182 //-------------------------------------------------------------
183 int MiniDisplayWidthInPixels(MiniDisplayDevice aDevice)
190 return ((GraphicDisplay*)aDevice)->WidthInPixels();
193 //-------------------------------------------------------------
194 int MiniDisplayHeightInPixels(MiniDisplayDevice aDevice)
201 return ((GraphicDisplay*)aDevice)->HeightInPixels();
204 //-------------------------------------------------------------
205 void MiniDisplaySetPixel(MiniDisplayDevice aDevice, int aX, int aY, unsigned int aPixel)
207 //aValue&=0x00FFFFFF; //Filter out alpha component
208 return ((GraphicDisplay*)aDevice)->SetPixel(aX,aY,aPixel);
211 //-------------------------------------------------------------
212 wchar_t* MiniDisplayVendor(MiniDisplayDevice aDevice)
214 return ((GraphicDisplay*)aDevice)->Vendor();
217 //-------------------------------------------------------------
218 wchar_t* MiniDisplayProduct(MiniDisplayDevice aDevice)
220 return ((GraphicDisplay*)aDevice)->Product();
223 //-------------------------------------------------------------
224 wchar_t* MiniDisplaySerialNumber(MiniDisplayDevice aDevice)
226 return ((GraphicDisplay*)aDevice)->SerialNumber();
229 //-------------------------------------------------------------
230 void MiniDisplayRequest(MiniDisplayDevice aDevice, TMiniDisplayRequest aRequest)
232 ((GraphicDisplay*)aDevice)->Request(aRequest);
235 //-------------------------------------------------------------
236 bool MiniDisplayRequestPending(MiniDisplayDevice aDevice)
238 return ((GraphicDisplay*)aDevice)->RequestPending();
241 //-------------------------------------------------------------
242 TMiniDisplayRequest MiniDisplayCurrentRequest(MiniDisplayDevice aDevice)
244 return ((GraphicDisplay*)aDevice)->CurrentRequest();
247 //-------------------------------------------------------------
248 void MiniDisplayCancelRequest(MiniDisplayDevice aDevice)
250 ((GraphicDisplay*)aDevice)->CancelRequest();
253 //-------------------------------------------------------------
254 TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(MiniDisplayDevice aDevice)
256 return ((GraphicDisplay*)aDevice)->AttemptRequestCompletion();
259 //-------------------------------------------------------------
260 char* MiniDisplayDeviceId(MiniDisplayDevice aDevice)
262 return ((GraphicDisplay*)aDevice)->DeviceId();
265 //-------------------------------------------------------------
266 char* MiniDisplayFirmwareRevision(MiniDisplayDevice aDevice)
268 return ((GraphicDisplay*)aDevice)->FirmwareRevision();
271 //-------------------------------------------------------------
272 bool MiniDisplayPowerSupplyStatus(MiniDisplayDevice aDevice)
274 return ((GraphicDisplay*)aDevice)->IsPowerOn();
277 //-------------------------------------------------------------
278 void MiniDisplayPowerOn(MiniDisplayDevice aDevice)
280 ((GraphicDisplay*)aDevice)->TurnPowerOn();
283 //-------------------------------------------------------------
284 void MiniDisplayPowerOff(MiniDisplayDevice aDevice)
286 ((GraphicDisplay*)aDevice)->TurnPowerOff();
289 //-------------------------------------------------------------
290 bool MiniDisplaySupportPowerOnOff(MiniDisplayDevice aDevice)
292 return ((GraphicDisplay*)aDevice)->SupportPowerOnOff();
295 //-------------------------------------------------------------
296 void MiniDisplayShowClock(MiniDisplayDevice aDevice)
298 ((GraphicDisplay*)aDevice)->ShowClock();
301 //-------------------------------------------------------------
302 void MiniDisplayHideClock(MiniDisplayDevice aDevice)
304 ((GraphicDisplay*)aDevice)->HideClock();
307 //-------------------------------------------------------------
308 bool MiniDisplaySupportClock(MiniDisplayDevice aDevice)
310 return ((GraphicDisplay*)aDevice)->SupportClock();
313 //-------------------------------------------------------------
314 int MiniDisplayIconCount(MiniDisplayDevice aDevice, TMiniDisplayIconType aIcon)
316 return ((GraphicDisplay*)aDevice)->IconCount(aIcon);
319 //-------------------------------------------------------------
320 int MiniDisplayIconStatusCount(MiniDisplayDevice aDevice, TMiniDisplayIconType aIcon)
322 return ((GraphicDisplay*)aDevice)->IconStatusCount(aIcon);
325 //-------------------------------------------------------------
326 void MiniDisplaySetIconStatus(MiniDisplayDevice aDevice, TMiniDisplayIconType aIcon, int aIndex, int aStatus)
328 ((GraphicDisplay*)aDevice)->SetIconStatus(aIcon,aIndex,aStatus);