1.1 --- a/FutabaGP1212A02.cpp Sat Aug 30 18:43:54 2014 +0200
1.2 +++ b/FutabaGP1212A02.cpp Sun Aug 31 17:42:10 2014 +0200
1.3 @@ -7,6 +7,9 @@
1.4
1.5 const int KNumberOfFrameBeforeDiffAlgo = 3;
1.6
1.7 +const unsigned short KMaxDataMemoryAddress = 0x4FFF;
1.8 +const unsigned short KFrameSizeInBytes = 0x800;
1.9 +
1.10 //
1.11 // class GP1212A02A
1.12 //
1.13 @@ -87,6 +90,7 @@
1.14 //Select current BMP box
1.15 BmpBoxSelect(EBmpBoxIdOne);
1.16
1.17 + iNextFrameAddress = 0x0000;
1.18
1.19 }
1.20 return success;
1.21 @@ -410,12 +414,20 @@
1.22 if (OffScreenMode())
1.23 {
1.24 //Send pixel directly into BMP box
1.25 - BmpBoxDataInput(FrameBufferSizeInBytes(),iFrameNext->Ptr());
1.26 + //BmpBoxDataInput(FrameBufferSizeInBytes(),iFrameNext->Ptr());
1.27 //Send pixel data directly into the display window
1.28 //BmpDataInput(ETargetDisplayWindow,0x0000,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
1.29 //Send pixel data first to Data Memory then copy into the selected BMP box
1.30 //BmpDataInput(ETargetDataMemory,0x0000,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
1.31 //BmpBoxDataMemoryTransfer(0x0000);
1.32 + //Send pixel data first to Data Memory then copy into the selected BMP box, cycling through our Data Memory frmae
1.33 + BmpDataInput(ETargetDataMemory,iNextFrameAddress,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
1.34 + BmpBoxDataMemoryTransfer(iNextFrameAddress);
1.35 + iNextFrameAddress+=KFrameSizeInBytes;
1.36 + if (iNextFrameAddress>KMaxDataMemoryAddress)
1.37 + {
1.38 + iNextFrameAddress=0x0000;
1.39 + }
1.40
1.41 //Cycle through our frame buffers
1.42 //We keep track of previous frame which is in fact our device back buffer.
1.43 @@ -456,6 +468,28 @@
1.44
1.45 /**
1.46 */
1.47 +void GP1212A02A::Request(TMiniDisplayRequest aRequest)
1.48 + {
1.49 + switch (aRequest)
1.50 + {
1.51 + case EMiniDisplayRequestDeviceId:
1.52 + RequestDeviceId();
1.53 + break;
1.54 + case EMiniDisplayRequestFirmwareRevision:
1.55 + RequestFirmwareRevision();
1.56 + break;
1.57 + case EMiniDisplayRequestPowerSupplyStatus:
1.58 + RequestPowerSupplyStatus();
1.59 + break;
1.60 + default:
1.61 + //Not supported
1.62 + break;
1.63 + };
1.64 + }
1.65 +
1.66 +
1.67 +/**
1.68 +*/
1.69 void GP1212A02A::ResetBuffers()
1.70 {
1.71 //iNextFrame->ClearAll();
1.72 @@ -471,10 +505,32 @@
1.73 }
1.74
1.75 /**
1.76 +ID code
1.77 +[Code] 1BH,6AH,49H,44H
1.78 +[Function] Send the ID code to the Host system. ID code is software version.
1.79 */
1.80 void GP1212A02A::RequestFirmwareRevision()
1.81 {
1.82 - //Not supported
1.83 + if (RequestPending())
1.84 + {
1.85 + //Abort silently for now
1.86 + return;
1.87 + }
1.88 +
1.89 + //1BH,6AH,49H,44H
1.90 + //Send Software Revision Read Command
1.91 + FutabaVfdReport report;
1.92 + report[0]=0x00; //Report ID
1.93 + report[1]=0x04; //Report length
1.94 + report[2]=0x1B; //Command ID
1.95 + report[3]=0x6A; //Command ID
1.96 + report[4]=0x49; //Command ID
1.97 + report[5]=0x44; //Command ID
1.98 + if (Write(report)==report.Size())
1.99 + {
1.100 + SetRequest(EMiniDisplayRequestFirmwareRevision);
1.101 + }
1.102 +
1.103 }
1.104
1.105 /**
1.106 @@ -520,8 +576,31 @@
1.107 */
1.108 TMiniDisplayRequest GP1212A02A::AttemptRequestCompletion()
1.109 {
1.110 - //That display does not support any requests
1.111 - return EMiniDisplayRequestNone;
1.112 + if (!RequestPending())
1.113 + {
1.114 + return EMiniDisplayRequestNone;
1.115 + }
1.116 +
1.117 + int res=Read(iInputReport);
1.118 +
1.119 + if (!res)
1.120 + {
1.121 + return EMiniDisplayRequestNone;
1.122 + }
1.123 +
1.124 + //Process our request
1.125 + if (CurrentRequest()==EMiniDisplayRequestFirmwareRevision)
1.126 + {
1.127 + unsigned char* ptr=&iInputReport[2];
1.128 + iInputReport[7]=0x00;
1.129 + strcpy(iFirmwareRevision,(const char*)ptr);
1.130 + }
1.131 +
1.132 + TMiniDisplayRequest completed=CurrentRequest();
1.133 + //Our request was completed
1.134 + SetRequest(EMiniDisplayRequestNone);
1.135 +
1.136 + return completed;
1.137 }
1.138
1.139