Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-mbed5-blinky by
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() 00010 { 00011 t = Timer(); 00012 } 00013 00014 Countdown(int ms) 00015 { 00016 t = Timer(); 00017 countdown_ms(ms); 00018 } 00019 00020 00021 bool expired() 00022 { 00023 return t.read_ms() >= interval_end_ms; 00024 } 00025 00026 void countdown_ms(unsigned long ms) 00027 { 00028 t.stop(); 00029 interval_end_ms = ms; 00030 t.reset(); 00031 t.start(); 00032 } 00033 00034 void countdown(int seconds) 00035 { 00036 countdown_ms((unsigned long)seconds * 1000L); 00037 } 00038 00039 int left_ms() 00040 { 00041 return interval_end_ms - t.read_ms(); 00042 } 00043 00044 private: 00045 Timer t; 00046 unsigned long interval_end_ms; 00047 }; 00048 00049 #endif
Generated on Wed Jul 13 2022 21:16:17 by
