Sorting out start-up/shutdown sequence to avoid flashing old frame upon connection.
authorsl
Wed, 28 May 2014 18:44:15 +0200
changeset 11b935de604982
parent 10 64cfde8062c7
child 12 f0c61338a2e8
Sorting out start-up/shutdown sequence to avoid flashing old frame upon connection.
Adding a couple of option to clear our frames upong close and/or open.
DisplayStatusBar.qml
DisplayTab.qml
MiniDisplay/FutabaVfd.cpp
MiniDisplay/FutabaVfd.h
MiniDisplay/minidisplay.cpp
MiniDisplay/minidisplay.h
     1.1 --- a/DisplayStatusBar.qml	Wed May 28 17:08:47 2014 +0200
     1.2 +++ b/DisplayStatusBar.qml	Wed May 28 18:44:15 2014 +0200
     1.3 @@ -15,6 +15,16 @@
     1.4          display.firmwareVersion.connect(updateFirmwareVersion);
     1.5      }
     1.6  
     1.7 +    //We need to disconnect our signals to avoid receiving stray events
     1.8 +    Component.onDestruction: {
     1.9 +        display.closed.disconnect(onDisplayClosed);
    1.10 +        display.opened.disconnect(onDisplayOpened);
    1.11 +        display.openError.disconnect(updateDisplayStatusError);
    1.12 +        display.powerStatus.disconnect(updatePowerStatus);
    1.13 +        display.deviceId.disconnect(updateDeviceId);
    1.14 +        display.firmwareVersion.disconnect(updateFirmwareVersion);
    1.15 +    }
    1.16 +
    1.17      function updatePowerStatus(powerOn)
    1.18      {
    1.19          if (powerOn)
     2.1 --- a/DisplayTab.qml	Wed May 28 17:08:47 2014 +0200
     2.2 +++ b/DisplayTab.qml	Wed May 28 18:44:15 2014 +0200
     2.3 @@ -12,13 +12,51 @@
     2.4      //SystemPalette { id: palette }
     2.5      clip: true
     2.6      //
     2.7 -    Component.onCompleted: { if(checkBoxConnectOnStartUp.checked) display.open()}
     2.8 +    Component.onCompleted: {
     2.9 +        display.closing.connect(onDisplayClosing);
    2.10 +        display.opened.connect(onDisplayOpened);
    2.11 +        if(checkBoxConnectOnStartUp.checked) display.open()
    2.12 +    }
    2.13 +
    2.14 +    //We need to disconnect our signals to avoid receiving stray events
    2.15 +    Component.onDestruction: {
    2.16 +        display.closed.disconnect(onDisplayClosing);
    2.17 +        display.opened.disconnect(onDisplayOpened);
    2.18 +        onDisplayClosing();
    2.19 +    }
    2.20      //
    2.21      Settings {
    2.22          property alias connectOnStratUp: checkBoxConnectOnStartUp.checked;
    2.23 +        property alias clearWhenDisconnecting: checkBoxClearWhenDisconnecting.checked;
    2.24 +        property alias clearWhenConnecting: checkBoxClearWhenConnecting.checked;
    2.25          property alias brightness: sliderBrightness.value;
    2.26      }
    2.27  
    2.28 +    function onDisplayClosing()
    2.29 +    {
    2.30 +        //Clear both our frames
    2.31 +        if (checkBoxClearWhenDisconnecting.checked)
    2.32 +        {
    2.33 +            display.clear();
    2.34 +            display.swapBuffers();
    2.35 +            display.clear();
    2.36 +            display.swapBuffers();
    2.37 +        }
    2.38 +    }
    2.39 +
    2.40 +    function onDisplayOpened()
    2.41 +    {
    2.42 +        //Clear both our frames
    2.43 +        if (checkBoxClearWhenConnecting.checked)
    2.44 +        {
    2.45 +            display.clear();
    2.46 +            display.swapBuffers();
    2.47 +            display.clear();
    2.48 +            display.swapBuffers();
    2.49 +        }
    2.50 +    }
    2.51 +
    2.52 +
    2.53      //
    2.54  
    2.55      Column {
    2.56 @@ -52,6 +90,17 @@
    2.57              text: qsTr("Connect on start-up")
    2.58          }
    2.59  
    2.60 +        CheckBox {
    2.61 +            id: checkBoxClearWhenDisconnecting
    2.62 +            text: qsTr("Clear when disconnecting")
    2.63 +        }
    2.64 +
    2.65 +        CheckBox {
    2.66 +            id: checkBoxClearWhenConnecting
    2.67 +            text: qsTr("Clear when connecting")
    2.68 +        }
    2.69 +
    2.70 +
    2.71      } //ColumnLayout
    2.72  
    2.73      Slider {
     3.1 --- a/MiniDisplay/FutabaVfd.cpp	Wed May 28 17:08:47 2014 +0200
     3.2 +++ b/MiniDisplay/FutabaVfd.cpp	Wed May 28 18:44:15 2014 +0200
     3.3 @@ -97,14 +97,10 @@
     3.4  		iFrameBuffer = NULL;
     3.5  		iFrameBuffer=new BitArray(KGP12xFrameBufferPixelCount);
     3.6  		SetNonBlocking(1);
     3.7 -		//Since we can't get our display position we for it to our default
     3.8 +        //Since we can't get our display position we force it to our default
     3.9  		//This makes sure frames are in sync from the start
    3.10 +        //Clever clients will have taken care of putting back frame (0,0) before closing
    3.11  		SetDisplayPosition(iDisplayPositionX,iDisplayPositionY);
    3.12 -		//Now clear both front and back buffer on host and device
    3.13 -		Clear();
    3.14 -		SwapBuffers();
    3.15 -		Clear();
    3.16 -		SwapBuffers();
    3.17  		}
    3.18  	return success;
    3.19  	}
     4.1 --- a/MiniDisplay/FutabaVfd.h	Wed May 28 17:08:47 2014 +0200
     4.2 +++ b/MiniDisplay/FutabaVfd.h	Wed May 28 18:44:15 2014 +0200
     4.3 @@ -145,8 +145,11 @@
     4.4  	//Specific to GP1212A01A
     4.5  	void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char aValue);
     4.6      void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char* aPixels);
     4.7 +    //Define display position within our display RAM
     4.8 +	void SetDisplayPosition(unsigned char aX, unsigned char aY);
     4.9 +    unsigned char DisplayPositionX() const {return iDisplayPositionX;}
    4.10 +    unsigned char DisplayPositionY() const {return iDisplayPositionY;}
    4.11      //
    4.12 -	void SetDisplayPosition(unsigned char aX, unsigned char aY);
    4.13  	void SwapBuffers();
    4.14      //
    4.15      void RequestDeviceId();
     5.1 --- a/MiniDisplay/minidisplay.cpp	Wed May 28 17:08:47 2014 +0200
     5.2 +++ b/MiniDisplay/minidisplay.cpp	Wed May 28 18:44:15 2014 +0200
     5.3 @@ -19,6 +19,7 @@
     5.4  MiniDisplay::~MiniDisplay()
     5.5  {
     5.6      //qDebug() << "Delete MiniDisplay";
     5.7 +    close();
     5.8  }
     5.9  
    5.10  
    5.11 @@ -39,6 +40,18 @@
    5.12  
    5.13  void MiniDisplay::close()
    5.14  {
    5.15 +    //qDebug() << "MiniDisplay::close";
    5.16 +    //Try to put back ourframe position to RAM 0,0 which is a multiple of 128
    5.17 +    if (iDisplay.IsOpen())
    5.18 +    {
    5.19 +        emit closing();
    5.20 +
    5.21 +        if (iDisplay.DisplayPositionY()%128!=0)
    5.22 +        {
    5.23 +            //qDebug() << "SwapBuffer to put back our frame position to zero " << iDisplay.DisplayPositionY();
    5.24 +            iDisplay.SwapBuffers();
    5.25 +        }
    5.26 +    }
    5.27      iDisplay.Close();
    5.28      emit closed();
    5.29      emit statusChanged();
    5.30 @@ -234,4 +247,19 @@
    5.31      iDisplay.SetBrightness(aBrightness);
    5.32  }
    5.33  
    5.34 +QPoint MiniDisplay::framePosition() const
    5.35 +{
    5.36 +    return QPoint(iDisplay.DisplayPositionX(),iDisplay.DisplayPositionX());
    5.37 +}
    5.38  
    5.39 +void MiniDisplay::setFramePosition(const QPoint& aPoint)
    5.40 +{
    5.41 +    iFramePosition = aPoint;
    5.42 +
    5.43 +    if (!iDisplay.IsOpen()) return;
    5.44 +
    5.45 +    iDisplay.SetDisplayPosition(aPoint.x(),aPoint.y());
    5.46 +}
    5.47 +
    5.48 +
    5.49 +
     6.1 --- a/MiniDisplay/minidisplay.h	Wed May 28 17:08:47 2014 +0200
     6.2 +++ b/MiniDisplay/minidisplay.h	Wed May 28 18:44:15 2014 +0200
     6.3 @@ -17,6 +17,7 @@
     6.4      Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
     6.5      Q_PROPERTY(int maxBrightness READ maxBrightness NOTIFY opened)
     6.6      Q_PROPERTY(int minBrightness READ minBrightness NOTIFY opened)
     6.7 +    Q_PROPERTY(QPoint framePosition READ framePosition WRITE setFramePosition NOTIFY closed)
     6.8  
     6.9  public:
    6.10      //Methods
    6.11 @@ -45,10 +46,14 @@
    6.12      int minBrightness() const;
    6.13      int brightness() const;
    6.14      void setBrightness(int aBrightness);
    6.15 +    //
    6.16 +    QPoint framePosition() const;
    6.17 +    void setFramePosition(const QPoint& aPoint);
    6.18  
    6.19  signals:
    6.20      void opened();
    6.21      void openError();
    6.22 +    void closing();
    6.23      void closed();
    6.24      void statusChanged();
    6.25      void fontChanged();
    6.26 @@ -71,6 +76,7 @@
    6.27      QFont iFont;
    6.28      int iReadAttempt;
    6.29      int iBrightness;
    6.30 +    QPoint iFramePosition;
    6.31  };
    6.32  
    6.33  #endif // MINIDISPLAY_H