Second attempt to fix the pi-blaster device

Former-commit-id: 53764c0169093bb50e0e9a64dc9112c3bebdf0f4
This commit is contained in:
T. van der Zwan 2015-03-20 21:11:39 +01:00
parent b3db42810c
commit a8c8a6a0d9

View File

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