Merge pull request #257 from pckhib/patch-1

Update LedDevicePiBlaster.cpp

Former-commit-id: 8ca0054753652bddd61dde03bfa3ce143ba4649a
This commit is contained in:
tvdzwan 2015-02-23 15:38:56 +01:00
commit 0823ba4513
1 changed files with 9 additions and 5 deletions

View File

@ -80,11 +80,13 @@ int LedDevicePiBlaster::write(const std::vector<ColorRgb> & ledValues)
return -1; return -1;
} }
std::vector<int> iPins = {4, 17, 18, 27, 21, 22, 23, 24, 25};
unsigned colorIdx = 0; unsigned colorIdx = 0;
for (unsigned iChannel=0; iChannel<8; ++iChannel) for (std::vector<int>::iterator it = iPins.begin; it != iPins.end(); ++it)
{ {
double pwmDutyCycle = 0.0; double pwmDutyCycle = 0.0;
switch (_channelAssignment[iChannel]) switch (_channelAssignment[*it])
{ {
case 'r': case 'r':
pwmDutyCycle = ledValues[colorIdx].red / 255.0; pwmDutyCycle = ledValues[colorIdx].red / 255.0;
@ -117,11 +119,13 @@ int LedDevicePiBlaster::switchOff()
return -1; return -1;
} }
for (unsigned iChannel=0; iChannel<8; ++iChannel) std::vector<int> iPins = {4, 17, 18, 21, 22, 23, 24, 25};
for (std::vector<int>::iterator it = iPins.begin; it != iPins.end(); ++it)
{ {
if (_channelAssignment[iChannel] != ' ') if (_channelAssignment[*it] != ' ')
{ {
fprintf(_fid, "%i=%f\n", iChannel, 0.0); fprintf(_fid, "%i=%f\n", *it, 0.0);
fflush(_fid); fflush(_fid);
} }
} }