# HG changeset patch # User sl # Date 1400617906 -7200 # Node ID 4cb67272815c87045a696081440a88ef00ca96b8 # Parent 50a4b94dafe68252721e0b7168eb3b846e70c206 Adding SetPixelBlock function which is now used by SetPixel. It allows us to fill our screen much faster than one pixel at a time. diff -r 50a4b94dafe6 -r 4cb67272815c test.cpp --- a/test.cpp Tue May 20 18:13:22 2014 +0200 +++ b/test.cpp Tue May 20 22:31:46 2014 +0200 @@ -131,6 +131,7 @@ long onMacTimeout(FXObject *sender, FXSelector sel, void *ptr); // void SetPixel(int aX, int aY, unsigned char aValue); + void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue); }; @@ -660,25 +661,43 @@ return 1; } + + + /** +Set a single pixel to the specified value. +@param X coordinate of our pixel. +@param Y coordinate of our pixel. +@param The LSB defines our pixel value. */ void MainWindow::SetPixel(int aX, int aY, unsigned char aValue) { + //Just specify a one pixel block + SetPixelBlock(aX,aY,0x00,0x01,aValue); + } + +/** +*/ +void MainWindow::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue) + { + //Size must be 63 or below memset(iOutputReportBuffer, 0x0, KFutabaOutputReportLength); iOutputReportBuffer[0]=0x00; //Report ID - iOutputReportBuffer[1]=0x09; //Report length + iOutputReportBuffer[1]=0x08+aSize; //Report length iOutputReportBuffer[2]=0x1B; // iOutputReportBuffer[3]=0x5B; // iOutputReportBuffer[4]=0xF0; // iOutputReportBuffer[5]=aX; //X iOutputReportBuffer[6]=aY; //Y - iOutputReportBuffer[7]=0x00; //Y length before return. Though outside the specs setting this to zero apparently allows us to modify a single pixel without touching any other. + iOutputReportBuffer[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. iOutputReportBuffer[8]=0x00; //Size of pixel data in bytes (MSB) - iOutputReportBuffer[9]=0x01; //Size of pixel data in bytes (LSB) - iOutputReportBuffer[10]=aValue; //Pixel data + iOutputReportBuffer[9]=aSize; //Size of pixel data in bytes (LSB) + memset(iOutputReportBuffer+10, aValue, KFutabaOutputReportLength); + //iOutputReportBuffer[10]=aValue; //Pixel data int res = hid_write(connected_device, iOutputReportBuffer, KFutabaOutputReportLength); } + /** */ long MainWindow::onFutabaSetPixel(FXObject *sender, FXSelector sel, void *ptr) @@ -705,13 +724,24 @@ long MainWindow::onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr) { + //One pixel at a time + /* for (int i=0;i<256;i++) { for (int j=0;j<64;j++) { SetPixel(i,j,0x01); } - + } + */ + //16x16=256 pixels at a time goes much faster + for (int i=0;i<256;i+=16) + { + for (int j=0;j<64;j+=16) + { + SetPixelBlock(i,j,15,32,0xFF); + //FXThread::sleep(1000000000); + } } return 1;