GPIO: Remove button interface from GPIO input
That doesn't make sense in most cases...pull/376/head
parent
cdff51655f
commit
02eb9c6728
|
|
@ -287,12 +287,6 @@ void IntegrationPluginGpio::thingRemoved(Thing *thing)
|
|||
delete monitor;
|
||||
}
|
||||
|
||||
if (m_longPressTimers.contains(thing)) {
|
||||
QTimer *timer = m_longPressTimers.take(thing);
|
||||
timer->stop();
|
||||
timer->deleteLater();
|
||||
}
|
||||
|
||||
if (m_counterValues.contains(thing->id())) {
|
||||
m_counterValues.remove(thing->id());
|
||||
}
|
||||
|
|
@ -389,18 +383,14 @@ void IntegrationPluginGpio::postSetupThing(Thing *thing)
|
|||
}
|
||||
|
||||
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);
|
||||
if (!monitor)
|
||||
return;
|
||||
|
||||
if (thing->thingClassId() == gpioInputRpiThingClassId) {
|
||||
thing->setStateValue(gpioInputRpiPressedStateTypeId, monitor->value());
|
||||
thing->setStateValue(gpioInputRpiPowerStateTypeId, monitor->value());
|
||||
} 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;
|
||||
|
||||
if (thing->thingClassId() == gpioInputRpiThingClassId) {
|
||||
thing->setStateValue(gpioInputRpiPressedStateTypeId, 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
|
||||
}
|
||||
}
|
||||
thing->setStateValue(gpioInputRpiPowerStateTypeId, value);
|
||||
} else if (thing->thingClassId() == gpioInputBbbThingClassId) {
|
||||
thing->setStateValue(gpioInputBbbPressedStateTypeId, 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
|
||||
}
|
||||
}
|
||||
thing->setStateValue(gpioInputBbbPowerStateTypeId, value);
|
||||
} else if (thing->thingClassId() == counterRpiThingClassId || thing->thingClassId() == counterBbbThingClassId) {
|
||||
if (value) {
|
||||
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();
|
||||
PluginTimer *m_counterTimer = nullptr;
|
||||
QHash<ThingId, int> m_counterValues;
|
||||
QHash<Thing *, QTimer *> m_longPressTimers;
|
||||
|
||||
private slots:
|
||||
void onGpioValueChanged(const bool &value);
|
||||
void onLongPressedTimeout();
|
||||
};
|
||||
|
||||
#endif // INTEGRATIONPLUGINGPIO_H
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@
|
|||
"displayName": "GPIO Input",
|
||||
"name": "gpioInputRpi",
|
||||
"createMethods": ["discovery"],
|
||||
"interfaces": ["longpressbutton"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "b45ca4a8-c67a-411c-957c-0e78e1f12c0b",
|
||||
|
|
@ -93,20 +92,13 @@
|
|||
"stateTypes": [
|
||||
{
|
||||
"id": "57f1b7cc-26c8-434b-ba04-d3077dc886c8",
|
||||
"name": "pressed",
|
||||
"displayName": "Pressed",
|
||||
"name": "power",
|
||||
"displayName": "Powered",
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"displayNameEvent": "Pressed changed",
|
||||
"displayNameEvent": "Powered changed",
|
||||
"ioType": "digitalInput"
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "0df945d3-38df-4560-b42a-12b05545904d",
|
||||
"name": "longPressed",
|
||||
"displayName": "Long pressed"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -205,7 +197,6 @@
|
|||
"displayName": "GPIO Input",
|
||||
"name": "gpioInputBbb",
|
||||
"createMethods": ["discovery"],
|
||||
"interfaces": ["longpressbutton"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "20773255-4576-4c8e-8c8b-051902919761",
|
||||
|
|
@ -232,20 +223,13 @@
|
|||
"stateTypes": [
|
||||
{
|
||||
"id": "22440876-417a-4d57-8e01-efe26ef9f235",
|
||||
"name": "pressed",
|
||||
"displayName": "Pressed",
|
||||
"name": "power",
|
||||
"displayName": "Power",
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"displayNameEvent": "Pressed changed",
|
||||
"displayNameEvent": "Power changed",
|
||||
"ioType": "digitalInput"
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "6b439e89-2cac-482a-b012-452c7c665acb",
|
||||
"name": "longPressed",
|
||||
"displayName": "Long pressed"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue