diff -r 0d9d062609eb -r 23cacc1d17a3 src/FutabaVfd.cpp --- a/src/FutabaVfd.cpp Thu May 22 11:29:23 2014 +0200 +++ b/src/FutabaVfd.cpp Thu May 22 13:46:37 2014 +0200 @@ -147,7 +147,7 @@ @param Y coordinate of our pixel block starting point. @param The height of our pixel block. @param The size of our pixel data. Number of pixels divided by 8. -@param The value set to 8 pixels. +@param The value set to 8 pixels used as a pattern. */ void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue) { @@ -168,6 +168,45 @@ Write(report); } +/** +Set the defined pixel block to the given value. +@param X coordinate of our pixel block starting point. +@param Y coordinate of our pixel block starting point. +@param The height of our pixel block. +@param The size of our pixel data. Number of pixels divided by 8. +@param Pointer to our pixel data. +*/ +void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char* aPixels) + { + FutabaVfdReport report; + report[0]=0x00; //Report ID + report[1]=0x08+(aSize<=report.Size()-10?aSize:64); //Report length. -10 is for our header first 10 bytes + report[2]=0x1B; //Command ID + report[3]=0x5B; //Command ID + report[4]=0xF0; //Command ID + report[5]=aX; //X + report[6]=aY; //Y + report[7]=aHeight; //Y length before return. Though outside the specs, setting this to zero apparently allows us to modify a single pixel without touching any other. + unsigned short* sizePtr=(unsigned short*)report.Buffer()+8; //Size of pixel data in bytes (MSB) + *sizePtr=aSize; //Put our size over 2 bytes + int sizeWritten=MIN(aSize,report.Size()-10); + memcpy(report.Buffer()+10, aPixels, sizeWritten); + Write(report); + + int remainingSize=aSize; + //We need to keep on sending our pixel data until we are done + while (report[1]==64) + { + report.Reset(); + remainingSize-=sizeWritten; + report[0]=0x00; //Report ID + report[1]=(remainingSize<=report.Size()-2?aSize:64); //Report length, should be 64 or the remaining size + sizeWritten=(report[1]==64?63:report[1]); + memcpy(report.Buffer()+2, aPixels+(aSize-remainingSize), sizeWritten); + Write(report); + } + } + /** Clear our display's screen.