Fixed minor issue and removed unsued includes

Former-commit-id: 87c86459a7a1be1705a837ee0f73e88c8de2ae53
This commit is contained in:
T. van der Zwan 2015-02-23 15:53:05 +01:00
parent 0823ba4513
commit 888239e910
2 changed files with 13 additions and 19 deletions

View File

@ -1,21 +1,15 @@
// STL includes
#include <cstring>
#include <cstdio>
#include <iostream>
// Linux includes
#include <fcntl.h>
#include <sys/ioctl.h>
// 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<ColorRgb> &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());
}

View File

@ -79,11 +79,11 @@ int LedDevicePiBlaster::write(const std::vector<ColorRgb> & ledValues)
{
return -1;
}
std::vector<int> iPins = {4, 17, 18, 27, 21, 22, 23, 24, 25};
unsigned colorIdx = 0;
for (std::vector<int>::iterator it = iPins.begin; it != iPins.end(); ++it)
for (std::vector<int>::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<ColorRgb> & 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<int> iPins = {4, 17, 18, 21, 22, 23, 24, 25};
for (std::vector<int>::iterator it = iPins.begin; it != iPins.end(); ++it)
for (std::vector<int>::iterator it = iPins.begin(); it != iPins.end(); ++it)
{
if (_channelAssignment[*it] != ' ')
{