Commit 1f16ff20 authored by Titta Heikkala's avatar Titta Heikkala

React to light switch changes

The room lights are changed with the switch from the ui as well as with
the switch from the KNX board.
parent 4bad2631
......@@ -136,6 +136,8 @@ void HouseModel::generateRooms()
addRoom(QStringLiteral("Master Bedroom"), QStringLiteral("Masterbedroom"), 18, 0.8, -380, -290);
addRoom(QStringLiteral("Bedroom"), QStringLiteral("Bedroom"), 15, 0.0, -405, 170);
addRoom(QStringLiteral("Bath Room"), QStringLiteral("Bathroom"), 30, 1.0, -20, -320);
#if !defined(KNX_BACKEND)
addRoom(QStringLiteral("Entrance"), QStringLiteral("Entrance"), 20, 0.6, -450, -70);
#endif
}
......@@ -212,6 +212,17 @@ Item {
}
Connections {
target: knxBackend
onBoardUpdate: {
if (lightNum > 0 && lightNum < 5) {
var oldValue = houseModel.data(houseModel.index(lightNum - 1, 0), 3)
houseModel.setData(houseModel.index(lightNum - 1, 0), !oldValue, 3)
lightControlLoader.item.value = houseModel.data(houseModel.index(index, 0), 3)
}
}
}
MouseArea {
id: mouseArea
property bool disableMouseEvents: false
......@@ -301,6 +312,18 @@ Item {
var newLightValue = lightControlLoader.item.lightValue * 100
home.light = newLightValue
presentation.setAttribute(currentLightAttribute, "opacity", newLightValue)
if (knxBackend) {
var lightNum = 0
if (scene.currentSlideName === "Livingroom")
lightNum = 1
else if (scene.currentSlideName === "Masterbedroom")
lightNum = 2
else if (scene.currentSlideName === "Bedroom")
lightNum = 3
else if (scene.currentSlideName === "Bathroom")
lightNum = 4
knxBackend.toggleLight(lightNum)
}
}
}
......
......@@ -8,4 +8,7 @@ The demo has controls to change lighting and temperature (represented as color)
The application is designed to be used with Pixel C, but it also has basic scaling in place.
By default the screen size is used as the main application window size. Uncommenting FIXEDWINDOW
definition from main.cpp will force the main application window to be of size 1280x900.
\ No newline at end of file
definition from main.cpp will force the main application window to be of size 1280x900.
Config variable KNX_BOARD can be used to compile the application so that it controls the
KNX board.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment