1.1 --- a/MiniDisplay/FutabaVfd.cpp Wed May 28 11:42:49 2014 +0200
1.2 +++ b/MiniDisplay/FutabaVfd.cpp Wed May 28 15:23:41 2014 +0200
1.3 @@ -73,7 +73,7 @@
1.4
1.5 GP1212A01A::GP1212A01A():
1.6 iDisplayPositionX(0),iDisplayPositionY(0),
1.7 - iOffScreenMode(true),iFrameBuffer(NULL)
1.8 + iOffScreenMode(true),iFrameBuffer(NULL),iRequest(ERequestNone),iPowerOn(false)
1.9 {
1.10 //ResetBuffers();
1.11 }
1.12 @@ -381,8 +381,14 @@
1.13
1.14 /**
1.15 */
1.16 -void GP1212A01A::RequestId()
1.17 +void GP1212A01A::RequestDeviceId()
1.18 {
1.19 + if (RequestPending())
1.20 + {
1.21 + //Abort silently for now
1.22 + return;
1.23 + }
1.24 +
1.25 //1BH,5BH,63H,49H,44H
1.26 //Send Read ID command
1.27 FutabaVfdReport report;
1.28 @@ -393,13 +399,22 @@
1.29 report[4]=0x63; //Command ID
1.30 report[5]=0x49; //Command ID
1.31 report[6]=0x44; //Command ID
1.32 - Write(report);
1.33 + if (Write(report)==report.Size())
1.34 + {
1.35 + iRequest=ERequestDeviceId;
1.36 + }
1.37 }
1.38
1.39 /**
1.40 */
1.41 void GP1212A01A::RequestFirmwareRevision()
1.42 {
1.43 + if (RequestPending())
1.44 + {
1.45 + //Abort silently for now
1.46 + return;
1.47 + }
1.48 +
1.49 //1BH,5BH,63H,46H,52H
1.50 //Send Software Revision Read Command
1.51 FutabaVfdReport report;
1.52 @@ -410,13 +425,21 @@
1.53 report[4]=0x63; //Command ID
1.54 report[5]=0x46; //Command ID
1.55 report[6]=0x52; //Command ID
1.56 - Write(report);
1.57 + if (Write(report)==report.Size())
1.58 + {
1.59 + iRequest=ERequestFirmwareRevision;
1.60 + }
1.61 }
1.62
1.63 /**
1.64 */
1.65 void GP1212A01A::RequestPowerSupplyStatus()
1.66 {
1.67 + if (RequestPending())
1.68 + {
1.69 + //Abort silently for now
1.70 + return;
1.71 + }
1.72 //1BH,5BH,63H,50H,4DH
1.73 //Send Power Suppply Monitor Command
1.74 FutabaVfdReport report;
1.75 @@ -427,7 +450,10 @@
1.76 report[4]=0x63; //Command ID
1.77 report[5]=0x50; //Command ID
1.78 report[6]=0x4D; //Command ID
1.79 - Write(report);
1.80 + if (Write(report)==report.Size())
1.81 + {
1.82 + iRequest=ERequestPowerSupplyStatus;
1.83 + }
1.84 }
1.85
1.86
1.87 @@ -444,3 +470,39 @@
1.88 SwapBuffers();
1.89 Clear();
1.90 }
1.91 +
1.92 +/**
1.93 + */
1.94 +GP1212A01A::Request GP1212A01A::AttemptRequestCompletion()
1.95 + {
1.96 + if (!RequestPending())
1.97 + {
1.98 + return ERequestNone;
1.99 + }
1.100 +
1.101 + int res=Read(iInputReport);
1.102 +
1.103 + if (!res)
1.104 + {
1.105 + return ERequestNone;
1.106 + }
1.107 +
1.108 + //Process our request
1.109 + if (CurrentRequest()==GP1212A01A::ERequestPowerSupplyStatus)
1.110 + {
1.111 + if (iInputReport[1]==0x4F && iInputReport[2]==0x4E)
1.112 + {
1.113 + iPowerOn = true;
1.114 + }
1.115 + else if (iInputReport[1]==0x4F && iInputReport[2]==0x46 && iInputReport[3]==0x46)
1.116 + {
1.117 + iPowerOn = false;
1.118 + }
1.119 + }
1.120 +
1.121 + Request completed=iRequest;
1.122 + //Our request was completed
1.123 + iRequest=ERequestNone;
1.124 +
1.125 + return completed;
1.126 + }