diff --git a/Controllers/PhilipsWizController/PhilipsWizController.cpp b/Controllers/PhilipsWizController/PhilipsWizController.cpp index e13ff39a..caad811a 100644 --- a/Controllers/PhilipsWizController/PhilipsWizController.cpp +++ b/Controllers/PhilipsWizController/PhilipsWizController.cpp @@ -10,13 +10,19 @@ using json = nlohmann::json; using namespace std::chrono_literals; -PhilipsWizController::PhilipsWizController(std::string ip) +PhilipsWizController::PhilipsWizController(std::string ip, bool use_cool, bool use_warm) { /*-----------------------------------------------------------------*\ | Fill in location string with device's IP address | \*-----------------------------------------------------------------*/ location = "IP: " + ip; + /*-----------------------------------------------------------------*\ + | Fill in settings | + \*-----------------------------------------------------------------*/ + use_cool_white = use_cool; + use_warm_white = use_warm; + /*-----------------------------------------------------------------*\ | Open a UDP client sending to the device's IP, port 38899 | \*-----------------------------------------------------------------*/ @@ -94,8 +100,23 @@ void PhilipsWizController::SetColor(unsigned char red, unsigned char green, unsi | correctly, set the cool white level to the average of RGB to | | improve its apparent brightness. | \*-----------------------------------------------------------------*/ - command["params"]["c"] = (red + green + blue) / 3; -// command["params"]["w"] = 0; + 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; + } /*-----------------------------------------------------------------*\ | Convert the JSON object to a string and write it | diff --git a/Controllers/PhilipsWizController/PhilipsWizController.h b/Controllers/PhilipsWizController/PhilipsWizController.h index aeeb09ab..065d192d 100644 --- a/Controllers/PhilipsWizController/PhilipsWizController.h +++ b/Controllers/PhilipsWizController/PhilipsWizController.h @@ -56,7 +56,7 @@ enum class PhilipsWizController { public: - PhilipsWizController(std::string ip); + PhilipsWizController(std::string ip, bool use_cool, bool use_warm); ~PhilipsWizController(); std::string GetLocation(); @@ -82,10 +82,8 @@ private: std::thread* ReceiveThread; std::atomic ReceiveThreadRun; - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned char brightness; + bool use_cool_white; + bool use_warm_white; void SendSetPilot(); }; diff --git a/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp b/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp index 83c8d77d..c77e1beb 100644 --- a/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp +++ b/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp @@ -33,9 +33,22 @@ void DetectPhilipsWizControllers() { if(wiz_settings["devices"][device_idx].contains("ip")) { - std::string wiz_ip = wiz_settings["devices"][device_idx]["ip"]; + std::string wiz_ip = wiz_settings["devices"][device_idx]["ip"]; - PhilipsWizController* controller = new PhilipsWizController(wiz_ip); + bool wiz_cool = false; + + if(wiz_settings["devices"][device_idx].contains("use_cool_white")) + { + wiz_cool = wiz_settings["devices"][device_idx]["use_cool_white"]; + } + + bool wiz_warm = false; + if(wiz_settings["devices"][device_idx].contains("use_warm_white")) + { + wiz_warm = wiz_settings["devices"][device_idx]["use_warm_white"]; + } + + PhilipsWizController* controller = new PhilipsWizController(wiz_ip, wiz_cool, wiz_warm); RGBController_PhilipsWiz* rgb_controller = new RGBController_PhilipsWiz(controller); ResourceManager::get()->RegisterRGBController(rgb_controller);