MiniDisplay/minidisplay.cpp
changeset 10 64cfde8062c7
parent 9 52372bbbc0f8
child 11 b935de604982
     1.1 --- a/MiniDisplay/minidisplay.cpp	Wed May 28 15:23:41 2014 +0200
     1.2 +++ b/MiniDisplay/minidisplay.cpp	Wed May 28 17:08:47 2014 +0200
     1.3 @@ -5,7 +5,7 @@
     1.4  const int KMaxReadAttempt=100;
     1.5  
     1.6  MiniDisplay::MiniDisplay(QQuickItem *parent):
     1.7 -    QQuickItem(parent),iReadAttempt(0)
     1.8 +    QQuickItem(parent),iReadAttempt(0),iBrightness(0)
     1.9  {
    1.10      // By default, QQuickItem does not draw anything. If you subclass
    1.11      // QQuickItem to create a visual item, you will need to uncomment the
    1.12 @@ -26,6 +26,7 @@
    1.13  {
    1.14      if (iDisplay.Open())
    1.15      {
    1.16 +        iDisplay.SetBrightness(iBrightness);
    1.17          emit opened();
    1.18          emit statusChanged();
    1.19      }
    1.20 @@ -167,6 +168,9 @@
    1.21  
    1.22  /**
    1.23   * @brief MiniDisplay::readTimer
    1.24 + * Called when our read timer completes.
    1.25 + * We then attempt to complete our pending display request.
    1.26 + * We typically attempt to read an input report from our HID device.
    1.27   */
    1.28  void MiniDisplay::readTimer()
    1.29  {
    1.30 @@ -204,3 +208,30 @@
    1.31      }
    1.32  }
    1.33  
    1.34 +
    1.35 +int MiniDisplay::maxBrightness() const
    1.36 +{
    1.37 +    return iDisplay.MaxBrightness();
    1.38 +}
    1.39 +
    1.40 +int MiniDisplay::minBrightness() const
    1.41 +{
    1.42 +    return iDisplay.MinBrightness();
    1.43 +}
    1.44 +
    1.45 +int MiniDisplay::brightness() const
    1.46 +{
    1.47 +    return iBrightness;
    1.48 +}
    1.49 +
    1.50 +void MiniDisplay::setBrightness(int aBrightness)
    1.51 +{
    1.52 +    //Still track the brightness when disconnected
    1.53 +    iBrightness=aBrightness;
    1.54 +
    1.55 +    if (!iDisplay.IsOpen()) return;
    1.56 +
    1.57 +    iDisplay.SetBrightness(aBrightness);
    1.58 +}
    1.59 +
    1.60 +