MQTT For Wiz750sr
Fork of MQTT by
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() 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 Thu Jul 14 2022 02:55:18 by 1.7.2