Metro SW timers as in Arduino

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Metro.h Source File

Metro.h

00001 /*
00002 The MIT License (MIT)
00003 
00004 Copyright (c) 2013 thomasfredericks
00005 Copyright (c) 2015 Eduardo de Mier
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy of
00008 this software and associated documentation files (the "Software"), to deal in
00009 the Software without restriction, including without limitation the rights to
00010 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
00011 the Software, and to permit persons to whom the Software is furnished to do so,
00012 subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in all
00015 copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
00019 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
00020 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
00021 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 */
00024 
00025 #ifndef Metro_h
00026 #define Metro_h
00027 
00028 #include "mbed.h"
00029 #include <inttypes.h>
00030 
00031 class Metro
00032 {
00033 
00034 public:
00035   Metro(unsigned long interval_millis);
00036   Metro(unsigned long interval_millis, uint8_t autoreset);
00037   void interval(unsigned long interval_millis);
00038   char check();
00039   void reset();
00040 
00041 private:
00042   uint8_t autoreset;
00043   unsigned long  previous_millis, interval_millis;
00044 
00045 };
00046 
00047 #endif
00048