Skip to content

Commit

Permalink
Red LED
Browse files Browse the repository at this point in the history
  • Loading branch information
carlou33 committed Sep 26, 2016
1 parent a140a31 commit fd89e31
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doc/2-PI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ To be able to play the songs correctly, ALSA needs a bit of configuration. To do

defaults.ctl.!card 1;

If there is any problem to access the ``alsamixer``, remove (or simply move or rename) the ``/etc/asound.conf`` file.

Auto-load .song files from a USB key
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
6 changes: 5 additions & 1 deletion doc/4-SETUP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ The following options are available :
~~~~~~~~~~~~~~~~~~

``led``
LED's WiringPi identifier (to use with the ``gpio`` command).
Green LED's WiringPi identifier (to use with the ``gpio`` command).
Default : ``6``

``warning``
Red LED's WiringPi identifier (to use with the ``gpio`` command).
Default : ``5``

``[osc]`` section
~~~~~~~~~~~~~~~~~

Expand Down
1 change: 1 addition & 0 deletions src/PlayThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void PlayThread::switchBox(const unsigned int track) {

void PlayThread::setThreshold(const unsigned int threshold){
m_threshold = (99 - threshold) * 4 + 100;
m_options->setValue("default/threshold", m_threshold);
}

void PlayThread::resetThreshold() {
Expand Down
20 changes: 17 additions & 3 deletions src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,30 @@
#define DEFAULT_PAN 0
#define DEFAULT_ACTIVATION false

#define DEFAULT_LED 6 /*< wiringPi LED's GPIO identifier */
#define DEFAULT_LED 6 /*< wiringPi green LED's GPIO identifier */
#define DEFAULT_WARNING_LED 5 /*< wiringPi red LED's GPIO identifier */

void Server::ledSetup(){
wiringPiSetupSys();
//pinMode(LED_VALUE, OUTPUT);

QString c = QStringLiteral("gpio mode %1 out").arg(m_options->value("gpio/led").toInt());
std::system(c.toStdString().c_str());
c = QStringLiteral("gpio mode %1 out").arg(m_options->value("gpio/warning").toInt());
std::system(c.toStdString().c_str());
}

void Server::ledOn(){
void Server::ledOn(int n){
//digitalWrite(LED_VALUE, HIGH);

QString c = QStringLiteral("gpio write %1 1").arg(m_options->value("gpio/led").toInt());
QString c = QStringLiteral("gpio write %1 1").arg(n);
std::system(c.toStdString().c_str());
}

void Server::ledOn(){
ledOn(m_options->value("gpio/led").toInt());
}

void Server::ledOff(int n){
//digitalWrite(n, LOW);

Expand Down Expand Up @@ -206,6 +213,7 @@ bool Server::initConf(QSettings *c) {
default_settings.append(Settings("files/extension", DEFAULT_EXTENSION));

default_settings.append(Settings("gpio/led", DEFAULT_LED));
default_settings.append(Settings("gpio/warning", DEFAULT_WARNING_LED));

default_settings.append(Settings("osc/ip", DEFAULT_IP));
default_settings.append(Settings("osc/sender", DEFAULT_SENDER));
Expand Down Expand Up @@ -549,6 +557,7 @@ void Server::sendMsgReady(bool isReady) {
}

int Server::load() {
ledOn(m_options->value("gpio/warning").toInt());
sendSongsList();
sendThreshold();

Expand All @@ -570,14 +579,19 @@ int Server::load() {

sendTracksCount();

ledOff(m_options->value("gpio/warning").toInt());
return 0;
}
ledOff(m_options->value("gpio/warning").toInt());
return 1;
} catch(std::exception& e) {
qCritical() << tr("LOADING ERROR :") << e.what();
ledOff(m_options->value("gpio/warning").toInt());
return 1;
}
}//end check selsong

ledOff(m_options->value("gpio/warning").toInt());
return 1;
}

Expand Down
7 changes: 6 additions & 1 deletion src/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ class Server : public QObject {
*/
bool initConf(QSettings *c);


/**
* @brief Activate the LED on pos n
* @param n
*/
void ledOn(int n);
/**
* @brief Activate the configured LED defined in config file
*/
Expand All @@ -272,7 +278,6 @@ class Server : public QObject {
* @brief Make the LED defined in config file blink
*/
void ledBlink();

signals:
/**
* @brief Notify the need to reload the actual song
Expand Down

0 comments on commit fd89e31

Please sign in to comment.