# HG changeset patch # User sl # Date 1401454935 -7200 # Node ID ca9e48af31e626328de470dd5b6d2c3d9cbba42b # Parent 434d6b8a406d743ef737dd2b80458fc82323d76b Cleaning up and customizing our frame diff algo. diff -r 434d6b8a406d -r ca9e48af31e6 MiniDisplay/FutabaVfd.cpp --- a/MiniDisplay/FutabaVfd.cpp Fri May 30 13:45:14 2014 +0200 +++ b/MiniDisplay/FutabaVfd.cpp Fri May 30 15:02:15 2014 +0200 @@ -9,13 +9,8 @@ #include #endif -// -// -// - - - +const int KNumberOfFrameBeforeDiffAlgo = 3; // // @@ -79,6 +74,7 @@ GP1212A01A::GP1212A01A(): iDisplayPositionX(0),iDisplayPositionY(0), iOffScreenMode(true), + iUseFrameDiffAlgo(true), iFrameNext(NULL), iFrameCurrent(NULL), iFramePrevious(NULL), @@ -380,14 +376,15 @@ if (OffScreenMode()) { //Send host back buffer to device back buffer - if (iNeedFullFrameUpdate<3) + if (!iUseFrameDiffAlgo || iNeedFullFrameUpdatePtr()); } else { + //Frame diff algo is enabled + //We are going to send to our device only the differences between next frame and previous frame SendModifiedPixelBlocks(); } //Swap device front and back buffer @@ -412,7 +409,6 @@ /** * @brief GP1212A01A::SendModifiedPixelBlocks * Compare our back and front buffer and send to the device only the modified pixels. - * TODO: Get this working at some point. */ void GP1212A01A::SendModifiedPixelBlocks() { @@ -420,13 +416,17 @@ //const int KBlocksPerRow = WidthInPixels()/16; //16 //const int KBlocksPerColumn = HeightInPixels()/16; //4 + const int KPixelBlockEdge = 16; + const int KPixelBlockSizeInBits = KPixelBlockEdge*KPixelBlockEdge; + const int KPixelBlockSizeInBytes = KPixelBlockSizeInBits/8; + int w=WidthInPixels(); int h=HeightInPixels(); - //TODO: optimize with memcmp and 16 inc /* + for (int i=0;iPtr()+offset,iFramePrevious->Ptr()+offset,32 )) //32=(16*16/8) - if (memcmp(nextBlock.Ptr(),previousBlock.Ptr(),32 )!=0) //32=(16*16/8) + if (memcmp(nextBlock.Ptr(),previousBlock.Ptr(),KPixelBlockSizeInBytes)!=0) { //We need to update that block - SetPixelBlock(i,j,15,32,nextBlock.Ptr()); + SetPixelBlock(i,j,KPixelBlockEdge-1,KPixelBlockSizeInBytes,nextBlock.Ptr()); //SetPixelBlock(i,j,15,32,0xFF/*nextBlock.Ptr()*/); //SetDisplayPosition(iDisplayPositionX,OffScreenY()); //SetDisplayPosition(iDisplayPositionX,OffScreenY()); diff -r 434d6b8a406d -r ca9e48af31e6 MiniDisplay/FutabaVfd.h --- a/MiniDisplay/FutabaVfd.h Fri May 30 13:45:14 2014 +0200 +++ b/MiniDisplay/FutabaVfd.h Fri May 30 15:02:15 2014 +0200 @@ -159,7 +159,9 @@ void ToggleOffScreenMode(); void SetOffScreenMode(bool aOn); bool OffScreenMode() const {return iOffScreenMode;} - // + void SetFrameDiffAlgo(bool aOn); + bool FrameDiffAlgo() const {return iUseFrameDiffAlgo;} + // bool RequestPending(){return iRequest!=ERequestNone;} Request CurrentRequest(){return iRequest;} void CancelRequest(){iRequest=ERequestNone;} @@ -187,6 +189,8 @@ ///Off screen mode is the recommended default settings to avoid tearing. ///Though turning it off can be useful for debugging bool iOffScreenMode; + ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case + bool iUseFrameDiffAlgo; /// //FutabaVfdReport iReport; /// diff -r 434d6b8a406d -r ca9e48af31e6 TestsTab.qml --- a/TestsTab.qml Fri May 30 13:45:14 2014 +0200 +++ b/TestsTab.qml Fri May 30 15:02:15 2014 +0200 @@ -111,6 +111,7 @@ Timer { id: timer interval: splash.timeoutInterval; running: true; repeat: true + property bool doFill: true onTriggered: { //visible = false @@ -132,8 +133,20 @@ { if (checkBoxFillOnly.checked) { - //Trying to make it a worth case scenario for our frame diff algo - (splash.frameCounter%3?display.fill():display.clear()); + //Trying to make it a worse case scenario for our frame diff algo + if (doFill) + { + display.fill(); + } + else + { + display.clear(); + } + + if (splash.frameCounter%2) + { + doFill=!doFill; + } } else if (checkBoxOnePixelOnly.checked) {