MiniDisplay/minidisplay.h
author sl
Tue, 03 Jun 2014 16:11:47 +0200
changeset 29 a42cc76a2d5a
parent 23 1f607fa8542f
child 33 cf5eba52cb1d
permissions -rw-r--r--
Trying to get rid of our QML timer.
We now connect to our window after animation signal from C++.
It looks like it works much better now. Less UI lags smother animation.
     1 #ifndef MINIDISPLAY_H
     2 #define MINIDISPLAY_H
     3 
     4 #include <QQuickItem>
     5 #include <QQuickWindow>
     6 #include "FutabaVfd.h"
     7 
     8 class MiniDisplay : public QQuickItem
     9 {
    10     Q_OBJECT
    11     Q_DISABLE_COPY(MiniDisplay)
    12     //
    13     Q_PROPERTY(bool isOpen READ isOpen NOTIFY statusChanged)
    14     Q_PROPERTY(bool offScreenMode READ offScreenMode WRITE setOffScreenMode NOTIFY offScreenModeChanged)
    15     Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
    16     Q_PROPERTY(QString vendor READ vendor)
    17     Q_PROPERTY(QString product READ product)
    18     Q_PROPERTY(QString serialNumber READ serialNumber)
    19     Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
    20     Q_PROPERTY(int maxBrightness READ maxBrightness NOTIFY opened)
    21     Q_PROPERTY(int minBrightness READ minBrightness NOTIFY opened)
    22     Q_PROPERTY(bool frameDifferencing READ frameDifferencing WRITE setFrameDifferencing NOTIFY frameDifferencingChanged)
    23     //Debug only
    24     Q_PROPERTY(QPoint framePosition READ framePosition WRITE setFramePosition NOTIFY closed)
    25 
    26 public:
    27     //Methods
    28     Q_INVOKABLE void open();
    29     Q_INVOKABLE void close();
    30     //
    31     Q_INVOKABLE void clear();
    32     Q_INVOKABLE void fill();
    33     Q_INVOKABLE void swapBuffers();
    34     //
    35     Q_INVOKABLE void requestPowerStatus();
    36     Q_INVOKABLE void requestDeviceId();
    37     Q_INVOKABLE void requestFirmwareVersion();
    38 
    39     Q_INVOKABLE void renderOwnWindow();
    40     Q_INVOKABLE void renderWindow(QQuickWindow* aWindow);
    41     Q_INVOKABLE void renderImage(QImage* aImage);
    42     //
    43     Q_INVOKABLE void connectWindow(QQuickWindow* aWindow, QJSValue aFunction);
    44     //
    45     Q_INVOKABLE void setPixel(int x, int y, bool on);
    46 
    47 
    48 
    49 
    50 public:
    51     //Properties
    52     bool isOpen();
    53     QFont font() const {return iFont;}
    54     void setFont(const QFont& aFont);
    55     //
    56     bool offScreenMode();
    57     void setOffScreenMode(bool aOn);
    58     //
    59     QString vendor();
    60     QString product();
    61     QString serialNumber();
    62     //
    63     int maxBrightness() const;
    64     int minBrightness() const;
    65     int brightness() const;
    66     void setBrightness(int aBrightness);
    67     //
    68     bool frameDifferencing() const;
    69     void setFrameDifferencing(bool aOn);
    70     //Debug only
    71     QPoint framePosition() const;
    72     void setFramePosition(const QPoint& aPoint);
    73 
    74 public slots:
    75     void onAfterAnimating();
    76 
    77 signals:
    78     void opened();
    79     void openError();
    80     void closing();
    81     void closed();
    82     void statusChanged();
    83     void fontChanged();
    84     void brightnessChanged();
    85     void offScreenModeChanged();
    86     void frameDifferencingChanged();
    87     //
    88     void powerStatus(bool powerOn);
    89     void deviceId(QString deviceId);
    90     void firmwareVersion(QString version);
    91 
    92 public slots:
    93     void readTimer();
    94 
    95 
    96 public:
    97     MiniDisplay(QQuickItem *parent = 0);
    98     ~MiniDisplay();
    99 
   100 private:
   101     GP1212A01A iDisplay;
   102     QFont iFont;
   103     int iReadAttempt;
   104     int iBrightness;
   105     QPoint iFramePosition;
   106     QJSValue iAfterAnimatingCallback;
   107     QQuickWindow* iWindow;
   108 };
   109 
   110 #endif // MINIDISPLAY_H
   111