circleColorMode.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #ifndef CIRCLECOLORMODE_H
00019 #define CIRCLECOLORMODE_H
00020 
00021 #include <mode.h>
00022 #include <algorithm>
00023 
00024 class CircleColorMode : public Mode
00025 {
00026 public:
00027    CircleColorMode(std::vector<color::rgba> colors, size_t num_leds, int priority = 0, double freq = 5, int pulses = 0, double timeout = 0)
00028     :Mode(priority, freq, pulses, timeout), _toggle(false), _timer_inc(0), _num_leds(num_leds)
00029   {
00030     _colors = colors;
00031     _colors.resize(num_leds);
00032     if(_pulses != 0)
00033     {
00034       _pulses *=2;
00035       _pulses +=1;
00036     }
00037     _inc = (1. / UPDATE_RATE_HZ) * _freq;
00038   }
00039 
00040   void execute()
00041   {
00042     if(_timer_inc >= 1.0)
00043     {
00044       std::rotate(_colors.begin(), _colors.begin()+1, _colors.end());
00045       _pulsed++;
00046       m_sigColorsReady(_colors);
00047       _timer_inc = 0.0;
00048     }
00049     else
00050       _timer_inc += _inc;
00051   }
00052 
00053   std::string getName(){ return std::string("CircleColorMode"); }
00054 
00055 private:
00056   bool _toggle;
00057   double _timer_inc;
00058   double _inc;
00059   size_t _num_leds;
00060 };
00061 
00062 #endif


cob_light
Author(s): Benjamin Maidel
autogenerated on Sat Jun 8 2019 21:02:07