From 2076675e8d25d0850937da7972415441b054c412 Mon Sep 17 00:00:00 2001 From: pckhib Date: Mon, 9 Feb 2015 23:11:59 +0100 Subject: [PATCH] Update LedDevicePiBlaster.cpp updated for the new version of pi-blaster Former-commit-id: 668084eefcb05f58e1f2e0ef6fc97ead2e540a65 --- libsrc/leddevice/LedDevicePiBlaster.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libsrc/leddevice/LedDevicePiBlaster.cpp b/libsrc/leddevice/LedDevicePiBlaster.cpp index 6bdcf726..c73dcd41 100644 --- a/libsrc/leddevice/LedDevicePiBlaster.cpp +++ b/libsrc/leddevice/LedDevicePiBlaster.cpp @@ -79,12 +79,14 @@ int LedDevicePiBlaster::write(const std::vector & ledValues) { return -1; } + + std::vector iPins = {4, 17, 18, 27, 21, 22, 23, 24, 25}; unsigned colorIdx = 0; - for (unsigned iChannel=0; iChannel<8; ++iChannel) + for (std::vector::iterator it = iPins.begin; it != iPins.end(); ++it) { double pwmDutyCycle = 0.0; - switch (_channelAssignment[iChannel]) + switch (_channelAssignment[*it]) { case 'r': pwmDutyCycle = ledValues[colorIdx].red / 255.0; @@ -117,11 +119,13 @@ int LedDevicePiBlaster::switchOff() return -1; } - for (unsigned iChannel=0; iChannel<8; ++iChannel) + std::vector iPins = {4, 17, 18, 21, 22, 23, 24, 25}; + + for (std::vector::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); } }