diff --git a/senic/devicepluginsenic.cpp b/senic/devicepluginsenic.cpp index 63241891..7473d228 100644 --- a/senic/devicepluginsenic.cpp +++ b/senic/devicepluginsenic.cpp @@ -110,6 +110,14 @@ Device::DeviceError DevicePluginSenic::executeAction(Device *device, const Actio nuimo->showImage(Nuimo::MatrixTypeMusic); if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Heart") nuimo->showImage(Nuimo::MatrixTypeHeart); + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Next") + nuimo->showImage(Nuimo::MatrixTypeNext); + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Previous") + nuimo->showImage(Nuimo::MatrixTypePrevious); + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Circle") + nuimo->showImage(Nuimo::MatrixTypeCircle); + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Light") + nuimo->showImage(Nuimo::MatrixTypeLight); return Device::DeviceErrorNoError; } @@ -185,8 +193,13 @@ void DevicePluginSenic::onButtonPressed() Nuimo *nuimo = static_cast(sender()); Device *device = m_nuimos.value(nuimo); emitEvent(Event(nuimoPressedEventTypeId, device->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "•"))); + + if(m_autoSymbolMode) { + nuimo->showImage(Nuimo::MatrixType::MatrixTypeCircle); + } } + void DevicePluginSenic::onButtonReleased() { // TODO: user timer for detekt long pressed (if needed) @@ -197,6 +210,7 @@ void DevicePluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direction) Nuimo *nuimo = static_cast(sender()); Device *device = m_nuimos.value(nuimo); + switch (direction) { case Nuimo::SwipeDirectionLeft: emitEvent(Event(nuimoPressedEventTypeId, device->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "←"))); @@ -211,6 +225,23 @@ void DevicePluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direction) emitEvent(Event(nuimoPressedEventTypeId, device->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "↓"))); break; } + + if (m_autoSymbolMode) { + switch (direction) { + case Nuimo::SwipeDirectionLeft: + nuimo->showImage(Nuimo::MatrixType::MatrixTypeLeft); + break; + case Nuimo::SwipeDirectionRight: + nuimo->showImage(Nuimo::MatrixType::MatrixTypeRight); + break; + case Nuimo::SwipeDirectionUp: + nuimo->showImage(Nuimo::MatrixType::MatrixTypeUp); + break; + case Nuimo::SwipeDirectionDown: + nuimo->showImage(Nuimo::MatrixType::MatrixTypeDown); + break; + } + } } void DevicePluginSenic::onRotationValueChanged(const uint &value) @@ -219,3 +250,15 @@ void DevicePluginSenic::onRotationValueChanged(const uint &value) Device *device = m_nuimos.value(nuimo); device->setStateValue(nuimoRotationStateTypeId, value); } + +void DevicePluginSenic::onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value) +{ + qCDebug(dcSenic()) << "Plugin configuration changed"; + + // Check auto symbol mode + if (paramTypeId == senicPluginAutoSymbolsParamTypeId) { + qCDebug(dcSenic()) << "Auto symbol mode" << (value.toBool() ? "enabled." : "disabled."); + m_autoSymbolMode = value.toBool(); + } + +} diff --git a/senic/devicepluginsenic.h b/senic/devicepluginsenic.h index 20f84dab..1ff2e7e8 100644 --- a/senic/devicepluginsenic.h +++ b/senic/devicepluginsenic.h @@ -49,10 +49,12 @@ public: private: QHash m_nuimos; PluginTimer *m_reconnectTimer = nullptr; + bool m_autoSymbolMode = true; bool verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo); private slots: + void onPluginConfigurationChanged(const ParamTypeId ¶mTypeId, const QVariant &value); void onReconnectTimeout(); void onBluetoothDiscoveryFinished(); diff --git a/senic/devicepluginsenic.json b/senic/devicepluginsenic.json index c36ac5fc..ec735948 100644 --- a/senic/devicepluginsenic.json +++ b/senic/devicepluginsenic.json @@ -2,6 +2,15 @@ "displayName": "Senic", "id": "413e9d77-335f-4ecf-abbc-8f2a8a399c39", "name": "Senic", + "paramTypes": [ + { + "id": "ba3d4269-940b-42ee-8c73-1e1bdea329c2", + "name": "autoSymbols", + "displayName": "Automatically display symbols", + "type": "bool", + "defaultValue": true + } + ], "vendors": [ { "displayName": "Senic", @@ -108,7 +117,11 @@ "Pause", "Stop", "Music", - "Heart" + "Heart", + "Next", + "Previous", + "Circle", + "Light" ] } ] diff --git a/senic/nuimo.cpp b/senic/nuimo.cpp index b659e474..441935b9 100644 --- a/senic/nuimo.cpp +++ b/senic/nuimo.cpp @@ -176,7 +176,57 @@ void Nuimo::showImage(const Nuimo::MatrixType &matrixType) " * "); time = 5; break; - default: + case MatrixTypeNext: + matrix = QByteArray( + " " + " * ** " + " ** ** " + " *** ** " + " ****** " + " *** ** " + " ** ** " + " * ** " + " "); + time = 5; + break; + case MatrixTypePrevious: + matrix = QByteArray( + " " + " ** * " + " ** ** " + " ** *** " + " ****** " + " ** *** " + " ** ** " + " ** * " + " "); + time = 5; + break; + case MatrixTypeCircle: + matrix = QByteArray( + " " + " " + " *** " + " * * " + " * * " + " * * " + " *** " + " " + " "); + time = 5; + break; + case MatrixTypeLight: + matrix = QByteArray( + " " + " *** " + " * * " + " * * " + " * * " + " *** " + " *** " + " *** " + " * "); + time = 5; break; } diff --git a/senic/nuimo.h b/senic/nuimo.h index d0928f38..fca27c8d 100644 --- a/senic/nuimo.h +++ b/senic/nuimo.h @@ -50,7 +50,11 @@ public: MatrixTypePause, MatrixTypeStop, MatrixTypeMusic, - MatrixTypeHeart + MatrixTypeHeart, + MatrixTypeNext, + MatrixTypePrevious, + MatrixTypeCircle, + MatrixTypeLight }; explicit Nuimo(Device *device, BluetoothLowEnergyDevice *bluetoothDevice, QObject *parent = nullptr);