1.1 --- a/src/FutabaVfd.cpp Thu May 22 22:36:43 2014 +0200
1.2 +++ b/src/FutabaVfd.cpp Sat May 24 00:43:18 2014 +0200
1.3 @@ -71,19 +71,40 @@
1.4 // class GP1212A01A
1.5 //
1.6
1.7 -GP1212A01A::GP1212A01A():iDisplayPositionX(0),iDisplayPositionY(0),iOffScreenMode(true)
1.8 +GP1212A01A::GP1212A01A():
1.9 + iDisplayPositionX(0),iDisplayPositionY(0),
1.10 + iOffScreenMode(true),iFrameBuffer(NULL)
1.11 {
1.12 + //ResetBuffers();
1.13 }
1.14
1.15 +/**
1.16 +*/
1.17 +GP1212A01A::~GP1212A01A()
1.18 + {
1.19 + delete iFrameBuffer;
1.20 + iFrameBuffer=NULL;
1.21 + }
1.22 +
1.23 +/**
1.24 +*/
1.25 int GP1212A01A::Open()
1.26 {
1.27 int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A01A,NULL);
1.28 if (success)
1.29 {
1.30 + delete iFrameBuffer;
1.31 + iFrameBuffer = NULL;
1.32 + iFrameBuffer=new BitArray(KGP12xFrameBufferPixelCount);
1.33 SetNonBlocking(1);
1.34 //Since we can't get our display position we for it to our default
1.35 //This makes sure frames are in sync from the start
1.36 SetDisplayPosition(iDisplayPositionX,iDisplayPositionY);
1.37 + //Now clear both front and back buffer on host and device
1.38 + Clear();
1.39 + SwapBuffers();
1.40 + Clear();
1.41 + SwapBuffers();
1.42 }
1.43 return success;
1.44 }
1.45 @@ -93,7 +114,32 @@
1.46 void GP1212A01A::SetPixel(unsigned char aX, unsigned char aY, bool aOn)
1.47 {
1.48 //Just specify a one pixel block
1.49 - SetPixelBlock(aX,aY,0x00,0x01,aOn);
1.50 + //SetPixelBlock(aX,aY,0x00,0x01,aOn);
1.51 + //
1.52 + //int byteOffset=(aX*HeightInPixels()+aY)/8;
1.53 + //int bitOffset=(aX*HeightInPixels()+aY)%8;
1.54 + //iFrameBuffer[byteOffset] |= ( (aOn?0x01:0x00) << bitOffset );
1.55 + if (aOn)
1.56 + {
1.57 + iFrameBuffer->SetBit(aX*HeightInPixels()+aY);
1.58 + }
1.59 + else
1.60 + {
1.61 + iFrameBuffer->ClearBit(aX*HeightInPixels()+aY);
1.62 + }
1.63 + }
1.64 +
1.65 +/**
1.66 +*/
1.67 +void GP1212A01A::BitBlit(BitArray& aBitmap, unsigned char aSrcWidth, unsigned char aSrcHeight, unsigned char aTargetX, unsigned char aTargetY) const
1.68 + {
1.69 + for (int i=0;i<aSrcWidth;i++)
1.70 + {
1.71 + for (int j=0;j<aSrcHeight;j++)
1.72 + {
1.73 + iFrameBuffer->SetBitValue((aTargetX+i)*HeightInPixels()+aTargetY+j,aBitmap[+i*aSrcHeight+j]);
1.74 + }
1.75 + }
1.76 }
1.77
1.78 /**
1.79 @@ -109,7 +155,10 @@
1.80 //SetPixelBlock(0,0,63,sizeof(screen),screen);
1.81
1.82 //Using pattern SetPixelBlock variant.
1.83 - SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),aPattern);
1.84 + memset(iFrameBuffer->Ptr(),aPattern,FrameBufferSizeInBytes());
1.85 + //
1.86 +
1.87 +
1.88 }
1.89
1.90 /**
1.91 @@ -220,14 +269,13 @@
1.92
1.93
1.94 /**
1.95 -Clear our display's screen.
1.96 -This operation is performed off screen to avoid tearing.
1.97 +Clear our client side back buffer.
1.98 +Call to SwapBuffers must follow to actually clear the display.
1.99 */
1.100 void GP1212A01A::Clear()
1.101 {
1.102 - //Using pattern SetPixelBlock variant.
1.103 - //First fill our off screen buffer with the desired values
1.104 - SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),(unsigned char)0x00);
1.105 + //memset(iFrameBuffer->Ptr(),0x00,FrameBufferSizeInBytes());
1.106 + iFrameBuffer->ClearAll();
1.107 }
1.108
1.109 /**
1.110 @@ -297,7 +345,14 @@
1.111 //Only perform buffer swapping if off screen mode is enabled
1.112 if (OffScreenMode())
1.113 {
1.114 + //Send host back buffer to device back buffer
1.115 + SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),iFrameBuffer->Ptr());
1.116 + //Swap device front and back buffer
1.117 SetDisplayPosition(iDisplayPositionX,OffScreenY());
1.118 + //Swap host buffers
1.119 + //unsigned char* backBuffer=iBackBuffer;
1.120 + //iBackBuffer = iFrontBuffer;
1.121 + //iFrontBuffer = backBuffer;
1.122 }
1.123 }
1.124
1.125 @@ -312,6 +367,17 @@
1.126 aY+=HeightInPixels()-iDisplayPositionY;
1.127 }
1.128 }
1.129 +
1.130 +
1.131 +/**
1.132 +*/
1.133 +void GP1212A01A::ResetBuffers()
1.134 + {
1.135 + //iFrameBuffer->ClearAll();
1.136 + //memset(iFrameBuffer,0x00,sizeof(iFrameBuffer));
1.137 + //memset(iFrameBeta,0x00,sizeof(iFrameBeta));
1.138 + }
1.139 +
1.140 /**
1.141 */
1.142 void GP1212A01A::RequestId()