GPIO: Remove button interface from GPIO input
That doesn't make sense in most cases...master
parent
cdff51655f
commit
02eb9c6728
|
|
@ -287,12 +287,6 @@ void IntegrationPluginGpio::thingRemoved(Thing *thing)
|
||||||
delete monitor;
|
delete monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_longPressTimers.contains(thing)) {
|
|
||||||
QTimer *timer = m_longPressTimers.take(thing);
|
|
||||||
timer->stop();
|
|
||||||
timer->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_counterValues.contains(thing->id())) {
|
if (m_counterValues.contains(thing->id())) {
|
||||||
m_counterValues.remove(thing->id());
|
m_counterValues.remove(thing->id());
|
||||||
}
|
}
|
||||||
|
|
@ -389,18 +383,14 @@ void IntegrationPluginGpio::postSetupThing(Thing *thing)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thing->thingClassId() == gpioInputRpiThingClassId || thing->thingClassId() == gpioInputBbbThingClassId) {
|
if (thing->thingClassId() == gpioInputRpiThingClassId || thing->thingClassId() == gpioInputBbbThingClassId) {
|
||||||
QTimer *timer = new QTimer(this);
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
m_longPressTimers.insert(thing, timer);
|
|
||||||
|
|
||||||
GpioMonitor *monitor = m_monitorDevices.key(thing);
|
GpioMonitor *monitor = m_monitorDevices.key(thing);
|
||||||
if (!monitor)
|
if (!monitor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (thing->thingClassId() == gpioInputRpiThingClassId) {
|
if (thing->thingClassId() == gpioInputRpiThingClassId) {
|
||||||
thing->setStateValue(gpioInputRpiPressedStateTypeId, monitor->value());
|
thing->setStateValue(gpioInputRpiPowerStateTypeId, monitor->value());
|
||||||
} else if (thing->thingClassId() == gpioInputBbbThingClassId) {
|
} else if (thing->thingClassId() == gpioInputBbbThingClassId) {
|
||||||
thing->setStateValue(gpioInputBbbPressedStateTypeId, monitor->value());
|
thing->setStateValue(gpioInputBbbPowerStateTypeId, monitor->value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -541,60 +531,12 @@ void IntegrationPluginGpio::onGpioValueChanged(const bool &value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (thing->thingClassId() == gpioInputRpiThingClassId) {
|
if (thing->thingClassId() == gpioInputRpiThingClassId) {
|
||||||
thing->setStateValue(gpioInputRpiPressedStateTypeId, value);
|
thing->setStateValue(gpioInputRpiPowerStateTypeId, value);
|
||||||
//start longpresss timer
|
|
||||||
QTimer *timer = m_longPressTimers.value(thing);
|
|
||||||
if (!timer){
|
|
||||||
qWarning(dcGpioController()) << "Long press timer not available";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (value) {
|
|
||||||
int seconds = configValue( gpioControllerPluginLongPressTimeParamTypeId).toInt();
|
|
||||||
timer->start(seconds * 1000);
|
|
||||||
} else {
|
|
||||||
if (timer->isActive()) {
|
|
||||||
timer->stop();
|
|
||||||
//emit timer pressed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (thing->thingClassId() == gpioInputBbbThingClassId) {
|
} else if (thing->thingClassId() == gpioInputBbbThingClassId) {
|
||||||
thing->setStateValue(gpioInputBbbPressedStateTypeId, value);
|
thing->setStateValue(gpioInputBbbPowerStateTypeId, value);
|
||||||
//start longpresss timer
|
|
||||||
QTimer *timer = m_longPressTimers.value(thing);
|
|
||||||
if (!timer){
|
|
||||||
qWarning(dcGpioController()) << "Long press timer not available";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (value) {
|
|
||||||
int seconds = configValue( gpioControllerPluginLongPressTimeParamTypeId).toInt();
|
|
||||||
timer->start(seconds * 1000);
|
|
||||||
} else {
|
|
||||||
if (timer->isActive()) {
|
|
||||||
timer->stop();
|
|
||||||
//emit timer pressed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) {
|
} else if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) {
|
||||||
if (value) {
|
if (value) {
|
||||||
m_counterValues[thing->id()] += 1;
|
m_counterValues[thing->id()] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IntegrationPluginGpio::onLongPressedTimeout()
|
|
||||||
{
|
|
||||||
QTimer *timer = static_cast<QTimer *>(sender());
|
|
||||||
qCDebug(dcGpioController()) << "Button long pressed";
|
|
||||||
timer->stop();
|
|
||||||
Thing *thing = m_longPressTimers.key(timer);
|
|
||||||
if (!thing)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (thing->thingClassId() == gpioInputRpiThingClassId){
|
|
||||||
emitEvent(Event(gpioInputRpiLongPressedEventTypeId, thing->id()));
|
|
||||||
} else if (thing->thingClassId() == gpioInputBbbThingClassId){
|
|
||||||
emitEvent(Event(gpioInputBbbLongPressedEventTypeId, thing->id()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,9 @@ private:
|
||||||
QList<GpioDescriptor> beagleboneBlackGpioDescriptors();
|
QList<GpioDescriptor> beagleboneBlackGpioDescriptors();
|
||||||
PluginTimer *m_counterTimer = nullptr;
|
PluginTimer *m_counterTimer = nullptr;
|
||||||
QHash<ThingId, int> m_counterValues;
|
QHash<ThingId, int> m_counterValues;
|
||||||
QHash<Thing *, QTimer *> m_longPressTimers;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onGpioValueChanged(const bool &value);
|
void onGpioValueChanged(const bool &value);
|
||||||
void onLongPressedTimeout();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINGPIO_H
|
#endif // INTEGRATIONPLUGINGPIO_H
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@
|
||||||
"displayName": "GPIO Input",
|
"displayName": "GPIO Input",
|
||||||
"name": "gpioInputRpi",
|
"name": "gpioInputRpi",
|
||||||
"createMethods": ["discovery"],
|
"createMethods": ["discovery"],
|
||||||
"interfaces": ["longpressbutton"],
|
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "b45ca4a8-c67a-411c-957c-0e78e1f12c0b",
|
"id": "b45ca4a8-c67a-411c-957c-0e78e1f12c0b",
|
||||||
|
|
@ -93,20 +92,13 @@
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "57f1b7cc-26c8-434b-ba04-d3077dc886c8",
|
"id": "57f1b7cc-26c8-434b-ba04-d3077dc886c8",
|
||||||
"name": "pressed",
|
"name": "power",
|
||||||
"displayName": "Pressed",
|
"displayName": "Powered",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
"displayNameEvent": "Pressed changed",
|
"displayNameEvent": "Powered changed",
|
||||||
"ioType": "digitalInput"
|
"ioType": "digitalInput"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"eventTypes": [
|
|
||||||
{
|
|
||||||
"id": "0df945d3-38df-4560-b42a-12b05545904d",
|
|
||||||
"name": "longPressed",
|
|
||||||
"displayName": "Long pressed"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -205,7 +197,6 @@
|
||||||
"displayName": "GPIO Input",
|
"displayName": "GPIO Input",
|
||||||
"name": "gpioInputBbb",
|
"name": "gpioInputBbb",
|
||||||
"createMethods": ["discovery"],
|
"createMethods": ["discovery"],
|
||||||
"interfaces": ["longpressbutton"],
|
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "20773255-4576-4c8e-8c8b-051902919761",
|
"id": "20773255-4576-4c8e-8c8b-051902919761",
|
||||||
|
|
@ -232,20 +223,13 @@
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "22440876-417a-4d57-8e01-efe26ef9f235",
|
"id": "22440876-417a-4d57-8e01-efe26ef9f235",
|
||||||
"name": "pressed",
|
"name": "power",
|
||||||
"displayName": "Pressed",
|
"displayName": "Power",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
"displayNameEvent": "Pressed changed",
|
"displayNameEvent": "Power changed",
|
||||||
"ioType": "digitalInput"
|
"ioType": "digitalInput"
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"eventTypes": [
|
|
||||||
{
|
|
||||||
"id": "6b439e89-2cac-482a-b012-452c7c665acb",
|
|
||||||
"name": "longPressed",
|
|
||||||
"displayName": "Long pressed"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue