colorO.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include <colorO.h>
19 #include <ros/ros.h>
20 
22 {
23  _serialIO = serialIO;
24 }
25 
27 {
28 }
29 
31 {
32  return true;
33 }
34 
35 void ColorO::setColorMulti(std::vector<color::rgba> &colors)
36 {
37 
38 }
39 
41 {
42  int bytes_wrote = 0;
43 
44  color::rgba color_tmp = color;
45 
46  //calculate rgb spektrum for spezific alpha value, because
47  //led board is not supporting alpha values
48  color.r *= color.a;
49  color.g *= color.a;
50  color.b *= color.a;
51  //led board value spektrum is from 0 - 999.
52  //at r@w's led strip, 0 means fully lighted and 999 light off(_invertMask)
53  color.r = (fabs(_invertMask-color.r) * 999.0);
54  color.g = (fabs(_invertMask-color.g) * 999.0);
55  color.b = (fabs(_invertMask-color.b) * 999.0);
56 
57  _ssOut.clear();
58  _ssOut.str("");
59  _ssOut << (int)color.r << " " << (int)color.g << " " << (int)color.b << "\n\r";
60 
61  // send data over serial port
62  bytes_wrote = _serialIO->sendData(_ssOut.str());
63  if(bytes_wrote == -1)
64  {
65  ROS_WARN("Can not write to serial port. Port closed!");
66  }
67  else
68  {
69  ROS_DEBUG("Wrote [%s] with %i bytes from %i bytes", \
70  _ssOut.str().c_str(), bytes_wrote, (int)_ssOut.str().length());
71  m_sigColorSet(color_tmp);
72  }
73 }
void setColor(color::rgba color)
Definition: colorO.cpp:40
#define ROS_WARN(...)
virtual ~ColorO()
Definition: colorO.cpp:26
SerialIO * _serialIO
Definition: colorO.h:38
int sendData(std::string value)
Definition: serialIO.cpp:63
void setColorMulti(std::vector< color::rgba > &colors)
Definition: colorO.cpp:35
ColorO(SerialIO *serialIO)
Definition: colorO.cpp:21
boost::signals2::signal< void(color::rgba color)> m_sigColorSet
Definition: iColorO.h:45
std::stringstream _ssOut
Definition: colorO.h:39
bool init()
Definition: colorO.cpp:30
int _invertMask
Definition: iColorO.h:43
#define ROS_DEBUG(...)


cob_light
Author(s): Benjamin Maidel
autogenerated on Wed Apr 7 2021 02:11:39