# HG changeset patch # User sl # Date 1401450314 -7200 # Node ID 434d6b8a406d743ef737dd2b80458fc82323d76b # Parent cd6d76b9b47e2f26f49bf65d9bdb67d18ba44596 Frame diff algo now working nicely and providing twice the frame rate. 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); } } } - */ } diff -r cd6d76b9b47e -r 434d6b8a406d TestsTab.qml --- a/TestsTab.qml Fri May 30 10:56:20 2014 +0200 +++ b/TestsTab.qml Fri May 30 13:45:14 2014 +0200 @@ -22,7 +22,10 @@ title: "Splash Window" modality: Qt.NonModal flags: Qt.SplashScreen - property int timeoutInterval: 41 + //24 FPS + //property int timeoutInterval: 41 + //32 FPS + property int timeoutInterval: 33 signal timeout //! [splash-properties] //! [screen-properties] @@ -129,7 +132,8 @@ { if (checkBoxFillOnly.checked) { - display.fill(); + //Trying to make it a worth case scenario for our frame diff algo + (splash.frameCounter%3?display.fill():display.clear()); } else if (checkBoxOnePixelOnly.checked) { @@ -202,7 +206,7 @@ CheckBox { id: checkBoxFillOnly - text: qsTr("Fill only") + text: qsTr("Only fill and clear") checked: false }