From 888239e910b5639f0fdabe0bde247b4dd1b9f27d Mon Sep 17 00:00:00 2001 From: "T. van der Zwan" Date: Mon, 23 Feb 2015 15:53:05 +0100 Subject: [PATCH] Fixed minor issue and removed unsued includes Former-commit-id: 87c86459a7a1be1705a837ee0f73e88c8de2ae53 --- libsrc/leddevice/LedDeviceAtmo.cpp | 24 +++++++++--------------- libsrc/leddevice/LedDevicePiBlaster.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAtmo.cpp b/libsrc/leddevice/LedDeviceAtmo.cpp index 22842233..dbcb48bd 100644 --- a/libsrc/leddevice/LedDeviceAtmo.cpp +++ b/libsrc/leddevice/LedDeviceAtmo.cpp @@ -1,21 +1,15 @@ // STL includes #include -#include #include -// Linux includes -#include -#include - // hyperion local includes #include "LedDeviceAtmo.h" LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate) : LedRs232Device(outputDevice, baudrate), - _ledBuffer(0) + _ledBuffer(4 + 5*3) // 4-byte header, 5 RGB values { - _ledBuffer.resize(4 + 3*5); _ledBuffer[0] = 0xFF; // Startbyte _ledBuffer[1] = 0x00; // StartChannel(Low) _ledBuffer[2] = 0x00; // StartChannel(High) @@ -24,16 +18,16 @@ LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned bau int LedDeviceAtmo::write(const std::vector &ledValues) { - // The protocol is shomehow limited. we always need to send exactly 5 channels + header - // (19 bytes) for the hardware to recognize the data - if (ledValues.size() != 5) - { - printf("AtmoLight: %d channels configured. This should always be 5!\n", ledValues.size()); - return 0; - } + // The protocol is shomehow limited. we always need to send exactly 5 channels + header + // (19 bytes) for the hardware to recognize the data + if (ledValues.size() != 5) + { + std::cerr << "AtmoLight: " << ledValues.size() << " channels configured. This should always be 5!" << std::endl; + return 0; + } // write data - memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3); + memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb)); return writeBytes(_ledBuffer.size(), _ledBuffer.data()); } diff --git a/libsrc/leddevice/LedDevicePiBlaster.cpp b/libsrc/leddevice/LedDevicePiBlaster.cpp index c73dcd41..7271931e 100644 --- a/libsrc/leddevice/LedDevicePiBlaster.cpp +++ b/libsrc/leddevice/LedDevicePiBlaster.cpp @@ -79,11 +79,11 @@ 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 (std::vector::iterator it = iPins.begin; it != iPins.end(); ++it) + for (std::vector::iterator it = iPins.begin(); it != iPins.end(); ++it) { double pwmDutyCycle = 0.0; switch (_channelAssignment[*it]) @@ -104,7 +104,7 @@ int LedDevicePiBlaster::write(const std::vector & ledValues) continue; } - fprintf(_fid, "%i=%f\n", iChannel, pwmDutyCycle); +// fprintf(_fid, "%i=%f\n", iChannel, pwmDutyCycle); fflush(_fid); } @@ -121,7 +121,7 @@ int LedDevicePiBlaster::switchOff() std::vector iPins = {4, 17, 18, 21, 22, 23, 24, 25}; - for (std::vector::iterator it = iPins.begin; it != iPins.end(); ++it) + for (std::vector::iterator it = iPins.begin(); it != iPins.end(); ++it) { if (_channelAssignment[*it] != ' ') {