Metro SW timers as in Arduino

Metro SW timer as for Arduino. Almost unchanged. Please use with "Arduino" library.

Committer:
eduardoG26
Date:
Fri Mar 27 15:32:41 2015 +0000
Revision:
1:33de962673fd
Parent:
0:1e3f8cf13bb8
changed include to Arduino.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eduardoG26 0:1e3f8cf13bb8 1 /*
eduardoG26 0:1e3f8cf13bb8 2 The MIT License (MIT)
eduardoG26 0:1e3f8cf13bb8 3
eduardoG26 0:1e3f8cf13bb8 4 Copyright (c) 2013 thomasfredericks
eduardoG26 0:1e3f8cf13bb8 5 Copyright (c) 2015 Eduardo de Mier
eduardoG26 0:1e3f8cf13bb8 6
eduardoG26 0:1e3f8cf13bb8 7 Permission is hereby granted, free of charge, to any person obtaining a copy of
eduardoG26 0:1e3f8cf13bb8 8 this software and associated documentation files (the "Software"), to deal in
eduardoG26 0:1e3f8cf13bb8 9 the Software without restriction, including without limitation the rights to
eduardoG26 0:1e3f8cf13bb8 10 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
eduardoG26 0:1e3f8cf13bb8 11 the Software, and to permit persons to whom the Software is furnished to do so,
eduardoG26 0:1e3f8cf13bb8 12 subject to the following conditions:
eduardoG26 0:1e3f8cf13bb8 13
eduardoG26 0:1e3f8cf13bb8 14 The above copyright notice and this permission notice shall be included in all
eduardoG26 0:1e3f8cf13bb8 15 copies or substantial portions of the Software.
eduardoG26 0:1e3f8cf13bb8 16
eduardoG26 0:1e3f8cf13bb8 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
eduardoG26 0:1e3f8cf13bb8 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
eduardoG26 0:1e3f8cf13bb8 19 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
eduardoG26 0:1e3f8cf13bb8 20 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
eduardoG26 0:1e3f8cf13bb8 21 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
eduardoG26 0:1e3f8cf13bb8 22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
eduardoG26 0:1e3f8cf13bb8 23 */
eduardoG26 0:1e3f8cf13bb8 24
eduardoG26 0:1e3f8cf13bb8 25 #ifndef Metro_h
eduardoG26 0:1e3f8cf13bb8 26 #define Metro_h
eduardoG26 0:1e3f8cf13bb8 27
eduardoG26 0:1e3f8cf13bb8 28 #include "mbed.h"
eduardoG26 0:1e3f8cf13bb8 29 #include <inttypes.h>
eduardoG26 0:1e3f8cf13bb8 30
eduardoG26 0:1e3f8cf13bb8 31 class Metro
eduardoG26 0:1e3f8cf13bb8 32 {
eduardoG26 0:1e3f8cf13bb8 33
eduardoG26 0:1e3f8cf13bb8 34 public:
eduardoG26 0:1e3f8cf13bb8 35 Metro(unsigned long interval_millis);
eduardoG26 0:1e3f8cf13bb8 36 Metro(unsigned long interval_millis, uint8_t autoreset);
eduardoG26 0:1e3f8cf13bb8 37 void interval(unsigned long interval_millis);
eduardoG26 0:1e3f8cf13bb8 38 char check();
eduardoG26 0:1e3f8cf13bb8 39 void reset();
eduardoG26 0:1e3f8cf13bb8 40
eduardoG26 0:1e3f8cf13bb8 41 private:
eduardoG26 0:1e3f8cf13bb8 42 uint8_t autoreset;
eduardoG26 0:1e3f8cf13bb8 43 unsigned long previous_millis, interval_millis;
eduardoG26 0:1e3f8cf13bb8 44
eduardoG26 0:1e3f8cf13bb8 45 };
eduardoG26 0:1e3f8cf13bb8 46
eduardoG26 0:1e3f8cf13bb8 47 #endif
eduardoG26 0:1e3f8cf13bb8 48