common
include
breathColorMode.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 BREATHCOLORMODE_H
19
#define BREATHCOLORMODE_H
20
21
#include <
mode.h
>
22
23
class
BreathColorMode
:
public
Mode
24
{
25
public
:
26
BreathColorMode
(
color::rgba
color
,
int
priority = 0,
double
freq = 0.25,
int
pulses = 0,
double
timeout = 0)
27
:
Mode
(priority, freq, pulses, timeout),
_timer_inc
(0.0)
28
{
29
_color
=
color
;
30
h
= 0.0;
31
_inc
= ((M_PI*2) /
UPDATE_RATE_HZ
) *
_freq
;
32
}
33
34
void
execute
()
35
{
36
float
r = 0;
37
float
g = 0;
38
float
b = 0;
39
40
color::Color::hsv2rgb
(
h
, 1.0, 1.0, r, g, b);
41
42
h
+= 0.001;
43
if
(
h
> 1.0)
h
= 0.0;
44
45
//double fV = (exp(sin(_timer_inc))-1.0/M_E)*(1.000/(M_E-1.0/M_E));
46
double
fV = (exp(sin(
_timer_inc
))-0.36787944)*0.42545906411;
47
48
_timer_inc
+=
_inc
;
49
if
(
_timer_inc
>= M_PI*2)
50
{
51
_timer_inc
= 0.0;
52
_pulsed
++;
53
}
54
55
color::rgba
col;
56
col.
r
= r;
57
col.
g
= g;
58
col.
b
= b;
59
col.
a
= fV;
60
61
m_sigColorReady
(col);
62
}
63
64
std::string
getName
(){
return
std::string(
"BreathColorMode"
); }
65
66
private
:
67
double
_timer_inc
;
68
double
_inc
;
69
float
h
;
70
};
71
72
#endif
color
Definition:
colorUtils.h:24
BreathColorMode::getName
std::string getName()
Definition:
breathColorMode.h:64
BreathColorMode::_inc
double _inc
Definition:
breathColorMode.h:68
mode.h
color::rgba
Definition:
colorUtils.h:26
BreathColorMode::_timer_inc
double _timer_inc
Definition:
breathColorMode.h:67
BreathColorMode::h
float h
Definition:
breathColorMode.h:69
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
BreathColorMode
Definition:
breathColorMode.h:23
BreathColorMode::BreathColorMode
BreathColorMode(color::rgba color, int priority=0, double freq=0.25, int pulses=0, double timeout=0)
Definition:
breathColorMode.h:26
Mode
Definition:
mode.h:26
color::rgba::r
float r
Definition:
colorUtils.h:29
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
color::rgba::a
float a
Definition:
colorUtils.h:32
BreathColorMode::execute
void execute()
Definition:
breathColorMode.h:34
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