Metro SW timers as in Arduino
Metro SW timer as for Arduino. Almost unchanged. Please use with "Arduino" library.
Diff: Metro.h
- Revision:
- 0:1e3f8cf13bb8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Metro.h Thu Mar 26 14:22:19 2015 +0000 @@ -0,0 +1,48 @@ +/* +The MIT License (MIT) + +Copyright (c) 2013 thomasfredericks +Copyright (c) 2015 Eduardo de Mier + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef Metro_h +#define Metro_h + +#include "mbed.h" +#include <inttypes.h> + +class Metro +{ + +public: + Metro(unsigned long interval_millis); + Metro(unsigned long interval_millis, uint8_t autoreset); + void interval(unsigned long interval_millis); + char check(); + void reset(); + +private: + uint8_t autoreset; + unsigned long previous_millis, interval_millis; + +}; + +#endif +