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.
Dependencies: FP MQTTPacket
Dependents: IDW01M1_Cloud_IBM IDW01M1-MQTT IDW01M1-MQTT-1 IDW01M1-MQTT3 ... more
Fork of MQTT 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 t = new Timer(); 00011 if (t == NULL) printf ("Countdown newfail\n\r"); 00012 } 00013 00014 Countdown(int ms) { 00015 t = new Timer(); 00016 if (t == NULL) printf ("Countdown newfail\n\r"); 00017 countdown_ms(ms); 00018 } 00019 00020 ~Countdown() { 00021 delete t; 00022 } 00023 00024 bool expired() { 00025 return t->read_ms() >= interval_end_ms; 00026 } 00027 00028 void countdown_ms(unsigned long ms) { 00029 t->stop(); 00030 interval_end_ms = ms; 00031 t->reset(); 00032 t->start(); 00033 } 00034 00035 void countdown(int seconds) { 00036 countdown_ms((unsigned long)seconds * 1000L); 00037 } 00038 00039 int left_ms() { 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 13:20:53 by
1.7.2
