Changed the constructor of LedDeviceW2801 (only incl required parameters)

Changed the call sign of the write functions (included const declaration of color parameter)
This commit is contained in:
T. van der Zwan 2013-09-09 15:23:44 +00:00
parent 8441dd51cc
commit db708da60a
3 changed files with 7 additions and 9 deletions

View File

@ -70,7 +70,7 @@ public:
/// @param[in] ledColor The color to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
///
void setColor(int priority, RgbColor &ledColor, const int timeout_ms);
void setColor(int priority, const RgbColor &ledColor, const int timeout_ms);
///
/// Writes the given colors to all leds for the given time and priority
@ -79,7 +79,7 @@ public:
/// @param[in] ledColors The colors to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
///
void setColors(int priority, std::vector<RgbColor> &ledColors, const int timeout_ms);
void setColors(int priority, const std::vector<RgbColor> &ledColors, const int timeout_ms);
///
/// Sets/Updates a part of the color transformation.

View File

@ -22,12 +22,10 @@ LedDevice* Hyperion::constructDevice(const Json::Value& deviceConfig)
LedDevice* device = nullptr;
if (deviceConfig["type"].asString() == "ws2801")
{
const std::string name = "WS-2801";
const std::string output = deviceConfig["output"].asString();
const unsigned interval = deviceConfig["interval"].asInt();
const unsigned rate = deviceConfig["rate"].asInt();
LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(name, output, interval, rate);
LedDeviceWs2801* deviceWs2801 = new LedDeviceWs2801(output, rate);
deviceWs2801->open();
device = deviceWs2801;
@ -117,7 +115,7 @@ unsigned Hyperion::getLedCount() const
return _ledString.leds().size();
}
void Hyperion::setColor(int priority, RgbColor & color, const int timeout_ms)
void Hyperion::setColor(int priority, const RgbColor &color, const int timeout_ms)
{
// create led output
std::vector<RgbColor> ledColors(_ledString.leds().size(), color);
@ -126,7 +124,7 @@ void Hyperion::setColor(int priority, RgbColor & color, const int timeout_ms)
setColors(priority, ledColors, timeout_ms);
}
void Hyperion::setColors(int priority, std::vector<RgbColor>& ledColors, const int timeout_ms)
void Hyperion::setColors(int priority, const std::vector<RgbColor>& ledColors, const int timeout_ms)
{
if (timeout_ms > 0)
{

View File

@ -54,7 +54,7 @@ void setColor(char* colorStr)
unsigned ledCnt = 50;
std::vector<RgbColor> buff(ledCnt, color);
LedDeviceWs2801 ledDevice("SpiPi", "/dev/spidev0.0", 20000, 40000);
LedDeviceWs2801 ledDevice("/dev/spidev0.0", 40000);
ledDevice.open();
ledDevice.write(buff);
}
@ -68,7 +68,7 @@ void doCircle()
unsigned ledCnt = 50;
std::vector<RgbColor> data(ledCnt, RgbColor::BLACK);
LedDeviceWs2801 ledDevice("SpiPi", "/dev/spidev0.0", 20000, 40000);
LedDeviceWs2801 ledDevice("/dev/spidev0.0", 40000);
ledDevice.open();
timespec loopTime;