20 #include <boost/cstdint.hpp> 21 #include <boost/integer.hpp> 38 const char init_data[] = {
'C',
'?' };
39 int init_len =
sizeof(init_data) /
sizeof(init_data[0]);
43 memcpy(&init_buf, init_data, init_len);
51 ROS_ERROR(
"Sending init command to stageprofi failed");
59 color_tmp.
r *= color.
a;
60 color_tmp.
g *= color.
a;
61 color_tmp.
b *= color.
a;
63 color_tmp.
r = fabs(color_tmp.
r * 255);
64 color_tmp.
g = fabs(color_tmp.
g * 255);
65 color_tmp.
b = fabs(color_tmp.
b * 255);
67 unsigned int num_channels =
_num_leds * 3;
68 char channelbuffer[num_channels];
72 channelbuffer[i * 3] = (int) color_tmp.
r;
73 channelbuffer[i * 3 + 1] = (
int) color_tmp.
g;
74 channelbuffer[i * 3 + 2] = (int) color_tmp.
b;
78 while (index < num_channels)
80 unsigned int size = std::min((
unsigned int)
MAX_CHANNELS,
81 num_channels - index);
82 if (
sendDMX(index, channelbuffer + index, size))
86 ROS_ERROR(
"Sending color to stageprofi failed");
97 unsigned int num_channels =
_num_leds * 3;
98 char channelbuffer[num_channels];
100 std::vector<color::rgba> color_out = colors;
105 std::rotate(color_out.begin(), color_out.begin()+
_led_offset, color_out.end());
107 std::rotate(color_out.begin(), color_out.begin()+color_out.size()+
_led_offset, color_out.end());
110 for (
int i = 0; i <
_num_leds || i < colors.size(); i++)
112 color_tmp.
r = color_out[i].r * color_out[i].a;
113 color_tmp.
g = color_out[i].g * color_out[i].a;
114 color_tmp.
b = color_out[i].b * color_out[i].a;
116 color_tmp.
r = fabs(color_tmp.
r * 255);
117 color_tmp.
g = fabs(color_tmp.
g * 255);
118 color_tmp.
b = fabs(color_tmp.
b * 255);
120 channelbuffer[i * 3] = (int) color_tmp.
r;
121 channelbuffer[i * 3 + 1] = (
int) color_tmp.
g;
122 channelbuffer[i * 3 + 2] = (int) color_tmp.
b;
126 while (index < num_channels)
128 unsigned int size = std::min((
unsigned int)
MAX_CHANNELS,
129 num_channels - index);
130 if (
sendDMX(index, channelbuffer + index, size))
134 ROS_ERROR(
"Sending color to stageprofi failed");
148 unsigned int len = std::min((
unsigned int)
MAX_CHANNELS, length);
151 msg[1] = start & 0xFF;
152 msg[2] = (start >> 8) & 0xFF;
168 ROS_WARN(
"Trying to recover stagedriver");
StageProfi(SerialIO *serialIO, unsigned int leds, int led_offset)
static const unsigned int HEADER_SIZE
bool sendDMX(uint16_t start, const char *buf, unsigned int length)
void setColor(color::rgba color)
void setColorMulti(std::vector< color::rgba > &colors)
int sendData(std::string value)
boost::signals2::signal< void(color::rgba color)> m_sigColorSet
int readData(std::string &value, size_t nBytes)
static const unsigned int MAX_CHANNELS