common
include
circleColorMode.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 CIRCLECOLORMODE_H
19
#define CIRCLECOLORMODE_H
20
21
#include <
mode.h
>
22
#include <algorithm>
23
24
class
CircleColorMode
:
public
Mode
25
{
26
public
:
27
CircleColorMode
(std::vector<color::rgba> colors,
size_t
num_leds,
int
priority = 0,
double
freq = 5,
int
pulses = 0,
double
timeout = 0)
28
:
Mode
(priority, freq, pulses, timeout),
_toggle
(false),
_timer_inc
(0),
_num_leds
(num_leds)
29
{
30
_colors
= colors;
31
_colors
.resize(num_leds);
32
if
(
_pulses
!= 0)
33
{
34
_pulses
*=2;
35
_pulses
+=1;
36
}
37
_inc
= (1. /
UPDATE_RATE_HZ
) *
_freq
;
38
}
39
40
void
execute
()
41
{
42
if
(
_timer_inc
>= 1.0)
43
{
44
std::rotate(
_colors
.begin(),
_colors
.begin()+1,
_colors
.end());
45
_pulsed
++;
46
m_sigColorsReady
(
_colors
);
47
_timer_inc
= 0.0;
48
}
49
else
50
_timer_inc
+=
_inc
;
51
}
52
53
std::string
getName
(){
return
std::string(
"CircleColorMode"
); }
54
55
private
:
56
bool
_toggle
;
57
double
_timer_inc
;
58
double
_inc
;
59
size_t
_num_leds
;
60
};
61
62
#endif
CircleColorMode::_inc
double _inc
Definition:
circleColorMode.h:58
CircleColorMode::_toggle
bool _toggle
Definition:
circleColorMode.h:56
CircleColorMode::_num_leds
size_t _num_leds
Definition:
circleColorMode.h:59
mode.h
Mode::_colors
std::vector< color::rgba > _colors
Definition:
mode.h:122
CircleColorMode
Definition:
circleColorMode.h:24
Mode::m_sigColorsReady
boost::signals2::signal< void(std::vector< color::rgba > &colors)> m_sigColorsReady
Definition:
mode.h:129
CircleColorMode::CircleColorMode
CircleColorMode(std::vector< color::rgba > colors, size_t num_leds, int priority=0, double freq=5, int pulses=0, double timeout=0)
Definition:
circleColorMode.h:27
CircleColorMode::execute
void execute()
Definition:
circleColorMode.h:40
Mode::UPDATE_RATE_HZ
static const unsigned int UPDATE_RATE_HZ
Definition:
mode.h:126
Mode::_pulses
int _pulses
Definition:
mode.h:115
Mode
Definition:
mode.h:26
CircleColorMode::_timer_inc
double _timer_inc
Definition:
circleColorMode.h:57
Mode::_pulsed
int _pulsed
Definition:
mode.h:119
CircleColorMode::getName
std::string getName()
Definition:
circleColorMode.h:53
Mode::_freq
double _freq
Definition:
mode.h:114
cob_light
Author(s): Benjamin Maidel
autogenerated on Wed Nov 8 2023 03:47:37