diff --git a/senic/devicepluginsenic.cpp b/senic/devicepluginsenic.cpp index a9f3400a..ff8bd34b 100644 --- a/senic/devicepluginsenic.cpp +++ b/senic/devicepluginsenic.cpp @@ -101,15 +101,39 @@ DeviceManager::DeviceError DevicePluginSenic::executeAction(Device *device, cons if (nuimo.isNull()) return DeviceManager::DeviceErrorHardwareFailure; + if (!nuimo->bluetoothDevice()->connected()) { + return DeviceManager::DeviceErrorHardwareNotAvailable; + } + if (action.actionTypeId() == nuimoShowLogoActionTypeId) { - if (action.param(nuimoLogoParamTypeId).value().toString() == "Guh") - nuimo->showGuhLogo(); + // "up", + // "down", + // "left", + // "right", + // "play", + // "pause", + // "stop", + // "music", + // "heart" - if (action.param(nuimoLogoParamTypeId).value().toString() == "Arrow up") - nuimo->showArrowUp(); - - if (action.param(nuimoLogoParamTypeId).value().toString() == "Arrow down") - nuimo->showArrowDown(); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Up") + nuimo->showImage(Nuimo::MatrixTypeUp); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Down") + nuimo->showImage(Nuimo::MatrixTypeDown); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Left") + nuimo->showImage(Nuimo::MatrixTypeLeft); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Right") + nuimo->showImage(Nuimo::MatrixTypeRight); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Play") + nuimo->showImage(Nuimo::MatrixTypePlay); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Pause") + nuimo->showImage(Nuimo::MatrixTypePause); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Stop") + nuimo->showImage(Nuimo::MatrixTypeStop); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Music") + nuimo->showImage(Nuimo::MatrixTypeStop); + if (action.param(nuimoLogoParamTypeId).value().toString() == "Heart") + nuimo->showImage(Nuimo::MatrixTypeHeart); return DeviceManager::DeviceErrorNoError; } diff --git a/senic/devicepluginsenic.json b/senic/devicepluginsenic.json index 0e06f229..d46ccd38 100644 --- a/senic/devicepluginsenic.json +++ b/senic/devicepluginsenic.json @@ -101,11 +101,17 @@ "name": "logo", "displayName": "logo", "type": "QString", - "defaultValue": "Guh", + "defaultValue": "heart", "allowedValues": [ - "Guh", - "Arrow up", - "Arrow down" + "Up", + "Down", + "Left", + "Right", + "Play", + "Pause", + "Stop", + "Music", + "Heart" ] } ] diff --git a/senic/docs/nuimo-gatt-profile.pdf b/senic/docs/nuimo-gatt-profile.pdf new file mode 100644 index 00000000..eec4c48e Binary files /dev/null and b/senic/docs/nuimo-gatt-profile.pdf differ diff --git a/senic/docs/senic-matrix-map.ods b/senic/docs/senic-matrix-map.ods new file mode 100644 index 00000000..e02d72ee Binary files /dev/null and b/senic/docs/senic-matrix-map.ods differ diff --git a/senic/nuimo.cpp b/senic/nuimo.cpp index 0cf51557..3b6f2111 100644 --- a/senic/nuimo.cpp +++ b/senic/nuimo.cpp @@ -54,52 +54,133 @@ BluetoothLowEnergyDevice *Nuimo::bluetoothDevice() return m_bluetoothDevice; } -void Nuimo::showGuhLogo() +void Nuimo::showImage(const Nuimo::MatrixType &matrixType) { - QByteArray matrix( - " " - " * " - " ** " - " *** ** " - " ***** " - " ** " - " ** " - " * " - " "); + QByteArray matrix; + int time = 3; + switch (matrixType) { + case MatrixTypeUp: + matrix = QByteArray( + " * " + " *** " + " * * * " + " * * * " + "* * *" + " * " + " * " + " * " + " * "); + time = 3; + break; + case MatrixTypeDown: + matrix = QByteArray( + " * " + " * " + " * " + " * " + "* * *" + " * * * " + " * * * " + " *** " + " * "); + time = 3; + break; + case MatrixTypeLeft: + matrix = QByteArray( + " * " + " * " + " * " + " * " + "*********" + " * " + " * " + " * " + " * "); + time = 3; + break; + case MatrixTypeRight: + matrix = QByteArray( + " * " + " * " + " * " + " * " + "*********" + " * " + " * " + " * " + " * "); + time = 3; + break; + case MatrixTypePlay: + matrix = QByteArray( + " " + " * " + " ** " + " *** " + " **** " + " *** " + " ** " + " * " + " "); + time = 3; + break; + case MatrixTypePause: + matrix = QByteArray( + " " + " " + " ** ** " + " ** ** " + " ** ** " + " ** ** " + " ** ** " + " " + " "); + time = 3; + break; + case MatrixTypeStop: + matrix = QByteArray( + " " + " " + " ***** " + " ***** " + " ***** " + " ***** " + " ***** " + " " + " "); + time = 3; + break; + case MatrixTypeMusic: + matrix = QByteArray( + " *******" + " *******" + " * *" + " * *" + " * *" + " * *" + " ** **" + "*** ***" + " * * "); + time = 5; + break; + case MatrixTypeHeart: + matrix = QByteArray( + " " + " ** ** " + " ******* " + "*********" + "*********" + " ******* " + " ***** " + " *** " + " * "); + time = 5; + break; + default: + break; + } - showMatrix(matrix, 10); -} - -void Nuimo::showArrowUp() -{ - QByteArray matrix( - " * " - " *** " - " * * * " - " * * * " - "* * *" - " * " - " * " - " * " - " * "); - - showMatrix(matrix, 3); -} - -void Nuimo::showArrowDown() -{ - QByteArray matrix( - " * " - " * " - " * " - " * " - "* * *" - " * * * " - " * * * " - " *** " - " * "); - - showMatrix(matrix, 3); + showMatrix(matrix, time); } void Nuimo::showMatrix(const QByteArray &matrix, const int &seconds) diff --git a/senic/nuimo.h b/senic/nuimo.h index 6f003417..f56a8587 100644 --- a/senic/nuimo.h +++ b/senic/nuimo.h @@ -41,14 +41,24 @@ public: SwipeDirectionDown }; + enum MatrixType { + MatrixTypeUp, + MatrixTypeDown, + MatrixTypeLeft, + MatrixTypeRight, + MatrixTypePlay, + MatrixTypePause, + MatrixTypeStop, + MatrixTypeMusic, + MatrixTypeHeart + }; + explicit Nuimo(Device *device, BluetoothLowEnergyDevice *bluetoothDevice, QObject *parent = nullptr); Device *device(); BluetoothLowEnergyDevice *bluetoothDevice(); - void showGuhLogo(); - void showArrowUp(); - void showArrowDown(); + void showImage(const MatrixType &matrixType); private: Device *m_device = nullptr;