Hyelicht 2.0
Controller application for the Hyelicht shelf. Paint on the shelf with colors, turn on the fireplace mode, and more.
Loading...
Searching...
No Matches
Signals | Public Member Functions | Properties | List of all members
DisplayController Class Reference

Provides PWM-based display backlight control with the help of an attached MCU. More...

#include <displaycontroller.h>

Inheritance diagram for DisplayController:
Inheritance graph
[legend]
Collaboration diagram for DisplayController:
Collaboration graph
[legend]

Signals

void enabledChanged () const
 Serial communication with the PWM generator MCU has turned on or off.
 
void serialPortNameChanged () const
 The serial port device filename used for communication with the PWM generator MCU has changed.
 
void baudRateChanged () const
 The baud rate used for serial communication with the PWM generator MCU has changed.
 
void onChanged () const
 The display has turned on or off.
 
void brightnessChanged () const
 The display brightness level while on has changed.
 
void idleTimeoutChanged () const
 The wait time in seconds after which the display is turned off has changed.
 
void fadeDurationChanged () const
 The duration in milliseconds for an animated fade between the two ends of the brightness range has changed.
 
void fadeEasingChanged () const
 The easing curve used when fading between display brightness levels has changed.
 

Public Member Functions

 DisplayController (QObject *parent=nullptr)
 Create a display backlight controller.
 
bool enabled () const
 Whether serial communication with the PWM generator MCU is enabled.
 
void setEnabled (bool enabled)
 Turn serial communication with the PWM generator MCU on or off.
 
QString serialPortName () const
 The serial port device filename used for communication with the PWM generator MCU.
 
void setSerialPortName (const QString &serialPortName)
 Set the serial port device filename used for communication with the PWM generator MCU.
 
qint32 baudRate () const
 The baud rate used for serial communication with the PWM generator MCU.
 
void setBaudRate (qint32 rate)
 Set the baud rate used for serial communication with the PWM generator MCU.
 
bool on () const
 Whether the display is on or off.
 
void setOn (bool on)
 Turn the display on or off.
 
qreal brightness () const
 The display brightness level while on.
 
void setBrightness (qreal brightness)
 Set the display brightness level while on.
 
int idleTimeout () const
 The wait time in seconds after which the display is turned off.
 
void setIdleTimeout (int timeout)
 Set the wait time in seconds after which the display is turned off.
 
Q_INVOKABLE void resetIdleTimeout ()
 Reset the auto-turnoff timer.
 
int fadeDuration () const
 The duration in milliseconds for an animated fade between the two ends of the brightness range.
 
void setFadeDuration (int fadeDuration)
 Set the duration in milliseconds for an animated fade between the two ends of the brightness range.
 
QEasingCurve fadeEasing () const
 The easing curve used when fading between display brightness levels.
 
void setFadeEasing (const QEasingCurve &fadeEasing)
 Set the easing curve used when fading between display brightness levels.
 
void classBegin () override
 Implements the QQmlParserStatus interface.
 
void componentComplete () override
 Implements the QQmlParserStatus interface.
 

Properties

bool enabled
 Toggle serial communication with the PWM generator MCU.
 
QString serialPortName
 Serial port device filename used for communication with the PWM generator MCU.
 
qint32 baudRate
 Baud rate used for serial communication with the PWM generator MCU.
 
bool on
 Toggle the display on or off.
 
qreal brightness
 Display brightness level while on.
 
int idleTimeout
 Wait time in seconds after which the display is turned off.
 
int fadeDuration
 Duration in milliseconds for an animated fade between the two ends of the brightness range.
 
QEasingCurve fadeEasing
 Easing curve used when fading between display brightness levels.
 

Detailed Description

Provides PWM-based display backlight control with the help of an attached MCU.

Performs serial port communication to a MCU (microcontroller unit) programmed to drive a HDMI display's backlight brightness by way of a PWM signal. The intended effect is to smoothly fade in and out the display for interactions with the project's onboard GUI (see fadeDuration).

An additional feature is support for automatically turning the display off after a determined idle period (see idleTimeout)

The attached MCU is assumed to accept writes of integer values between 0 and 255, representing intended display backlight brightness, on serial.

In the Hyelicht project, the attached MCU is an Arduino Nano 3.0 (AVR ATmega328). The Arduino sketch used to program it is provided in the source file support/arduino_pwm_generator.cpp.

