Fix previous commit

This commit is contained in:
Adam Honse 2019-12-27 12:28:18 -06:00
parent 9fc9059b0b
commit cdaae5fb9f
5 changed files with 77 additions and 1 deletions

View file

@ -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)

View file

@ -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);

View file

@ -0,0 +1,69 @@
#include "PolychromeController.h"
#include "RGBController.h"
#include "RGBController_Polychrome.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* 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<i2c_smbus_interface*>& busses, std::vector<RGBController*>& 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() */