Add gpio plugin with raspberry pi 2 support
This commit is contained in:
parent
cb982ac4f1
commit
24c48e8af3
1
debian/guh-plugins-maker.install
vendored
1
debian/guh-plugins-maker.install
vendored
@ -2,3 +2,4 @@ usr/lib/guh/plugins/libguh_devicepluginlircd.so
|
||||
usr/lib/guh/plugins/libguh_deviceplugincommandlauncher.so
|
||||
usr/lib/guh/plugins/libguh_devicepluginudpcommander.so
|
||||
usr/lib/guh/plugins/libguh_devicepluginavahimonitor.so
|
||||
usr/lib/guh/plugins/libguh_deviceplugingpio.so
|
||||
|
||||
BIN
doc/images/Raspberry-Pi-2-GPIO.png
Normal file
BIN
doc/images/Raspberry-Pi-2-GPIO.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
@ -161,7 +161,7 @@ int Gpio::gpioNumber() const
|
||||
/*! Returns true if the directories \tt {/sys/class/gpio} and \tt {/sys/class/gpio/export} do exist. */
|
||||
bool Gpio::isAvailable()
|
||||
{
|
||||
return QDir("/sys/class/gpio").exists() && QDir("/sys/class/gpio/export").exists();
|
||||
return QFile("/sys/class/gpio/export").exists();
|
||||
}
|
||||
|
||||
/*! Returns true if this \l{Gpio} could be exported in the system file \tt {/sys/class/gpio/export}. If this Gpio is already exported, this function will return true. */
|
||||
|
||||
@ -28,4 +28,5 @@ SUBDIRS += elro \
|
||||
denon \
|
||||
avahimonitor \
|
||||
senic \
|
||||
gpio \
|
||||
|
||||
|
||||
287
plugins/deviceplugins/gpio/deviceplugingpio.cpp
Normal file
287
plugins/deviceplugins/gpio/deviceplugingpio.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*!
|
||||
\page gpioplugin.html
|
||||
\title GPIO Plugin
|
||||
\brief Plugin to controll gpios on different boards.
|
||||
|
||||
\ingroup plugins
|
||||
\ingroup guh-plugins-maker
|
||||
|
||||
\chapter Raspberry Pi 2
|
||||
|
||||
\image Raspberry-Pi-2-GPIO.png "Raspberry Pi 2 GPIOs"
|
||||
|
||||
\chapter Plugin properties
|
||||
Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses}
|
||||
and \l{Vendor}{Vendors} of this \l{DevicePlugin}.
|
||||
|
||||
For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}.
|
||||
|
||||
\quotefile plugins/deviceplugins/gpio/deviceplugingpio.json
|
||||
*/
|
||||
|
||||
|
||||
#include "deviceplugingpio.h"
|
||||
#include "types/param.h"
|
||||
#include "plugin/device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
DevicePluginGpio::DevicePluginGpio()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcGpioController()) << "Setup" << device->name() << device->params();
|
||||
|
||||
// Check if GPIOs are available on this platform
|
||||
if (!Gpio::isAvailable()) {
|
||||
qCWarning(dcGpioController()) << "There are ou GPIOs on this plattform";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
// GPIO Switch
|
||||
if (device->deviceClassId() == gpioSwitchDeviceClassId) {
|
||||
// Create and configure gpio
|
||||
Gpio *gpio = new Gpio(device->paramValue(gpioParamTypeId).toInt(), this);
|
||||
|
||||
if (!gpio->exportGpio()) {
|
||||
qCWarning(dcGpioController()) << "Could not export gpio for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
if (!gpio->setDirection(Gpio::DirectionOutput)) {
|
||||
qCWarning(dcGpioController()) << "Could not configure output gpio for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
if (!gpio->setValue(Gpio::ValueLow)) {
|
||||
qCWarning(dcGpioController()) << "Could not set gpio value for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
m_gpioDevices.insert(gpio, device);
|
||||
m_raspberryPiGpios.insert(gpio->gpioNumber(), gpio);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == gpioSwitchDeviceClassId) {
|
||||
GpioMonitor *monior = new GpioMonitor(device->paramValue(gpioParamTypeId).toInt(), this);
|
||||
if (!monior->enable()) {
|
||||
qCWarning(dcGpioController()) << "Could not enable gpio monitor for device" << device->name();
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
connect(monior, &GpioMonitor::valueChanged, this, &DevicePluginGpio::onGpioValueChanged);
|
||||
|
||||
m_monitorDevices.insert(monior, device);
|
||||
m_raspberryPiGpioMoniors.insert(monior->gpio()->gpioNumber(), monior);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
Q_UNUSED(params)
|
||||
|
||||
// Check if GPIOs are available on this platform
|
||||
if (!Gpio::isAvailable()) {
|
||||
qCWarning(dcGpioController()) << "There are ou GPIOs on this plattform";
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
// Check which board / gpio configuration
|
||||
const DeviceClass deviceClass = deviceManager()->findDeviceClass(deviceClassId);
|
||||
if (deviceClass.vendorId() == raspberryPiVendorId) {
|
||||
|
||||
// Create the list of available gpios
|
||||
QList<DeviceDescriptor> deviceDescriptors;
|
||||
|
||||
QList<GpioDescriptor> gpioDescriptors = raspberryPiGpioDescriptors();
|
||||
for (int i = 0; i < gpioDescriptors.count(); i++) {
|
||||
const GpioDescriptor gpioDescriptor = gpioDescriptors.at(i);
|
||||
|
||||
// Offer only gpios which arn't in use already
|
||||
if (m_raspberryPiGpios.keys().contains(gpioDescriptor.gpio()))
|
||||
continue;
|
||||
|
||||
if (m_raspberryPiGpioMoniors.keys().contains(gpioDescriptor.gpio()))
|
||||
continue;
|
||||
|
||||
QString description;
|
||||
if (gpioDescriptor.description().isEmpty()) {
|
||||
description = QString("Pin %1").arg(gpioDescriptor.pin());
|
||||
} else {
|
||||
description = QString("Pin %1 | %2").arg(gpioDescriptor.pin()).arg(gpioDescriptor.description());
|
||||
}
|
||||
|
||||
DeviceDescriptor descriptor(deviceClassId, QString("GPIO %1").arg(gpioDescriptor.gpio()), description);
|
||||
ParamList parameters;
|
||||
parameters.append(Param(gpioParamTypeId, gpioDescriptor.gpio()));
|
||||
parameters.append(Param(pinParamTypeId, gpioDescriptor.pin()));
|
||||
parameters.append(Param(descriptionParamTypeId, gpioDescriptor.description()));
|
||||
descriptor.setParams(parameters);
|
||||
|
||||
deviceDescriptors.append(descriptor);
|
||||
}
|
||||
|
||||
emit devicesDiscovered(deviceClassId, deviceDescriptors);
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginGpio::requiredHardware() const
|
||||
{
|
||||
return DeviceManager::HardwareResourceNone;
|
||||
}
|
||||
|
||||
void DevicePluginGpio::deviceRemoved(Device *device)
|
||||
{
|
||||
if (m_gpioDevices.values().contains(device)) {
|
||||
Gpio *gpio = m_gpioDevices.key(device);
|
||||
if (!gpio)
|
||||
return;
|
||||
|
||||
m_gpioDevices.remove(gpio);
|
||||
|
||||
if (m_raspberryPiGpios.values().contains(gpio))
|
||||
m_raspberryPiGpios.remove(gpio->gpioNumber());
|
||||
|
||||
delete gpio;
|
||||
}
|
||||
|
||||
if (m_monitorDevices.values().contains(device)) {
|
||||
GpioMonitor *monitor = m_monitorDevices.key(device);
|
||||
if (!monitor)
|
||||
return;
|
||||
|
||||
m_monitorDevices.remove(monitor);
|
||||
|
||||
if (m_raspberryPiGpioMoniors.values().contains(monitor))
|
||||
m_raspberryPiGpios.remove(monitor->gpio()->gpioNumber());
|
||||
|
||||
delete monitor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
// Get the gpio
|
||||
const DeviceClass deviceClass = deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
Gpio *gpio = Q_NULLPTR;
|
||||
// Find the gpio in the corresponding hash
|
||||
if (deviceClass.vendorId() == raspberryPiVendorId)
|
||||
gpio = m_raspberryPiGpios.value(device->paramValue(gpioParamTypeId).toInt());
|
||||
|
||||
// Check if gpio was found
|
||||
if (!gpio) {
|
||||
qCWarning(dcGpioController()) << "Could not find gpio for executing action on" << device->name();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
// GPIO Switch power action
|
||||
if (device->deviceClassId() == gpioSwitchDeviceClassId && action.actionTypeId() == powerValueActionTypeId) {
|
||||
bool success = false;
|
||||
if (action.param(powerValueStateParamTypeId).value().toBool()) {
|
||||
success = gpio->setValue(Gpio::ValueHigh);
|
||||
} else {
|
||||
success = gpio->setValue(Gpio::ValueLow);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
qCWarning(dcGpioController()) << "Could not set gpio value while execute action on" << device->name();
|
||||
return DeviceManager::DeviceErrorHardwareFailure;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
|
||||
void DevicePluginGpio::postSetupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == gpioSwitchDeviceClassId) {
|
||||
Gpio *gpio = m_gpioDevices.key(device);
|
||||
device->setStateValue(powerValueStateTypeId, (bool)gpio->value());
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == gpioButtonDeviceClassId) {
|
||||
GpioMonitor *monitor = m_monitorDevices.key(device);
|
||||
device->setStateValue(pressedStateTypeId, monitor->value());
|
||||
}
|
||||
}
|
||||
|
||||
QList<GpioDescriptor> DevicePluginGpio::raspberryPiGpioDescriptors()
|
||||
{
|
||||
// Note: http://www.raspberrypi-spy.co.uk/wp-content/uploads/2012/06/Raspberry-Pi-GPIO-Layout-Model-B-Plus-rotated-2700x900.png
|
||||
QList<GpioDescriptor> gpioDescriptors;
|
||||
gpioDescriptors << GpioDescriptor(2, 3, "SDA1_I2C");
|
||||
gpioDescriptors << GpioDescriptor(3, 5, "SCL1_I2C");
|
||||
gpioDescriptors << GpioDescriptor(4, 7);
|
||||
gpioDescriptors << GpioDescriptor(5, 29);
|
||||
gpioDescriptors << GpioDescriptor(6, 31);
|
||||
gpioDescriptors << GpioDescriptor(7, 26, "SPI0_CE1_N");
|
||||
gpioDescriptors << GpioDescriptor(8, 24, "SPI0_CE0_N");
|
||||
gpioDescriptors << GpioDescriptor(9, 21, "SPI0_MISO");
|
||||
gpioDescriptors << GpioDescriptor(10, 19, "SPI0_MOSI");
|
||||
gpioDescriptors << GpioDescriptor(11, 23, "SPI0_SCLK");
|
||||
gpioDescriptors << GpioDescriptor(12, 32);
|
||||
gpioDescriptors << GpioDescriptor(13, 33);
|
||||
gpioDescriptors << GpioDescriptor(14, 8, "UART0_TXD");
|
||||
gpioDescriptors << GpioDescriptor(15, 10, "UART0_RXD");
|
||||
gpioDescriptors << GpioDescriptor(16, 36);
|
||||
gpioDescriptors << GpioDescriptor(17, 11);
|
||||
gpioDescriptors << GpioDescriptor(18, 12, "PCM_CLK");
|
||||
gpioDescriptors << GpioDescriptor(19, 35);
|
||||
gpioDescriptors << GpioDescriptor(20, 38);
|
||||
gpioDescriptors << GpioDescriptor(21, 40);
|
||||
gpioDescriptors << GpioDescriptor(22, 15);
|
||||
gpioDescriptors << GpioDescriptor(23, 16);
|
||||
gpioDescriptors << GpioDescriptor(24, 18);
|
||||
gpioDescriptors << GpioDescriptor(25, 22);
|
||||
gpioDescriptors << GpioDescriptor(26, 37);
|
||||
gpioDescriptors << GpioDescriptor(27, 13);
|
||||
return gpioDescriptors;
|
||||
}
|
||||
|
||||
void DevicePluginGpio::onGpioValueChanged(const bool &value)
|
||||
{
|
||||
GpioMonitor *monitor = static_cast<GpioMonitor *>(sender());
|
||||
|
||||
// Get device and set state value
|
||||
if (m_raspberryPiGpioMoniors.values().contains(monitor)) {
|
||||
Device *device = m_monitorDevices.value(monitor);
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
device->setStateValue(pressedStateTypeId, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
63
plugins/deviceplugins/gpio/deviceplugingpio.h
Normal file
63
plugins/deviceplugins/gpio/deviceplugingpio.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef DEVICEPLUGINGPIO_H
|
||||
#define DEVICEPLUGINGPIO_H
|
||||
|
||||
#include "hardware/gpio.h"
|
||||
#include "hardware/gpiomonitor.h"
|
||||
#include "gpiodescriptor.h"
|
||||
#include "hardware/gpiomonitor.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
class DevicePluginGpio : public DevicePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "deviceplugingpio.json")
|
||||
Q_INTERFACES(DevicePlugin)
|
||||
|
||||
public:
|
||||
explicit DevicePluginGpio();
|
||||
~DevicePluginGpio();
|
||||
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
void postSetupDevice(Device *device);
|
||||
|
||||
private:
|
||||
QHash<Gpio *, Device *> m_gpioDevices;
|
||||
QHash<int, Gpio *> m_raspberryPiGpios;
|
||||
|
||||
QHash<GpioMonitor *, Device *> m_monitorDevices;
|
||||
QHash<int, GpioMonitor *> m_raspberryPiGpioMoniors;
|
||||
|
||||
QList<GpioDescriptor> raspberryPiGpioDescriptors();
|
||||
|
||||
private slots:
|
||||
void onGpioValueChanged(const bool &value);
|
||||
|
||||
};
|
||||
|
||||
#endif // DEVICEPLUGINGPIO_H
|
||||
112
plugins/deviceplugins/gpio/deviceplugingpio.json
Normal file
112
plugins/deviceplugins/gpio/deviceplugingpio.json
Normal file
@ -0,0 +1,112 @@
|
||||
{
|
||||
"name": "Gpio Controller",
|
||||
"idName": "GpioController",
|
||||
"id": "127ead55-996a-44ac-ba82-fc3c634e018a",
|
||||
"vendors": [
|
||||
{
|
||||
"name": "Raspberry Pi 2",
|
||||
"idName": "raspberryPi",
|
||||
"id": "f0d00b66-bbd8-4a07-8591-ea48a61b229e",
|
||||
"deviceClasses": [
|
||||
{
|
||||
"id": "3885c520-e202-4435-88f6-3c35c362b2e6",
|
||||
"name": "GPIO Switch",
|
||||
"idName": "gpioSwitch",
|
||||
"deviceIcon": "Switch",
|
||||
"basicTags": [
|
||||
"Device",
|
||||
"Actuator"
|
||||
],
|
||||
"createMethods": ["discovery"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "9eda783f-6d9f-4d39-986d-d2cbfff5a7dd",
|
||||
"idName": "gpio",
|
||||
"name": "GPIO",
|
||||
"type": "int",
|
||||
"index": 0,
|
||||
"defaultValue": -1
|
||||
},
|
||||
{
|
||||
"id": "2204d278-7bc7-407f-ac82-ce3ae1d5779c",
|
||||
"idName": "pin",
|
||||
"name": "Pin number",
|
||||
"type": "int",
|
||||
"index": 1,
|
||||
"defaultValue": -1
|
||||
},
|
||||
{
|
||||
"id": "504798eb-1faa-4703-a57a-2778e4bf9a67",
|
||||
"idName": "description",
|
||||
"name": "Description",
|
||||
"type": "QString",
|
||||
"index": 2,
|
||||
"defaultValue": "-"
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "06843766-358e-44b0-8d52-2b46ef98459a",
|
||||
"idName": "powerValue",
|
||||
"name": "Power",
|
||||
"index": 0,
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"writable": true,
|
||||
"eventTypeName": "Power changed",
|
||||
"actionTypeName": "Set power"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "6aff228b-0410-4ef9-9593-51e8639aacea",
|
||||
"name": "GPIO Button",
|
||||
"idName": "gpioButton",
|
||||
"deviceIcon": "Power",
|
||||
"basicTags": [
|
||||
"Device",
|
||||
"Sensor"
|
||||
],
|
||||
"createMethods": ["discovery"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "9eda783f-6d9f-4d39-986d-d2cbfff5a7dd",
|
||||
"idName": "gpio",
|
||||
"name": "GPIO",
|
||||
"type": "int",
|
||||
"index": 0,
|
||||
"defaultValue": -1
|
||||
},
|
||||
{
|
||||
"id": "2204d278-7bc7-407f-ac82-ce3ae1d5779c",
|
||||
"idName": "pin",
|
||||
"name": "Pin number",
|
||||
"type": "int",
|
||||
"index": 1,
|
||||
"defaultValue": -1
|
||||
},
|
||||
{
|
||||
"id": "504798eb-1faa-4703-a57a-2778e4bf9a67",
|
||||
"idName": "description",
|
||||
"name": "Description",
|
||||
"type": "QString",
|
||||
"index": 2,
|
||||
"defaultValue": "-"
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "57f1b7cc-26c8-434b-ba04-d3077dc886c8",
|
||||
"idName": "pressed",
|
||||
"name": "Pressed",
|
||||
"index": 0,
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"eventTypeName": "Pressed changed"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
17
plugins/deviceplugins/gpio/gpio.pro
Normal file
17
plugins/deviceplugins/gpio/gpio.pro
Normal file
@ -0,0 +1,17 @@
|
||||
TRANSLATIONS = translations/en_US.ts \
|
||||
translations/de_DE.ts
|
||||
|
||||
# Note: include after the TRANSLATIONS definition
|
||||
include(../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(guh_deviceplugingpio)
|
||||
|
||||
SOURCES += \
|
||||
deviceplugingpio.cpp \
|
||||
gpiodescriptor.cpp
|
||||
|
||||
HEADERS += \
|
||||
deviceplugingpio.h \
|
||||
gpiodescriptor.h
|
||||
|
||||
|
||||
44
plugins/deviceplugins/gpio/gpiodescriptor.cpp
Normal file
44
plugins/deviceplugins/gpio/gpiodescriptor.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "gpiodescriptor.h"
|
||||
|
||||
GpioDescriptor::GpioDescriptor(const int &gpio, const int &pin, const QString &description):
|
||||
m_gpio(gpio),
|
||||
m_pin(pin),
|
||||
m_description(description)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int GpioDescriptor::gpio() const
|
||||
{
|
||||
return m_gpio;
|
||||
}
|
||||
|
||||
int GpioDescriptor::pin() const
|
||||
{
|
||||
return m_pin;
|
||||
}
|
||||
|
||||
QString GpioDescriptor::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
41
plugins/deviceplugins/gpio/gpiodescriptor.h
Normal file
41
plugins/deviceplugins/gpio/gpiodescriptor.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef GPIODESCRIPTOR_H
|
||||
#define GPIODESCRIPTOR_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class GpioDescriptor
|
||||
{
|
||||
public:
|
||||
GpioDescriptor(const int &gpio, const int &pin, const QString &description = QString());
|
||||
|
||||
int gpio() const;
|
||||
int pin() const;
|
||||
QString description() const;
|
||||
|
||||
private:
|
||||
int m_gpio;
|
||||
int m_pin;
|
||||
QString m_description;
|
||||
};
|
||||
|
||||
#endif // GPIODESCRIPTOR_H
|
||||
79
plugins/deviceplugins/gpio/translations/de_DE.ts
Normal file
79
plugins/deviceplugins/gpio/translations/de_DE.ts
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="de_DE">
|
||||
<context>
|
||||
<name>GpioController</name>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="38"/>
|
||||
<source>Gpio Controller</source>
|
||||
<extracomment>The name of the plugin Gpio Controller (127ead55-996a-44ac-ba82-fc3c634e018a)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="41"/>
|
||||
<source>Raspberry Pi 2</source>
|
||||
<extracomment>The name of the vendor (f0d00b66-bbd8-4a07-8591-ea48a61b229e)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="44"/>
|
||||
<source>GPIO Switch</source>
|
||||
<extracomment>The name of the DeviceClass (3885c520-e202-4435-88f6-3c35c362b2e6)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="47"/>
|
||||
<source>GPIO</source>
|
||||
<extracomment>The name of the paramType (9eda783f-6d9f-4d39-986d-d2cbfff5a7dd) of GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="50"/>
|
||||
<source>Pin number</source>
|
||||
<extracomment>The name of the paramType (2204d278-7bc7-407f-ac82-ce3ae1d5779c) of GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="53"/>
|
||||
<source>Description</source>
|
||||
<extracomment>The name of the paramType (504798eb-1faa-4703-a57a-2778e4bf9a67) of GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="56"/>
|
||||
<source>Power changed</source>
|
||||
<extracomment>The name of the autocreated EventType (06843766-358e-44b0-8d52-2b46ef98459a)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="59"/>
|
||||
<source>Power</source>
|
||||
<extracomment>The name of the ParamType of StateType (06843766-358e-44b0-8d52-2b46ef98459a) of DeviceClass GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="62"/>
|
||||
<source>Set power</source>
|
||||
<extracomment>The name of the autocreated ActionType (06843766-358e-44b0-8d52-2b46ef98459a)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="65"/>
|
||||
<source>GPIO Button</source>
|
||||
<extracomment>The name of the DeviceClass (6aff228b-0410-4ef9-9593-51e8639aacea)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="68"/>
|
||||
<source>Pressed changed</source>
|
||||
<extracomment>The name of the autocreated EventType (57f1b7cc-26c8-434b-ba04-d3077dc886c8)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="71"/>
|
||||
<source>Pressed</source>
|
||||
<extracomment>The name of the ParamType of StateType (57f1b7cc-26c8-434b-ba04-d3077dc886c8) of DeviceClass GPIO Button</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
79
plugins/deviceplugins/gpio/translations/en_US.ts
Normal file
79
plugins/deviceplugins/gpio/translations/en_US.ts
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>GpioController</name>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="38"/>
|
||||
<source>Gpio Controller</source>
|
||||
<extracomment>The name of the plugin Gpio Controller (127ead55-996a-44ac-ba82-fc3c634e018a)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="41"/>
|
||||
<source>Raspberry Pi 2</source>
|
||||
<extracomment>The name of the vendor (f0d00b66-bbd8-4a07-8591-ea48a61b229e)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="44"/>
|
||||
<source>GPIO Switch</source>
|
||||
<extracomment>The name of the DeviceClass (3885c520-e202-4435-88f6-3c35c362b2e6)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="47"/>
|
||||
<source>GPIO</source>
|
||||
<extracomment>The name of the paramType (9eda783f-6d9f-4d39-986d-d2cbfff5a7dd) of GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="50"/>
|
||||
<source>Pin number</source>
|
||||
<extracomment>The name of the paramType (2204d278-7bc7-407f-ac82-ce3ae1d5779c) of GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="53"/>
|
||||
<source>Description</source>
|
||||
<extracomment>The name of the paramType (504798eb-1faa-4703-a57a-2778e4bf9a67) of GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="56"/>
|
||||
<source>Power changed</source>
|
||||
<extracomment>The name of the autocreated EventType (06843766-358e-44b0-8d52-2b46ef98459a)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="59"/>
|
||||
<source>Power</source>
|
||||
<extracomment>The name of the ParamType of StateType (06843766-358e-44b0-8d52-2b46ef98459a) of DeviceClass GPIO Switch</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="62"/>
|
||||
<source>Set power</source>
|
||||
<extracomment>The name of the autocreated ActionType (06843766-358e-44b0-8d52-2b46ef98459a)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="65"/>
|
||||
<source>GPIO Button</source>
|
||||
<extracomment>The name of the DeviceClass (6aff228b-0410-4ef9-9593-51e8639aacea)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="68"/>
|
||||
<source>Pressed changed</source>
|
||||
<extracomment>The name of the autocreated EventType (57f1b7cc-26c8-434b-ba04-d3077dc886c8)</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../../../build-guh-Desktop-Debug/plugins/deviceplugins/gpio/plugininfo.h" line="71"/>
|
||||
<source>Pressed</source>
|
||||
<extracomment>The name of the ParamType of StateType (57f1b7cc-26c8-434b-ba04-d3077dc886c8) of DeviceClass GPIO Button</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
Reference in New Issue
Block a user