Implements QQmlParserStatus for use from QML.

See also
QSerialPort
QSerialPortInfo
QQmlParserStatus

Constructor & Destructor Documentation

◆ DisplayController()

DisplayController::DisplayController ( QObject *  parent = nullptr)
explicit

Create a display backlight controller.

Parameters
parentParent object

Member Function Documentation

◆ baudRate()

qint32 DisplayController::baudRate ( ) const

The baud rate used for serial communication with the PWM generator MCU.

Returns
Serial baud rate.
See also
baudRate (property)
setBaudRate
baudRateChanged
serialPortName

◆ baudRateChanged

void DisplayController::baudRateChanged ( ) const
signal

The baud rate used for serial communication with the PWM generator MCU has changed.

See also
baudRate
setBaudRate

◆ brightness()

qreal DisplayController::brightness ( ) const

The display brightness level while on.

This property is independent of the value of the property on.

Returns
Display brightness level between 0.0 and 1.0.
See also
brightness (property)
setBrightness
brightnessChanged
on

◆ brightnessChanged

void DisplayController::brightnessChanged ( ) const
signal

The display brightness level while on has changed.

See also
brightness
setBrightness

◆ enabled()

bool DisplayController::enabled ( ) const

Whether serial communication with the PWM generator MCU is enabled.

Returns
Serial communication on or off.
See also
enabled (property)
setEnabled
enabledChanged

◆ enabledChanged

void DisplayController::enabledChanged ( ) const
signal

Serial communication with the PWM generator MCU has turned on or off.

See also
enabled
setEnabled

◆ fadeDuration()

int DisplayController::fadeDuration ( ) const

The duration in milliseconds for an animated fade between the two ends of the brightness range.

Returns
Duration in milliseconds.
See also
fadeDuration (property)
setFadeDuration
fadeDurationChanged
fadeEasing

◆ fadeDurationChanged

void DisplayController::fadeDurationChanged ( ) const
signal

The duration in milliseconds for an animated fade between the two ends of the brightness range has changed.

See also
fadeDuration
setFadeDuration

◆ fadeEasing()

QEasingCurve DisplayController::fadeEasing ( ) const

The easing curve used when fading between display brightness levels.

Returns
Easing curve.
See also
fadeEasing (property)
setFadeEasing
fadeEasingChanged
fadeDuration

◆ fadeEasingChanged

void DisplayController::fadeEasingChanged ( ) const
signal

The easing curve used when fading between display brightness levels has changed.

See also
fadeEasing
setFadeEasing

◆ idleTimeout()

int DisplayController::idleTimeout ( ) const

The wait time in seconds after which the display is turned off.

Returns
Wait time in seconds.
See also
idleTimeout (property)
setIdleTimeout
idleTimeoutChanged
resetIdleTimeout

◆ idleTimeoutChanged

void DisplayController::idleTimeoutChanged ( ) const
signal

The wait time in seconds after which the display is turned off has changed.

See also
idleTimeout
setIdleTimeout

◆ on()

bool DisplayController::on ( ) const

Whether the display is on or off.

When on, the display brightness is set to the current value of brightness.

When off, the display brightness is set to 0 (without changing brightness).

Returns
Display on or off.
See also
on (property)
setOn
onChanged
brightness

◆ onChanged

void DisplayController::onChanged ( ) const
signal

The display has turned on or off.

See also
on
setOn

◆ resetIdleTimeout()

void DisplayController::resetIdleTimeout ( )

Reset the auto-turnoff timer.

Begins a new wait with the duration set as idleTimeout.

See also
idleTimeout
setIdleTimeout
idleTimeoutChanged
resetIdleTimeout

◆ serialPortName()

QString DisplayController::serialPortName ( ) const

The serial port device filename used for communication with the PWM generator MCU.

Returns
Serial port device filename.
See also
serialPortName (property)
setSerialPortName
serialPortNameChanged
baudRate

◆ serialPortNameChanged

void DisplayController::serialPortNameChanged ( ) const
signal

The serial port device filename used for communication with the PWM generator MCU has changed.

See also
serialPortName
setSerialPortName

◆ setBaudRate()

void DisplayController::setBaudRate ( qint32  rate)

Set the baud rate used for serial communication with the PWM generator MCU.

Parameters
rateSerial baud rate.
See also
baudRate
baudRateChanged
serialPortName

