Cleaned Up the Hue Controllers

This commit is contained in:
Dracrius 2022-03-25 22:45:03 +00:00 committed by Adam Honse
parent 19c2b98e8a
commit e0e2c9e20b
7 changed files with 93 additions and 64 deletions

View file

@ -4,7 +4,6 @@
| Adam Honse (calcprogrammer1@gmail.com), 9/15/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include "HueDeviceTypes.h"
#include <string>

View file

@ -121,6 +121,7 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
\*-------------------------------------------------*/
bool save_settings = false;
bool use_entertainment = false;
bool auto_connect = false;
if(hue_settings.contains("bridges"))
{
@ -155,9 +156,10 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
\*-------------------------------------------------*/
if(save_settings)
{
hue_settings["bridges"][0]["username"] = bridge.getUsername();
hue_settings["bridges"][0]["clientkey"] = bridge.getClientKey();
hue_settings["bridges"][0]["entertainment"] = use_entertainment;
hue_settings["bridges"][0]["username"] = bridge.getUsername();
hue_settings["bridges"][0]["clientkey"] = bridge.getClientKey();
hue_settings["bridges"][0]["entertainment"] = use_entertainment;
hue_settings["bridges"][0]["autoconnect"] = auto_connect;
ResourceManager::get()->GetSettingsManager()->SetSettings("PhilipsHueDevices", hue_settings);
@ -165,13 +167,18 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
}
/*-------------------------------------------------*\
| Get all groups from the bridge |
| Get entertainment mode settings |
\*-------------------------------------------------*/
if(hue_settings["bridges"][0].contains("entertainment"))
{
use_entertainment = hue_settings["bridges"][0]["entertainment"];
}
if(hue_settings["bridges"][0].contains("autoconnect"))
{
auto_connect = hue_settings["bridges"][0]["autoconnect"];
}
/*-------------------------------------------------*\
| Get all groups from the bridge |
\*-------------------------------------------------*/
@ -195,19 +202,22 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
}
}
/*-------------------------------------------------*\
| Loop through RGB Controllers to find the first |
| Entertainment group and Set it to "Connect", |
| as only one Stream can be open at a time. |
\*-------------------------------------------------*/
for (unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++)
{
if (rgb_controllers[controller_idx]->description == "Philips Hue Entertainment Mode Device")
{
rgb_controllers[controller_idx]->SetMode(0);
break;
}
}
/*-------------------------------------------------*\
| Loop through RGB Controllers to find the first |
| Entertainment group and Set it to "Connect", |
| as only one Stream can be open at a time. |
\*-------------------------------------------------*/
if(auto_connect)
{
for(unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++)
{
if(rgb_controllers[controller_idx]->description == "Philips Hue Entertainment Mode Device")
{
rgb_controllers[controller_idx]->SetMode(0);
break;
}
}
}
}
}

View file

@ -4,6 +4,7 @@
| Adam Honse (calcprogrammer1@gmail.com), 11/6/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include "PhilipsHueEntertainmentController.h"
PhilipsHueEntertainmentController::PhilipsHueEntertainmentController(hueplusplus::Bridge& bridge_ptr, hueplusplus::Group group_ptr):bridge(bridge_ptr),group(group_ptr)
@ -101,4 +102,4 @@ void PhilipsHueEntertainmentController::Disconnect()
delete entertainment;
}
}
}

View file

@ -4,7 +4,6 @@
| Adam Honse (calcprogrammer1@gmail.com), 11/6/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include "Bridge.h"
#include "EntertainmentMode.h"
#include "Group.h"

View file

@ -116,9 +116,9 @@ void RGBController_PhilipsHueEntertainment::DeviceUpdateMode()
{
std::vector<RGBController*> rgb_controllers = ResourceManager::get()->GetRGBControllers();
for (unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++)
for(unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++)
{
if (rgb_controllers[controller_idx] != this && rgb_controllers[controller_idx]->description == "Philips Hue Entertainment Mode Device" && rgb_controllers[controller_idx]->active_mode == 0)
if(rgb_controllers[controller_idx] != this && rgb_controllers[controller_idx]->description == "Philips Hue Entertainment Mode Device" && rgb_controllers[controller_idx]->active_mode == 0)
{
rgb_controllers[controller_idx]->SetMode(1);
}

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>207</height>
<width>297</width>
<height>228</height>
</rect>
</property>
<property name="sizePolicy">
@ -26,13 +26,6 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="EntertainmentLabel">
<property name="text">
@ -40,30 +33,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="UsernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="UsernameValue">
<property name="text">
<string></string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="MACEdit"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="ClientKeyLabel">
<property name="text">
<string>Client Key:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="EntertainmentCheckBox">
<property name="text">
@ -71,13 +40,45 @@
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="6" column="0" colspan="4">
<widget class="QPushButton" name="UnpairButton">
<item row="4" column="0">
<widget class="QLabel" name="AutoConnectLabel">
<property name="text">
<string>Unpair Bridge</string>
<string>Auto Connect Group:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="AutoConnectCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="IPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLabel" name="ClientKeyValue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="ClientKeyLabel">
<property name="text">
<string>Client Key:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="UsernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
@ -88,10 +89,23 @@
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="ClientKeyValue">
<item row="7" column="0" colspan="4">
<widget class="QPushButton" name="UnpairButton">
<property name="text">
<string></string>
<string>Unpair Bridge</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="MACEdit"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="IPEdit"/>
</item>
<item row="5" column="3">
<widget class="QLabel" name="UsernameValue">
<property name="text">
<string/>
</property>
</widget>
</item>

View file

@ -41,6 +41,11 @@ OpenRGBPhilipsHueSettingsPage::OpenRGBPhilipsHueSettingsPage(QWidget *parent) :
entry->ui->EntertainmentCheckBox->setChecked(hue_settings["bridges"][device_idx]["entertainment"]);
}
if(hue_settings["bridges"][device_idx].contains("autoconnect"))
{
entry->ui->AutoConnectCheckBox->setChecked(hue_settings["bridges"][device_idx]["autoconnect"]);
}
if(hue_settings["bridges"][device_idx].contains("username"))
{
entry->ui->UsernameValue->setText(QString::fromStdString(hue_settings["bridges"][device_idx]["username"]));
@ -120,6 +125,7 @@ void Ui::OpenRGBPhilipsHueSettingsPage::on_SavePhilipsHueConfigurationButton_cli
hue_settings["bridges"][device_idx]["ip"] = entries[device_idx]->ui->IPEdit->text().toStdString();
hue_settings["bridges"][device_idx]["mac"] = entries[device_idx]->ui->MACEdit->text().toStdString();
hue_settings["bridges"][device_idx]["entertainment"] = entries[device_idx]->ui->EntertainmentCheckBox->isChecked();
hue_settings["bridges"][device_idx]["autoconnect"] = entries[device_idx]->ui->AutoConnectCheckBox->isChecked();
if(entries[device_idx]->ui->UsernameValue->text() != "")
{