Skip to content

Commit

Permalink
The LED can blink !
Browse files Browse the repository at this point in the history
  • Loading branch information
carlou33 committed Sep 8, 2016
1 parent 5b037cd commit 0c9406c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
26 changes: 26 additions & 0 deletions src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <exception>

#include <wiringPi.h>
#include <unistd.h>

#define DEFAULT_EXTENSION "*.song" /*< Song files extension */
#define DEFAULT_FOLDER "/home/pi/songs/" /*< Files save/load folder*/
Expand Down Expand Up @@ -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){

Expand Down Expand Up @@ -269,6 +278,7 @@ void Server::handle__box_updateThreshold(osc::ReceivedMessageArgumentStream args
args >> senseUpdated;
qDebug() << "received /box/update_threshold" << senseUpdated;

ledBlink();
emit updateThreshold(senseUpdated);
}

Expand All @@ -277,6 +287,7 @@ void Server::handle__box_resetThreshold(osc::ReceivedMessageArgumentStream args)
args >> senseUpdated;
qDebug() << "received /box/reset_threshold" << senseUpdated;

ledBlink();
emit resetThreshold();
}

Expand All @@ -285,6 +296,7 @@ void Server::handle__box_enable(osc::ReceivedMessageArgumentStream args) {
args >> box;
qDebug() << "received /box/enable" << box;

ledBlink();
switchBox(box, player->getThreshold());
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -329,6 +345,7 @@ void Server::handle__box_master(osc::ReceivedMessageArgumentStream args) {
args >> vol;
qDebug() << "received /box/master" << vol;

ledBlink();
player->setMasterVolume(vol);
}

Expand All @@ -337,6 +354,7 @@ void Server::handle__box_play(osc::ReceivedMessageArgumentStream args) {
args >> state;
qDebug() << "received /box/play" << state;

ledBlink();
play();
}

Expand All @@ -345,6 +363,7 @@ void Server::handle__box_stop(osc::ReceivedMessageArgumentStream args) {
args >> state;
qDebug() << "received /box/stop" << state;

ledBlink();
stop();
}

Expand All @@ -353,6 +372,8 @@ void Server::handle__box_reset(osc::ReceivedMessageArgumentStream args) {
args >> state;
qDebug() << "received /box/reset" << state;

ledBlink();

if(state)
stop();

Expand All @@ -364,6 +385,7 @@ void Server::handle__box_refreshSong(osc::ReceivedMessageArgumentStream args) {
args >> state;
qDebug() << "received /box/refresh_song" << state;

ledBlink();
load();
}

Expand All @@ -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;
Expand All @@ -387,6 +411,8 @@ void Server::handle__box_sync(osc::ReceivedMessageArgumentStream args)
args >> state;
qDebug() << "received /box/sync" << state;

ledBlink();

sendSongsList();
sendThreshold();

Expand Down
21 changes: 13 additions & 8 deletions src/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c9406c

Please sign in to comment.