flashMode.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 FLASHMODE_H
00019 #define FLASHMODE_H
00020 
00021 #include <mode.h>
00022 
00023 class FlashMode : public Mode
00024 {
00025 public:
00026         FlashMode(color::rgba color, int priority = 0, double freq = 0.25, int pulses = 0, double timeout = 0)
00027                 :Mode(priority, freq, pulses, timeout), _toggle(false), _timer_inc(0)
00028         {
00029                 _color = color;
00030                 if(_pulses != 0)
00031                 {
00032                         _pulses *=2;
00033                         _pulses +=1;
00034                 }
00035                 _inc = (1. / UPDATE_RATE_HZ) * _freq;
00036         }
00037 
00038         void execute()
00039         {
00040                 color::rgba col;
00041                 col.r = _color.r;
00042                 col.g = _color.g;
00043                 col.b = _color.b;
00044                 if(_timer_inc >= 1.0)
00045                 {
00046                   col.a = _color.a * (int)_toggle;
00047                   _pulsed++;
00048                   _toggle = !_toggle;
00049                   m_sigColorReady(col);
00050                   _timer_inc = 0.0;
00051                 }
00052                 else
00053                   _timer_inc += _inc;
00054         }
00055 
00056         std::string getName(){ return std::string("FlashMode"); }
00057 
00058 private:
00059         bool _toggle;
00060         double _timer_inc;
00061         double _inc;
00062 };
00063 
00064 #endif


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