Merge pull request #31 from guh/improve-senic-plugin

Add new icons and documentation
This commit is contained in:
Simon Stürz 2018-02-12 14:51:20 +01:00 committed by GitHub
commit 25cdc60537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 174 additions and 62 deletions

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * *
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> * * Copyright (C) 2016-2018 Simon Stürz <simon.stuerz@guh.io> *
* * * *
* This file is part of guh. * * This file is part of guh. *
* * * *
@ -101,15 +101,30 @@ DeviceManager::DeviceError DevicePluginSenic::executeAction(Device *device, cons
if (nuimo.isNull()) if (nuimo.isNull())
return DeviceManager::DeviceErrorHardwareFailure; return DeviceManager::DeviceErrorHardwareFailure;
if (!nuimo->bluetoothDevice()->connected()) {
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
if (action.actionTypeId() == nuimoShowLogoActionTypeId) { if (action.actionTypeId() == nuimoShowLogoActionTypeId) {
if (action.param(nuimoLogoParamTypeId).value().toString() == "Guh")
nuimo->showGuhLogo();
if (action.param(nuimoLogoParamTypeId).value().toString() == "Arrow up") if (action.param(nuimoLogoParamTypeId).value().toString() == "Up")
nuimo->showArrowUp(); nuimo->showImage(Nuimo::MatrixTypeUp);
if (action.param(nuimoLogoParamTypeId).value().toString() == "Down")
if (action.param(nuimoLogoParamTypeId).value().toString() == "Arrow down") nuimo->showImage(Nuimo::MatrixTypeDown);
nuimo->showArrowDown(); 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; return DeviceManager::DeviceErrorNoError;
} }

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * *
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> * * Copyright (C) 2016-2018 Simon Stürz <simon.stuerz@guh.io> *
* * * *
* This file is part of guh. * * This file is part of guh. *
* * * *

View File

@ -101,11 +101,17 @@
"name": "logo", "name": "logo",
"displayName": "logo", "displayName": "logo",
"type": "QString", "type": "QString",
"defaultValue": "Guh", "defaultValue": "Heart",
"allowedValues": [ "allowedValues": [
"Guh", "Up",
"Arrow up", "Down",
"Arrow down" "Left",
"Right",
"Play",
"Pause",
"Stop",
"Music",
"Heart"
] ]
} }
] ]

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * *
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> * * Copyright (C) 2016-2018 Simon Stürz <simon.stuerz@guh.io> *
* * * *
* This file is part of guh. * * This file is part of guh. *
* * * *
@ -54,52 +54,133 @@ BluetoothLowEnergyDevice *Nuimo::bluetoothDevice()
return m_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); showMatrix(matrix, time);
}
void Nuimo::showArrowUp()
{
QByteArray matrix(
" * "
" *** "
" * * * "
" * * * "
"* * *"
" * "
" * "
" * "
" * ");
showMatrix(matrix, 3);
}
void Nuimo::showArrowDown()
{
QByteArray matrix(
" * "
" * "
" * "
" * "
"* * *"
" * * * "
" * * * "
" *** "
" * ");
showMatrix(matrix, 3);
} }
void Nuimo::showMatrix(const QByteArray &matrix, const int &seconds) void Nuimo::showMatrix(const QByteArray &matrix, const int &seconds)

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * *
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> * * Copyright (C) 2016-2018 Simon Stürz <simon.stuerz@guh.io> *
* * * *
* This file is part of guh. * * This file is part of guh. *
* * * *
@ -41,14 +41,24 @@ public:
SwipeDirectionDown SwipeDirectionDown
}; };
enum MatrixType {
MatrixTypeUp,
MatrixTypeDown,
MatrixTypeLeft,
MatrixTypeRight,
MatrixTypePlay,
MatrixTypePause,
MatrixTypeStop,
MatrixTypeMusic,
MatrixTypeHeart
};
explicit Nuimo(Device *device, BluetoothLowEnergyDevice *bluetoothDevice, QObject *parent = nullptr); explicit Nuimo(Device *device, BluetoothLowEnergyDevice *bluetoothDevice, QObject *parent = nullptr);
Device *device(); Device *device();
BluetoothLowEnergyDevice *bluetoothDevice(); BluetoothLowEnergyDevice *bluetoothDevice();
void showGuhLogo(); void showImage(const MatrixType &matrixType);
void showArrowUp();
void showArrowDown();
private: private:
Device *m_device = nullptr; Device *m_device = nullptr;