Fixed call to thinkerforge library

Former-commit-id: e2764d3ecbf7d462ad5d967572b3ea37548fec73
This commit is contained in:
T. van der Zwan 2014-03-08 19:55:23 +01:00
parent cbd354c18f
commit e549e15c3f

View File

@ -106,7 +106,6 @@ int LedDeviceTinkerforge::write(const std::vector<ColorRgb> &ledValues)
int LedDeviceTinkerforge::switchOff() int LedDeviceTinkerforge::switchOff()
{ {
std::cerr << "Switchoff" << std::endl;
std::fill(_redChannel.begin(), _redChannel.end(), 0); std::fill(_redChannel.begin(), _redChannel.end(), 0);
std::fill(_greenChannel.begin(), _greenChannel.end(), 0); std::fill(_greenChannel.begin(), _greenChannel.end(), 0);
std::fill(_blueChannel.begin(), _blueChannel.end(), 0); std::fill(_blueChannel.begin(), _blueChannel.end(), 0);
@ -121,17 +120,18 @@ int LedDeviceTinkerforge::transferLedData(LEDStrip *ledStrip, unsigned index, un
return E_INVALID_PARAMETER; return E_INVALID_PARAMETER;
} }
uint8_t * redPtr = redChannel; uint8_t reds[MAX_NUM_LEDS_SETTABLE];
uint8_t * greenPtr = greenChannel; uint8_t greens[MAX_NUM_LEDS_SETTABLE];
uint8_t * bluePtr = blueChannel; uint8_t blues[MAX_NUM_LEDS_SETTABLE];
for (unsigned i=index; i<length; i+=MAX_NUM_LEDS_SETTABLE) for (unsigned i=index; i<length; i+=MAX_NUM_LEDS_SETTABLE)
{ {
const unsigned copyLength = (i + MAX_NUM_LEDS_SETTABLE > length) ? length - i : MAX_NUM_LEDS_SETTABLE; const unsigned copyLength = (i + MAX_NUM_LEDS_SETTABLE > length) ? length - i : MAX_NUM_LEDS_SETTABLE;
const int status = led_strip_set_rgb_values(ledStrip, i, copyLength, redPtr, greenPtr, bluePtr); memcpy(reds, redChannel + i, copyLength);
redPtr += copyLength; memcpy(greens, greenChannel + i, copyLength);
greenPtr += copyLength; memcpy(blues, blueChannel + i, copyLength);
bluePtr += copyLength;
const int status = led_strip_set_rgb_values(ledStrip, i, copyLength, reds, greens, blues);
if (status != E_OK) if (status != E_OK)
{ {
std::cerr << "Setting led values failed with status " << status << std::endl; std::cerr << "Setting led values failed with status " << status << std::endl;