diff -r c6b5c552980a -r 233a997193b8 src/FutabaVfd.cpp --- a/src/FutabaVfd.cpp Thu May 22 22:36:43 2014 +0200 +++ b/src/FutabaVfd.cpp Sat May 24 00:43:18 2014 +0200 @@ -71,19 +71,40 @@ // class GP1212A01A // -GP1212A01A::GP1212A01A():iDisplayPositionX(0),iDisplayPositionY(0),iOffScreenMode(true) +GP1212A01A::GP1212A01A(): + iDisplayPositionX(0),iDisplayPositionY(0), + iOffScreenMode(true),iFrameBuffer(NULL) { + //ResetBuffers(); } +/** +*/ +GP1212A01A::~GP1212A01A() + { + delete iFrameBuffer; + iFrameBuffer=NULL; + } + +/** +*/ int GP1212A01A::Open() { int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A01A,NULL); if (success) { + delete iFrameBuffer; + iFrameBuffer = NULL; + iFrameBuffer=new BitArray(KGP12xFrameBufferPixelCount); SetNonBlocking(1); //Since we can't get our display position we for it to our default //This makes sure frames are in sync from the start SetDisplayPosition(iDisplayPositionX,iDisplayPositionY); + //Now clear both front and back buffer on host and device + Clear(); + SwapBuffers(); + Clear(); + SwapBuffers(); } return success; } @@ -93,7 +114,32 @@ void GP1212A01A::SetPixel(unsigned char aX, unsigned char aY, bool aOn) { //Just specify a one pixel block - SetPixelBlock(aX,aY,0x00,0x01,aOn); + //SetPixelBlock(aX,aY,0x00,0x01,aOn); + // + //int byteOffset=(aX*HeightInPixels()+aY)/8; + //int bitOffset=(aX*HeightInPixels()+aY)%8; + //iFrameBuffer[byteOffset] |= ( (aOn?0x01:0x00) << bitOffset ); + if (aOn) + { + iFrameBuffer->SetBit(aX*HeightInPixels()+aY); + } + else + { + iFrameBuffer->ClearBit(aX*HeightInPixels()+aY); + } + } + +/** +*/ +void GP1212A01A::BitBlit(BitArray& aBitmap, unsigned char aSrcWidth, unsigned char aSrcHeight, unsigned char aTargetX, unsigned char aTargetY) const + { + for (int i=0;iSetBitValue((aTargetX+i)*HeightInPixels()+aTargetY+j,aBitmap[+i*aSrcHeight+j]); + } + } } /** @@ -109,7 +155,10 @@ //SetPixelBlock(0,0,63,sizeof(screen),screen); //Using pattern SetPixelBlock variant. - SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),aPattern); + memset(iFrameBuffer->Ptr(),aPattern,FrameBufferSizeInBytes()); + // + + } /** @@ -220,14 +269,13 @@ /** -Clear our display's screen. -This operation is performed off screen to avoid tearing. +Clear our client side back buffer. +Call to SwapBuffers must follow to actually clear the display. */ void GP1212A01A::Clear() { - //Using pattern SetPixelBlock variant. - //First fill our off screen buffer with the desired values - SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),(unsigned char)0x00); + //memset(iFrameBuffer->Ptr(),0x00,FrameBufferSizeInBytes()); + iFrameBuffer->ClearAll(); } /** @@ -297,7 +345,14 @@ //Only perform buffer swapping if off screen mode is enabled if (OffScreenMode()) { + //Send host back buffer to device back buffer + SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),iFrameBuffer->Ptr()); + //Swap device front and back buffer SetDisplayPosition(iDisplayPositionX,OffScreenY()); + //Swap host buffers + //unsigned char* backBuffer=iBackBuffer; + //iBackBuffer = iFrontBuffer; + //iFrontBuffer = backBuffer; } } @@ -312,6 +367,17 @@ aY+=HeightInPixels()-iDisplayPositionY; } } + + +/** +*/ +void GP1212A01A::ResetBuffers() + { + //iFrameBuffer->ClearAll(); + //memset(iFrameBuffer,0x00,sizeof(iFrameBuffer)); + //memset(iFrameBeta,0x00,sizeof(iFrameBeta)); + } + /** */ void GP1212A01A::RequestId()