Hyelicht 2.0
Controller application for the Hyelicht shelf. Paint on the shelf with colors, turn on the fireplace mode, and more.
|
Data model and business logic specific to the Hyelicht shelf. More...
#include <shelfmodel.h>
Public Types | |
enum | AdditionalRoles : int { AverageColor = Qt::UserRole + 1 , AverageRed , AverageGreen , AverageBlue , AverageBrightness } |
Non-standard model data roles offered by this model. More... | |
Signals | |
void | ledStripChanged () const |
The LedStrip instance this model operates on has changed. | |
void | enabledChanged (bool enabled) const |
The shelf has turned on or off. | |
void | rowsChanged (int rows) const |
The number of boards in the shelf has changed. | |
void | columnsChanged (int columns) const |
The number of compartments in each shelf board has changed. | |
void | densityChanged (int density) const |
The number of LEDs in each shelf compartment has changed. | |
void | wallThicknessChanged (int thickness) const |
The number of LEDs behind each compartment-dividing wall has changed. | |
void | brightnessChanged (qreal brightness) const |
The brightness of the shelf has changed. | |
void | animateBrightnessTransitionsChanged (bool animate) const |
Whether to animate transitions between brightness levels has changed. | |
void | averageColorChanged (const QColor &color) const |
The average color of the shelf has changed. | |
void | animateAverageColorTransitionsChanged (bool animate) const |
Whether to animate transitions between full-shelf color fills has changed. | |
void | transitionDurationChanged (int duration) const |
The duration in milliseconds for an animated fade between brightness levels or full-shelf color fills has changed. | |
void | animationChanged () const |
The animation operating on ledStrip has changed. | |
void | animatingChanged (bool animating) const |
Whether to run the animation has changed. | |
void | remotingEnabledChanged () const |
Whether to enable the remoting API server has changed. | |
void | listenAddressChanged () const |
The listen address for the remoting API server has changed. | |
Public Member Functions | |
ShelfModel (QObject *parent=nullptr) | |
Create a shelf model. | |
LedStrip * | ledStrip () const |
The LedStrip instance this model operates on. | |
void | setLedStrip (LedStrip *ledStrip) |
Set the LedStrip instance this model operates on. | |
bool | enabled () const |
Whether the shelf is on or off. | |
void | setEnabled (bool enabled) |
Turn the shelf on or off. | |
int | rows () const |
The number of boards in the shelf. | |
void | setRows (int rows) |
Set the number of boards in the shelf. | |
int | columns () const |
The number of compartments in each shelf board. | |
void | setColumns (int columns) |
Set the number of compartments in each shelf board. | |
int | density () const |
The number of LEDs in each shelf compartment. | |
void | setDensity (int density) |
Set the number of LEDs in each shelf compartment. | |
int | wallThickness () const |
The number of LEDs behind each compartment-dividing wall. | |
void | setWallThickness (int thickness) |
Set the number of LEDs behind each compartment-dividing wall. | |
qreal | brightness () const |
The shelf brightness level while on. | |
void | setBrightness (qreal brightness) |
Set the shelf brightness level while on. | |
bool | animateBrightnessTransitions () const |
Whether to animate transitions between brightness levels. | |
void | setAnimateBrightnessTransitions (bool animate) |
Set whether to animate transitions between brightness levels. | |
QColor | averageColor () const |
The average color of the shelf. | |
void | setAverageColor (const QColor &color) |
Sets the average color of the shelf. | |
bool | animateAverageColorTransitions () const |
Whether to animate transitions between full-shelf color fills. | |
void | setAnimateAverageColorTransitions (bool animate) |
Set whether to animate transitions between full-shelf color fills. | |
int | transitionDuration () const |
The duration in milliseconds for an animated fade between brightness levels or full-shelf color fills has changed. | |
void | setTransitionDuration (int duration) |
Set the duration in milliseconds for an animated fade between brightness levels or full-shelf color fills has changed. | |
AbstractAnimation * | animation () const |
The animation operating on ledStrip. | |
void | setAnimation (AbstractAnimation *animation) |
Set animation operating on ledStrip. | |
bool | animating () const |
Whether to run the animation. | |
void | setAnimating (bool animating) |
Set whether to run the animation. | |
bool | remotingEnabled () const |
Whether to enable the remoting API server. | |
void | setRemotingEnabled (bool enabled) |
Set whether to enable the remoting API server. | |
QUrl | listenAddress () const |
The listen address for the remoting API server. | |
void | setListenAddress (const QUrl &url) |
Set the listen address for the remoting API server. | |
QHash< int, QByteArray > | roleNames () const override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
QVariant | data (const QModelIndex &proxyIndex, int role) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
void | classBegin () override |
Implements the QQmlParserStatus interface. | |
void | componentComplete () override |
Implements the QQmlParserStatus interface. | |
Properties | |
LedStrip * | ledStrip |
LedStrip instance this model operates on. | |
bool | enabled |
Toggle the shelf on or off. | |
int | rows |
Number of boards in the shelf. | |
int | columns |
Number of compartments in each shelf board. | |
int | density |
Number of LEDs in each shelf compartment. | |
int | wallThickness |
Number of LEDs behind each compartment-dividing wall. | |
qreal | brightness |
The shelf brightness level while on. | |
bool | animateBrightnessTransitions |
Toggle animated transitions between brightness levels. | |
QColor | averageColor |
Average color of the shelf. | |
bool | animateAverageColorTransitions |
Toggle animated transitions between full-shelf color fills. | |
int | transitionDuration |
Duration in milliseconds for an animated fade between brightness levels or full-shelf color fills. | |
AbstractAnimation * | animation |
Animation to operate on ledStrip. | |
bool | animating |
Toggle the animation. | |
bool | remotingEnabled |
Toggle the remoting API server. | |
QUrl | listenAddress |
Listen address for the remoting API server. | |
Data model and business logic specific to the Hyelicht shelf.
The Hyelicht shelf is a 5x5 IKEA Kallax shelf, of which the top 4 rows have LED backlighting of 104 LEDs each. This data model maps the 416 LEDs to rows in a QAbstractListModel
, each row representing one compartment in the shelf.
In addition to this mapping the extended API of the model provides painting operations and sophisticated application behaviors on top of LedStrip.
ShelfModel with the remotingEnabled property enabled can act as an API server for instances of RemoteShelfModel, which act as client, either out of process or over the network. This allows running the onboard GUI out of process and also enables the PC/Android offboard instances of the application.
Communication between RemoteShelfModel and ShelfModel is implemented using Qt Remote Objects.
Implements QQmlParserStatus
for use from QML.
enum ShelfModel::AdditionalRoles : int |
Non-standard model data roles offered by this model.
|
explicit |
Create a shelf model.
parent | Parent object |
bool ShelfModel::animateAverageColorTransitions | ( | ) | const |
Whether to animate transitions between full-shelf color fills.
This property is independent of the value of the property enabled.
|
signal |
Whether to animate transitions between full-shelf color fills has changed.
animate | Full-shelf color fill transitions on or off. |
bool ShelfModel::animateBrightnessTransitions | ( | ) | const |
Whether to animate transitions between brightness levels.
This property is independent of the value of the property enabled.
|
signal |
Whether to animate transitions between brightness levels has changed.
animate | Brightness transitions on or off. |
bool ShelfModel::animating | ( | ) | const |
Whether to run the animation.
The animation will be paused when enabled is false (without changing this property).
|
signal |
Whether to run the animation has changed.
animating | Animation on or off. |
AbstractAnimation * ShelfModel::animation | ( | ) | const |
The animation operating on ledStrip.
|
signal |
The animation operating on ledStrip has changed.
QColor ShelfModel::averageColor | ( | ) | const |
The average color of the shelf.
While animating, this is the average color of all LEDs in the ledStrip. Otherwise, it is only the color average of LEDs found in shelf compartments (in the Hyelicht shelf, some LEDs are located behind divider walls and usually turned off to reduce color bleed).
If ledStrip is not set, this has the initial or the last set value.
|
signal |
The average color of the shelf has changed.
color | Color to fill with. |
qreal ShelfModel::brightness | ( | ) | const |
The shelf brightness level while on.
This property is independent of the value of the property enabled.
0.0
and 1.0
.
|
signal |
The brightness of the shelf has changed.
brightness | Shelf brightness level between 0.0 and 1.0 . |
int ShelfModel::columns | ( | ) | const |
The number of compartments in each shelf board.
|
signal |
The number of compartments in each shelf board has changed.
columns | Number of compartments. |
|
override |
QAbstractItemModel::data
int ShelfModel::density | ( | ) | const |
The number of LEDs in each shelf compartment.
|
signal |
The number of LEDs in each shelf compartment has changed.
density | Number of LEDs. |
bool ShelfModel::enabled | ( | ) | const |
Whether the shelf is on or off.
When on, the shelf brightness is set to the current value of brightness.
When off, the shelf brightness is set to 0
(without changing brightness).
|
signal |
|
override |
QAbstractItemModel::headerData
LedStrip * ShelfModel::ledStrip | ( | ) | const |
The LedStrip instance this model operates on.
|
signal |
The LedStrip instance this model operates on has changed.
QUrl ShelfModel::listenAddress | ( | ) | const |
The listen address for the remoting API server.
|
signal |
The listen address for the remoting API server has changed.
bool ShelfModel::remotingEnabled | ( | ) | const |
Whether to enable the remoting API server.
|
signal |
Whether to enable the remoting API server has changed.
|
override |
QAbstractItemModel::roleNames
|
override |
QAbstractItemModel::rowCount
int ShelfModel::rows | ( | ) | const |
The number of boards in the shelf.
|
signal |
void ShelfModel::setAnimateAverageColorTransitions | ( | bool | animate | ) |
Set whether to animate transitions between full-shelf color fills.
animate | Full-shelf color fill transitions on or off. |
void ShelfModel::setAnimateBrightnessTransitions | ( | bool | animate | ) |
Set whether to animate transitions between brightness levels.
animate | Brightness transitions on or off. |
void ShelfModel::setAnimating | ( | bool | animating | ) |
Set whether to run the animation.
The animation will be paused when enabled is false (without changing this property).
animating | Animation on or off. |
void ShelfModel::setAnimation | ( | AbstractAnimation * | animation | ) |
Set animation operating on ledStrip.
The animation will be started or stopped based on the value of animating.
Should the animation be destroyed or set to nullptr
, animating is automatically set to false
.
animation | An AbstractAnimation. |
void ShelfModel::setAverageColor | ( | const QColor & | color | ) |
Sets the average color of the shelf.
When set, this sets all LEDs found in shelf compartments to the given color.
color | Color to fill with. |
void ShelfModel::setBrightness | ( | qreal | brightness | ) |
Set the shelf brightness level while on.
brightness | Shelf brightness level between 0.0 and 1.0 . |
void ShelfModel::setColumns | ( | int | columns | ) |
Set the number of compartments in each shelf board.
Cannot be lower than 1.
columns | Number of compartments. |
|
override |
QAbstractItemModel::data
void ShelfModel::setDensity | ( | int | density | ) |
Set the number of LEDs in each shelf compartment.
Cannot be lower than 1.
density | Number of LEDs. |
void ShelfModel::setEnabled | ( | bool | enabled | ) |
Turn the shelf on or off.
When turned on, the shelf brightness is set to the current value of brightness.
When turned off, the shelf brightness is set to 0
(without changing brightness).
enabled | Shelf on or off. |
void ShelfModel::setLedStrip | ( | LedStrip * | ledStrip | ) |
Set the LedStrip instance this model operates on.
LedStrip::enabled is not required to be true
in order to use the model.
ledStrip | LedStrip instance. |
void ShelfModel::setListenAddress | ( | const QUrl & | url | ) |
Set the listen address for the remoting API server.
Can be e.g. tcp://
or local:
.
url | Animation on or off. |
void ShelfModel::setRemotingEnabled | ( | bool | enabled | ) |
Set whether to enable the remoting API server.
When enabled acts as an API server for instances of RemoteShelfModel, which act as client, either out of process or over the network. This allows running the onboard GUI out of process and also enables the PC/Android offboard instances of the application.
enabled | Server on or off. |
void ShelfModel::setRows | ( | int | rows | ) |
Set the number of boards in the shelf.
Cannot be lower than 1.
rows | Number of boards. |
void ShelfModel::setTransitionDuration | ( | int | duration | ) |
Set the duration in milliseconds for an animated fade between brightness levels or full-shelf color fills has changed.
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 all animated fading and change to new brightness levels or full-shelf color fills immediately instead.
duration | Brightness transitions on or off. |
void ShelfModel::setWallThickness | ( | int | thickness | ) |
Set the number of LEDs behind each compartment-dividing wall.
The application will turn these off most of the time, in order to improve light bleed. Cannot be lower than 0.
thickness | Wall thickness in LEDs. |
int ShelfModel::transitionDuration | ( | ) | const |
The duration in milliseconds for an animated fade between brightness levels or full-shelf color fills has changed.
This property is independent of the value of the property enabled.
|
signal |
The duration in milliseconds for an animated fade between brightness levels or full-shelf color fills has changed.
duration | Brightness transitions on or off. |
int ShelfModel::wallThickness | ( | ) | const |
The number of LEDs behind each compartment-dividing wall.
The application will turn these off most of the time, in order to improve light bleed.
|
signal |
The number of LEDs behind each compartment-dividing wall has changed.
thickness | Wall thickness in LEDs. |
|
readwrite |
Toggle animated transitions between full-shelf color fills.
Defaults to true
.
|
readwrite |
Toggle animated transitions between brightness levels.
Defaults to true
.
|
readwrite |
Toggle the animation.
The animation will be paused when enabled is false (without changing this property).
Defaults to false
.
|
readwrite |
Animation to operate on ledStrip.
When set, the animation will be started or stopped based on the value of animating.
Should the animation be destroyed or set to nullptr
, animating is automatically set to false
.
Defaults to nullptr
.
|
readwrite |
Average color of the shelf.
While animating, this is the average color of all LEDs in the ledStrip. Otherwise, it is only the color average of LEDs found in shelf compartments (in the Hyelicht shelf, some LEDs are located behind divider walls and usually turned off to reduce color bleed).
If ledStrip is not set, this has the initial or the last set value.
When set, this sets all LEDs found in shelf compartments to the given color.
Defaults to white
. The shelf is initialized to this value at application startup.
|
readwrite |
The shelf brightness level while on.
Shelf brightness is set in a range between 0.0
and 1.0
.
This property is independent of the value of the property enabled.
Defaults to 1.0
.
|
readwrite |
Number of compartments in each shelf board.
Cannot be lower than 1
.
Defaults to 5
.
|
readwrite |
Number of LEDs in each shelf compartment.
Cannot be lower than 1
.
Defaults to 20
.
|
readwrite |
Toggle the shelf on or off.
When turned on, the shelf brightness is set to the current value of brightness.
When turned off, the shelf brightness is set to 0
(without changing brightness).
Defaults to false
.
|
readwrite |
LedStrip instance this model operates on.
LedStrip::enabled is not required to be true
in order to use the model.
Defaults to nullptr
.
|
readwrite |
Listen address for the remoting API server.
Can be e.g. tcp://
or local:
.
Defaults to tcp://0
.0.0.0:8042.
|
readwrite |
Toggle the remoting API server.
When enabled acts as an API server for instances of RemoteShelfModel, which act as client, either out of process or over the network. This allows running the onboard GUI out of process and also enables the PC/Android offboard instances of the application.
Defaults to true
.
|
readwrite |
Number of boards in the shelf.
Cannot be lower than 1.
Defaults to 4
.
|
readwrite |
Duration in milliseconds for an animated fade between brightness levels or full-shelf color fills.
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 all animated fading and change to new brightness levels or full-shelf color fills immediately instead.
Defaults to 400
.
|
readwrite |
Number of LEDs behind each compartment-dividing wall.
The application will turn these off most of the time, in order to improve light bleed.
Cannot be lower than 0
.
Defaults to 1
.