Display auto detect implementation.
1.1 --- a/MiniDisplay.cpp Sun Aug 31 21:35:36 2014 +0200
1.2 +++ b/MiniDisplay.cpp Sun Aug 31 22:57:32 2014 +0200
1.3 @@ -4,19 +4,13 @@
1.4 #include "FutabaGP1212A02.h"
1.5
1.6
1.7 -
1.8 -//Open & Close functions
1.9 -MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType)
1.10 +MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType, bool aAutoDetect)
1.11 {
1.12 GraphicDisplay* device=NULL;
1.13
1.14 switch (aType)
1.15 {
1.16 case EMiniDisplayAutoDetect:
1.17 - //TODO
1.18 - device=new GP1212A01A();
1.19 - break;
1.20 -
1.21 case EMiniDisplayFutabaGP1212A01:
1.22 device=new GP1212A01A();
1.23 break;
1.24 @@ -24,6 +18,11 @@
1.25 case EMiniDisplayFutabaGP1212A02:
1.26 device=new GP1212A02A();
1.27 break;
1.28 +
1.29 + case EMiniDisplayAutoDetectFailed:
1.30 + //Auto detect sequence failed
1.31 + return NULL;
1.32 + break;
1.33 };
1.34
1.35 int success = device->Open();
1.36 @@ -31,11 +30,30 @@
1.37 {
1.38 delete device;
1.39 device=NULL;
1.40 + if (aAutoDetect)
1.41 + {
1.42 + //Go recursive for auto detect
1.43 + int typeValue=(int)aType;
1.44 + typeValue++;
1.45 + TMiniDisplayType nextType=(TMiniDisplayType)typeValue;
1.46 + return MiniDisplayOpen(nextType,aAutoDetect);
1.47 + }
1.48 }
1.49
1.50 return device;
1.51 }
1.52
1.53 +
1.54 +//Open & Close functions
1.55 +MiniDisplayDevice MiniDisplayOpen(TMiniDisplayType aType)
1.56 + {
1.57 + bool autoDetect=aType==EMiniDisplayAutoDetect;
1.58 + return MiniDisplayOpen(EMiniDisplayFutabaGP1212A01,autoDetect);
1.59 + }
1.60 +
1.61 +
1.62 +
1.63 +
1.64 //
1.65
1.66 void MiniDisplayClose(MiniDisplayDevice aDevice)
2.1 --- a/MiniDisplay.h Sun Aug 31 21:35:36 2014 +0200
2.2 +++ b/MiniDisplay.h Sun Aug 31 22:57:32 2014 +0200
2.3 @@ -29,7 +29,8 @@
2.4 {
2.5 EMiniDisplayAutoDetect=0, /*Not yet implemented*/
2.6 EMiniDisplayFutabaGP1212A01,
2.7 - EMiniDisplayFutabaGP1212A02
2.8 + EMiniDisplayFutabaGP1212A02,
2.9 + EMiniDisplayAutoDetectFailed
2.10 }
2.11 TMiniDisplayType;
2.12