From f86cfba6f6b0cb586b5ee1ccdcd05a335390d893 Mon Sep 17 00:00:00 2001 From: zomfg Date: Sat, 30 May 2020 01:26:30 +0200 Subject: [PATCH 1/8] device brightness cap --- Software/src/AbstractLedDevice.cpp | 20 +- Software/src/AbstractLedDevice.hpp | 2 + Software/src/LedDeviceManager.cpp | 33 +- Software/src/LedDeviceManager.hpp | 3 + Software/src/LightpackApplication.cpp | 3 +- Software/src/Settings.cpp | 27 +- Software/src/Settings.hpp | 6 +- Software/src/SettingsDefaults.hpp | 4 + Software/src/SettingsWindow.cpp | 20 +- Software/src/SettingsWindow.hpp | 2 + Software/src/SettingsWindow.ui | 599 +++++++++++++++----------- Software/src/enums.hpp | 1 + 12 files changed, 443 insertions(+), 277 deletions(-) diff --git a/Software/src/AbstractLedDevice.cpp b/Software/src/AbstractLedDevice.cpp index a60d5cd96..b72e54478 100644 --- a/Software/src/AbstractLedDevice.cpp +++ b/Software/src/AbstractLedDevice.cpp @@ -41,6 +41,12 @@ void AbstractLedDevice::setBrightness(int value, bool updateColors) { setColors(m_colorsSaved); } +void AbstractLedDevice::setBrightnessCap(int value, bool updateColors) { + m_brightnessCap = value; + if (updateColors) + setColors(m_colorsSaved); +} + void AbstractLedDevice::setLuminosityThreshold(int value, bool updateColors) { m_luminosityThreshold = value; if (updateColors) @@ -69,6 +75,7 @@ void AbstractLedDevice::updateDeviceSettings() using namespace SettingsScope; setGamma(Settings::getDeviceGamma(), false); setBrightness(Settings::getDeviceBrightness(), false); + setBrightnessCap(Settings::getDeviceBrightnessCap(), false); setLuminosityThreshold(Settings::getLuminosityThreshold(), false); setMinimumLuminosityThresholdEnabled(Settings::isMinimumLuminosityEnabled(), false); updateWBAdjustments(Settings::getLedCoefs(), false); @@ -89,9 +96,9 @@ void AbstractLedDevice::applyColorModifications(const QList &inColors, QLi //renormalize to 12bit double k = 4095/255.0; - outColors[i].r = qRed(inColors[i]) * k; + outColors[i].r = qRed(inColors[i]) * k; outColors[i].g = qGreen(inColors[i]) * k; - outColors[i].b = qBlue(inColors[i]) * k; + outColors[i].b = qBlue(inColors[i]) * k; PrismatikMath::gammaCorrection(m_gamma, outColors[i]); } @@ -127,6 +134,13 @@ void AbstractLedDevice::applyColorModifications(const QList &inColors, QLi outColors[i].g *= m_wbAdjustments[i].green; outColors[i].b *= m_wbAdjustments[i].blue; } + if (m_brightnessCap < SettingsScope::Profile::Device::BrightnessCapMax) { + const double bcapFactor = (40.95 * 3 * m_brightnessCap) / (outColors[i].r + outColors[i].g + outColors[i].b); + if (bcapFactor < 1.0) { + outColors[i].r *= bcapFactor; + outColors[i].g *= bcapFactor; + outColors[i].b *= bcapFactor; + } + } } - } diff --git a/Software/src/AbstractLedDevice.hpp b/Software/src/AbstractLedDevice.hpp index 06f49e450..69dcb6fcb 100644 --- a/Software/src/AbstractLedDevice.hpp +++ b/Software/src/AbstractLedDevice.hpp @@ -71,6 +71,7 @@ public slots: virtual void setSmoothSlowdown(int value) = 0; virtual void setGamma(double value, bool updateColors = true); virtual void setBrightness(int value, bool updateColors = true); + virtual void setBrightnessCap(int value, bool updateColors = true); virtual void setColorSequence(QString value) = 0; virtual void setLuminosityThreshold(int value, bool updateColors = true); virtual void setMinimumLuminosityThresholdEnabled(bool value, bool updateColors = true); @@ -98,6 +99,7 @@ public slots: QString m_colorSequence; double m_gamma; int m_brightness; + int m_brightnessCap; int m_luminosityThreshold; bool m_isMinimumLuminosityEnabled; diff --git a/Software/src/LedDeviceManager.cpp b/Software/src/LedDeviceManager.cpp index eeeaaaa67..c58721534 100644 --- a/Software/src/LedDeviceManager.cpp +++ b/Software/src/LedDeviceManager.cpp @@ -60,6 +60,10 @@ LedDeviceManager::LedDeviceManager(QObject *parent) m_failedCreationAttempts = 0; + m_savedBrightness = SettingsScope::Profile::Device::BrightnessDefault; + + m_savedBrightnessCap = SettingsScope::Profile::Device::BrightnessCapDefault; + for (int i = 0; i < SupportedDevices::DeviceTypesCount; i++) m_ledDevices.append(NULL); } @@ -245,6 +249,22 @@ void LedDeviceManager::setBrightness(int value) } } +void LedDeviceManager::setBrightnessCap(int value) +{ + DEBUG_MID_LEVEL << Q_FUNC_INFO << value << "Is last command completed:" << m_isLastCommandCompleted; + + if (m_isLastCommandCompleted) + { + m_isLastCommandCompleted = false; + m_cmdTimeoutTimer->start(); + emit ledDeviceSetBrightnessCap(value); + } + else { + m_savedBrightnessCap = value; + cmdQueueAppend(LedDeviceCommands::SetBrightnessCap); + } +} + void LedDeviceManager::setLuminosityThreshold(int value) { DEBUG_MID_LEVEL << Q_FUNC_INFO << value << "Is last command completed:" << m_isLastCommandCompleted; @@ -419,7 +439,7 @@ void LedDeviceManager::initLedDevice() } AbstractLedDevice * LedDeviceManager::createLedDevice(SupportedDevices::DeviceType deviceType) -{ +{ if (deviceType == SupportedDevices::DeviceTypeAlienFx){ # if !defined(Q_OS_WIN) @@ -487,10 +507,10 @@ void LedDeviceManager::connectSignalSlotsLedDevice() qWarning() << Q_FUNC_INFO << "m_ledDevice == NULL"; return; } - + connect(m_ledDevice, SIGNAL(commandCompleted(bool)), this, SLOT(ledDeviceCommandCompleted(bool)), Qt::QueuedConnection); connect(m_ledDevice, SIGNAL(ioDeviceSuccess(bool)), this, SLOT(ledDeviceIoDeviceSuccess(bool)), Qt::QueuedConnection); - connect(m_ledDevice, SIGNAL(openDeviceSuccess(bool)), this, SLOT(ledDeviceOpenDeviceSuccess(bool)), Qt::QueuedConnection); + connect(m_ledDevice, SIGNAL(openDeviceSuccess(bool)), this, SLOT(ledDeviceOpenDeviceSuccess(bool)), Qt::QueuedConnection); connect(m_ledDevice, SIGNAL(firmwareVersion(QString)), this, SIGNAL(firmwareVersion(QString)), Qt::QueuedConnection); connect(m_ledDevice, SIGNAL(firmwareVersionUnofficial(int)), this, SIGNAL(firmwareVersionUnofficial(int)), Qt::QueuedConnection); @@ -505,6 +525,7 @@ void LedDeviceManager::connectSignalSlotsLedDevice() connect(this, SIGNAL(ledDeviceSetSmoothSlowdown(int)), m_ledDevice, SLOT(setSmoothSlowdown(int)), Qt::QueuedConnection); connect(this, SIGNAL(ledDeviceSetGamma(double)), m_ledDevice, SLOT(setGamma(double)), Qt::QueuedConnection); connect(this, SIGNAL(ledDeviceSetBrightness(int)), m_ledDevice, SLOT(setBrightness(int)), Qt::QueuedConnection); + connect(this, SIGNAL(ledDeviceSetBrightnessCap(int)), m_ledDevice, SLOT(setBrightnessCap(int)), Qt::QueuedConnection); connect(this, SIGNAL(ledDeviceSetColorSequence(QString)), m_ledDevice, SLOT(setColorSequence(QString)), Qt::QueuedConnection); connect(this, SIGNAL(ledDeviceSetLuminosityThreshold(int)), m_ledDevice, SLOT(setLuminosityThreshold(int)), Qt::QueuedConnection); connect(this, SIGNAL(ledDeviceSetMinimumLuminosityEnabled(bool)), m_ledDevice, SLOT(setMinimumLuminosityThresholdEnabled(bool)), Qt::QueuedConnection); @@ -538,6 +559,7 @@ void LedDeviceManager::disconnectSignalSlotsLedDevice() disconnect(this, SIGNAL(ledDeviceSetSmoothSlowdown(int)), m_ledDevice, SLOT(setSmoothSlowdown(int))); disconnect(this, SIGNAL(ledDeviceSetGamma(double)), m_ledDevice, SLOT(setGamma(double))); disconnect(this, SIGNAL(ledDeviceSetBrightness(int)), m_ledDevice, SLOT(setBrightness(int))); + disconnect(this, SIGNAL(ledDeviceSetBrightnessCap(int)), m_ledDevice, SLOT(setBrightnessCap(int))); disconnect(this, SIGNAL(ledDeviceSetColorSequence(QString)), m_ledDevice, SLOT(setColorSequence(QString))); disconnect(this, SIGNAL(ledDeviceSetLuminosityThreshold(int)), m_ledDevice, SLOT(setLuminosityThreshold(int))); disconnect(this, SIGNAL(ledDeviceSetMinimumLuminosityEnabled(bool)), m_ledDevice, SLOT(setMinimumLuminosityThresholdEnabled(bool))); @@ -610,6 +632,11 @@ void LedDeviceManager::cmdQueueProcessNext() emit ledDeviceSetBrightness(m_savedBrightness); break; + case LedDeviceCommands::SetBrightnessCap: + m_cmdTimeoutTimer->start(); + emit ledDeviceSetBrightness(m_savedBrightness); + break; + case LedDeviceCommands::SetColorSequence: m_cmdTimeoutTimer->start(); emit ledDeviceSetColorSequence(m_savedColorSequence); diff --git a/Software/src/LedDeviceManager.hpp b/Software/src/LedDeviceManager.hpp index 1835c91b1..63db83685 100644 --- a/Software/src/LedDeviceManager.hpp +++ b/Software/src/LedDeviceManager.hpp @@ -60,6 +60,7 @@ class LedDeviceManager : public QObject void ledDeviceSetSmoothSlowdown(int value); void ledDeviceSetGamma(double value); void ledDeviceSetBrightness(int value); + void ledDeviceSetBrightnessCap(int value); void ledDeviceSetLuminosityThreshold(int value); void ledDeviceSetMinimumLuminosityEnabled(bool); void ledDeviceSetColorSequence(QString value); @@ -82,6 +83,7 @@ public slots: void setSmoothSlowdown(int value); void setGamma(double value); void setBrightness(int value); + void setBrightnessCap(int value); void setLuminosityThreshold(int value); void setMinimumLuminosityEnabled(bool value); void setColorSequence(QString value); @@ -119,6 +121,7 @@ private slots: int m_savedSmoothSlowdown; double m_savedGamma; int m_savedBrightness; + int m_savedBrightnessCap; int m_savedLuminosityThreshold; bool m_savedIsMinimumLuminosityEnabled; QString m_savedColorSequence; diff --git a/Software/src/LightpackApplication.cpp b/Software/src/LightpackApplication.cpp index 5523d2bb6..332b18237 100644 --- a/Software/src/LightpackApplication.cpp +++ b/Software/src/LightpackApplication.cpp @@ -647,6 +647,7 @@ void LightpackApplication::startLedDeviceManager() connect(settings(), SIGNAL(deviceUsbPowerLedDisabledChanged(bool)), m_ledDeviceManager, SLOT(setUsbPowerLedDisabled(bool)), Qt::QueuedConnection); connect(settings(), SIGNAL(deviceGammaChanged(double)), m_ledDeviceManager, SLOT(setGamma(double)), Qt::QueuedConnection); connect(settings(), SIGNAL(deviceBrightnessChanged(int)), m_ledDeviceManager, SLOT(setBrightness(int)), Qt::QueuedConnection); + connect(settings(), SIGNAL(deviceBrightnessCapChanged(int)), m_ledDeviceManager, SLOT(setBrightnessCap(int)), Qt::QueuedConnection); connect(settings(), SIGNAL(luminosityThresholdChanged(int)), m_ledDeviceManager, SLOT(setLuminosityThreshold(int)), Qt::QueuedConnection); connect(settings(), SIGNAL(minimumLuminosityEnabledChanged(bool)), m_ledDeviceManager, SLOT(setMinimumLuminosityEnabled(bool)), Qt::QueuedConnection); connect(settings(), SIGNAL(ledCoefBlueChanged(int,double)), m_ledDeviceManager, SLOT(updateWBAdjustments()), Qt::QueuedConnection); @@ -709,7 +710,7 @@ void LightpackApplication::initGrabManager() else qWarning() << Q_FUNC_INFO << "No compatible Sound Manager"; #endif - + connect(settings(), SIGNAL(grabberTypeChanged(const Grab::GrabberType &)), m_grabManager, SLOT(onGrabberTypeChanged(const Grab::GrabberType &)), Qt::QueuedConnection); connect(settings(), SIGNAL(grabSlowdownChanged(int)), m_grabManager, SLOT(onGrabSlowdownChanged(int)), Qt::QueuedConnection); connect(settings(), SIGNAL(grabAvgColorsEnabledChanged(bool)), m_grabManager, SLOT(onGrabAvgColorsEnabledChanged(bool)), Qt::QueuedConnection); diff --git a/Software/src/Settings.cpp b/Software/src/Settings.cpp index cd14534d9..193f0b5a2 100644 --- a/Software/src/Settings.cpp +++ b/Software/src/Settings.cpp @@ -211,6 +211,7 @@ static const QString RefreshDelay = "Device/RefreshDelay"; static const QString IsUsbPowerLedDisabled = "Device/IsUsbPowerLedDisabled"; static const QString Smooth = "Device/Smooth"; static const QString Brightness = "Device/Brightness"; +static const QString BrightnessCap = "Device/BrightnessCap"; static const QString ColorDepth = "Device/ColorDepth"; static const QString Gamma = "Device/Gamma"; } @@ -664,7 +665,7 @@ void Settings::setApiKey(const QString & apiKey) } bool Settings::isExpertModeEnabled() -{ +{ return valueMain(Main::Key::IsExpertModeEnabled).toBool(); } @@ -1282,6 +1283,18 @@ void Settings::setDeviceBrightness(int value) m_this->deviceBrightnessChanged(value); } +int Settings::getDeviceBrightnessCap() +{ + return getValidDeviceBrightnessCap(value(Profile::Key::Device::BrightnessCap).toInt()); +} + +void Settings::setDeviceBrightnessCap(int value) +{ + DEBUG_LOW_LEVEL << Q_FUNC_INFO; + setValue(Profile::Key::Device::BrightnessCap, getValidDeviceBrightnessCap(value)); + m_this->deviceBrightnessCapChanged(value); +} + int Settings::getDeviceSmooth() { return getValidDeviceSmooth(value(Profile::Key::Device::Smooth).toInt()); @@ -1743,6 +1756,15 @@ int Settings::getValidDeviceBrightness(int value) return value; } +int Settings::getValidDeviceBrightnessCap(int value) +{ + if (value < Profile::Device::BrightnessCapMin) + value = Profile::Device::BrightnessCapMin; + else if (value > Profile::Device::BrightnessCapMax) + value = Profile::Device::BrightnessCapMax; + return value; +} + int Settings::getValidDeviceSmooth(int value) { if (value < Profile::Device::SmoothMin) @@ -1826,7 +1848,7 @@ void Settings::setValidLedCoef(int ledIndex, const QString & keyCoef, double coe << keyCoef << error << "Convert to double error. Set it to default value" << keyCoef << "=" << Profile::Led::CoefDefault; - coef = Profile::Led::CoefDefault; + coef = Profile::Led::CoefDefault; } Settings::setValue(Profile::Key::Led::Prefix + QString::number(ledIndex + 1) + "/" + keyCoef, coef); } @@ -1928,6 +1950,7 @@ void Settings::initCurrentProfile(bool isResetDefault) setNewOption(Profile::Key::Device::RefreshDelay, Profile::Device::RefreshDelayDefault, isResetDefault); setNewOption(Profile::Key::Device::IsUsbPowerLedDisabled, Profile::Device::IsUsbPowerLedDisabled, isResetDefault); setNewOption(Profile::Key::Device::Brightness, Profile::Device::BrightnessDefault, isResetDefault); + setNewOption(Profile::Key::Device::BrightnessCap, Profile::Device::BrightnessCapDefault, isResetDefault); setNewOption(Profile::Key::Device::Smooth, Profile::Device::SmoothDefault, isResetDefault); setNewOption(Profile::Key::Device::Gamma, Profile::Device::GammaDefault, isResetDefault); setNewOption(Profile::Key::Device::ColorDepth, Profile::Device::ColorDepthDefault, isResetDefault); diff --git a/Software/src/Settings.hpp b/Software/src/Settings.hpp index d326712a5..569e69fd5 100644 --- a/Software/src/Settings.hpp +++ b/Software/src/Settings.hpp @@ -189,6 +189,8 @@ class Settings : public QObject static void setDeviceUsbPowerLedDisabled(bool isDisabled); static int getDeviceBrightness(); static void setDeviceBrightness(int value); + static int getDeviceBrightnessCap(); + static void setDeviceBrightnessCap(int value); static int getDeviceSmooth(); static void setDeviceSmooth(int value); static int getDeviceColorDepth(); @@ -256,9 +258,10 @@ class Settings : public QObject static QString getAutoUpdatingVersion(); static void setAutoUpdatingVersion(const QString & version); -private: +private: static int getValidDeviceRefreshDelay(int value); static int getValidDeviceBrightness(int value); + static int getValidDeviceBrightnessCap(int value); static int getValidDeviceSmooth(int value); static int getValidDeviceColorDepth(int value); static double getValidDeviceGamma(double value); @@ -340,6 +343,7 @@ class Settings : public QObject void deviceRefreshDelayChanged(int value); void deviceUsbPowerLedDisabledChanged(bool isDisabled); void deviceBrightnessChanged(int value); + void deviceBrightnessCapChanged(int value); void deviceSmoothChanged(int value); void deviceColorDepthChanged(int value); void deviceGammaChanged(double gamma); diff --git a/Software/src/SettingsDefaults.hpp b/Software/src/SettingsDefaults.hpp index 3955b7e75..f74560de8 100644 --- a/Software/src/SettingsDefaults.hpp +++ b/Software/src/SettingsDefaults.hpp @@ -222,6 +222,10 @@ static const int BrightnessMin = 0; static const int BrightnessDefault = 100; static const int BrightnessMax = 100; +static const int BrightnessCapMin = 1; +static const int BrightnessCapDefault = 100; +static const int BrightnessCapMax = 100; + static const int SmoothMin = 0; static const int SmoothDefault = 100; static const int SmoothMax = 255; diff --git a/Software/src/SettingsWindow.cpp b/Software/src/SettingsWindow.cpp index 9d4ee42f3..ba7e737b6 100644 --- a/Software/src/SettingsWindow.cpp +++ b/Software/src/SettingsWindow.cpp @@ -233,6 +233,7 @@ void SettingsWindow::connectSignalsSlots() connect(ui->checkBox_DisableUsbPowerLed, SIGNAL(toggled(bool)), this, SLOT(onDisableUsbPowerLed_toggled(bool))); connect(ui->spinBox_DeviceSmooth, SIGNAL(valueChanged(int)), this, SLOT(onDeviceSmooth_valueChanged(int))); connect(ui->spinBox_DeviceBrightness, SIGNAL(valueChanged(int)), this, SLOT(onDeviceBrightness_valueChanged(int))); + connect(ui->spinBox_DeviceBrightnessCap, SIGNAL(valueChanged(int)), this, SLOT(onDeviceBrightnessCap_valueChanged(int))); connect(ui->spinBox_DeviceColorDepth, SIGNAL(valueChanged(int)), this, SLOT(onDeviceColorDepth_valueChanged(int))); connect(ui->doubleSpinBox_DeviceGamma, SIGNAL(valueChanged(double)), this, SLOT(onDeviceGammaCorrection_valueChanged(double))); connect(ui->horizontalSlider_GammaCorrection, SIGNAL(valueChanged(int)), this, SLOT(onSliderDeviceGammaCorrection_valueChanged(int))); @@ -267,7 +268,7 @@ void SettingsWindow::connectSignalsSlots() #else ui->pushButton_SoundVizDeviceHelp->hide(); #endif // Q_OS_MACOS - + #endif// SOUNDVIZ_SUPPORT connect(ui->checkBox_ExpertModeEnabled, SIGNAL(toggled(bool)), this, SLOT(onExpertModeEnabled_Toggled(bool))); connect(ui->checkBox_KeepLightsOnAfterExit, SIGNAL(toggled(bool)), this, SLOT(onKeepLightsAfterExit_Toggled(bool))); @@ -464,6 +465,7 @@ void SettingsWindow::setDeviceTabWidgetsVisibility(DeviceTab::Options options) void SettingsWindow::syncLedDeviceWithSettingsWindow() { emit updateBrightness(Settings::getDeviceBrightness()); + emit updateBrightnessCap(Settings::getDeviceBrightnessCap()); emit updateGamma(Settings::getDeviceGamma()); } @@ -1076,7 +1078,7 @@ void SettingsWindow::ledDeviceOpenSuccess(bool isSuccess) } void SettingsWindow::ledDeviceCallSuccess(bool isSuccess) -{ +{ DEBUG_HIGH_LEVEL << Q_FUNC_INFO << isSuccess << m_backlightStatus << sender(); // If Backlight::StatusOff then nothings changed @@ -1135,7 +1137,7 @@ void SettingsWindow::ledDeviceFirmwareVersionUnofficialResult(const int version) } void SettingsWindow::refreshAmbilightEvaluated(double updateResultMs) -{ +{ DEBUG_HIGH_LEVEL << Q_FUNC_INFO << updateResultMs; double hz = 0; @@ -1161,7 +1163,7 @@ void SettingsWindow::refreshAmbilightEvaluated(double updateResultMs) DEBUG_HIGH_LEVEL << Q_FUNC_INFO << "Therotical Max Hz for led count and baud rate:" << theoreticalMaxHz << ledCount << baudRate; if (theoreticalMaxHz <= hz) qWarning() << Q_FUNC_INFO << hz << "FPS went over theoretical max of" << theoreticalMaxHz; - + const QPalette& defaultPalette = ui->label_GrabFrequency_txt_fps->palette(); QPalette palette = ui->label_GrabFrequency_value->palette(); @@ -1345,6 +1347,13 @@ void SettingsWindow::onDeviceBrightness_valueChanged(int percent) Settings::setDeviceBrightness(percent); } +void SettingsWindow::onDeviceBrightnessCap_valueChanged(int percent) +{ + DEBUG_LOW_LEVEL << Q_FUNC_INFO << percent; + + Settings::setDeviceBrightnessCap(percent); +} + void SettingsWindow::onDeviceColorDepth_valueChanged(int value) { DEBUG_LOW_LEVEL << Q_FUNC_INFO << value; @@ -1850,7 +1859,7 @@ void SettingsWindow::updateUiFromSettings() onLightpackModeChanged(mode); ui->checkBox_ExpertModeEnabled->setChecked (Settings::isExpertModeEnabled()); - + ui->checkBox_checkForUpdates->setChecked (Settings::isCheckForUpdatesEnabled()); ui->checkBox_installUpdates->setChecked (Settings::isInstallUpdatesEnabled()); @@ -1913,6 +1922,7 @@ void SettingsWindow::updateUiFromSettings() ui->checkBox_DisableUsbPowerLed->setChecked (Settings::isDeviceUsbPowerLedDisabled()); ui->horizontalSlider_DeviceRefreshDelay->setValue (Settings::getDeviceRefreshDelay()); ui->horizontalSlider_DeviceBrightness->setValue (Settings::getDeviceBrightness()); + ui->horizontalSlider_DeviceBrightnessCap->setValue (Settings::getDeviceBrightnessCap()); ui->horizontalSlider_DeviceSmooth->setValue (Settings::getDeviceSmooth()); ui->horizontalSlider_DeviceColorDepth->setValue (Settings::getDeviceColorDepth()); ui->doubleSpinBox_DeviceGamma->setValue (Settings::getDeviceGamma()); diff --git a/Software/src/SettingsWindow.hpp b/Software/src/SettingsWindow.hpp index 405f1440a..9e37df2ca 100644 --- a/Software/src/SettingsWindow.hpp +++ b/Software/src/SettingsWindow.hpp @@ -73,6 +73,7 @@ class SettingsWindow : public QMainWindow { void updateSlowdown(int value); void updateGamma(double value); void updateBrightness(int percent); + void updateBrightnessCap(int percent); void requestFirmwareVersion(); #ifdef SOUNDVIZ_SUPPORT void requestSoundVizDevices(); @@ -179,6 +180,7 @@ private slots: void onDisableUsbPowerLed_toggled(bool state); void onDeviceSmooth_valueChanged(int value); void onDeviceBrightness_valueChanged(int value); + void onDeviceBrightnessCap_valueChanged(int value); void onDeviceColorDepth_valueChanged(int value); void onDeviceGammaCorrection_valueChanged(double value); void onSliderDeviceGammaCorrection_valueChanged(int value); diff --git a/Software/src/SettingsWindow.ui b/Software/src/SettingsWindow.ui index 278f6b2f1..703c307db 100644 --- a/Software/src/SettingsWindow.ui +++ b/Software/src/SettingsWindow.ui @@ -1300,66 +1300,20 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< 20 - - - - 13 - - - - - Run configuration wizard - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - margin:0px; + + + + + 0 + 0 + - % - - - Qt::AlignCenter - - - - - - - 0 - - - 100 - - - 1 - - - 100 - - - Qt::Horizontal + Gamma correction: - + @@ -1382,41 +1336,14 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - 0.050000000000000 - - - 10.000000000000000 - - - 0.050000000000000 - - - 0.050000000000000 + + + + Keep lights ON after display sleep - + @@ -1459,50 +1386,6 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< 0 - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - 64 - - - 1023 - - - 64 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1525,8 +1408,8 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - + + 0 @@ -1534,12 +1417,25 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - Smoothness: + Refresh delay (Lightpack 5 and below): - - + + + + Qt::Vertical + + + + 20 + 40 + + + + + + 0 @@ -1561,21 +1457,53 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - + + - + 0 0 + + margin:0px; + - Refresh delay (Lightpack 5 and below): + + + + + :/icons/help.png:/icons/help.png + + + true - - + + + + <h4>Color depth</h4> Number of colors per channel, one RGB LED uses 3 channels (value in power of 3). + + + 32 + + + 255 + + + 1 + + + 100 + + + Qt::Horizontal + + + + + 0 @@ -1595,42 +1523,58 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 32 + 64 - 255 + 1023 - 100 + 64 - - - - <h4>Color depth</h4> Number of colors per channel, one RGB LED uses 3 channels (value in power of 3). - - - 32 + + + + + 0 + 0 + - - 255 + + margin:0px; - - 1 + + - - 100 + + + :/icons/help.png:/icons/help.png - - Qt::Horizontal + + true - - - - <h4>Smoothness</h4> It defines how many steps will be color changed in + + + + + 0 + 0 + + + + + 50 + 0 + + + + + 60 + 16777215 + 0 @@ -1638,19 +1582,26 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< 255 - - 1 - 100 - - Qt::Horizontal + + + + + + + 0 + 0 + + + + Color depth (Lightpack 5 and below): - - + + 0 @@ -1670,7 +1621,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 0 + 32 255 @@ -1680,54 +1631,37 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - - 0 - 0 - + + + + <h4>Smoothness</h4> It defines how many steps will be color changed in - - margin:0px; + + 0 - - + + 255 - - - :/icons/help.png:/icons/help.png + + 1 + + + 100 - - true + + Qt::Horizontal - - - - - 0 - 0 - - - - margin:0px; - + + - - - - - :/icons/help.png:/icons/help.png - - - true + Disable USB Power LED - - + + 0 @@ -1735,14 +1669,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - Color depth (Lightpack 5 and below): - - - - - - - Disable USB Power LED + Smoothness: @@ -1788,45 +1715,54 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - Keep lights ON after lock computer - - - - - + + - + 0 0 - - <h4>Gamma correction</h4> It controls the level of saturation. The effect is clearly detectable in a video in screen grabbing mode<br/>Recommended value: 2.00 + + + 50 + 0 + + + + + 60 + 16777215 + - 5 + 0.050000000000000 - 1000 + 10.000000000000000 - 5 + 0.050000000000000 - - Qt::Horizontal + + 0.050000000000000 - - QSlider::NoTicks + + + + + + margin:0px; - - 100 + + % + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + Qt::Vertical @@ -1839,8 +1775,54 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - + + + + 0 + + + 100 + + + 1 + + + 100 + + + Qt::Horizontal + + + + + + + 13 + + + + + Run configuration wizard + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 @@ -1848,7 +1830,14 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - Gamma correction: + Overall brightness: + + + + + + + Keep lights ON after lock computer @@ -1883,43 +1872,97 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - - 0 - 0 - + + + + + 0 + 0 + - Overall brightness: + Keep lights ON after exit - + Keep lights ON after system suspend - - - - - 0 - 0 - + + + + + 0 + 0 + + + + <h4>Gamma correction</h4> It controls the level of saturation. The effect is clearly detectable in a video in screen grabbing mode<br/>Recommended value: 2.00 + + + 5 + + + 1000 + + + 5 + + + Qt::Horizontal + + + QSlider::NoTicks + + + 100 + + + + - Keep lights ON after exit + % - - + + - Keep lights ON after display sleep + Brightness cap: + + + + + + + 1 + + + 100 + + + 100 + + + + + + + 1 + + + 100 + + + 100 + + + Qt::Horizontal @@ -3447,5 +3490,37 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< + + horizontalSlider_DeviceBrightnessCap + valueChanged(int) + spinBox_DeviceBrightnessCap + setValue(int) + + + 253 + 116 + + + 390 + 116 + + + + + spinBox_DeviceBrightnessCap + valueChanged(int) + horizontalSlider_DeviceBrightnessCap + setValue(int) + + + 390 + 116 + + + 253 + 116 + + + diff --git a/Software/src/enums.hpp b/Software/src/enums.hpp index def92e6d7..1dfa61e13 100644 --- a/Software/src/enums.hpp +++ b/Software/src/enums.hpp @@ -171,6 +171,7 @@ enum Cmd { SetSmoothSlowdown, SetGamma, SetBrightness, + SetBrightnessCap, SetLuminosityThreshold, SetMinimumLuminosityEnabled, SetColorSequence, From 9e51867c85be3e259f53f11fff1d6e69071700d5 Mon Sep 17 00:00:00 2001 From: zomfg Date: Sat, 30 May 2020 12:25:38 +0200 Subject: [PATCH 2/8] led device manager: set brightness cap fix --- Software/src/LedDeviceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/src/LedDeviceManager.cpp b/Software/src/LedDeviceManager.cpp index c58721534..c97d90bdc 100644 --- a/Software/src/LedDeviceManager.cpp +++ b/Software/src/LedDeviceManager.cpp @@ -634,7 +634,7 @@ void LedDeviceManager::cmdQueueProcessNext() case LedDeviceCommands::SetBrightnessCap: m_cmdTimeoutTimer->start(); - emit ledDeviceSetBrightness(m_savedBrightness); + emit ledDeviceSetBrightnessCap(m_savedBrightnessCap); break; case LedDeviceCommands::SetColorSequence: From 2828b370efe2a5d6988ef0b07ed089196b1a9ba5 Mon Sep 17 00:00:00 2001 From: zomfg Date: Fri, 5 Jun 2020 15:48:34 +0200 Subject: [PATCH 3/8] power limit no-UI --- Software/src/AbstractLedDevice.cpp | 46 +++++-- Software/src/AbstractLedDevice.hpp | 4 + Software/src/LedDeviceManager.cpp | 26 ++-- Software/src/Settings.cpp | 206 +++++++++++++++++++++++++++-- Software/src/Settings.hpp | 22 ++- Software/src/SettingsDefaults.hpp | 5 + 6 files changed, 280 insertions(+), 29 deletions(-) diff --git a/Software/src/AbstractLedDevice.cpp b/Software/src/AbstractLedDevice.cpp index b72e54478..70e5d17bf 100644 --- a/Software/src/AbstractLedDevice.cpp +++ b/Software/src/AbstractLedDevice.cpp @@ -47,6 +47,18 @@ void AbstractLedDevice::setBrightnessCap(int value, bool updateColors) { setColors(m_colorsSaved); } +void AbstractLedDevice::setLedMilliAmps(const int value, const bool updateColors) { + m_ledMilliAmps = value; + if (updateColors) + setColors(m_colorsSaved); +} + +void AbstractLedDevice::setPowerSupplyAmps(const double value, const bool updateColors) { + m_powerSupplyAmps = value; + if (updateColors) + setColors(m_colorsSaved); +} + void AbstractLedDevice::setLuminosityThreshold(int value, bool updateColors) { m_luminosityThreshold = value; if (updateColors) @@ -90,12 +102,12 @@ void AbstractLedDevice::updateDeviceSettings() */ void AbstractLedDevice::applyColorModifications(const QList &inColors, QList &outColors) { - bool isApplyWBAdjustments = m_wbAdjustments.count() == inColors.count(); + const bool isApplyWBAdjustments = m_wbAdjustments.count() == inColors.count(); for(int i = 0; i < inColors.count(); i++) { //renormalize to 12bit - double k = 4095/255.0; + const constexpr double k = 4095/255.0; outColors[i].r = qRed(inColors[i]) * k; outColors[i].g = qGreen(inColors[i]) * k; outColors[i].b = qBlue(inColors[i]) * k; @@ -103,22 +115,25 @@ void AbstractLedDevice::applyColorModifications(const QList &inColors, QLi PrismatikMath::gammaCorrection(m_gamma, outColors[i]); } - StructLab avgColor = PrismatikMath::toLab(PrismatikMath::avgColor(outColors)); + const StructLab avgColor = PrismatikMath::toLab(PrismatikMath::avgColor(outColors)); + + const double ampCoef = m_ledMilliAmps / (4095.0 * 3.0) / 1000.0; + double estimatedTotalAmps = 0.0; for (int i = 0; i < outColors.count(); ++i) { StructLab lab = PrismatikMath::toLab(outColors[i]); - int dl = m_luminosityThreshold - lab.l; + const int dl = m_luminosityThreshold - lab.l; if (dl > 0) { if (m_isMinimumLuminosityEnabled) { // apply minimum luminosity or dead-zone // Cross-fade a and b channels to avarage value within kFadingRange, fadingFactor = (dL - fadingRange)^2 / (fadingRange^2) - const int kFadingRange = 5; - double fadingCoeff = dl < kFadingRange ? (dl - kFadingRange)*(dl - kFadingRange)/(kFadingRange*kFadingRange): 1; - char da = avgColor.a - lab.a; - char db = avgColor.b - lab.b; + constexpr int kFadingRange = 5; + const double fadingCoeff = dl < kFadingRange ? (dl - kFadingRange)*(dl - kFadingRange)/(kFadingRange*kFadingRange): 1; + const char da = avgColor.a - lab.a; + const char db = avgColor.b - lab.b; lab.l = m_luminosityThreshold; lab.a += PrismatikMath::round(da * fadingCoeff); lab.b += PrismatikMath::round(db * fadingCoeff); - StructRgb rgb = PrismatikMath::toRgb(lab); + const StructRgb rgb = PrismatikMath::toRgb(lab); outColors[i] = rgb; } else { outColors[i].r = 0; @@ -135,12 +150,23 @@ void AbstractLedDevice::applyColorModifications(const QList &inColors, QLi outColors[i].b *= m_wbAdjustments[i].blue; } if (m_brightnessCap < SettingsScope::Profile::Device::BrightnessCapMax) { - const double bcapFactor = (40.95 * 3 * m_brightnessCap) / (outColors[i].r + outColors[i].g + outColors[i].b); + const double bcapFactor = (m_brightnessCap / 100.0 * 4095 * 3) / (outColors[i].r + outColors[i].g + outColors[i].b); if (bcapFactor < 1.0) { outColors[i].r *= bcapFactor; outColors[i].g *= bcapFactor; outColors[i].b *= bcapFactor; } } + + estimatedTotalAmps += ((double)outColors[i].r + (double)outColors[i].g + (double)outColors[i].b) * ampCoef; + } + + if (m_powerSupplyAmps > 0.0 && m_powerSupplyAmps < estimatedTotalAmps) { + const double powerRatio = m_powerSupplyAmps / estimatedTotalAmps; + for (StructRgb& color : outColors) { + color.r *= powerRatio; + color.g *= powerRatio; + color.b *= powerRatio; + } } } diff --git a/Software/src/AbstractLedDevice.hpp b/Software/src/AbstractLedDevice.hpp index 69dcb6fcb..075b6d220 100644 --- a/Software/src/AbstractLedDevice.hpp +++ b/Software/src/AbstractLedDevice.hpp @@ -72,6 +72,8 @@ public slots: virtual void setGamma(double value, bool updateColors = true); virtual void setBrightness(int value, bool updateColors = true); virtual void setBrightnessCap(int value, bool updateColors = true); + virtual void setLedMilliAmps(const int value, const bool updateColors = true); + virtual void setPowerSupplyAmps(const double value, const bool updateColors = true); virtual void setColorSequence(QString value) = 0; virtual void setLuminosityThreshold(int value, bool updateColors = true); virtual void setMinimumLuminosityThresholdEnabled(bool value, bool updateColors = true); @@ -100,6 +102,8 @@ public slots: double m_gamma; int m_brightness; int m_brightnessCap; + int m_ledMilliAmps{0}; + double m_powerSupplyAmps{0.0}; int m_luminosityThreshold; bool m_isMinimumLuminosityEnabled; diff --git a/Software/src/LedDeviceManager.cpp b/Software/src/LedDeviceManager.cpp index c97d90bdc..d582e29f4 100644 --- a/Software/src/LedDeviceManager.cpp +++ b/Software/src/LedDeviceManager.cpp @@ -450,54 +450,62 @@ AbstractLedDevice * LedDeviceManager::createLedDevice(SupportedDevices::DeviceTy # endif /* Q_OS_WIN */ } + AbstractLedDevice* device = nullptr; + switch (deviceType){ case SupportedDevices::DeviceTypeLightpack: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::LightpackDevice"; - return (AbstractLedDevice *)new LedDeviceLightpack(); + device = (AbstractLedDevice *)new LedDeviceLightpack(); case SupportedDevices::DeviceTypeAlienFx: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::AlienFxDevice"; # ifdef Q_OS_WIN - return (AbstractLedDevice *)new LedDeviceAlienFx(); + device = (AbstractLedDevice *)new LedDeviceAlienFx(); # else break; # endif /* Q_OS_WIN */ case SupportedDevices::DeviceTypeAdalight: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::AdalightDevice"; - return (AbstractLedDevice *)new LedDeviceAdalight(Settings::getAdalightSerialPortName(), Settings::getAdalightSerialPortBaudRate()); + device = (AbstractLedDevice *)new LedDeviceAdalight(Settings::getAdalightSerialPortName(), Settings::getAdalightSerialPortBaudRate()); case SupportedDevices::DeviceTypeArdulight: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::ArdulightDevice"; - return (AbstractLedDevice *)new LedDeviceArdulight(Settings::getArdulightSerialPortName(), Settings::getArdulightSerialPortBaudRate()); + device = (AbstractLedDevice *)new LedDeviceArdulight(Settings::getArdulightSerialPortName(), Settings::getArdulightSerialPortBaudRate()); case SupportedDevices::DeviceTypeDrgb: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::DrgbDevice"; - return (AbstractLedDevice*)new LedDeviceDrgb(Settings::getDrgbAddress(), Settings::getDrgbPort(), Settings::getDrgbTimeout()); + device = (AbstractLedDevice*)new LedDeviceDrgb(Settings::getDrgbAddress(), Settings::getDrgbPort(), Settings::getDrgbTimeout()); case SupportedDevices::DeviceTypeDnrgb: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::DnrgbDevice"; - return (AbstractLedDevice*)new LedDeviceDnrgb(Settings::getDnrgbAddress(), Settings::getDnrgbPort(), Settings::getDnrgbTimeout()); + device = (AbstractLedDevice*)new LedDeviceDnrgb(Settings::getDnrgbAddress(), Settings::getDnrgbPort(), Settings::getDnrgbTimeout()); case SupportedDevices::DeviceTypeWarls: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::WarlsDevice"; - return (AbstractLedDevice*)new LedDeviceWarls(Settings::getWarlsAddress(), Settings::getWarlsPort(), Settings::getWarlsTimeout()); + device = (AbstractLedDevice*)new LedDeviceWarls(Settings::getWarlsAddress(), Settings::getWarlsPort(), Settings::getWarlsTimeout()); case SupportedDevices::DeviceTypeVirtual: DEBUG_LOW_LEVEL << Q_FUNC_INFO << "SupportedDevices::VirtualDevice"; - return (AbstractLedDevice *)new LedDeviceVirtual(); + device = (AbstractLedDevice *)new LedDeviceVirtual(); default: break; } + if (device) { + device->setLedMilliAmps(Settings::getDeviceLedMilliAmps(deviceType)); + device->setPowerSupplyAmps(Settings::getDevicePowerSupplyAmps(deviceType)); + return device; + } + qFatal("%s %s%d%s", Q_FUNC_INFO, "Create LedDevice fail. deviceType = '", deviceType, "'. Application exit."); - return NULL; // Avoid compiler warning + return nullptr; // Avoid compiler warning } void LedDeviceManager::connectSignalSlotsLedDevice() diff --git a/Software/src/Settings.cpp b/Software/src/Settings.cpp index 193f0b5a2..420ad58b5 100644 --- a/Software/src/Settings.cpp +++ b/Software/src/Settings.cpp @@ -100,6 +100,8 @@ static const QString NumberOfLeds = "Adalight/NumberOfLeds"; static const QString ColorSequence = "Adalight/ColorSequence"; static const QString Port = "Adalight/SerialPort"; static const QString BaudRate = "Adalight/BaudRate"; +static const QString LedMilliAmps = "Adalight/LedMilliAmps"; +static const QString PowerSupplyAmps = "Adalight/PowerSupplyAmps"; } namespace Ardulight { @@ -107,18 +109,26 @@ static const QString NumberOfLeds = "Ardulight/NumberOfLeds"; static const QString ColorSequence = "Ardulight/ColorSequence"; static const QString Port = "Ardulight/SerialPort"; static const QString BaudRate = "Ardulight/BaudRate"; +static const QString LedMilliAmps = "Ardulight/LedMilliAmps"; +static const QString PowerSupplyAmps = "Ardulight/PowerSupplyAmps"; } namespace AlienFx { static const QString NumberOfLeds = "AlienFx/NumberOfLeds"; +static const QString LedMilliAmps = "AlienFx/LedMilliAmps"; +static const QString PowerSupplyAmps = "AlienFx/PowerSupplyAmps"; } namespace Lightpack { static const QString NumberOfLeds = "Lightpack/NumberOfLeds"; +static const QString LedMilliAmps = "Lightpack/LedMilliAmps"; +static const QString PowerSupplyAmps = "Lightpack/PowerSupplyAmps"; } namespace Virtual { static const QString NumberOfLeds = "Virtual/NumberOfLeds"; +static const QString LedMilliAmps = "Virtual/LedMilliAmps"; +static const QString PowerSupplyAmps = "Virtual/PowerSupplyAmps"; } namespace Drgb { @@ -126,6 +136,8 @@ static const QString NumberOfLeds = "Drgb/NumberOfLeds"; static const QString Address = "Drgb/Address"; static const QString Port = "Drgb/Port"; static const QString Timeout = "Drgb/Timeout"; +static const QString LedMilliAmps = "Drgb/LedMilliAmps"; +static const QString PowerSupplyAmps = "Drgb/PowerSupplyAmps"; } namespace Dnrgb { @@ -133,6 +145,8 @@ static const QString NumberOfLeds = "Dnrgb/NumberOfLeds"; static const QString Address = "Dnrgb/Address"; static const QString Port = "Dnrgb/Port"; static const QString Timeout = "Dnrgb/Timeout"; +static const QString LedMilliAmps = "Dnrgb/LedMilliAmps"; +static const QString PowerSupplyAmps = "Dnrgb/PowerSupplyAmps"; } namespace Warls { @@ -140,6 +154,8 @@ static const QString NumberOfLeds = "Warls/NumberOfLeds"; static const QString Address = "Warls/Address"; static const QString Port = "Warls/Port"; static const QString Timeout = "Warls/Timeout"; +static const QString LedMilliAmps = "Warls/LedMilliAmps"; +static const QString PowerSupplyAmps = "Warls/PowerSupplyAmps"; } } /*Key*/ @@ -266,6 +282,8 @@ QString Settings::m_applicationDirPath = ""; QMap Settings::m_devicesTypeToNameMap; QMap Settings::m_devicesTypeToKeyNumberOfLedsMap; +QMap Settings::m_devicesTypeToKeyLedMilliAmpsMap; +QMap Settings::m_devicesTypeToKeyPowerSupplyAmpsMap; Settings::Settings() : QObject(NULL) { qRegisterMetaType("Grab::GrabberType"); @@ -328,9 +346,27 @@ bool Settings::Initialize( const QString & applicationDirPath, bool isDebugLevel setNewOptionMain(Main::Key::AlienFx::NumberOfLeds, Main::AlienFx::NumberOfLedsDefault); setNewOptionMain(Main::Key::Lightpack::NumberOfLeds, Main::Lightpack::NumberOfLedsDefault); setNewOptionMain(Main::Key::Virtual::NumberOfLeds, Main::Virtual::NumberOfLedsDefault); - setNewOptionMain(Main::Key::Drgb::NumberOfLeds, Main::Drgb::NumberOfLedsDefault); - setNewOptionMain(Main::Key::Dnrgb::NumberOfLeds, Main::Dnrgb::NumberOfLedsDefault); - setNewOptionMain(Main::Key::Warls::NumberOfLeds, Main::Warls::NumberOfLedsDefault); + setNewOptionMain(Main::Key::Drgb::NumberOfLeds, Main::Drgb::NumberOfLedsDefault); + setNewOptionMain(Main::Key::Dnrgb::NumberOfLeds, Main::Dnrgb::NumberOfLedsDefault); + setNewOptionMain(Main::Key::Warls::NumberOfLeds, Main::Warls::NumberOfLedsDefault); + + setNewOptionMain(Main::Key::Adalight::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::Ardulight::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::AlienFx::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::Lightpack::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::Virtual::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::Drgb::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::Dnrgb::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + setNewOptionMain(Main::Key::Warls::LedMilliAmps, Main::Device::LedMilliAmpsDefault); + + setNewOptionMain(Main::Key::Adalight::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::Ardulight::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::AlienFx::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::Lightpack::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::Virtual::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::Drgb::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::Dnrgb::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); + setNewOptionMain(Main::Key::Warls::PowerSupplyAmps, Main::Device::PowerSupplyAmpsDefault); setNewOptionMain(Main::Key::Drgb::Address, Main::Drgb::AddressDefault); setNewOptionMain(Main::Key::Drgb::Port, Main::Drgb::PortDefault); @@ -1085,6 +1121,141 @@ int Settings::getNumberOfLeds(SupportedDevices::DeviceType device) return valueMain(key).toInt(); } +void Settings::setDeviceLedMilliAmps(const SupportedDevices::DeviceType device, const int mAmps) +{ + DEBUG_LOW_LEVEL << Q_FUNC_INFO; + + if(getDeviceLedMilliAmps(device) == mAmps) + //nothing to do + return; + + const QString& key = m_devicesTypeToKeyLedMilliAmpsMap.value(device); + + if (key == "") + { + qCritical() << Q_FUNC_INFO << "Device type not recognized, device ==" << device << "LedMilliAmps ==" << mAmps; + return; + } + + setValueMain(key, mAmps); + { + using namespace SupportedDevices; + switch(device) { + case DeviceTypeLightpack: + m_this->lightpackLedMilliAmpsChanged(mAmps); + break; + + case DeviceTypeAdalight: + m_this->adalightLedMilliAmpsChanged(mAmps); + break; + + case DeviceTypeArdulight: + m_this->ardulightLedMilliAmpsChanged(mAmps); + break; + + case DeviceTypeVirtual: + m_this->virtualLedMilliAmpsChanged(mAmps); + break; + + case DeviceTypeDrgb: + m_this->drgbLedMilliAmpsChanged(mAmps); + break; + + case DeviceTypeDnrgb: + m_this->dnrgbLedMilliAmpsChanged(mAmps); + break; + + case DeviceTypeWarls: + m_this->warlsLedMilliAmpsChanged(mAmps); + break; + default: + qCritical() << Q_FUNC_INFO << "Device type not recognized, device ==" << device << "LedMilliAmps ==" << mAmps; + } + } +} + +int Settings::getDeviceLedMilliAmps(const SupportedDevices::DeviceType device) +{ + const QString& key = m_devicesTypeToKeyLedMilliAmpsMap.value(device); + + if (key == "") + { + qCritical() << Q_FUNC_INFO << "Device type not recognized, device ==" << device; + return Main::Device::LedMilliAmpsDefault; + } + + // TODO: validator on maximum number of leds for current 'device' + return valueMain(key).toInt(); +} + + +void Settings::setDevicePowerSupplyAmps(const SupportedDevices::DeviceType device, const double amps) +{ + DEBUG_LOW_LEVEL << Q_FUNC_INFO; + + if(getDevicePowerSupplyAmps(device) == amps) + //nothing to do + return; + + const QString& key = m_devicesTypeToKeyPowerSupplyAmpsMap.value(device); + + if (key == "") + { + qCritical() << Q_FUNC_INFO << "Device type not recognized, device ==" << device << "PowerSupplyAmps ==" << amps; + return; + } + + setValueMain(key, amps); + { + using namespace SupportedDevices; + switch(device) { + case DeviceTypeLightpack: + m_this->lightpackPowerSupplyAmpsChanged(amps); + break; + + case DeviceTypeAdalight: + m_this->adalightPowerSupplyAmpsChanged(amps); + break; + + case DeviceTypeArdulight: + m_this->ardulightPowerSupplyAmpsChanged(amps); + break; + + case DeviceTypeVirtual: + m_this->virtualPowerSupplyAmpsChanged(amps); + break; + + case DeviceTypeDrgb: + m_this->drgbPowerSupplyAmpsChanged(amps); + break; + + case DeviceTypeDnrgb: + m_this->dnrgbPowerSupplyAmpsChanged(amps); + break; + + case DeviceTypeWarls: + m_this->warlsPowerSupplyAmpsChanged(amps); + break; + default: + qCritical() << Q_FUNC_INFO << "Device type not recognized, device ==" << device << "PowerSupplyAmps ==" << amps; + } + } +} + +double Settings::getDevicePowerSupplyAmps(const SupportedDevices::DeviceType device) +{ + const QString& key = m_devicesTypeToKeyPowerSupplyAmpsMap.value(device); + + if (key == "") + { + qCritical() << Q_FUNC_INFO << "Device type not recognized, device ==" << device; + return Main::Device::PowerSupplyAmpsDefault; + } + + // TODO: validator on maximum number of leds for current 'device' + return valueMain(key).toInt(); +} + void Settings::setColorSequence(SupportedDevices::DeviceType device, QString colorSequence) { DEBUG_LOW_LEVEL << Q_FUNC_INFO << device << colorSequence; @@ -2077,25 +2248,42 @@ void Settings::initDevicesMap() { DEBUG_LOW_LEVEL << Q_FUNC_INFO; - m_devicesTypeToNameMap[SupportedDevices::DeviceTypeAdalight] = Main::Value::ConnectedDevice::AdalightDevice; + m_devicesTypeToNameMap[SupportedDevices::DeviceTypeAdalight] = Main::Value::ConnectedDevice::AdalightDevice; m_devicesTypeToNameMap[SupportedDevices::DeviceTypeArdulight] = Main::Value::ConnectedDevice::ArdulightDevice; m_devicesTypeToNameMap[SupportedDevices::DeviceTypeLightpack] = Main::Value::ConnectedDevice::LightpackDevice; - m_devicesTypeToNameMap[SupportedDevices::DeviceTypeVirtual] = Main::Value::ConnectedDevice::VirtualDevice; + m_devicesTypeToNameMap[SupportedDevices::DeviceTypeVirtual] = Main::Value::ConnectedDevice::VirtualDevice; m_devicesTypeToNameMap[SupportedDevices::DeviceTypeDrgb] = Main::Value::ConnectedDevice::DrgbDevice; m_devicesTypeToNameMap[SupportedDevices::DeviceTypeDnrgb] = Main::Value::ConnectedDevice::DnrgbDevice; m_devicesTypeToNameMap[SupportedDevices::DeviceTypeWarls] = Main::Value::ConnectedDevice::WarlsDevice; - m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeAdalight] = Main::Key::Adalight::NumberOfLeds; + m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeAdalight] = Main::Key::Adalight::NumberOfLeds; m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeArdulight] = Main::Key::Ardulight::NumberOfLeds; m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeLightpack] = Main::Key::Lightpack::NumberOfLeds; - m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeVirtual] = Main::Key::Virtual::NumberOfLeds; + m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeVirtual] = Main::Key::Virtual::NumberOfLeds; m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeDrgb] = Main::Key::Drgb::NumberOfLeds; m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeDnrgb] = Main::Key::Dnrgb::NumberOfLeds; m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeWarls] = Main::Key::Warls::NumberOfLeds; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeAdalight] = Main::Key::Adalight::LedMilliAmps; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeArdulight] = Main::Key::Ardulight::LedMilliAmps; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeLightpack] = Main::Key::Lightpack::LedMilliAmps; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeVirtual] = Main::Key::Virtual::LedMilliAmps; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeDrgb] = Main::Key::Drgb::LedMilliAmps; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeDnrgb] = Main::Key::Dnrgb::LedMilliAmps; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeWarls] = Main::Key::Warls::LedMilliAmps; + + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeAdalight] = Main::Key::Adalight::PowerSupplyAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeArdulight] = Main::Key::Ardulight::PowerSupplyAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeLightpack] = Main::Key::Lightpack::PowerSupplyAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeVirtual] = Main::Key::Virtual::PowerSupplyAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeDrgb] = Main::Key::Drgb::PowerSupplyAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeDnrgb] = Main::Key::Dnrgb::PowerSupplyAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeWarls] = Main::Key::Warls::PowerSupplyAmps; #ifdef ALIEN_FX_SUPPORTED - m_devicesTypeToNameMap[SupportedDevices::DeviceTypeAlienFx] = Main::Value::ConnectedDevice::AlienFxDevice; - m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeAlienFx] = Main::Key::AlienFx::NumberOfLeds; + m_devicesTypeToNameMap[SupportedDevices::DeviceTypeAlienFx] = Main::Value::ConnectedDevice::AlienFxDevice; + m_devicesTypeToKeyNumberOfLedsMap[SupportedDevices::DeviceTypeAlienFx] = Main::Key::AlienFx::NumberOfLeds; + m_devicesTypeToKeyLedMilliAmpsMap[SupportedDevices::DeviceTypeAlienFx] = Main::Key::AlienFx::LedMilliAmps; + m_devicesTypeToKeyPowerSupplyAmpsMap[SupportedDevices::DeviceTypeAlienFx] = Main::Key::AlienFx::PowerSupplyAmps; #endif } diff --git a/Software/src/Settings.hpp b/Software/src/Settings.hpp index 569e69fd5..ce452105c 100644 --- a/Software/src/Settings.hpp +++ b/Software/src/Settings.hpp @@ -150,6 +150,10 @@ class Settings : public QObject static void setWarlsPort(const QString& port); static int getWarlsTimeout(); static void setWarlsTimeout(const int timeout); + static int getDeviceLedMilliAmps(const SupportedDevices::DeviceType device); + static void setDeviceLedMilliAmps(const SupportedDevices::DeviceType device, const int mamps); + static double getDevicePowerSupplyAmps(const SupportedDevices::DeviceType device); + static void setDevicePowerSupplyAmps(const SupportedDevices::DeviceType device, const double amps); static QStringList getSupportedSerialPortBaudRates(); static bool isConnectedDeviceUsesSerialPort(); // [Adalight | Ardulight | Lightpack | ... | Virtual] @@ -311,24 +315,38 @@ class Settings : public QObject void hotkeyChanged(const QString &actionName, const QKeySequence & newKeySequence, const QKeySequence &oldKeySequence); void adalightSerialPortNameChanged(const QString & port); void adalightSerialPortBaudRateChanged(const QString & baud); + void adalightLedMilliAmpsChanged(const int mAmps); + void adalightPowerSupplyAmpsChanged(const double amps); void ardulightSerialPortNameChanged(const QString & port); void ardulightSerialPortBaudRateChanged(const QString & baud); + void ardulightLedMilliAmpsChanged(const int mAmps); + void ardulightPowerSupplyAmpsChanged(const double amps); void drgbAddressChanged(const QString& address); void drgbPortChanged(const QString& port); void drgbTimeoutChanged(const int timeout); + void drgbLedMilliAmpsChanged(const int mAmps); + void drgbPowerSupplyAmpsChanged(const double amps); void dnrgbAddressChanged(const QString& address); void dnrgbPortChanged(const QString& port); void dnrgbTimeoutChanged(const int timeout); + void dnrgbLedMilliAmpsChanged(const int mAmps); + void dnrgbPowerSupplyAmpsChanged(const double amps); void warlsAddressChanged(const QString& address); void warlsPortChanged(const QString& port); void warlsTimeoutChanged(const int timeout); + void warlsLedMilliAmpsChanged(const int mAmps); + void warlsPowerSupplyAmpsChanged(const double amps); void lightpackNumberOfLedsChanged(int numberOfLeds); + void lightpackLedMilliAmpsChanged(const int mAmps); + void lightpackPowerSupplyAmpsChanged(const double amps); void adalightNumberOfLedsChanged(int numberOfLeds); void ardulightNumberOfLedsChanged(int numberOfLeds); - void virtualNumberOfLedsChanged(int numberOfLeds); void drgbNumberOfLedsChanged(int numberOfLeds); void dnrgbNumberOfLedsChanged(int numberOfLeds); void warlsNumberOfLedsChanged(int numberOfLeds); + void virtualNumberOfLedsChanged(int numberOfLeds); + void virtualLedMilliAmpsChanged(const int mAmps); + void virtualPowerSupplyAmpsChanged(const double amps); void grabSlowdownChanged(int value); void backlightEnabledChanged(bool isEnabled); void grabAvgColorsEnabledChanged(bool isEnabled); @@ -381,5 +399,7 @@ class Settings : public QObject static Settings *m_this; static QMap m_devicesTypeToNameMap; static QMap m_devicesTypeToKeyNumberOfLedsMap; + static QMap m_devicesTypeToKeyLedMilliAmpsMap; + static QMap m_devicesTypeToKeyPowerSupplyAmpsMap; }; } /*SettingsScope*/ diff --git a/Software/src/SettingsDefaults.hpp b/Software/src/SettingsDefaults.hpp index f74560de8..2c385e8aa 100644 --- a/Software/src/SettingsDefaults.hpp +++ b/Software/src/SettingsDefaults.hpp @@ -103,6 +103,11 @@ static const int PortDefault = 3636; static const QString AuthKey = ""; // See ApiKey generation in Settings initialization } +namespace Device +{ +static const int LedMilliAmpsDefault = 50; +static const double PowerSupplyAmpsDefault = 0.0; +} namespace Adalight { static const int NumberOfLedsDefault = 25; From aeca807b12df5111d02a99df9c50ff4c287a1f3f Mon Sep 17 00:00:00 2001 From: zomfg Date: Fri, 5 Jun 2020 20:21:27 +0200 Subject: [PATCH 4/8] power limit wizard UI --- Software/src/Settings.cpp | 2 +- Software/src/src.pro | 3 + .../src/wizard/ConfigureDevicePowerPage.cpp | 108 +++++++++++++ .../src/wizard/ConfigureDevicePowerPage.hpp | 53 ++++++ .../src/wizard/ConfigureDevicePowerPage.ui | 152 ++++++++++++++++++ Software/src/wizard/Wizard.cpp | 2 + Software/src/wizard/Wizard.hpp | 1 + 7 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 Software/src/wizard/ConfigureDevicePowerPage.cpp create mode 100644 Software/src/wizard/ConfigureDevicePowerPage.hpp create mode 100644 Software/src/wizard/ConfigureDevicePowerPage.ui diff --git a/Software/src/Settings.cpp b/Software/src/Settings.cpp index 420ad58b5..417783d3a 100644 --- a/Software/src/Settings.cpp +++ b/Software/src/Settings.cpp @@ -1253,7 +1253,7 @@ double Settings::getDevicePowerSupplyAmps(const SupportedDevices::DeviceType dev } // TODO: validator on maximum number of leds for current 'device' - return valueMain(key).toInt(); + return valueMain(key).toDouble(); } void Settings::setColorSequence(SupportedDevices::DeviceType device, QString colorSequence) diff --git a/Software/src/src.pro b/Software/src/src.pro index 66546f492..7d1dada82 100644 --- a/Software/src/src.pro +++ b/Software/src/src.pro @@ -299,6 +299,7 @@ SOURCES += \ wizard/LightpackDiscoveryPage.cpp \ wizard/ConfigureDevicePage.cpp \ wizard/ConfigureUdpDevicePage.cpp \ + wizard/ConfigureDevicePowerPage.cpp \ wizard/SelectDevicePage.cpp \ wizard/GlobalColorCoefPage.cpp \ wizard/CustomDistributor.cpp \ @@ -355,6 +356,7 @@ HEADERS += \ wizard/LightpackDiscoveryPage.hpp \ wizard/ConfigureDevicePage.hpp \ wizard/ConfigureUdpDevicePage.hpp \ + wizard/ConfigureDevicePowerPage.hpp \ wizard/SelectDevicePage.hpp \ wizard/GlobalColorCoefPage.hpp \ types.h \ @@ -400,6 +402,7 @@ FORMS += SettingsWindow.ui \ wizard/LightpackDiscoveryPage.ui \ wizard/ConfigureDevicePage.ui \ wizard/ConfigureUdpDevicePage.ui \ + wizard/ConfigureDevicePowerPage.ui \ wizard/SelectDevicePage.ui \ wizard/GlobalColorCoefPage.ui diff --git a/Software/src/wizard/ConfigureDevicePowerPage.cpp b/Software/src/wizard/ConfigureDevicePowerPage.cpp new file mode 100644 index 000000000..334a0e73c --- /dev/null +++ b/Software/src/wizard/ConfigureDevicePowerPage.cpp @@ -0,0 +1,108 @@ +/* + * ConfigureDevicePowerPage.cpp + * + * Created on: 15/02/2020 + * Project: Prismatik + * + * Copyright (c) 2013 Tim + * + * Lightpack is an open-source, USB content-driving ambient lighting + * hardware. + * + * Prismatik is a free, open-source software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Prismatik and Lightpack files is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include "ConfigureDevicePowerPage.hpp" +#include "ui_ConfigureDevicePowerPage.h" +#include "Settings.hpp" +#include "LedDeviceDrgb.hpp" +#include "LedDeviceDnrgb.hpp" +#include "LedDeviceWarls.hpp" +#include "Wizard.hpp" + +using namespace SettingsScope; + +ConfigureDevicePowerPage::ConfigureDevicePowerPage(bool isInitFromSettings, TransientSettings *ts, QWidget *parent): + QWizardPage(parent), + SettingsAwareTrait(isInitFromSettings, ts), + ui(new Ui::ConfigureDevicePowerPage) +{ + ui->setupUi(this); +} + +void ConfigureDevicePowerPage::initializePage() +{ + SupportedDevices::DeviceType device = SupportedDevices::DefaultDeviceType; + if (field("isDrgb").toBool()) + device = SupportedDevices::DeviceTypeDrgb; + else if (field("isDnrgb").toBool()) + device = SupportedDevices::DeviceTypeDnrgb; + else if (field("isWarls").toBool()) + device = SupportedDevices::DeviceTypeWarls; + else if (field("isLightpack").toBool()) + device = SupportedDevices::DeviceTypeLightpack; + else if (field("isAdalight").toBool()) + device = SupportedDevices::DeviceTypeAdalight; + else if (field("isArdulight").toBool()) + device = SupportedDevices::DeviceTypeArdulight; + else if (field("isVirtual").toBool()) + device = SupportedDevices::DeviceTypeVirtual; + else if (field("isAlienFx").toBool()) + device = SupportedDevices::DeviceTypeAlienFx; + + ui->sbLedMilliAmps->setValue(Settings::getDeviceLedMilliAmps(device)); + ui->sbPowerSupplyAmps->setValue(Settings::getDevicePowerSupplyAmps(device)); +} + + +bool ConfigureDevicePowerPage::validatePage() +{ + SupportedDevices::DeviceType device = SupportedDevices::DefaultDeviceType; + if (field("isDrgb").toBool()) + device = SupportedDevices::DeviceTypeDrgb; + else if (field("isDnrgb").toBool()) + device = SupportedDevices::DeviceTypeDnrgb; + else if (field("isWarls").toBool()) + device = SupportedDevices::DeviceTypeWarls; + else if (field("isLightpack").toBool()) + device = SupportedDevices::DeviceTypeLightpack; + else if (field("isAdalight").toBool()) + device = SupportedDevices::DeviceTypeAdalight; + else if (field("isArdulight").toBool()) + device = SupportedDevices::DeviceTypeArdulight; + else if (field("isVirtual").toBool()) + device = SupportedDevices::DeviceTypeVirtual; + else if (field("isAlienFx").toBool()) + device = SupportedDevices::DeviceTypeAlienFx; + + const int ledMilliAmps = ui->sbLedMilliAmps->value(); + const double powerSupplyAmps = ui->sbPowerSupplyAmps->value(); + + Settings::setDeviceLedMilliAmps(device, ledMilliAmps); + Settings::setDevicePowerSupplyAmps(device, powerSupplyAmps); + + _transSettings->ledDevice->setLedMilliAmps(ledMilliAmps); + _transSettings->ledDevice->setPowerSupplyAmps(powerSupplyAmps); + + return true; +} + +ConfigureDevicePowerPage::~ConfigureDevicePowerPage() +{ + delete ui; +} diff --git a/Software/src/wizard/ConfigureDevicePowerPage.hpp b/Software/src/wizard/ConfigureDevicePowerPage.hpp new file mode 100644 index 000000000..e98983c4e --- /dev/null +++ b/Software/src/wizard/ConfigureDevicePowerPage.hpp @@ -0,0 +1,53 @@ +/* + * ConfigureDevicePowerPage.hpp + * + * Created on: 15/02/2020 + * Project: Prismatik + * + * Copyright (c) 2013 Tim + * + * Lightpack is an open-source, USB content-driving ambient lighting + * hardware. + * + * Prismatik is a free, open-source software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Prismatik and Lightpack files is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef CONFIGUREDEVICEPOWERPAGE_HPP +#define CONFIGUREDEVICEPOWERPAGE_HPP + +#include +#include "SettingsAwareTrait.hpp" + +namespace Ui { +class ConfigureDevicePowerPage; +} + +class ConfigureDevicePowerPage : public QWizardPage, SettingsAwareTrait +{ + Q_OBJECT + +public: + explicit ConfigureDevicePowerPage(bool isInitFromSettings, TransientSettings *ts, QWidget *parent = 0); + ~ConfigureDevicePowerPage(); + +protected: + void initializePage(); + bool validatePage(); + +private: + Ui::ConfigureDevicePowerPage*ui; +}; + +#endif // CONFIGUREDEVICEPOWERPAGE_HPP diff --git a/Software/src/wizard/ConfigureDevicePowerPage.ui b/Software/src/wizard/ConfigureDevicePowerPage.ui new file mode 100644 index 000000000..39c5cae99 --- /dev/null +++ b/Software/src/wizard/ConfigureDevicePowerPage.ui @@ -0,0 +1,152 @@ + + + ConfigureDevicePowerPage + + + + 0 + 0 + 400 + 300 + + + + WizardPage + + + Device configuration + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + mAmps + + + + + + + Amps + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0.100000000000000 + + + + + + + Power Supply current limit + + + + + + + Single LED current + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 1 + + + 100 + + + 50 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + <html><head/><body><p align="justify">If your LED power supply cannot provide enough current AND you know your LED's current requirements (check datasheet if needed) you can limit the current here. This will reduce the overall brightness on current hungry scenes. </p><p align="justify">Leave Power Supply current limit at &quot;0&quot; to disable limiting.</p><p align="justify"><span style=" font-weight:600;">Warning</span>: Power Supply current limit value might not match exactly your power supply so adjust as necessary.</p></body></html> + + + Qt::AlignBottom|Qt::AlignJustify + + + true + + + + + + + + + + + + + diff --git a/Software/src/wizard/Wizard.cpp b/Software/src/wizard/Wizard.cpp index fab3cd2ba..a8d3bb684 100644 --- a/Software/src/wizard/Wizard.cpp +++ b/Software/src/wizard/Wizard.cpp @@ -33,6 +33,7 @@ #include "SelectDevicePage.hpp" #include "ConfigureDevicePage.hpp" #include "ConfigureUdpDevicePage.hpp" +#include "ConfigureDevicePowerPage.hpp" #include "GlobalColorCoefPage.hpp" #include "AbstractLedDevice.hpp" @@ -51,6 +52,7 @@ Wizard::Wizard(bool isInitFromSettings, QWidget *parent) : this->setPage(Page_MonitorConfiguration, new MonitorConfigurationPage(_isInitFromSettings, _transSettings) ); this->setPage(Page_ChooseProfile, new SelectProfilePage(_isInitFromSettings, _transSettings)); this->setPage(Page_ZonePlacement, new ZonePlacementPage(_isInitFromSettings, _transSettings)); + this->setPage(Page_ConfigureDevicePower, new ConfigureDevicePowerPage(_isInitFromSettings, _transSettings)); this->setPage(Page_GlobalColorCoef, new GlobalColorCoefPage(_isInitFromSettings, _transSettings)); } diff --git a/Software/src/wizard/Wizard.hpp b/Software/src/wizard/Wizard.hpp index 5e7e70b0c..3dc4ffefc 100644 --- a/Software/src/wizard/Wizard.hpp +++ b/Software/src/wizard/Wizard.hpp @@ -43,6 +43,7 @@ enum { Page_MonitorConfiguration, Page_ChooseProfile, Page_ZonePlacement, + Page_ConfigureDevicePower, Page_GlobalColorCoef }; From ea96195685475fc1a9faf59691a72c034f5bd668 Mon Sep 17 00:00:00 2001 From: zomfg Date: Fri, 5 Jun 2020 20:31:21 +0200 Subject: [PATCH 5/8] wizard indents --- Software/src/wizard/Wizard.cpp | 4 ++-- Software/src/wizard/Wizard.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Software/src/wizard/Wizard.cpp b/Software/src/wizard/Wizard.cpp index a8d3bb684..fad6cde37 100644 --- a/Software/src/wizard/Wizard.cpp +++ b/Software/src/wizard/Wizard.cpp @@ -48,11 +48,11 @@ Wizard::Wizard(bool isInitFromSettings, QWidget *parent) : this->setPage(Page_LightpackDiscovery, new LightpackDiscoveryPage(_isInitFromSettings, _transSettings) ); this->setPage(Page_ChooseDevice, new SelectDevicePage(_isInitFromSettings, _transSettings) ); this->setPage(Page_ConfigureDevice, new ConfigureDevicePage(_isInitFromSettings, _transSettings) ); - this->setPage(Page_ConfigureUdpDevice, new ConfigureUdpDevicePage(_isInitFromSettings, _transSettings)); + this->setPage(Page_ConfigureUdpDevice, new ConfigureUdpDevicePage(_isInitFromSettings, _transSettings)); this->setPage(Page_MonitorConfiguration, new MonitorConfigurationPage(_isInitFromSettings, _transSettings) ); this->setPage(Page_ChooseProfile, new SelectProfilePage(_isInitFromSettings, _transSettings)); this->setPage(Page_ZonePlacement, new ZonePlacementPage(_isInitFromSettings, _transSettings)); - this->setPage(Page_ConfigureDevicePower, new ConfigureDevicePowerPage(_isInitFromSettings, _transSettings)); + this->setPage(Page_ConfigureDevicePower, new ConfigureDevicePowerPage(_isInitFromSettings, _transSettings)); this->setPage(Page_GlobalColorCoef, new GlobalColorCoefPage(_isInitFromSettings, _transSettings)); } diff --git a/Software/src/wizard/Wizard.hpp b/Software/src/wizard/Wizard.hpp index 3dc4ffefc..0b4bde1c0 100644 --- a/Software/src/wizard/Wizard.hpp +++ b/Software/src/wizard/Wizard.hpp @@ -39,11 +39,11 @@ enum { Page_LightpackDiscovery, Page_ChooseDevice, Page_ConfigureDevice, - Page_ConfigureUdpDevice, + Page_ConfigureUdpDevice, Page_MonitorConfiguration, Page_ChooseProfile, Page_ZonePlacement, - Page_ConfigureDevicePower, + Page_ConfigureDevicePower, Page_GlobalColorCoef }; From 5e38c2f534613bdbc444a02a1c378cd173d46b19 Mon Sep 17 00:00:00 2001 From: zomfg Date: Thu, 25 Jun 2020 01:43:17 +0200 Subject: [PATCH 6/8] settings window: brightness cap help --- Software/src/SettingsWindow.cpp | 5 + Software/src/SettingsWindow.hpp | 1 + Software/src/SettingsWindow.ui | 424 ++++++++++++++++++-------------- 3 files changed, 252 insertions(+), 178 deletions(-) diff --git a/Software/src/SettingsWindow.cpp b/Software/src/SettingsWindow.cpp index ba7e737b6..99c686440 100644 --- a/Software/src/SettingsWindow.cpp +++ b/Software/src/SettingsWindow.cpp @@ -2106,6 +2106,11 @@ void SettingsWindow::on_pushButton_GammaCorrectionHelp_clicked() showHelpOf(ui->horizontalSlider_GammaCorrection); } +void SettingsWindow::on_pushButton_BrightnessCapHelp_clicked() +{ + showHelpOf(ui->horizontalSlider_DeviceBrightnessCap); +} + void SettingsWindow::on_pushButton_lumosityThresholdHelp_clicked() { showHelpOf(ui->horizontalSlider_LuminosityThreshold); diff --git a/Software/src/SettingsWindow.hpp b/Software/src/SettingsWindow.hpp index 9e37df2ca..d07208e13 100644 --- a/Software/src/SettingsWindow.hpp +++ b/Software/src/SettingsWindow.hpp @@ -216,6 +216,7 @@ private slots: void on_pushButton_LightpackRefreshDelayHelp_clicked(); void on_pushButton_GammaCorrectionHelp_clicked(); + void on_pushButton_BrightnessCapHelp_clicked(); void on_pushButton_lumosityThresholdHelp_clicked(); diff --git a/Software/src/SettingsWindow.ui b/Software/src/SettingsWindow.ui index 703c307db..341d7ac67 100644 --- a/Software/src/SettingsWindow.ui +++ b/Software/src/SettingsWindow.ui @@ -1300,30 +1300,169 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< 20 - - - - - 0 - 0 - + + + + Keep lights ON after lock computer + + + + + + + + 16 + 16777215 + - Gamma correction: + % - - + + - + 0 0 + + <h4>Gamma correction</h4> It controls the level of saturation. The effect is clearly detectable in a video in screen grabbing mode<br/>Recommended value: 2.00 + + + 5 + + + 1000 + + + 5 + + + Qt::Horizontal + + + QSlider::NoTicks + + + 100 + + + + + + + + 0 + 0 + + + + Keep lights ON after exit + + + + + + + Keep lights ON after system suspend + + + + + + + + 200 + 0 + + + + 0 + + + 100 + + + 1 + + + 100 + + + Qt::Horizontal + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 13 + + + + + Run configuration wizard + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 16 + 16777215 + + margin:0px; + + % + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 16 + 16777215 + + @@ -1343,7 +1482,20 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - + + + + + 0 + 0 + + + + Gamma correction: + + + + @@ -1715,77 +1867,23 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - - 0 - 0 - - + + - 50 + 200 0 - - - 60 - 16777215 - - - - 0.050000000000000 - - - 10.000000000000000 - - - 0.050000000000000 - - - 0.050000000000000 - - - - - - - margin:0px; - - - % - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - + + <html><head/><body><p><span style=" font-weight:600;">Brightness Cap</span></p><p>Lowers the brightness limit of LEDs (as opposed to overall brightness). Can be used to limit the power draw and the heat output. Defaults to 100% (no limit).</p></body></html> - - - - - 0 + 1 100 - - 1 - 100 @@ -1794,33 +1892,6 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - 13 - - - - - Run configuration wizard - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -1834,14 +1905,39 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - + + - Keep lights ON after lock computer + Brightness cap: - + + + + + 45 + 16777215 + + + + + 29 + 0 + + + + 1 + + + 100 + + + 100 + + + + @@ -1851,16 +1947,22 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 60 + 45 0 - 50 + 45 16777215 + + + 9 + 0 + + 0 @@ -1872,97 +1974,66 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - + + + + + 0 + 0 + + + - 0 - 0 + 16 + 16777215 - - Keep lights ON after exit + + margin:0px; - - - - - Keep lights ON after system suspend + + + + + :/icons/help.png:/icons/help.png + + + true - - + + - + 0 0 - - <h4>Gamma correction</h4> It controls the level of saturation. The effect is clearly detectable in a video in screen grabbing mode<br/>Recommended value: 2.00 - - - 5 - - - 1000 - - - 5 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 100 - - - - - - - % + + + 50 + 0 + - - - - - - Brightness cap: + + + 60 + 16777215 + - - - - - 1 + 0.050000000000000 - 100 - - - 100 - - - - - - - 1 + 10.000000000000000 - - 100 + + 0.050000000000000 - 100 - - - Qt::Horizontal + 0.050000000000000 @@ -3146,10 +3217,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< radioButton_LuminosityDeadZone pushButton_EnableDisableDevice horizontalSlider_DeviceBrightness - spinBox_DeviceBrightness horizontalSlider_GammaCorrection - doubleSpinBox_DeviceGamma - pushButton_GammaCorrectionHelp checkBox_KeepLightsOnAfterLockComputer checkBox_KeepLightsOnAfterScreenOff checkBox_KeepLightsOnAfterSuspend From 571a50a7c361aead146515ac70b3b28ea8f2dd0c Mon Sep 17 00:00:00 2001 From: zomfg Date: Thu, 25 Jun 2020 18:31:10 +0200 Subject: [PATCH 7/8] settings window: larger brightness spinbox --- Software/src/SettingsWindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Software/src/SettingsWindow.ui b/Software/src/SettingsWindow.ui index 341d7ac67..9ecc2c514 100644 --- a/Software/src/SettingsWindow.ui +++ b/Software/src/SettingsWindow.ui @@ -1916,7 +1916,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 45 + 50 16777215 @@ -1953,7 +1953,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 45 + 50 16777215 From 10799b4bbff40942bdfaf7044103f2f580ce7a0b Mon Sep 17 00:00:00 2001 From: zomfg Date: Sat, 27 Jun 2020 00:02:49 +0200 Subject: [PATCH 8/8] settings window: device: brightness spinboxes with suffixes --- Software/src/SettingsWindow.ui | 46 ++++++++-------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/Software/src/SettingsWindow.ui b/Software/src/SettingsWindow.ui index 9ecc2c514..36d18d683 100644 --- a/Software/src/SettingsWindow.ui +++ b/Software/src/SettingsWindow.ui @@ -1307,19 +1307,6 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - - 16 - 16777215 - - - - % - - - @@ -1436,25 +1423,6 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - - - - - 16 - 16777215 - - - - margin:0px; - - - % - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - @@ -1916,7 +1884,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 50 + 60 16777215 @@ -1935,7 +1903,10 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< 100 - + + % + + @@ -1953,7 +1924,7 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< - 50 + 60 16777215 @@ -1972,7 +1943,10 @@ Internally emulates the effects of f.lux, redshift, Night Light, Night Shift...< 100 - + + % + +