ros
src
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
21
ColorO::ColorO
(
SerialIO
* serialIO)
22
{
23
_serialIO
= serialIO;
24
}
25
26
ColorO::~ColorO
()
27
{
28
}
29
30
bool
ColorO::init
()
31
{
32
return
true
;
33
}
34
35
void
ColorO::setColorMulti
(std::vector<color::rgba> &colors)
36
{
37
38
}
39
40
void
ColorO::setColor
(
color::rgba
color
)
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
}
color
Definition:
colorUtils.h:24
ColorO::setColorMulti
void setColorMulti(std::vector< color::rgba > &colors)
Definition:
colorO.cpp:35
IColorO::_invertMask
int _invertMask
Definition:
iColorO.h:43
ColorO::ColorO
ColorO(SerialIO *serialIO)
Definition:
colorO.cpp:21
ros.h
ColorO::_ssOut
std::stringstream _ssOut
Definition:
colorO.h:39
SerialIO
Definition:
serialIO.h:39
ColorO::~ColorO
virtual ~ColorO()
Definition:
colorO.cpp:26
ColorO::init
bool init()
Definition:
colorO.cpp:30
IColorO::m_sigColorSet
boost::signals2::signal< void(color::rgba color)> m_sigColorSet
Definition:
iColorO.h:45
SerialIO::sendData
int sendData(std::string value)
Definition:
serialIO.cpp:63
color::rgba
Definition:
colorUtils.h:26
ColorO::setColor
void setColor(color::rgba color)
Definition:
colorO.cpp:40
ROS_DEBUG
#define ROS_DEBUG(...)
ROS_WARN
#define ROS_WARN(...)
colorO.h
ColorO::_serialIO
SerialIO * _serialIO
Definition:
colorO.h:38
cob_light
Author(s): Benjamin Maidel
autogenerated on Wed Nov 8 2023 03:47:37