diff --git a/Controllers/PolychromeController/PolychromeController.cpp b/Controllers/PolychromeController/PolychromeController.cpp index 111f84d2..849ba5ad 100644 --- a/Controllers/PolychromeController/PolychromeController.cpp +++ b/Controllers/PolychromeController/PolychromeController.cpp @@ -74,6 +74,11 @@ unsigned int PolychromeController::GetLEDCount() return(led_count); } +unsigned int PolychromeController::GetMode() +{ + return(0); +} + void PolychromeController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue) { if (asr_led) diff --git a/Controllers/PolychromeController/PolychromeController.h b/Controllers/PolychromeController/PolychromeController.h index db9b73cd..60ec8ab0 100644 --- a/Controllers/PolychromeController/PolychromeController.h +++ b/Controllers/PolychromeController/PolychromeController.h @@ -76,6 +76,7 @@ public: char* GetDeviceName(); unsigned int GetLEDCount(); + unsigned int GetMode(); void SetAllColors(unsigned char red, unsigned char green, unsigned char blue); void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue); void SetMode(unsigned char mode); diff --git a/Controllers/PolychromeController/PolychromeControllerDetect.cpp b/Controllers/PolychromeController/PolychromeControllerDetect.cpp new file mode 100644 index 00000000..86800a1e --- /dev/null +++ b/Controllers/PolychromeController/PolychromeControllerDetect.cpp @@ -0,0 +1,69 @@ +#include "PolychromeController.h" +#include "RGBController.h" +#include "RGBController_Polychrome.h" +#include "i2c_smbus.h" +#include +#include +#include + +/******************************************************************************************\ +* * +* TestForPolychromeController * +* * +* Tests the given address to see if an ASRock Polychrome RGB controller exists there.* +* First does a quick write to test for a response * +* * +\******************************************************************************************/ + +bool TestForPolychromeController(i2c_smbus_interface* bus, unsigned char address) +{ + bool pass = false; + + int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); + + if (res >= 0) + { + pass = true; + } + + return(pass); + +} /* TestForPolychromeController() */ + +/******************************************************************************************\ +* * +* DetectPolychromeControllers * +* * +* Detect ASRock Polychrome RGB controllers on the enumerated I2C busses at address * +* 0x6A. * +* * +* bus - pointer to i2c_smbus_interface where Polychrome device is connected * +* dev - I2C address of Polychrome device * +* * +\******************************************************************************************/ + +void DetectPolychromeControllers(std::vector& busses, std::vector& rgb_controllers) +{ + PolychromeController* new_polychrome; + RGBController_Polychrome* new_controller; + + for (unsigned int bus = 0; bus < busses.size(); bus++) + { + // Check for Polychrome controller at 0x6A + if (TestForPolychromeController(busses[bus], 0x6A)) + { + new_polychrome = new PolychromeController(busses[bus], 0x6A); + + if(new_polychrome->GetLEDCount() != 0) + { + new_controller = new RGBController_Polychrome(new_polychrome); + rgb_controllers.push_back(new_controller); + } + else + { + delete new_polychrome; + } + } + } + +} /* DetectPolychromeControllers() */ diff --git a/OpenRGB.pro b/OpenRGB.pro index d86e4e53..514106d6 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -60,6 +60,7 @@ SOURCES += \ RGBController/RGBController_HuePlus.cpp \ RGBController/RGBController_HyperX.cpp \ RGBController/RGBController_LEDStrip.cpp \ + RGBController/RGBController_Polychrome.cpp \ RGBController/RGBController_RGBFusion.cpp HEADERS += \ diff --git a/RGBController/RGBController_Polychrome.cpp b/RGBController/RGBController_Polychrome.cpp index a817965c..ca66fc96 100644 --- a/RGBController/RGBController_Polychrome.cpp +++ b/RGBController/RGBController_Polychrome.cpp @@ -109,4 +109,4 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr // Push new zone to zones vector zones.push_back(*new_zone); } -} \ No newline at end of file +}