◆ setBrightness()

void DisplayController::setBrightness ( qreal  brightness)

Set the display brightness level while on.

Parameters
brightnessDisplay brightness level between 0.0 and 1.0.
See also
brightness
brightnessChanged
on

◆ setEnabled()

void DisplayController::setEnabled ( bool  enabled)

Turn serial communication with the PWM generator MCU on or off.

Parameters
enabledSerial communication on or off.
See also
enabled
enabledChanged

◆ setFadeDuration()

void DisplayController::setFadeDuration ( int  fadeDuration)

Set the duration in milliseconds for an animated fade between the two ends of the brightness range.

The actual duration of a brightness fade is scaled by the delta between the old and the new brightness levels, as a fraction of the full range of 0.0 - 1.0.

Can be set to 0 to disable fading and change to new brightness levels immediately instead.

Parameters
fadeDurationDuration in milliseconds.
See also
fadeDuration
fadeDurationChanged
fadeEasing

◆ setFadeEasing()

void DisplayController::setFadeEasing ( const QEasingCurve &  fadeEasing)

Set the easing curve used when fading between display brightness levels.

Parameters
fadeEasingEasing curve.
See also
fadeEasing
fadeEasingChanged
fadeDuration

◆ setIdleTimeout()

void DisplayController::setIdleTimeout ( int  timeout)

Set the wait time in seconds after which the display is turned off.

Can be set to 0 to turn off the auto-turnoff behavior.

Parameters
timeoutWait time in seconds.
See also
idleTimeout
idleTimeoutChanged
resetIdleTimeout

◆ setOn()

void DisplayController::setOn ( bool  on)

Turn the display on or off.

When turned on, the display brightness is set to the current value of brightness.

When turned off, the display brightness is set to 0 (without changing brightness).

Parameters
onDisplay on or off.
See also
on
onChanged
brightness

◆ setSerialPortName()

void DisplayController::setSerialPortName ( const QString &  serialPortName)

Set the serial port device filename used for communication with the PWM generator MCU.

Parameters
serialPortNameSerial port device filename.
See also
serialPortName
serialPortNameChanged
baudRate

Property Documentation

◆ baudRate

qint32 DisplayController::baudRate
readwrite

Baud rate used for serial communication with the PWM generator MCU.

Defaults to 115200.

See also
setBaudRate
baudRateChanged
serialPortName

◆ brightness

qreal DisplayController::brightness
readwrite

Display brightness level while on.

Display brightness is set in a range between 0.0 and 1.0.

This property is independent of the value of the property on.

Defaults to 1.0.

See also
setBrightness
brightnessChanged
on

◆ enabled

bool DisplayController::enabled
readwrite

Toggle serial communication with the PWM generator MCU.

Defaults to false.

See also
setEnabled
enabledChanged
serialPortName
baudRate

◆ fadeDuration

int DisplayController::fadeDuration
readwrite

Duration in milliseconds for an animated fade between the two ends of the brightness range.

The actual duration of a brightness fade is scaled by the delta between the old and the new brightness levels, as a fraction of the full range of 0.0 - 1.0.

Can be set to 0 to disable fading and change to new brightness levels immediately instead.

Defaults to 400.

See also
setFadeDuration
fadeDurationChanged
fadeEasing

◆ fadeEasing

QEasingCurve DisplayController::fadeEasing
readwrite

Easing curve used when fading between display brightness levels.

Defaults to QEasingCurve::InCubic.

See also
setFadeEasing
fadeEasingChanged
fadeDuration

◆ idleTimeout

int DisplayController::idleTimeout
readwrite

Wait time in seconds after which the display is turned off.

Can be set to 0 to turn off the auto-turnoff behavior.

Defaults to 20.

See also
setIdleTimeout
idleTimeoutChanged
resetIdleTimeout

◆ on

bool DisplayController::on
readwrite

Toggle the display on or off.

When turned on, the display brightness is set to the current value of brightness.

When turned off, the display brightness is set to 0 (without changing brightness).

Defaults to true.

See also
setOn
onChanged
brightness

◆ serialPortName

QString DisplayController::serialPortName
readwrite

Serial port device filename used for communication with the PWM generator MCU.

Defaults to /dev/ttyUSB0.

See also
setSerialPortName
serialPortNameChanged
baudRate

The documentation for this class was generated from the following files: