Adding SetPixelBlock function which is now used by SetPixel.
It allows us to fill our screen much faster than one pixel at a time.
1.1 --- a/test.cpp Tue May 20 18:13:22 2014 +0200
1.2 +++ b/test.cpp Tue May 20 22:31:46 2014 +0200
1.3 @@ -131,6 +131,7 @@
1.4 long onMacTimeout(FXObject *sender, FXSelector sel, void *ptr);
1.5 //
1.6 void SetPixel(int aX, int aY, unsigned char aValue);
1.7 + void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
1.8
1.9 };
1.10
1.11 @@ -660,25 +661,43 @@
1.12 return 1;
1.13 }
1.14
1.15 +
1.16 +
1.17 +
1.18 /**
1.19 +Set a single pixel to the specified value.
1.20 +@param X coordinate of our pixel.
1.21 +@param Y coordinate of our pixel.
1.22 +@param The LSB defines our pixel value.
1.23 */
1.24 void MainWindow::SetPixel(int aX, int aY, unsigned char aValue)
1.25 {
1.26 + //Just specify a one pixel block
1.27 + SetPixelBlock(aX,aY,0x00,0x01,aValue);
1.28 + }
1.29 +
1.30 +/**
1.31 +*/
1.32 +void MainWindow::SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue)
1.33 + {
1.34 + //Size must be 63 or below
1.35 memset(iOutputReportBuffer, 0x0, KFutabaOutputReportLength);
1.36 iOutputReportBuffer[0]=0x00; //Report ID
1.37 - iOutputReportBuffer[1]=0x09; //Report length
1.38 + iOutputReportBuffer[1]=0x08+aSize; //Report length
1.39 iOutputReportBuffer[2]=0x1B; //
1.40 iOutputReportBuffer[3]=0x5B; //
1.41 iOutputReportBuffer[4]=0xF0; //
1.42 iOutputReportBuffer[5]=aX; //X
1.43 iOutputReportBuffer[6]=aY; //Y
1.44 - 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.
1.45 + 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.
1.46 iOutputReportBuffer[8]=0x00; //Size of pixel data in bytes (MSB)
1.47 - iOutputReportBuffer[9]=0x01; //Size of pixel data in bytes (LSB)
1.48 - iOutputReportBuffer[10]=aValue; //Pixel data
1.49 + iOutputReportBuffer[9]=aSize; //Size of pixel data in bytes (LSB)
1.50 + memset(iOutputReportBuffer+10, aValue, KFutabaOutputReportLength);
1.51 + //iOutputReportBuffer[10]=aValue; //Pixel data
1.52 int res = hid_write(connected_device, iOutputReportBuffer, KFutabaOutputReportLength);
1.53 }
1.54
1.55 +
1.56 /**
1.57 */
1.58 long MainWindow::onFutabaSetPixel(FXObject *sender, FXSelector sel, void *ptr)
1.59 @@ -705,13 +724,24 @@
1.60
1.61 long MainWindow::onFutabaSetAllPixels(FXObject *sender, FXSelector sel, void *ptr)
1.62 {
1.63 + //One pixel at a time
1.64 + /*
1.65 for (int i=0;i<256;i++)
1.66 {
1.67 for (int j=0;j<64;j++)
1.68 {
1.69 SetPixel(i,j,0x01);
1.70 }
1.71 -
1.72 + }
1.73 + */
1.74 + //16x16=256 pixels at a time goes much faster
1.75 + for (int i=0;i<256;i+=16)
1.76 + {
1.77 + for (int j=0;j<64;j+=16)
1.78 + {
1.79 + SetPixelBlock(i,j,15,32,0xFF);
1.80 + //FXThread::sleep(1000000000);
1.81 + }
1.82 }
1.83
1.84 return 1;