Hyelicht 2.0
Controller application for the Hyelicht shelf. Paint on the shelf with colors, turn on the fireplace mode, and more.
|
Provides PWM-based display backlight control with the help of an attached MCU. More...
#include <displaycontroller.h>
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. | |
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.
|
explicit |
Create a display backlight controller.
parent | Parent object |
qint32 DisplayController::baudRate | ( | ) | const |
The baud rate used for serial communication with the PWM generator MCU.
|
signal |
The baud rate used for serial communication with the PWM generator MCU has changed.
qreal DisplayController::brightness | ( | ) | const |
The display brightness level while on.
This property is independent of the value of the property on.
0.0
and 1.0
.
|
signal |
The display brightness level while on has changed.
bool DisplayController::enabled | ( | ) | const |
Whether serial communication with the PWM generator MCU is enabled.
|
signal |
Serial communication with the PWM generator MCU has turned on or off.
int DisplayController::fadeDuration | ( | ) | const |
The duration in milliseconds for an animated fade between the two ends of the brightness range.
|
signal |
The duration in milliseconds for an animated fade between the two ends of the brightness range has changed.
QEasingCurve DisplayController::fadeEasing | ( | ) | const |
The easing curve used when fading between display brightness levels.
|
signal |
The easing curve used when fading between display brightness levels has changed.
int DisplayController::idleTimeout | ( | ) | const |
The wait time in seconds after which the display is turned off.
|
signal |
The wait time in seconds after which the display is turned off has changed.
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).
|
signal |
void DisplayController::resetIdleTimeout | ( | ) |
Reset the auto-turnoff timer.
Begins a new wait with the duration set as idleTimeout.
QString DisplayController::serialPortName | ( | ) | const |
The serial port device filename used for communication with the PWM generator MCU.
|
signal |
The serial port device filename used for communication with the PWM generator MCU has changed.
void DisplayController::setBaudRate | ( | qint32 | rate | ) |
Set the baud rate used for serial communication with the PWM generator MCU.
rate | Serial baud rate. |
void DisplayController::setBrightness | ( | qreal | brightness | ) |
Set the display brightness level while on.
brightness | Display brightness level between 0.0 and 1.0 . |
void DisplayController::setEnabled | ( | bool | enabled | ) |
Turn serial communication with the PWM generator MCU on or off.
enabled | Serial communication on or off. |
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.
fadeDuration | Duration in milliseconds. |
void DisplayController::setFadeEasing | ( | const QEasingCurve & | fadeEasing | ) |
Set the easing curve used when fading between display brightness levels.
fadeEasing | Easing curve. |
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.
timeout | Wait time in seconds. |
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).
on | Display on or off. |
void DisplayController::setSerialPortName | ( | const QString & | serialPortName | ) |
Set the serial port device filename used for communication with the PWM generator MCU.
serialPortName | Serial port device filename. |
|
readwrite |
Baud rate used for serial communication with the PWM generator MCU.
Defaults to 115200
.
|
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
.
|
readwrite |
Toggle serial communication with the PWM generator MCU.
Defaults to false
.
|
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
.
|
readwrite |
Easing curve used when fading between display brightness levels.
Defaults to QEasingCurve::InCubic
.
|
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
.
|
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
.
|
readwrite |
Serial port device filename used for communication with the PWM generator MCU.
Defaults to /dev/ttyUSB0
.