diff --git a/Controllers/PhilipsWizController/PhilipsWizController.cpp b/Controllers/PhilipsWizController/PhilipsWizController.cpp
index 6c6a55a7..6e0cc254 100644
--- a/Controllers/PhilipsWizController/PhilipsWizController.cpp
+++ b/Controllers/PhilipsWizController/PhilipsWizController.cpp
@@ -15,7 +15,7 @@
using json = nlohmann::json;
using namespace std::chrono_literals;
-PhilipsWizController::PhilipsWizController(std::string ip, bool use_cool, bool use_warm)
+PhilipsWizController::PhilipsWizController(std::string ip, bool use_cool, bool use_warm, std::string selected_white_strategy)
{
/*-----------------------------------------------------------------*\
| Fill in location string with device's IP address |
@@ -27,6 +27,7 @@ PhilipsWizController::PhilipsWizController(std::string ip, bool use_cool, bool u
\*-----------------------------------------------------------------*/
use_cool_white = use_cool;
use_warm_white = use_warm;
+ white_strategy = selected_white_strategy;
/*-----------------------------------------------------------------*\
| Open a UDP client sending to the device's IP, port 38899 |
@@ -85,7 +86,51 @@ std::string PhilipsWizController::GetUniqueID()
void PhilipsWizController::SetColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char brightness)
{
json command;
+ unsigned char white;
+ /*-----------------------------------------------------------------*\
+ | The official Wiz app also sends a warm white level with its |
+ | custom colours. Until we can figure out a way to account for it |
+ | correctly, set the white level based on selected strategy. |
+ \*-----------------------------------------------------------------*/
+ if(white_strategy == "Average")
+ {
+ white = (red + green + blue) / 3;
+ }
+ else if(white_strategy == "Minimum")
+ {
+ white = std::min(std::min(red, green), blue);
+ if(use_cool_white || use_warm_white)
+ {
+ red = red - white;
+ green = green - white;
+ blue = blue - white;
+ }
+ }
+ else
+ {
+ white = 0;
+ }
+
+ if(use_cool_white)
+ {
+ command["params"]["c"] = white;
+ }
+ else
+ {
+ command["params"]["c"] = 0;
+ }
+
+ if(use_warm_white)
+ {
+ command["params"]["w"] = white;
+ }
+ else
+ {
+ command["params"]["w"] = 0;
+ }
+
+
/*-----------------------------------------------------------------*\
| Fill in the setPilot command with RGB and brightness information. |
| The bulb will not respond to 0, 0, 0, so if all channels are zero,|
@@ -97,31 +142,7 @@ void PhilipsWizController::SetColor(unsigned char red, unsigned char green, unsi
command["params"]["g"] = green;
command["params"]["b"] = blue;
command["params"]["dimming"] = brightness;
- command["params"]["state"] = !((red == 0) && (green == 0) && (blue == 0));
-
- /*-----------------------------------------------------------------*\
- | The official Wiz app also sends a warm white level with its |
- | custom colours. Until we can figure out a way to account for it |
- | correctly, set the cool white level to the average of RGB to |
- | improve its apparent brightness. |
- \*-----------------------------------------------------------------*/
- if(use_warm_white)
- {
- command["params"]["w"] = (red + green + blue) / 3;
- }
- else
- {
- command["params"]["w"] = 0;
- }
-
- if(use_cool_white)
- {
- command["params"]["c"] = (red + green + blue) / 3;
- }
- else
- {
- command["params"]["c"] = 0;
- }
+ command["params"]["state"] = !((red == 0) && (green == 0) && (blue == 0) && (white == 0));
/*-----------------------------------------------------------------*\
| Convert the JSON object to a string and write it |
diff --git a/Controllers/PhilipsWizController/PhilipsWizController.h b/Controllers/PhilipsWizController/PhilipsWizController.h
index 86d01d26..147a5416 100644
--- a/Controllers/PhilipsWizController/PhilipsWizController.h
+++ b/Controllers/PhilipsWizController/PhilipsWizController.h
@@ -60,7 +60,7 @@ enum
class PhilipsWizController
{
public:
- PhilipsWizController(std::string ip, bool use_cool, bool use_warm);
+ PhilipsWizController(std::string ip, bool use_cool, bool use_warm, std::string selected_white_strategy);
~PhilipsWizController();
std::string GetLocation();
@@ -88,6 +88,7 @@ private:
bool use_cool_white;
bool use_warm_white;
+ std::string white_strategy;
void SendSetPilot();
};
diff --git a/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp b/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp
index 03078c39..56e0676f 100644
--- a/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp
+++ b/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp
@@ -58,8 +58,13 @@ void DetectPhilipsWizControllers()
{
wiz_warm = wiz_settings["devices"][device_idx]["use_warm_white"];
}
+ std::string wiz_white_strategy = "Average";
+ if(wiz_settings["devices"][device_idx].contains("selected_white_strategy"))
+ {
+ wiz_white_strategy = wiz_settings["devices"][device_idx]["selected_white_strategy"];
+ }
- PhilipsWizController* controller = new PhilipsWizController(wiz_ip, wiz_cool, wiz_warm);
+ PhilipsWizController* controller = new PhilipsWizController(wiz_ip, wiz_cool, wiz_warm, wiz_white_strategy);
RGBController_PhilipsWiz* rgb_controller = new RGBController_PhilipsWiz(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
diff --git a/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.cpp b/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.cpp
index 0117f90a..16fbffcd 100644
--- a/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.cpp
+++ b/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.cpp
@@ -17,6 +17,9 @@ OpenRGBPhilipsWizSettingsEntry::OpenRGBPhilipsWizSettingsEntry(QWidget *parent)
ui(new Ui::OpenRGBPhilipsWizSettingsEntryUi)
{
ui->setupUi(this);
+
+ ui->WhiteStrategyComboBox->addItem(tr("Average"));
+ ui->WhiteStrategyComboBox->addItem(tr("Minimum"));
}
OpenRGBPhilipsWizSettingsEntry::~OpenRGBPhilipsWizSettingsEntry()
diff --git a/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.ui b/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.ui
index 394c2001..dfb6af9b 100644
--- a/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.ui
+++ b/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsEntry.ui
@@ -50,6 +50,16 @@
+ -
+
+
+ -
+
+
+ White Strategy:
+
+
+
diff --git a/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.cpp b/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.cpp
index 57e9c841..384991ce 100644
--- a/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.cpp
+++ b/qt/OpenRGBPhilipsWizSettingsPage/OpenRGBPhilipsWizSettingsPage.cpp
@@ -51,6 +51,11 @@ OpenRGBPhilipsWizSettingsPage::OpenRGBPhilipsWizSettingsPage(QWidget *parent) :
entry->ui->UseWarmWhiteCheckBox->setChecked(wiz_settings["devices"][device_idx]["use_warm_white"]);
}
+ if(wiz_settings["devices"][device_idx].contains("selected_white_strategy"))
+ {
+ entry->ui->WhiteStrategyComboBox->setCurrentText(QString::fromStdString(wiz_settings["devices"][device_idx]["selected_white_strategy"]));
+ }
+
entries.push_back(entry);
QListWidgetItem* item = new QListWidgetItem;
@@ -128,6 +133,7 @@ void Ui::OpenRGBPhilipsWizSettingsPage::on_SavePhilipsWizConfigurationButton_cli
wiz_settings["devices"][device_idx]["ip"] = entries[device_idx]->ui->IPEdit->text().toStdString();
wiz_settings["devices"][device_idx]["use_cool_white"] = entries[device_idx]->ui->UseCoolWhiteCheckBox->isChecked();
wiz_settings["devices"][device_idx]["use_warm_white"] = entries[device_idx]->ui->UseWarmWhiteCheckBox->isChecked();
+ wiz_settings["devices"][device_idx]["selected_white_strategy"] = entries[device_idx]->ui->WhiteStrategyComboBox->currentText().toStdString();
}
ResourceManager::get()->GetSettingsManager()->SetSettings("PhilipsWizDevices", wiz_settings);