From 0c9406ce22c5ca364925441f1a197a04f5092b49 Mon Sep 17 00:00:00 2001 From: carlou Date: Thu, 8 Sep 2016 15:55:15 +0200 Subject: [PATCH] The LED can blink ! --- src/Server.cpp | 26 ++++++++++++++++++++++++++ src/Server.h | 21 +++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/Server.cpp b/src/Server.cpp index cc9f753..8f996b0 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -9,6 +9,7 @@ #include #include +#include #define DEFAULT_EXTENSION "*.song" /*< Song files extension */ #define DEFAULT_FOLDER "/home/pi/songs/" /*< Files save/load folder*/ @@ -48,6 +49,14 @@ void Server::ledOff(){ std::system(c.toStdString().c_str()); } +void Server::ledBlink(){ + for(int i=0; i<2; i++) { + ledOff(); + usleep(300); + ledOn(); + } +} + Server::Server(QSettings* opt): options(opt){ @@ -269,6 +278,7 @@ void Server::handle__box_updateThreshold(osc::ReceivedMessageArgumentStream args args >> senseUpdated; qDebug() << "received /box/update_threshold" << senseUpdated; + ledBlink(); emit updateThreshold(senseUpdated); } @@ -277,6 +287,7 @@ void Server::handle__box_resetThreshold(osc::ReceivedMessageArgumentStream args) args >> senseUpdated; qDebug() << "received /box/reset_threshold" << senseUpdated; + ledBlink(); emit resetThreshold(); } @@ -285,6 +296,7 @@ void Server::handle__box_enable(osc::ReceivedMessageArgumentStream args) { args >> box; qDebug() << "received /box/enable" << box; + ledBlink(); switchBox(box, player->getThreshold()); } @@ -294,6 +306,7 @@ void Server::handle__box_volume(osc::ReceivedMessageArgumentStream args) { args >> box >> vol; qDebug() << "received /box/volume" << vol; + ledBlink(); player->setVolume(box, vol); } @@ -303,6 +316,7 @@ void Server::handle__box_pan(osc::ReceivedMessageArgumentStream args) { args >> box >> vol; qDebug() << "received /box/pan" << box << vol; + ledBlink(); player->setPan(box, vol); } @@ -312,6 +326,7 @@ void Server::handle__box_mute(osc::ReceivedMessageArgumentStream args) { args >> box >> state; qDebug() << "received /box/mute" << box << state; + ledBlink(); player->setMute(box, state); } @@ -321,6 +336,7 @@ void Server::handle__box_solo(osc::ReceivedMessageArgumentStream args) { args >> box >> state; qDebug() << "received /box/solo" << box << state; + ledBlink(); player->solo(box, state); } @@ -329,6 +345,7 @@ void Server::handle__box_master(osc::ReceivedMessageArgumentStream args) { args >> vol; qDebug() << "received /box/master" << vol; + ledBlink(); player->setMasterVolume(vol); } @@ -337,6 +354,7 @@ void Server::handle__box_play(osc::ReceivedMessageArgumentStream args) { args >> state; qDebug() << "received /box/play" << state; + ledBlink(); play(); } @@ -345,6 +363,7 @@ void Server::handle__box_stop(osc::ReceivedMessageArgumentStream args) { args >> state; qDebug() << "received /box/stop" << state; + ledBlink(); stop(); } @@ -353,6 +372,8 @@ void Server::handle__box_reset(osc::ReceivedMessageArgumentStream args) { args >> state; qDebug() << "received /box/reset" << state; + ledBlink(); + if(state) stop(); @@ -364,6 +385,7 @@ void Server::handle__box_refreshSong(osc::ReceivedMessageArgumentStream args) { args >> state; qDebug() << "received /box/refresh_song" << state; + ledBlink(); load(); } @@ -372,6 +394,8 @@ void Server::handle__box_selectSong(osc::ReceivedMessageArgumentStream args) { args >> receptSong; qDebug() << "received /box/select_song" << receptSong; + ledBlink(); + QString so = QString(QLatin1String(receptSong)); if(!so.isEmpty()) selSong = so; @@ -387,6 +411,8 @@ void Server::handle__box_sync(osc::ReceivedMessageArgumentStream args) args >> state; qDebug() << "received /box/sync" << state; + ledBlink(); + sendSongsList(); sendThreshold(); diff --git a/src/Server.h b/src/Server.h index de1633e..7dae621 100644 --- a/src/Server.h +++ b/src/Server.h @@ -69,14 +69,6 @@ class Server : public /*QCoreApplication*/ QObject { * @brief Setup WiringPi interface */ void ledSetup(); - /** - * @brief Activate the configured LED - */ - void ledOn(); - /** - * @brief Deactivate the configured LED - */ - void ledOff(); /*************************** * TRANSMISSIONS TO CLIENT * @@ -268,6 +260,19 @@ class Server : public /*QCoreApplication*/ QObject { */ bool initConf(QSettings *c); + /** + * @brief Activate the configured LED + */ + void ledOn(); + /** + * @brief Deactivate the configured LED + */ + void ledOff(); + /** + * @brief Make the LED blink + */ + void ledBlink(); + signals: /** * @brief Notify the need to reload the actual song