Fix press/rotation repeated forever
parent
f8f06be358
commit
dabaf34bae
|
|
@ -111,16 +111,16 @@ void HueTapDial::updateStates(const QVariantMap &sensorMap)
|
||||||
|
|
||||||
// If rotated
|
// If rotated
|
||||||
if (sensorMap.value("uniqueid").toString() == m_rotaryUuid) {
|
if (sensorMap.value("uniqueid").toString() == m_rotaryUuid) {
|
||||||
QString lastUpdate = stateMap.value("lastupdated").toString();
|
QString lastUpdateRotation = stateMap.value("lastupdated").toString();
|
||||||
int rotationCode = stateMap.value("expectedrotation").toInt();
|
int rotationCode = stateMap.value("expectedrotation").toInt();
|
||||||
|
|
||||||
// If we never polled, just store lastUpdate/rotationCode and not emit a false rotated event
|
// If we never polled, just store lastUpdate/rotationCode and not emit a false rotated event
|
||||||
if (m_lastUpdate.isEmpty() || m_lastRotationCode == 0) {
|
if (m_lastUpdateRotation.isEmpty() || m_lastRotationCode == 0) {
|
||||||
m_lastUpdate = lastUpdate;
|
m_lastUpdateRotation = lastUpdateRotation;
|
||||||
m_lastRotationCode = rotationCode;
|
m_lastRotationCode = rotationCode;
|
||||||
}
|
}
|
||||||
if (m_lastUpdate != lastUpdate || m_lastRotationCode != rotationCode) {
|
if (m_lastUpdateRotation != lastUpdateRotation || m_lastRotationCode != rotationCode) {
|
||||||
m_lastUpdate = lastUpdate;
|
m_lastUpdateRotation = lastUpdateRotation;
|
||||||
m_lastRotationCode = rotationCode;
|
m_lastRotationCode = rotationCode;
|
||||||
qCDebug(dcPhilipsHue) << "rotated" << rotationCode;
|
qCDebug(dcPhilipsHue) << "rotated" << rotationCode;
|
||||||
emit rotated(rotationCode);
|
emit rotated(rotationCode);
|
||||||
|
|
@ -129,16 +129,16 @@ void HueTapDial::updateStates(const QVariantMap &sensorMap)
|
||||||
|
|
||||||
// If button press
|
// If button press
|
||||||
if (sensorMap.value("uniqueid").toString() == m_switchUuid) {
|
if (sensorMap.value("uniqueid").toString() == m_switchUuid) {
|
||||||
QString lastUpdate = stateMap.value("lastupdated").toString();
|
QString lastUpdateButton = stateMap.value("lastupdated").toString();
|
||||||
int buttonCode = stateMap.value("buttonevent").toInt();
|
int buttonCode = stateMap.value("buttonevent").toInt();
|
||||||
|
|
||||||
// If we never polled, just store lastUpdate/buttonCode and not emit a false button pressed event
|
// If we never polled, just store lastUpdate/buttonCode and not emit a false button pressed event
|
||||||
if (m_lastUpdate.isEmpty() || m_lastButtonCode == -1) {
|
if (m_lastUpdateButton.isEmpty() || m_lastButtonCode == -1) {
|
||||||
m_lastUpdate = lastUpdate;
|
m_lastUpdateButton = lastUpdateButton;
|
||||||
m_lastButtonCode = buttonCode;
|
m_lastButtonCode = buttonCode;
|
||||||
}
|
}
|
||||||
if (m_lastUpdate != lastUpdate || m_lastButtonCode != buttonCode) {
|
if (m_lastUpdateButton != lastUpdateButton || m_lastButtonCode != buttonCode) {
|
||||||
m_lastUpdate = lastUpdate;
|
m_lastUpdateButton = lastUpdateButton;
|
||||||
m_lastButtonCode = buttonCode;
|
m_lastButtonCode = buttonCode;
|
||||||
qCDebug(dcPhilipsHue) << "button pressed" << buttonCode;
|
qCDebug(dcPhilipsHue) << "button pressed" << buttonCode;
|
||||||
emit buttonPressed(buttonCode);
|
emit buttonPressed(buttonCode);
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ private:
|
||||||
QString m_switchUuid;
|
QString m_switchUuid;
|
||||||
|
|
||||||
// States
|
// States
|
||||||
QString m_lastUpdate;
|
QString m_lastUpdateButton;
|
||||||
|
QString m_lastUpdateRotation;
|
||||||
double m_level = 0;
|
double m_level = 0;
|
||||||
int m_batteryLevel = 0;
|
int m_batteryLevel = 0;
|
||||||
int m_lastButtonCode = -1;
|
int m_lastButtonCode = -1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue