Add options to use warm and cool white channels on Philips Wiz
This commit is contained in:
parent
2c7baaa1ef
commit
89f13d9ec9
3 changed files with 42 additions and 10 deletions
|
|
@ -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 |
|
||||
|
|
|
|||
|
|
@ -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<bool> ReceiveThreadRun;
|
||||
|
||||
unsigned char red;
|
||||
unsigned char green;
|
||||
unsigned char blue;
|
||||
unsigned char brightness;
|
||||
bool use_cool_white;
|
||||
bool use_warm_white;
|
||||
|
||||
void SendSetPilot();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue