d
Embed:
(wiki syntax)
Show/hide line numbers
MQTTmbed.h
00001 #if !defined(MQTT_MBED_H) 00002 #define MQTT_MBED_H 00003 00004 #include "mbed.h" 00005 00006 class Countdown 00007 { 00008 public: 00009 Countdown() : t() 00010 { 00011 00012 } 00013 00014 Countdown(int ms) : t() 00015 { 00016 countdown_ms(ms); 00017 } 00018 00019 00020 bool expired() 00021 { 00022 return t.read_ms() >= interval_end_ms; 00023 } 00024 00025 void countdown_ms(unsigned long ms) 00026 { 00027 t.stop(); 00028 interval_end_ms = ms; 00029 t.reset(); 00030 t.start(); 00031 } 00032 00033 void countdown(int seconds) 00034 { 00035 countdown_ms((unsigned long)seconds * 1000L); 00036 } 00037 00038 int left_ms() 00039 { 00040 return interval_end_ms - t.read_ms(); 00041 } 00042 00043 private: 00044 Timer t; 00045 unsigned long interval_end_ms; 00046 }; 00047 00048 #endif
Generated on Tue Jul 12 2022 17:35:33 by 1.7.2