diff -r 9543e1703afb -r 52372bbbc0f8 MiniDisplay/FutabaVfd.cpp --- a/MiniDisplay/FutabaVfd.cpp Wed May 28 11:42:49 2014 +0200 +++ b/MiniDisplay/FutabaVfd.cpp Wed May 28 15:23:41 2014 +0200 @@ -73,7 +73,7 @@ GP1212A01A::GP1212A01A(): iDisplayPositionX(0),iDisplayPositionY(0), - iOffScreenMode(true),iFrameBuffer(NULL) + iOffScreenMode(true),iFrameBuffer(NULL),iRequest(ERequestNone),iPowerOn(false) { //ResetBuffers(); } @@ -381,8 +381,14 @@ /** */ -void GP1212A01A::RequestId() +void GP1212A01A::RequestDeviceId() { + if (RequestPending()) + { + //Abort silently for now + return; + } + //1BH,5BH,63H,49H,44H //Send Read ID command FutabaVfdReport report; @@ -393,13 +399,22 @@ report[4]=0x63; //Command ID report[5]=0x49; //Command ID report[6]=0x44; //Command ID - Write(report); + if (Write(report)==report.Size()) + { + iRequest=ERequestDeviceId; + } } /** */ void GP1212A01A::RequestFirmwareRevision() { + if (RequestPending()) + { + //Abort silently for now + return; + } + //1BH,5BH,63H,46H,52H //Send Software Revision Read Command FutabaVfdReport report; @@ -410,13 +425,21 @@ report[4]=0x63; //Command ID report[5]=0x46; //Command ID report[6]=0x52; //Command ID - Write(report); + if (Write(report)==report.Size()) + { + iRequest=ERequestFirmwareRevision; + } } /** */ void GP1212A01A::RequestPowerSupplyStatus() { + if (RequestPending()) + { + //Abort silently for now + return; + } //1BH,5BH,63H,50H,4DH //Send Power Suppply Monitor Command FutabaVfdReport report; @@ -427,7 +450,10 @@ report[4]=0x63; //Command ID report[5]=0x50; //Command ID report[6]=0x4D; //Command ID - Write(report); + if (Write(report)==report.Size()) + { + iRequest=ERequestPowerSupplyStatus; + } } @@ -444,3 +470,39 @@ SwapBuffers(); Clear(); } + +/** + */ +GP1212A01A::Request GP1212A01A::AttemptRequestCompletion() + { + if (!RequestPending()) + { + return ERequestNone; + } + + int res=Read(iInputReport); + + if (!res) + { + return ERequestNone; + } + + //Process our request + if (CurrentRequest()==GP1212A01A::ERequestPowerSupplyStatus) + { + if (iInputReport[1]==0x4F && iInputReport[2]==0x4E) + { + iPowerOn = true; + } + else if (iInputReport[1]==0x4F && iInputReport[2]==0x46 && iInputReport[3]==0x46) + { + iPowerOn = false; + } + } + + Request completed=iRequest; + //Our request was completed + iRequest=ERequestNone; + + return completed; + }