From fd89e314f7c6035097fa52b07a51b29af2fd309f Mon Sep 17 00:00:00 2001 From: carlou Date: Mon, 26 Sep 2016 14:18:12 +0200 Subject: [PATCH] Red LED --- doc/2-PI.rst | 2 ++ doc/4-SETUP.rst | 6 +++++- src/PlayThread.cpp | 1 + src/Server.cpp | 20 +++++++++++++++++--- src/Server.h | 7 ++++++- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/doc/2-PI.rst b/doc/2-PI.rst index 7daf924..926ce6f 100644 --- a/doc/2-PI.rst +++ b/doc/2-PI.rst @@ -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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/4-SETUP.rst b/doc/4-SETUP.rst index 8284062..eaf17d6 100644 --- a/doc/4-SETUP.rst +++ b/doc/4-SETUP.rst @@ -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 ~~~~~~~~~~~~~~~~~ diff --git a/src/PlayThread.cpp b/src/PlayThread.cpp index 322acad..99b0abb 100644 --- a/src/PlayThread.cpp +++ b/src/PlayThread.cpp @@ -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() { diff --git a/src/Server.cpp b/src/Server.cpp index 5e649f0..292d0e7 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -25,7 +25,8 @@ #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(); @@ -33,15 +34,21 @@ void Server::ledSetup(){ 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); @@ -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)); @@ -549,6 +557,7 @@ void Server::sendMsgReady(bool isReady) { } int Server::load() { + ledOn(m_options->value("gpio/warning").toInt()); sendSongsList(); sendThreshold(); @@ -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; } diff --git a/src/Server.h b/src/Server.h index afd953e..82c0615 100644 --- a/src/Server.h +++ b/src/Server.h @@ -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 */ @@ -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