74 lines
1.7 KiB
QML
74 lines
1.7 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
import QtQuick.Controls.Material 2.15
|
|
|
|
Page {
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
|
|
property int lampState: 0
|
|
|
|
onLampStateChanged: {
|
|
console.log(lampState.toString(16))
|
|
sendBufferTimer.start()
|
|
}
|
|
|
|
Timer {
|
|
id: sendBufferTimer
|
|
interval: 500
|
|
running: false
|
|
repeat: false
|
|
onTriggered: {
|
|
ble.sendData("s:" + lampState.toString(16))
|
|
}
|
|
}
|
|
|
|
Column {
|
|
anchors.centerIn: parent
|
|
Switch {
|
|
checked: app.remoteState >> 24 === 1
|
|
onCheckedChanged: {
|
|
let newState = lampState & 16777215
|
|
lampState = newState | ((checked ? 1:0) << 24)
|
|
}
|
|
}
|
|
|
|
Slider {
|
|
id: red
|
|
Material.accent: Material.Red
|
|
from: 0
|
|
to: 255
|
|
value: app.remoteState >> 16 & 255
|
|
onValueChanged: {
|
|
let newColor = lampState & 16842751
|
|
lampState = newColor | (value << 16)
|
|
}
|
|
}
|
|
|
|
Slider {
|
|
id: green
|
|
Material.accent: Material.Green
|
|
from: 0
|
|
to: 255
|
|
value: app.remoteState >> 8 & 255
|
|
onValueChanged: {
|
|
let newColor = lampState & 33489151
|
|
lampState = newColor | (value << 8)
|
|
}
|
|
}
|
|
|
|
Slider {
|
|
id: blue
|
|
Material.accent: Material.Blue
|
|
from: 0
|
|
to: 255
|
|
value: app.remoteState & 255
|
|
onValueChanged: {
|
|
let newColor = lampState & 33554176
|
|
lampState = newColor | (value)
|
|
}
|
|
}
|
|
}
|
|
}
|