Main Page
+
Namespaces
Namespace List
+
Namespace Members
All
Functions
+
Classes
Class List
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
u
v
w
x
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
w
x
~
+
Variables
_
a
b
c
d
g
h
l
m
p
r
s
t
u
v
Typedefs
+
Files
File List
+
File Members
All
Functions
Variables
Typedefs
Enumerations
Enumerator
common
include
kitMode.h
Go to the documentation of this file.
1
/*
2
* Copyright 2021 Mojin Robotics GmbH https://www.mojin-robotics.de
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 KITMODE_H
19
#define KITMODE_H
20
21
#include <
mode.h
>
22
23
class
KitMode
:
public
Mode
24
{
25
public
:
26
KitMode
(
color::rgba
color
,
size_t
num_leds,
int
priority = 0,
double
freq = 0.25,
int
pulses = 0,
double
timeout = 0)
27
:
Mode
(priority, freq, pulses, timeout),
_num_leds
(num_leds)
28
{
29
_inc
= (1. /
UPDATE_RATE_HZ
) *
_freq
;
30
31
_color
= color;
32
_colors
.assign(num_leds,
color::rgba
());
33
_colors
[0] = color;
34
_pos
= 0;
35
_dir
= 1;
36
_fade_fac
= 0.8;
37
}
38
39
void
execute
()
40
{
41
if
(
_timer_inc
>= 1.0)
42
{
43
for
(
int
i = 0; i <
_num_leds
; i++)
44
{
45
46
_colors
[i].a =
_colors
[i].a *
_fade_fac
;
47
}
48
for
(
int
j = 0; j < 5; j++)
49
{
50
_pos
+=
_dir
;
51
if
(
_pos
== -1)
52
{
53
_pos
= 0;
54
_dir
= 1;
55
}
56
else
if
(
_pos
== _num_leds)
57
{
58
_pos
= _num_leds-1;
59
_dir
= -1;
60
}
61
62
_colors
[
_pos
] =
_color
;
63
64
}
65
m_sigColorsReady
(
_colors
);
66
67
_timer_inc
= 0.0;
68
}
69
else
70
_timer_inc
+=
_inc
;
71
72
}
73
74
std::string
getName
(){
return
std::string(
"KitMode"
); }
75
76
private
:
77
double
_timer_inc
;
78
double
_inc
;
79
double
_pos
;
80
double
_dir
;
81
int
_num_leds
;
82
double
_fade_fac
;
83
};
84
85
#endif
KitMode::_pos
double _pos
Definition:
kitMode.h:79
KitMode::getName
std::string getName()
Definition:
kitMode.h:74
Mode::_color
color::rgba _color
Definition:
mode.h:121
Mode::_colors
std::vector< color::rgba > _colors
Definition:
mode.h:122
Mode
Definition:
mode.h:26
Mode::UPDATE_RATE_HZ
static const unsigned int UPDATE_RATE_HZ
Definition:
mode.h:126
KitMode::_timer_inc
double _timer_inc
Definition:
kitMode.h:77
KitMode::_inc
double _inc
Definition:
kitMode.h:78
KitMode::_num_leds
int _num_leds
Definition:
kitMode.h:81
KitMode
Definition:
kitMode.h:23
Mode::_freq
double _freq
Definition:
mode.h:114
KitMode::_fade_fac
double _fade_fac
Definition:
kitMode.h:82
Mode::m_sigColorsReady
boost::signals2::signal< void(std::vector< color::rgba > &colors)> m_sigColorsReady
Definition:
mode.h:129
KitMode::_dir
double _dir
Definition:
kitMode.h:80
color::rgba
Definition:
colorUtils.h:26
mode.h
KitMode::execute
void execute()
Definition:
kitMode.h:39
color
Definition:
colorUtils.h:24
KitMode::KitMode
KitMode(color::rgba color, size_t num_leds, int priority=0, double freq=0.25, int pulses=0, double timeout=0)
Definition:
kitMode.h:26
cob_light
Author(s): Benjamin Maidel
autogenerated on Thu Nov 17 2022 03:17:28