diff --git a/plugins/deviceplugins/gpio/deviceplugingpio.cpp b/plugins/deviceplugins/gpio/deviceplugingpio.cpp index 561a13de..998e2775 100644 --- a/plugins/deviceplugins/gpio/deviceplugingpio.cpp +++ b/plugins/deviceplugins/gpio/deviceplugingpio.cpp @@ -66,7 +66,7 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) } // GPIO Switch - if (device->deviceClassId() == gpioSwitchDeviceClassId) { + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId || device->deviceClassId() == gpioSwitchBbbDeviceClassId) { // Create and configure gpio Gpio *gpio = new Gpio(device->paramValue(gpioParamTypeId).toInt(), this); @@ -86,12 +86,19 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) } m_gpioDevices.insert(gpio, device); - m_raspberryPiGpios.insert(gpio->gpioNumber(), gpio); + + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId) + m_raspberryPiGpios.insert(gpio->gpioNumber(), gpio); + + if (device->deviceClassId() == gpioSwitchBbbDeviceClassId) + m_beagleboneBlackGpios.insert(gpio->gpioNumber(), gpio); + return DeviceManager::DeviceSetupStatusSuccess; } - if (device->deviceClassId() == gpioSwitchDeviceClassId) { + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId || device->deviceClassId() == gpioSwitchBbbDeviceClassId) { 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; @@ -100,7 +107,13 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) connect(monior, &GpioMonitor::valueChanged, this, &DevicePluginGpio::onGpioValueChanged); m_monitorDevices.insert(monior, device); - m_raspberryPiGpioMoniors.insert(monior->gpio()->gpioNumber(), monior); + + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId) + m_raspberryPiGpioMoniors.insert(monior->gpio()->gpioNumber(), monior); + + if (device->deviceClassId() == gpioSwitchBbbDeviceClassId) + m_beagleboneBlackGpioMoniors.insert(monior->gpio()->gpioNumber(), monior); + return DeviceManager::DeviceSetupStatusSuccess; } @@ -113,7 +126,7 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId // Check if GPIOs are available on this platform if (!Gpio::isAvailable()) { - qCWarning(dcGpioController()) << "There are ou GPIOs on this plattform"; + qCWarning(dcGpioController()) << "There are no GPIOs on this plattform"; return DeviceManager::DeviceErrorHardwareNotAvailable; } @@ -153,6 +166,7 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId } emit devicesDiscovered(deviceClassId, deviceDescriptors); + return DeviceManager::DeviceErrorAsync; } if (deviceClass.vendorId() == beagleboneBlackVendorId) { @@ -189,10 +203,10 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId } emit devicesDiscovered(deviceClassId, deviceDescriptors); + return DeviceManager::DeviceErrorAsync; } - - return DeviceManager::DeviceErrorAsync; + return DeviceManager::DeviceErrorVendorNotFound; } DeviceManager::HardwareResources DevicePluginGpio::requiredHardware() const @@ -241,10 +255,14 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const // 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()); + if (deviceClass.vendorId() == beagleboneBlackVendorId) + gpio = m_beagleboneBlackGpios.value(device->paramValue(gpioParamTypeId).toInt()); + // Check if gpio was found if (!gpio) { qCWarning(dcGpioController()) << "Could not find gpio for executing action on" << device->name(); @@ -252,7 +270,7 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const } // GPIO Switch power action - if (device->deviceClassId() == gpioSwitchDeviceClassId && action.actionTypeId() == powerValueActionTypeId) { + if (action.actionTypeId() == powerValueActionTypeId) { bool success = false; if (action.param(powerValueStateParamTypeId).value().toBool()) { success = gpio->setValue(Gpio::ValueHigh); @@ -276,14 +294,20 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const void DevicePluginGpio::postSetupDevice(Device *device) { - if (device->deviceClassId() == gpioSwitchDeviceClassId) { + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId || device->deviceClassId() == gpioSwitchBbbDeviceClassId) { Gpio *gpio = m_gpioDevices.key(device); + if (!gpio) + return; + gpio->setValue(Gpio::ValueLow); device->setStateValue(powerValueStateTypeId, false); } - if (device->deviceClassId() == gpioButtonDeviceClassId) { + if (device->deviceClassId() == gpioButtonRpiDeviceClassId || device->deviceClassId() == gpioButtonBbbDeviceClassId) { GpioMonitor *monitor = m_monitorDevices.key(device); + if (!monitor) + return; + device->setStateValue(pressedStateTypeId, monitor->value()); } } @@ -325,72 +349,73 @@ QList DevicePluginGpio::beagleboneBlackGpioDescriptors() { // Note: https://www.mathworks.com/help/examples/beaglebone_product/beaglebone_black_gpio_pinmap.png QList gpioDescriptors; + gpioDescriptors << GpioDescriptor(2, 22, "P9"); + gpioDescriptors << GpioDescriptor(3, 21, "P9"); + gpioDescriptors << GpioDescriptor(4, 18, "P9 - I2C1_SDA"); + gpioDescriptors << GpioDescriptor(5, 17, "P9 - I2C1_SCL"); + gpioDescriptors << GpioDescriptor(7, 42, "P9"); + gpioDescriptors << GpioDescriptor(12, 20, "P9 - I2C2_SDA"); + gpioDescriptors << GpioDescriptor(13, 19, "P9 - I2C2_SCL"); + gpioDescriptors << GpioDescriptor(14, 26, "P9"); + gpioDescriptors << GpioDescriptor(15, 24, "P9"); + gpioDescriptors << GpioDescriptor(20, 41, "P9"); gpioDescriptors << GpioDescriptor(30, 11, "P9"); gpioDescriptors << GpioDescriptor(31, 13, "P9"); gpioDescriptors << GpioDescriptor(48, 15, "P9"); - gpioDescriptors << GpioDescriptor(5, 17, "P9 - I2C1_SCL"); - gpioDescriptors << GpioDescriptor(13, 19, "P9 - I2C2_SCL"); - gpioDescriptors << GpioDescriptor(3, 21, "P9"); gpioDescriptors << GpioDescriptor(49, 23, "P9"); - gpioDescriptors << GpioDescriptor(117, 25, "P9"); - gpioDescriptors << GpioDescriptor(121, 29, "P9"); - gpioDescriptors << GpioDescriptor(120, 31, "P9"); - gpioDescriptors << GpioDescriptor(20, 41, "P9"); - gpioDescriptors << GpioDescriptor(60, 12, "P9"); gpioDescriptors << GpioDescriptor(50, 14, "P9"); gpioDescriptors << GpioDescriptor(51, 16, "P9"); - gpioDescriptors << GpioDescriptor(4, 18, "P9 - I2C1_SDA"); - gpioDescriptors << GpioDescriptor(12, 20, "P9 - I2C2_SDA"); - gpioDescriptors << GpioDescriptor(2, 22, "P9"); - gpioDescriptors << GpioDescriptor(15, 24, "P9"); - gpioDescriptors << GpioDescriptor(14, 26, "P9"); - gpioDescriptors << GpioDescriptor(123, 28, "P9"); + gpioDescriptors << GpioDescriptor(60, 12, "P9"); + gpioDescriptors << GpioDescriptor(117, 25, "P9"); + gpioDescriptors << GpioDescriptor(120, 31, "P9"); + gpioDescriptors << GpioDescriptor(121, 29, "P9"); gpioDescriptors << GpioDescriptor(122, 30, "P9"); - gpioDescriptors << GpioDescriptor(7, 42, "P9"); - gpioDescriptors << GpioDescriptor(38, 3, "P8 - MMC1_DAT6"); - gpioDescriptors << GpioDescriptor(34, 5, "P8 - MMC1_DAT2"); - gpioDescriptors << GpioDescriptor(66, 7, "P8"); - gpioDescriptors << GpioDescriptor(69, 9, "P8"); - gpioDescriptors << GpioDescriptor(45, 11, "P8"); - gpioDescriptors << GpioDescriptor(23, 13, "P8"); - gpioDescriptors << GpioDescriptor(47, 15, "P8"); - gpioDescriptors << GpioDescriptor(27, 17, "P8"); - gpioDescriptors << GpioDescriptor(22, 19, "P8"); - gpioDescriptors << GpioDescriptor(62, 21, "P8 - MMC1-CLK"); - gpioDescriptors << GpioDescriptor(36, 23, "P8 - MMC1-DAT4"); - gpioDescriptors << GpioDescriptor(32, 25, "P8 - MMC1-DAT0"); - gpioDescriptors << GpioDescriptor(86, 27, "P8 - LCD_VSYNC"); - gpioDescriptors << GpioDescriptor(87, 29, "P8 - LCD_HSYNC"); - gpioDescriptors << GpioDescriptor(10, 31, "P8 - LCD_DATA14"); - gpioDescriptors << GpioDescriptor(9, 33, "P8 - LCD_DATA13"); + gpioDescriptors << GpioDescriptor(123, 28, "P9"); + gpioDescriptors << GpioDescriptor(8, 35, "P8 - LCD_DATA12"); - gpioDescriptors << GpioDescriptor(78, 37, "P8 - LCD_DATA8"); - gpioDescriptors << GpioDescriptor(76, 39, "P8 - LCD_DATA6"); - gpioDescriptors << GpioDescriptor(74, 41, "P8 - LCD_DATA4"); - gpioDescriptors << GpioDescriptor(72, 43, "P8 - LCD_DATA2"); - gpioDescriptors << GpioDescriptor(70, 45, "P8 - LCD_DATA0"); - gpioDescriptors << GpioDescriptor(39, 4, "P8 - MMC1_DAT7"); + gpioDescriptors << GpioDescriptor(9, 33, "P8 - LCD_DATA13"); + gpioDescriptors << GpioDescriptor(10, 31, "P8 - LCD_DATA14"); + gpioDescriptors << GpioDescriptor(11, 32, "P8 - LCD_DATA15"); + gpioDescriptors << GpioDescriptor(22, 19, "P8"); + gpioDescriptors << GpioDescriptor(23, 13, "P8"); + gpioDescriptors << GpioDescriptor(26, 14, "P8"); + gpioDescriptors << GpioDescriptor(27, 17, "P8"); + gpioDescriptors << GpioDescriptor(32, 25, "P8 - MMC1-DAT0"); + gpioDescriptors << GpioDescriptor(33, 24, "P8 - MMC1_DAT1"); + gpioDescriptors << GpioDescriptor(34, 5, "P8 - MMC1_DAT2"); gpioDescriptors << GpioDescriptor(35, 6, "P8 - MMC1_DAT3"); + gpioDescriptors << GpioDescriptor(36, 23, "P8 - MMC1-DAT4"); + gpioDescriptors << GpioDescriptor(37, 22, "P8 - MMC1_DAT5"); + gpioDescriptors << GpioDescriptor(38, 3, "P8 - MMC1_DAT6"); + gpioDescriptors << GpioDescriptor(39, 4, "P8 - MMC1_DAT7"); + gpioDescriptors << GpioDescriptor(44, 12, "P8"); + gpioDescriptors << GpioDescriptor(45, 11, "P8"); + gpioDescriptors << GpioDescriptor(46, 16, "P8"); + gpioDescriptors << GpioDescriptor(47, 15, "P8"); + gpioDescriptors << GpioDescriptor(61, 26, "P8"); + gpioDescriptors << GpioDescriptor(62, 21, "P8 - MMC1-CLK"); + gpioDescriptors << GpioDescriptor(63, 20, "P8 - MMC1_CMD"); + gpioDescriptors << GpioDescriptor(65, 18, "P8"); + gpioDescriptors << GpioDescriptor(66, 7, "P8"); gpioDescriptors << GpioDescriptor(67, 8, "P8"); gpioDescriptors << GpioDescriptor(68, 10, "P8"); - gpioDescriptors << GpioDescriptor(44, 12, "P8"); - gpioDescriptors << GpioDescriptor(26, 14, "P8"); - gpioDescriptors << GpioDescriptor(46, 16, "P8"); - gpioDescriptors << GpioDescriptor(65, 18, "P8"); - gpioDescriptors << GpioDescriptor(63, 20, "P8 - MMC1_CMD"); - gpioDescriptors << GpioDescriptor(37, 22, "P8 - MMC1_DAT5"); - gpioDescriptors << GpioDescriptor(33, 24, "P8 - MMC1_DAT1"); - gpioDescriptors << GpioDescriptor(61, 26, "P8"); + gpioDescriptors << GpioDescriptor(69, 9, "P8"); + gpioDescriptors << GpioDescriptor(70, 45, "P8 - LCD_DATA0"); + gpioDescriptors << GpioDescriptor(71, 46, "P8 - LCD_DATA1"); + gpioDescriptors << GpioDescriptor(72, 43, "P8 - LCD_DATA2"); + gpioDescriptors << GpioDescriptor(73, 44, "P8 - LCD_DATA3"); + gpioDescriptors << GpioDescriptor(74, 41, "P8 - LCD_DATA4"); + gpioDescriptors << GpioDescriptor(75, 42, "P8 - LCD_DATA5"); + gpioDescriptors << GpioDescriptor(76, 39, "P8 - LCD_DATA6"); + gpioDescriptors << GpioDescriptor(77, 40, "P8 - LCD_DATA7"); + gpioDescriptors << GpioDescriptor(78, 37, "P8 - LCD_DATA8"); + gpioDescriptors << GpioDescriptor(79, 38, "P8 - LCD_DATA9"); + gpioDescriptors << GpioDescriptor(80, 36, "P8 - LCD_DATA10"); + gpioDescriptors << GpioDescriptor(81, 34, "P8 - LCD_DATA11"); + gpioDescriptors << GpioDescriptor(86, 27, "P8 - LCD_VSYNC"); + gpioDescriptors << GpioDescriptor(87, 29, "P8 - LCD_HSYNC"); gpioDescriptors << GpioDescriptor(88, 28, "P8 - LCD_PCLK"); gpioDescriptors << GpioDescriptor(89, 30, "P8 - LCD_AC_BIAS_E"); - gpioDescriptors << GpioDescriptor(11, 32, "P8 - LCD_DATA15"); - gpioDescriptors << GpioDescriptor(81, 34, "P8 - LCD_DATA11"); - gpioDescriptors << GpioDescriptor(80, 36, "P8 - LCD_DATA10"); - gpioDescriptors << GpioDescriptor(79, 38, "P8 - LCD_DATA9"); - gpioDescriptors << GpioDescriptor(77, 40, "P8 - LCD_DATA7"); - gpioDescriptors << GpioDescriptor(75, 42, "P8 - LCD_DATA5"); - gpioDescriptors << GpioDescriptor(73, 44, "P8 - LCD_DATA3"); - gpioDescriptors << GpioDescriptor(71, 46, "P8 - LCD_DATA1"); return gpioDescriptors; } diff --git a/plugins/deviceplugins/gpio/deviceplugingpio.json b/plugins/deviceplugins/gpio/deviceplugingpio.json index fb11ae1d..b8e306b0 100644 --- a/plugins/deviceplugins/gpio/deviceplugingpio.json +++ b/plugins/deviceplugins/gpio/deviceplugingpio.json @@ -11,7 +11,7 @@ { "id": "3885c520-e202-4435-88f6-3c35c362b2e6", "name": "GPIO Switch", - "idName": "gpioSwitch", + "idName": "gpioSwitchRpi", "deviceIcon": "Switch", "basicTags": [ "Device", @@ -61,7 +61,7 @@ { "id": "6aff228b-0410-4ef9-9593-51e8639aacea", "name": "GPIO Button", - "idName": "gpioButton", + "idName": "gpioButtonRpi", "deviceIcon": "Power", "basicTags": [ "Device", @@ -114,9 +114,9 @@ "id": "7835d14b-b455-49bd-9f31-72c6e8c3033d", "deviceClasses": [ { - "id": "3885c520-e202-4435-88f6-3c35c362b2e6", + "id": "75d54a59-f9b0-4bc4-a86c-6b1fc47e0663", "name": "GPIO Switch", - "idName": "gpioSwitch", + "idName": "gpioSwitchBbb", "deviceIcon": "Switch", "basicTags": [ "Device", @@ -164,9 +164,9 @@ ] }, { - "id": "6aff228b-0410-4ef9-9593-51e8639aacea", + "id": "ffd2aa29-55cc-4824-ba95-c311784f7824", "name": "GPIO Button", - "idName": "gpioButton", + "idName": "gpioButtonBbb", "deviceIcon": "Power", "basicTags": [ "Device", diff --git a/plugins/deviceplugins/gpio/translations/de_DE.ts b/plugins/deviceplugins/gpio/translations/de_DE.ts index 62720933..784b832a 100644 --- a/plugins/deviceplugins/gpio/translations/de_DE.ts +++ b/plugins/deviceplugins/gpio/translations/de_DE.ts @@ -4,79 +4,85 @@ GpioController - + Gpio Controller The name of the plugin Gpio Controller (127ead55-996a-44ac-ba82-fc3c634e018a) - + Raspberry Pi 2 The name of the vendor (f0d00b66-bbd8-4a07-8591-ea48a61b229e) - + + GPIO Switch - The name of the DeviceClass (3885c520-e202-4435-88f6-3c35c362b2e6) + The name of the DeviceClass (3885c520-e202-4435-88f6-3c35c362b2e6) +---------- +The name of the DeviceClass (75d54a59-f9b0-4bc4-a86c-6b1fc47e0663) - + GPIO The name of the paramType (9eda783f-6d9f-4d39-986d-d2cbfff5a7dd) of GPIO Switch - + Pin number The name of the paramType (2204d278-7bc7-407f-ac82-ce3ae1d5779c) of GPIO Switch - + Description The name of the paramType (504798eb-1faa-4703-a57a-2778e4bf9a67) of GPIO Switch - + Power changed The name of the autocreated EventType (06843766-358e-44b0-8d52-2b46ef98459a) - + Power The name of the ParamType of StateType (06843766-358e-44b0-8d52-2b46ef98459a) of DeviceClass GPIO Switch - + Set power The name of the autocreated ActionType (06843766-358e-44b0-8d52-2b46ef98459a) - + + GPIO Button - The name of the DeviceClass (6aff228b-0410-4ef9-9593-51e8639aacea) + The name of the DeviceClass (6aff228b-0410-4ef9-9593-51e8639aacea) +---------- +The name of the DeviceClass (ffd2aa29-55cc-4824-ba95-c311784f7824) - + Pressed changed The name of the autocreated EventType (57f1b7cc-26c8-434b-ba04-d3077dc886c8) - + Pressed The name of the ParamType of StateType (57f1b7cc-26c8-434b-ba04-d3077dc886c8) of DeviceClass GPIO Button - + Beaglebone Black The name of the vendor (7835d14b-b455-49bd-9f31-72c6e8c3033d) diff --git a/plugins/deviceplugins/gpio/translations/en_US.ts b/plugins/deviceplugins/gpio/translations/en_US.ts index 1ab459d2..fdcf9312 100644 --- a/plugins/deviceplugins/gpio/translations/en_US.ts +++ b/plugins/deviceplugins/gpio/translations/en_US.ts @@ -4,79 +4,85 @@ GpioController - + Gpio Controller The name of the plugin Gpio Controller (127ead55-996a-44ac-ba82-fc3c634e018a) - + Raspberry Pi 2 The name of the vendor (f0d00b66-bbd8-4a07-8591-ea48a61b229e) - + + GPIO Switch - The name of the DeviceClass (3885c520-e202-4435-88f6-3c35c362b2e6) + The name of the DeviceClass (3885c520-e202-4435-88f6-3c35c362b2e6) +---------- +The name of the DeviceClass (75d54a59-f9b0-4bc4-a86c-6b1fc47e0663) - + GPIO The name of the paramType (9eda783f-6d9f-4d39-986d-d2cbfff5a7dd) of GPIO Switch - + Pin number The name of the paramType (2204d278-7bc7-407f-ac82-ce3ae1d5779c) of GPIO Switch - + Description The name of the paramType (504798eb-1faa-4703-a57a-2778e4bf9a67) of GPIO Switch - + Power changed The name of the autocreated EventType (06843766-358e-44b0-8d52-2b46ef98459a) - + Power The name of the ParamType of StateType (06843766-358e-44b0-8d52-2b46ef98459a) of DeviceClass GPIO Switch - + Set power The name of the autocreated ActionType (06843766-358e-44b0-8d52-2b46ef98459a) - + + GPIO Button - The name of the DeviceClass (6aff228b-0410-4ef9-9593-51e8639aacea) + The name of the DeviceClass (6aff228b-0410-4ef9-9593-51e8639aacea) +---------- +The name of the DeviceClass (ffd2aa29-55cc-4824-ba95-c311784f7824) - + Pressed changed The name of the autocreated EventType (57f1b7cc-26c8-434b-ba04-d3077dc886c8) - + Pressed The name of the ParamType of StateType (57f1b7cc-26c8-434b-ba04-d3077dc886c8) of DeviceClass GPIO Button - + Beaglebone Black The name of the vendor (7835d14b-b455-49bd-9f31-72c6e8c3033d)