common
include
fadeColorMode.h
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
#ifndef FADECOLORMODE_H
19
#define FADECOLORMODE_H
20
21
#include <
mode.h
>
22
23
class
FadeColorMode
:
public
Mode
24
{
25
public
:
26
FadeColorMode
(
color::rgba
color
,
int
priority = 0,
double
freq = 0.25,
int
pulses = 0,
double
timeout = 0)
27
:
Mode
(priority, freq, pulses, timeout)
28
{
29
_color
=
color
;
30
31
doOnce
=
true
;
32
h
= 0.0;
33
h_s
= 0.0;
34
h_t
= 0.0;
35
36
_inc
= (1. /
UPDATE_RATE_HZ
) *
_freq
;
37
}
38
39
void
execute
()
40
{
41
float
r = 0;
42
float
g = 0;
43
float
b = 0;
44
float
s
, v;
45
46
if
(
doOnce
==
true
)
47
{
48
color::Color::rgb2hsv
(
_color
.
r
,
_color
.
g
,
_color
.
b
,
h
,
s
, v);
49
h_s
=
h
;
50
h_t
=
h
;
51
h_s
+= 1;
52
doOnce
=
false
;
53
}
54
55
color::Color::hsv2rgb
(
h
, 1.0, 1.0, r, g, b);
56
57
h
+=
_inc
;
58
h_t
+=
_inc
;
59
if
(
h
> 1.0)
60
h
= 0.0;
61
62
if
(
h_t
>=
h_s
)
63
{
64
_pulsed
++;
h_s
+=1;
65
}
66
67
color::rgba
col;
68
col.
r
= r;
69
col.
g
= g;
70
col.
b
= b;
71
col.
a
=
_color
.
a
;
72
73
m_sigColorReady
(col);
74
}
75
76
std::string
getName
(){
return
std::string(
"FadeColorMode"
); }
77
78
private
:
79
bool
doOnce
;
80
float
h
;
81
float
h_s
;
82
float
h_t
;
83
double
_inc
;
84
};
85
86
#endif
FadeColorMode::execute
void execute()
Definition:
fadeColorMode.h:39
FadeColorMode::h_t
float h_t
Definition:
fadeColorMode.h:82
color
Definition:
colorUtils.h:24
s
XmlRpcServer s
mode.h
color::rgba
Definition:
colorUtils.h:26
FadeColorMode::h_s
float h_s
Definition:
fadeColorMode.h:81
color::rgba::g
float g
Definition:
colorUtils.h:30
Mode::UPDATE_RATE_HZ
static const unsigned int UPDATE_RATE_HZ
Definition:
mode.h:126
color::rgba::b
float b
Definition:
colorUtils.h:31
FadeColorMode::doOnce
bool doOnce
Definition:
fadeColorMode.h:79
color::Color::rgb2hsv
static void rgb2hsv(float r, float g, float b, float &h, float &s, float &v)
Definition:
colorUtils.h:54
FadeColorMode::FadeColorMode
FadeColorMode(color::rgba color, int priority=0, double freq=0.25, int pulses=0, double timeout=0)
Definition:
fadeColorMode.h:26
FadeColorMode::h
float h
Definition:
fadeColorMode.h:80
Mode
Definition:
mode.h:26
color::rgba::r
float r
Definition:
colorUtils.h:29
FadeColorMode::getName
std::string getName()
Definition:
fadeColorMode.h:76
Mode::_color
color::rgba _color
Definition:
mode.h:121
Mode::m_sigColorReady
boost::signals2::signal< void(color::rgba color)> m_sigColorReady
Definition:
mode.h:128
Mode::_pulsed
int _pulsed
Definition:
mode.h:119
FadeColorMode::_inc
double _inc
Definition:
fadeColorMode.h:83
color::rgba::a
float a
Definition:
colorUtils.h:32
FadeColorMode
Definition:
fadeColorMode.h:23
color::Color::hsv2rgb
static void hsv2rgb(float h, float s, float v, float &r, float &g, float &b)
Definition:
colorUtils.h:81
Mode::_freq
double _freq
Definition:
mode.h:114
cob_light
Author(s): Benjamin Maidel
autogenerated on Wed Nov 8 2023 03:47:37