MiniDisplay/minidisplay.h
author sl
Tue, 17 Jun 2014 09:49:12 +0200
changeset 36 f2a9369e7fb9
parent 29 a42cc76a2d5a
permissions -rw-r--r--
Adding reset function called when changing font.
     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 connectRenderLoop(QQuickWindow* aWindow, QJSValue aFunction);
    44     Q_INVOKABLE void disconnectRenderLoop();
    45     //
    46     Q_INVOKABLE void setPixel(int x, int y, bool on);
    47 
    48 
    49 
    50 
    51 public:
    52     //Properties
    53     bool isOpen();
    54     QFont font() const {return iFont;}
    55     void setFont(const QFont& aFont);
    56     //
    57     bool offScreenMode();
    58     void setOffScreenMode(bool aOn);
    59     //
    60     QString vendor();
    61     QString product();
    62     QString serialNumber();
    63     //
    64     int maxBrightness() const;
    65     int minBrightness() const;
    66     int brightness() const;
    67     void setBrightness(int aBrightness);
    68     //
    69     bool frameDifferencing() const;
    70     void setFrameDifferencing(bool aOn);
    71     //Debug only
    72     QPoint framePosition() const;
    73     void setFramePosition(const QPoint& aPoint);
    74 
    75 public slots:
    76     void onAfterAnimating();
    77 
    78 signals:
    79     void opened();
    80     void openError();
    81     void closing();
    82     void closed();
    83     void statusChanged();
    84     void fontChanged();
    85     void brightnessChanged();
    86     void offScreenModeChanged();
    87     void frameDifferencingChanged();
    88     //
    89     void powerStatus(bool powerOn);
    90     void deviceId(QString deviceId);
    91     void firmwareVersion(QString version);
    92 
    93 public slots:
    94     void readTimer();
    95 
    96 
    97 public:
    98     MiniDisplay(QQuickItem *parent = 0);
    99     ~MiniDisplay();
   100 
   101 private:
   102     GP1212A01A iDisplay;
   103     QFont iFont;
   104     int iReadAttempt;
   105     int iBrightness;
   106     QPoint iFramePosition;
   107     QJSValue iAfterAnimatingCallback;
   108     QQuickWindow* iWindow;
   109     int iFrameCount;
   110 };
   111 
   112 #endif // MINIDISPLAY_H
   113