1.1 --- a/src/FutabaVfd.cpp Thu May 22 11:29:23 2014 +0200
1.2 +++ b/src/FutabaVfd.cpp Thu May 22 13:46:37 2014 +0200
1.3 @@ -147,7 +147,7 @@
1.4 @param Y coordinate of our pixel block starting point.
1.5 @param The height of our pixel block.
1.6 @param The size of our pixel data. Number of pixels divided by 8.
1.7 -@param The value set to 8 pixels.
1.8 +@param The value set to 8 pixels used as a pattern.
1.9 */
1.10 void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue)
1.11 {
1.12 @@ -168,6 +168,45 @@
1.13 Write(report);
1.14 }
1.15
1.16 +/**
1.17 +Set the defined pixel block to the given value.
1.18 +@param X coordinate of our pixel block starting point.
1.19 +@param Y coordinate of our pixel block starting point.
1.20 +@param The height of our pixel block.
1.21 +@param The size of our pixel data. Number of pixels divided by 8.
1.22 +@param Pointer to our pixel data.
1.23 +*/
1.24 +void GP1212A01A::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char* aPixels)
1.25 + {
1.26 + FutabaVfdReport report;
1.27 + report[0]=0x00; //Report ID
1.28 + report[1]=0x08+(aSize<=report.Size()-10?aSize:64); //Report length. -10 is for our header first 10 bytes
1.29 + report[2]=0x1B; //Command ID
1.30 + report[3]=0x5B; //Command ID
1.31 + report[4]=0xF0; //Command ID
1.32 + report[5]=aX; //X
1.33 + report[6]=aY; //Y
1.34 + 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.
1.35 + unsigned short* sizePtr=(unsigned short*)report.Buffer()+8; //Size of pixel data in bytes (MSB)
1.36 + *sizePtr=aSize; //Put our size over 2 bytes
1.37 + int sizeWritten=MIN(aSize,report.Size()-10);
1.38 + memcpy(report.Buffer()+10, aPixels, sizeWritten);
1.39 + Write(report);
1.40 +
1.41 + int remainingSize=aSize;
1.42 + //We need to keep on sending our pixel data until we are done
1.43 + while (report[1]==64)
1.44 + {
1.45 + report.Reset();
1.46 + remainingSize-=sizeWritten;
1.47 + report[0]=0x00; //Report ID
1.48 + report[1]=(remainingSize<=report.Size()-2?aSize:64); //Report length, should be 64 or the remaining size
1.49 + sizeWritten=(report[1]==64?63:report[1]);
1.50 + memcpy(report.Buffer()+2, aPixels+(aSize-remainingSize), sizeWritten);
1.51 + Write(report);
1.52 + }
1.53 + }
1.54 +
1.55
1.56 /**
1.57 Clear our display's screen.