mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fixed minor issue and removed unsued includes
Former-commit-id: 87c86459a7a1be1705a837ee0f73e88c8de2ae53
This commit is contained in:
parent
0823ba4513
commit
888239e910
@ -1,21 +1,15 @@
|
|||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Linux includes
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
// hyperion local includes
|
// hyperion local includes
|
||||||
#include "LedDeviceAtmo.h"
|
#include "LedDeviceAtmo.h"
|
||||||
|
|
||||||
LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate) :
|
LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate) :
|
||||||
LedRs232Device(outputDevice, 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[0] = 0xFF; // Startbyte
|
||||||
_ledBuffer[1] = 0x00; // StartChannel(Low)
|
_ledBuffer[1] = 0x00; // StartChannel(Low)
|
||||||
_ledBuffer[2] = 0x00; // StartChannel(High)
|
_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)
|
int LedDeviceAtmo::write(const std::vector<ColorRgb> &ledValues)
|
||||||
{
|
{
|
||||||
// The protocol is shomehow limited. we always need to send exactly 5 channels + header
|
// The protocol is shomehow limited. we always need to send exactly 5 channels + header
|
||||||
// (19 bytes) for the hardware to recognize the data
|
// (19 bytes) for the hardware to recognize the data
|
||||||
if (ledValues.size() != 5)
|
if (ledValues.size() != 5)
|
||||||
{
|
{
|
||||||
printf("AtmoLight: %d channels configured. This should always be 5!\n", ledValues.size());
|
std::cerr << "AtmoLight: " << ledValues.size() << " channels configured. This should always be 5!" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write data
|
// 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());
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,11 +79,11 @@ 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};
|
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 (std::vector<int>::iterator it = iPins.begin(); it != iPins.end(); ++it)
|
||||||
{
|
{
|
||||||
double pwmDutyCycle = 0.0;
|
double pwmDutyCycle = 0.0;
|
||||||
switch (_channelAssignment[*it])
|
switch (_channelAssignment[*it])
|
||||||
@ -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", iChannel, pwmDutyCycle);
|
||||||
fflush(_fid);
|
fflush(_fid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ 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 (std::vector<int>::iterator it = iPins.begin(); it != iPins.end(); ++it)
|
||||||
{
|
{
|
||||||
if (_channelAssignment[*it] != ' ')
|
if (_channelAssignment[*it] != ' ')
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user