diff -r cd6d76b9b47e -r 434d6b8a406d MiniDisplay/FutabaVfd.cpp --- a/MiniDisplay/FutabaVfd.cpp Fri May 30 10:56:20 2014 +0200 +++ b/MiniDisplay/FutabaVfd.cpp Fri May 30 13:45:14 2014 +0200 @@ -4,6 +4,11 @@ #include +#ifdef DEBUG_FRAME_DIFF +#include +#include +#endif + // // // @@ -378,7 +383,7 @@ if (iNeedFullFrameUpdate<3) { //TODO: enable this once SendModifiedPixelBlocks works - //iNeedFullFrameUpdate++; + iNeedFullFrameUpdate++; SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),iFrameNext->Ptr()); } else @@ -387,14 +392,18 @@ } //Swap device front and back buffer SetDisplayPosition(iDisplayPositionX,OffScreenY()); - //Swap host buffers - //BitArray* nextFrame=iFrameNext; - //iFrameCurrent = iFramePrevious; - //iFrameNext = iFramePrevious; + //Cycle through our frame buffers + //We keep track of previous frame which is in fact our device back buffer. + //We can then compare previous and next frame and send only the differences to our device. + //This mechanism allows us to reduce traffic over our USB bus thus improving our frame rate from 14 FPS to 30 FPS. + //Keep our previous frame pointer BitArray* previousFrame=iFramePrevious; + //Current frame becomes the previous one iFramePrevious = iFrameCurrent; + //Next frame becomes the current one iFrameCurrent = iFrameNext; + //Next frame is now our former previous iFrameNext = previousFrame; } } @@ -414,10 +423,10 @@ int w=WidthInPixels(); int h=HeightInPixels(); - BitArray block(16*16); //TODO: optimize with memcmp and 16 inc + /* for (int i=0;iPtr()+offset,iCurrentFrame->Ptr()+offset,32 )) //32=(16*16/8) + //int offset=(i*w/8)+(j/8); + +#ifdef DEBUG_FRAME_DIFF + QImage imagePrevious(16,16,QImage::Format_RGB32); + QImage imageNext(16,16,QImage::Format_RGB32); +#endif + + //Get both our blocks from our buffers + for (int x=i;xPtr()+offset,iFramePrevious->Ptr()+offset,32 )) //32=(16*16/8) + if (memcmp(nextBlock.Ptr(),previousBlock.Ptr(),32 )!=0) //32=(16*16/8) { //We need to update that block - - for (int x=i;xPtr()+offset); + //SetPixelBlock(i,j,15,32,iFrameNext->Ptr()+offset); } } } - */ }