Tarea 2

Dependencies:   MQTTPacket FP

Revision:
49:c66fdbb9eb83
Parent:
43:21da1f744243
--- a/MQTTmbed.h	Wed Sep 28 15:34:12 2016 +0000
+++ b/MQTTmbed.h	Mon Oct 30 13:50:53 2017 +0100
@@ -6,43 +6,42 @@
 class Countdown
 {
 public:
-    Countdown()
-    {
-        t = Timer();   
+    Countdown() {
+        t = new Timer();
+        if (t == NULL) printf ("Countdown newfail\n\r");		
     }
     
-    Countdown(int ms)
-    {
-        t = Timer();
+    Countdown(int ms) {
+        t = new Timer();
+        if (t == NULL) printf ("Countdown newfail\n\r");					
         countdown_ms(ms);   
     }
     
+    ~Countdown() {
+        delete t;
+    }
     
-    bool expired()
-    {
-        return t.read_ms() >= interval_end_ms;
+    bool expired() {
+        return t->read_ms() >= interval_end_ms;
     }
     
-    void countdown_ms(unsigned long ms)  
-    {
-        t.stop();
+    void countdown_ms(unsigned long ms) {
+        t->stop();
         interval_end_ms = ms;
-        t.reset();
-        t.start();
+        t->reset();
+        t->start();
     }
     
-    void countdown(int seconds)
-    {
+    void countdown(int seconds) {
         countdown_ms((unsigned long)seconds * 1000L);
     }
     
-    int left_ms()
-    {
-        return interval_end_ms - t.read_ms();
+    int left_ms() {
+        return interval_end_ms - t->read_ms();
     }
     
 private:
-    Timer t;
+    Timer *t;
     unsigned long interval_end_ms; 
 };