From 0e756beae4ea8b206cdf1c4b5e434a834fb4d293 Mon Sep 17 00:00:00 2001 From: Portisch Date: Fri, 19 Apr 2019 06:22:23 +0000 Subject: [PATCH] Add SIGUSR1 and SIGUSR2 signals to disable/enable the LEDs Fixed enable on LedDeviceWrapper constructor. --- libsrc/hyperion/LinearColorSmoothing.cpp | 2 ++ libsrc/leddevice/LedDeviceWrapper.cpp | 1 + src/hyperiond/main.cpp | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/libsrc/hyperion/LinearColorSmoothing.cpp b/libsrc/hyperion/LinearColorSmoothing.cpp index 47bafe45..6bef0d58 100644 --- a/libsrc/hyperion/LinearColorSmoothing.cpp +++ b/libsrc/hyperion/LinearColorSmoothing.cpp @@ -98,6 +98,8 @@ int LinearColorSmoothing::switchOff() _outputQueue.pop_front(); } + emit _hyperion->ledDeviceData(std::vector(_ledCount, ColorRgb::BLACK)); + return 0; } diff --git a/libsrc/leddevice/LedDeviceWrapper.cpp b/libsrc/leddevice/LedDeviceWrapper.cpp index b067c4d7..f9eebc01 100644 --- a/libsrc/leddevice/LedDeviceWrapper.cpp +++ b/libsrc/leddevice/LedDeviceWrapper.cpp @@ -20,6 +20,7 @@ LedDeviceWrapper::LedDeviceWrapper(Hyperion* hyperion) : QObject(hyperion) , _hyperion(hyperion) , _ledDevice(nullptr) + , _enabled(true) { // prepare the device constrcutor map #define REGISTER(className) LedDeviceWrapper::addToDeviceMap(QString(#className).toLower(), LedDevice##className::construct); diff --git a/src/hyperiond/main.cpp b/src/hyperiond/main.cpp index 726dcc97..34ec1cf0 100644 --- a/src/hyperiond/main.cpp +++ b/src/hyperiond/main.cpp @@ -41,12 +41,33 @@ using namespace commandline; void signal_handler(const int signum) { + /// Hyperion instance + Hyperion* _hyperion = Hyperion::getInstance(); + if(signum == SIGCHLD) { // only quit when a registered child process is gone // currently this feature is not active ... return; } + else if (signum == SIGUSR1) + { + if (_hyperion != nullptr) + { + _hyperion->setComponentState(hyperion::COMP_SMOOTHING, false); + _hyperion->setComponentState(hyperion::COMP_LEDDEVICE, false); + } + return; + } + else if (signum == SIGUSR2) + { + if (_hyperion != nullptr) + { + _hyperion->setComponentState(hyperion::COMP_LEDDEVICE, true); + _hyperion->setComponentState(hyperion::COMP_SMOOTHING, true); + } + return; + } QCoreApplication::quit(); // reset signal handler to default (in case this handler is not capable of stopping) @@ -132,6 +153,8 @@ int main(int argc, char** argv) signal(SIGABRT, signal_handler); signal(SIGCHLD, signal_handler); signal(SIGPIPE, signal_handler); + signal(SIGUSR1, signal_handler); + signal(SIGUSR2, signal_handler); // force the locale setlocale(LC_ALL, "C");