Adding MiniDisplay methods to display image and window.
Using our test tab to render our display frame in QML and send it to our display.
Using a timer and frame counter to profile our performance.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/DisplayFrame.qml Thu May 29 14:27:08 2014 +0200
1.3 @@ -0,0 +1,7 @@
1.4 +import QtQuick 2.0
1.5 +
1.6 +Rectangle {
1.7 + width: 256
1.8 + height: 64
1.9 + color: red
1.10 +}
2.1 --- a/FontsTab.qml Wed May 28 21:31:03 2014 +0200
2.2 +++ b/FontsTab.qml Thu May 29 14:27:08 2014 +0200
2.3 @@ -34,7 +34,9 @@
2.4 onAccepted: {
2.5 //console.log("Accepted: " + font);
2.6 textFontDemoLowerCase.font = currentFont;
2.7 + display.clear();
2.8 display.font = currentFont;
2.9 + display.swapBuffers();
2.10 //textFontDemoUpperCase.font = currentFont;
2.11 //textFontDemoDigits.font = currentFont;
2.12 }
3.1 --- a/Manager.pro Wed May 28 21:31:03 2014 +0200
3.2 +++ b/Manager.pro Thu May 29 14:27:08 2014 +0200
3.3 @@ -23,4 +23,5 @@
3.4 main.qml \
3.5 TestsTab.qml \
3.6 DisplayTab.qml \
3.7 - DisplayStatusBar.qml
3.8 + DisplayStatusBar.qml \
3.9 + DisplayFrame.qml
4.1 --- a/MiniDisplay/minidisplay.cpp Wed May 28 21:31:03 2014 +0200
4.2 +++ b/MiniDisplay/minidisplay.cpp Thu May 29 14:27:08 2014 +0200
4.3 @@ -5,7 +5,7 @@
4.4 const int KMaxReadAttempt=100;
4.5
4.6 MiniDisplay::MiniDisplay(QQuickItem *parent):
4.7 - QQuickItem(parent),iReadAttempt(0),iBrightness(0)
4.8 + QQuickItem(parent),iReadAttempt(0),iBrightness(iDisplay.MaxBrightness())
4.9 {
4.10 // By default, QQuickItem does not draw anything. If you subclass
4.11 // QQuickItem to create a visual item, you will need to uncomment the
4.12 @@ -137,9 +137,47 @@
4.13 painter.drawText(0,metrics.ascent(),strDemo);
4.14 }
4.15 //Save image as PNG for validation
4.16 - image.save("font.png");
4.17 + //image.save("font.png");
4.18 //
4.19 - //int sizeInBytes=image.byteCount();
4.20 + renderImage(&image);
4.21 +}
4.22 +
4.23 +/**
4.24 + * @brief MiniDisplay::renderWindow
4.25 + */
4.26 +void MiniDisplay::renderOwnWindow()
4.27 +{
4.28 + QImage image=window()->grabWindow();
4.29 + //image.save("window.png");
4.30 + renderImage(&image);
4.31 +}
4.32 +
4.33 +/**
4.34 + * @brief MiniDisplay::render
4.35 + * @param aWindow
4.36 + */
4.37 +void MiniDisplay::renderWindow(QQuickWindow* aWindow)
4.38 +{
4.39 + QImage image=aWindow->grabWindow();
4.40 + //image.save("window.png");
4.41 + renderImage(&image);
4.42 +}
4.43 +
4.44 +/**
4.45 + * @brief MiniDisplay::render
4.46 + * @param aImage
4.47 + */
4.48 +void MiniDisplay::renderImage(QImage* aImage)
4.49 +{
4.50 + if (!iDisplay.IsOpen())
4.51 + {
4.52 + return;
4.53 + }
4.54 +
4.55 + //Convert our image into a bit array
4.56 + int w=aImage->width();
4.57 + int h=aImage->height();
4.58 +
4.59 int pixelCount=w*h;
4.60 BitArray bits(pixelCount);
4.61
4.62 @@ -147,7 +185,7 @@
4.63 {
4.64 for (int j=0;j<h;j++)
4.65 {
4.66 - QRgb color=image.pixel(i,j);
4.67 + QRgb color=aImage->pixel(i,j);
4.68 if (color!=0xffffffff)
4.69 {
4.70 bits.SetBit(i*h+j);
4.71 @@ -155,26 +193,32 @@
4.72 }
4.73 }
4.74
4.75 - if (iDisplay.IsOpen())
4.76 - {
4.77 - iDisplay.Clear();
4.78 - iDisplay.BitBlit(bits,w,h,0,0);
4.79 - iDisplay.SwapBuffers();
4.80 - }
4.81 - //
4.82 + //Just blit it then
4.83 + iDisplay.BitBlit(bits,w,h,0,0);
4.84 }
4.85
4.86 -
4.87 +/**
4.88 + * @brief MiniDisplay::vendor
4.89 + * @return
4.90 + */
4.91 QString MiniDisplay::vendor()
4.92 {
4.93 return QString::fromWCharArray(iDisplay.Vendor());
4.94 }
4.95
4.96 +/**
4.97 + * @brief MiniDisplay::product
4.98 + * @return
4.99 + */
4.100 QString MiniDisplay::product()
4.101 {
4.102 return QString::fromWCharArray(iDisplay.Product());
4.103 }
4.104
4.105 +/**
4.106 + * @brief MiniDisplay::serialNumber
4.107 + * @return
4.108 + */
4.109 QString MiniDisplay::serialNumber()
4.110 {
4.111 return QString::fromWCharArray(iDisplay.SerialNumber());
5.1 --- a/MiniDisplay/minidisplay.h Wed May 28 21:31:03 2014 +0200
5.2 +++ b/MiniDisplay/minidisplay.h Thu May 29 14:27:08 2014 +0200
5.3 @@ -2,6 +2,7 @@
5.4 #define MINIDISPLAY_H
5.5
5.6 #include <QQuickItem>
5.7 +#include <QQuickWindow>
5.8 #include "FutabaVfd.h"
5.9
5.10 class MiniDisplay : public QQuickItem
5.11 @@ -32,6 +33,10 @@
5.12 Q_INVOKABLE void requestDeviceId();
5.13 Q_INVOKABLE void requestFirmwareVersion();
5.14
5.15 + Q_INVOKABLE void renderOwnWindow();
5.16 + Q_INVOKABLE void renderWindow(QQuickWindow* aWindow);
5.17 + Q_INVOKABLE void renderImage(QImage* aImage);
5.18 +
5.19 public:
5.20 //Properties
5.21 bool isOpen();
6.1 --- a/TestsTab.qml Wed May 28 21:31:03 2014 +0200
6.2 +++ b/TestsTab.qml Thu May 29 14:27:08 2014 +0200
6.3 @@ -1,10 +1,109 @@
6.4 import QtQuick 2.2
6.5 import QtQuick.Controls 1.2
6.6 +import QtQuick.Window 2.1
6.7 +import MiniDisplay 1.0
6.8 +import QtQuick.Layouts 1.1
6.9 +
6.10
6.11 Item {
6.12 - width: 100
6.13 - height: 62
6.14 + //width: 100
6.15 + //height: 62
6.16 //SystemPalette { id: palette }
6.17 clip: true
6.18 + //anchors.fill:parent
6.19
6.20 +
6.21 +
6.22 + Window {
6.23 + //parent: appWindow
6.24 + id: splash
6.25 + color: "transparent"
6.26 + title: "Splash Window"
6.27 + modality: Qt.NonModal
6.28 + flags: Qt.SplashScreen
6.29 + property int timeoutInterval: 41
6.30 + signal timeout
6.31 + //! [splash-properties]
6.32 + //! [screen-properties]
6.33 + x: (Screen.width - rectangleScreen.width) / 2
6.34 + y: (Screen.height - rectangleScreen.height) / 2
6.35 + //! [screen-properties]
6.36 + width: rectangleScreen.width
6.37 + height: rectangleScreen.height
6.38 + property int frameCounter:0;
6.39 + property var startTime:new Date();
6.40 +
6.41 + Rectangle {
6.42 + id: rectangleScreen
6.43 + anchors.centerIn: parent
6.44 + width: 256
6.45 + height: 64
6.46 + color: "white"
6.47 + border.width:1
6.48 + border.color: "black"
6.49 + smooth: false
6.50 + }
6.51 +
6.52 + ColumnLayout {
6.53 + anchors.fill:parent
6.54 + anchors.margins: 6
6.55 + spacing: 4
6.56 +
6.57 + Label {
6.58 + id: labelFrameCount
6.59 + //anchors.centerIn: parent
6.60 + text: "Frame Count"
6.61 + antialiasing: false
6.62 + }
6.63 +
6.64 + Label {
6.65 + id: labelTime
6.66 + //anchors.centerIn: parent
6.67 + text: "Time"
6.68 + antialiasing: false
6.69 + }
6.70 +
6.71 + }
6.72 +
6.73 +
6.74 +
6.75 +
6.76 +
6.77 + //! [timer]
6.78 + Timer {
6.79 + interval: splash.timeoutInterval; running: true; repeat: true
6.80 + onTriggered: {
6.81 + //visible = false
6.82 +
6.83 + var current = new Date();
6.84 + var seconds = (current.getTime() - splash.startTime.getTime())/1000;
6.85 +
6.86 + splash.frameCounter++;
6.87 + labelFrameCount.text=splash.frameCounter;
6.88 + labelTime.text=seconds;
6.89 + display.renderWindow(splash);
6.90 + display.swapBuffers();
6.91 + splash.timeout()
6.92 + }
6.93 + }
6.94 + //! [timer]
6.95 + Component.onCompleted: {
6.96 + visible = true
6.97 + }
6.98 +
6.99 + }
6.100 +
6.101 + Column {
6.102 + anchors.fill: parent
6.103 + anchors.margins: 8
6.104 + spacing: 8
6.105 +
6.106 + Button {
6.107 + text: qsTr("Render Window")
6.108 + onClicked: {
6.109 + display.renderWindow(splash);
6.110 + display.swapBuffers();
6.111 + }
6.112 + }
6.113 + }
6.114 }
7.1 --- a/qml.qrc Wed May 28 21:31:03 2014 +0200
7.2 +++ b/qml.qrc Thu May 29 14:27:08 2014 +0200
7.3 @@ -5,5 +5,6 @@
7.4 <file>TestsTab.qml</file>
7.5 <file>DisplayTab.qml</file>
7.6 <file>DisplayStatusBar.qml</file>
7.7 + <file>DisplayFrame.qml</file>
7.8 </qresource>
7.9 </RCC>