Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 87c8645

Browse files
committed
Fixed minor issue and removed unsued includes
1 parent 8ca0054 commit 87c8645

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

libsrc/leddevice/LedDeviceAtmo.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11

22
// STL includes
33
#include <cstring>
4-
#include <cstdio>
54
#include <iostream>
65

7-
// Linux includes
8-
#include <fcntl.h>
9-
#include <sys/ioctl.h>
10-
116
// hyperion local includes
127
#include "LedDeviceAtmo.h"
138

149
LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate) :
1510
LedRs232Device(outputDevice, baudrate),
16-
_ledBuffer(0)
11+
_ledBuffer(4 + 5*3) // 4-byte header, 5 RGB values
1712
{
18-
_ledBuffer.resize(4 + 3*5);
1913
_ledBuffer[0] = 0xFF; // Startbyte
2014
_ledBuffer[1] = 0x00; // StartChannel(Low)
2115
_ledBuffer[2] = 0x00; // StartChannel(High)
@@ -24,16 +18,16 @@ LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned bau
2418

2519
int LedDeviceAtmo::write(const std::vector<ColorRgb> &ledValues)
2620
{
27-
// The protocol is shomehow limited. we always need to send exactly 5 channels + header
28-
// (19 bytes) for the hardware to recognize the data
29-
if (ledValues.size() != 5)
30-
{
31-
printf("AtmoLight: %d channels configured. This should always be 5!\n", ledValues.size());
32-
return 0;
33-
}
21+
// The protocol is shomehow limited. we always need to send exactly 5 channels + header
22+
// (19 bytes) for the hardware to recognize the data
23+
if (ledValues.size() != 5)
24+
{
25+
std::cerr << "AtmoLight: " << ledValues.size() << " channels configured. This should always be 5!" << std::endl;
26+
return 0;
27+
}
3428

3529
// write data
36-
memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
30+
memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb));
3731
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
3832
}
3933

libsrc/leddevice/LedDevicePiBlaster.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ int LedDevicePiBlaster::write(const std::vector<ColorRgb> & ledValues)
7979
{
8080
return -1;
8181
}
82-
82+
8383
std::vector<int> iPins = {4, 17, 18, 27, 21, 22, 23, 24, 25};
8484

8585
unsigned colorIdx = 0;
86-
for (std::vector<int>::iterator it = iPins.begin; it != iPins.end(); ++it)
86+
for (std::vector<int>::iterator it = iPins.begin(); it != iPins.end(); ++it)
8787
{
8888
double pwmDutyCycle = 0.0;
8989
switch (_channelAssignment[*it])
@@ -104,7 +104,7 @@ int LedDevicePiBlaster::write(const std::vector<ColorRgb> & ledValues)
104104
continue;
105105
}
106106

107-
fprintf(_fid, "%i=%f\n", iChannel, pwmDutyCycle);
107+
// fprintf(_fid, "%i=%f\n", iChannel, pwmDutyCycle);
108108
fflush(_fid);
109109
}
110110

@@ -121,7 +121,7 @@ int LedDevicePiBlaster::switchOff()
121121

122122
std::vector<int> iPins = {4, 17, 18, 21, 22, 23, 24, 25};
123123

124-
for (std::vector<int>::iterator it = iPins.begin; it != iPins.end(); ++it)
124+
for (std::vector<int>::iterator it = iPins.begin(); it != iPins.end(); ++it)
125125
{
126126
if (_channelAssignment[*it] != ' ')
127127
{

0 commit comments

Comments
 (0)