# HG changeset patch # User sl # Date 1401366428 -7200 # Node ID 737f8bb110becfaf4cb7df692c911f42655d6b36 # Parent 9903a5edeb5685968cc5bb14fae9db30bacc706a 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. diff -r 9903a5edeb56 -r 737f8bb110be DisplayFrame.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DisplayFrame.qml Thu May 29 14:27:08 2014 +0200 @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Rectangle { + width: 256 + height: 64 + color: red +} diff -r 9903a5edeb56 -r 737f8bb110be FontsTab.qml --- a/FontsTab.qml Wed May 28 21:31:03 2014 +0200 +++ b/FontsTab.qml Thu May 29 14:27:08 2014 +0200 @@ -34,7 +34,9 @@ onAccepted: { //console.log("Accepted: " + font); textFontDemoLowerCase.font = currentFont; + display.clear(); display.font = currentFont; + display.swapBuffers(); //textFontDemoUpperCase.font = currentFont; //textFontDemoDigits.font = currentFont; } diff -r 9903a5edeb56 -r 737f8bb110be Manager.pro --- a/Manager.pro Wed May 28 21:31:03 2014 +0200 +++ b/Manager.pro Thu May 29 14:27:08 2014 +0200 @@ -23,4 +23,5 @@ main.qml \ TestsTab.qml \ DisplayTab.qml \ - DisplayStatusBar.qml + DisplayStatusBar.qml \ + DisplayFrame.qml diff -r 9903a5edeb56 -r 737f8bb110be MiniDisplay/minidisplay.cpp --- a/MiniDisplay/minidisplay.cpp Wed May 28 21:31:03 2014 +0200 +++ b/MiniDisplay/minidisplay.cpp Thu May 29 14:27:08 2014 +0200 @@ -5,7 +5,7 @@ const int KMaxReadAttempt=100; MiniDisplay::MiniDisplay(QQuickItem *parent): - QQuickItem(parent),iReadAttempt(0),iBrightness(0) + QQuickItem(parent),iReadAttempt(0),iBrightness(iDisplay.MaxBrightness()) { // By default, QQuickItem does not draw anything. If you subclass // QQuickItem to create a visual item, you will need to uncomment the @@ -137,9 +137,47 @@ painter.drawText(0,metrics.ascent(),strDemo); } //Save image as PNG for validation - image.save("font.png"); + //image.save("font.png"); // - //int sizeInBytes=image.byteCount(); + renderImage(&image); +} + +/** + * @brief MiniDisplay::renderWindow + */ +void MiniDisplay::renderOwnWindow() +{ + QImage image=window()->grabWindow(); + //image.save("window.png"); + renderImage(&image); +} + +/** + * @brief MiniDisplay::render + * @param aWindow + */ +void MiniDisplay::renderWindow(QQuickWindow* aWindow) +{ + QImage image=aWindow->grabWindow(); + //image.save("window.png"); + renderImage(&image); +} + +/** + * @brief MiniDisplay::render + * @param aImage + */ +void MiniDisplay::renderImage(QImage* aImage) +{ + if (!iDisplay.IsOpen()) + { + return; + } + + //Convert our image into a bit array + int w=aImage->width(); + int h=aImage->height(); + int pixelCount=w*h; BitArray bits(pixelCount); @@ -147,7 +185,7 @@ { for (int j=0;jpixel(i,j); if (color!=0xffffffff) { bits.SetBit(i*h+j); @@ -155,26 +193,32 @@ } } - if (iDisplay.IsOpen()) - { - iDisplay.Clear(); - iDisplay.BitBlit(bits,w,h,0,0); - iDisplay.SwapBuffers(); - } - // + //Just blit it then + iDisplay.BitBlit(bits,w,h,0,0); } - +/** + * @brief MiniDisplay::vendor + * @return + */ QString MiniDisplay::vendor() { return QString::fromWCharArray(iDisplay.Vendor()); } +/** + * @brief MiniDisplay::product + * @return + */ QString MiniDisplay::product() { return QString::fromWCharArray(iDisplay.Product()); } +/** + * @brief MiniDisplay::serialNumber + * @return + */ QString MiniDisplay::serialNumber() { return QString::fromWCharArray(iDisplay.SerialNumber()); diff -r 9903a5edeb56 -r 737f8bb110be MiniDisplay/minidisplay.h --- a/MiniDisplay/minidisplay.h Wed May 28 21:31:03 2014 +0200 +++ b/MiniDisplay/minidisplay.h Thu May 29 14:27:08 2014 +0200 @@ -2,6 +2,7 @@ #define MINIDISPLAY_H #include +#include #include "FutabaVfd.h" class MiniDisplay : public QQuickItem @@ -32,6 +33,10 @@ Q_INVOKABLE void requestDeviceId(); Q_INVOKABLE void requestFirmwareVersion(); + Q_INVOKABLE void renderOwnWindow(); + Q_INVOKABLE void renderWindow(QQuickWindow* aWindow); + Q_INVOKABLE void renderImage(QImage* aImage); + public: //Properties bool isOpen(); diff -r 9903a5edeb56 -r 737f8bb110be TestsTab.qml --- a/TestsTab.qml Wed May 28 21:31:03 2014 +0200 +++ b/TestsTab.qml Thu May 29 14:27:08 2014 +0200 @@ -1,10 +1,109 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 +import QtQuick.Window 2.1 +import MiniDisplay 1.0 +import QtQuick.Layouts 1.1 + Item { - width: 100 - height: 62 + //width: 100 + //height: 62 //SystemPalette { id: palette } clip: true + //anchors.fill:parent + + + Window { + //parent: appWindow + id: splash + color: "transparent" + title: "Splash Window" + modality: Qt.NonModal + flags: Qt.SplashScreen + property int timeoutInterval: 41 + signal timeout + //! [splash-properties] + //! [screen-properties] + x: (Screen.width - rectangleScreen.width) / 2 + y: (Screen.height - rectangleScreen.height) / 2 + //! [screen-properties] + width: rectangleScreen.width + height: rectangleScreen.height + property int frameCounter:0; + property var startTime:new Date(); + + Rectangle { + id: rectangleScreen + anchors.centerIn: parent + width: 256 + height: 64 + color: "white" + border.width:1 + border.color: "black" + smooth: false + } + + ColumnLayout { + anchors.fill:parent + anchors.margins: 6 + spacing: 4 + + Label { + id: labelFrameCount + //anchors.centerIn: parent + text: "Frame Count" + antialiasing: false + } + + Label { + id: labelTime + //anchors.centerIn: parent + text: "Time" + antialiasing: false + } + + } + + + + + + //! [timer] + Timer { + interval: splash.timeoutInterval; running: true; repeat: true + onTriggered: { + //visible = false + + var current = new Date(); + var seconds = (current.getTime() - splash.startTime.getTime())/1000; + + splash.frameCounter++; + labelFrameCount.text=splash.frameCounter; + labelTime.text=seconds; + display.renderWindow(splash); + display.swapBuffers(); + splash.timeout() + } + } + //! [timer] + Component.onCompleted: { + visible = true + } + + } + + Column { + anchors.fill: parent + anchors.margins: 8 + spacing: 8 + + Button { + text: qsTr("Render Window") + onClicked: { + display.renderWindow(splash); + display.swapBuffers(); + } + } + } } diff -r 9903a5edeb56 -r 737f8bb110be qml.qrc --- a/qml.qrc Wed May 28 21:31:03 2014 +0200 +++ b/qml.qrc Thu May 29 14:27:08 2014 +0200 @@ -5,5 +5,6 @@ TestsTab.qml DisplayTab.qml DisplayStatusBar.qml + DisplayFrame.qml