OverHeat in Stealth / Mbed 2 deprecated power_watch

Dependencies:   mbed

Revision:
2:2c163adb4304
Parent:
1:0940fc3527d9
--- a/main.cpp	Sun Mar 29 00:51:57 2015 +0000
+++ b/main.cpp	Sun Mar 29 06:54:47 2015 +0000
@@ -8,50 +8,44 @@
 {
     struct
     {
-        int   header;
-        int   index;
+        unsigned int index;
         float busVoltage;
         float shuntVoltage;
         float shuntCurrent;
-        char  zero;
     };
 
-    const char * str;
+    char raw[];
 };
 
-Adafruit_INA219 sensor(I2C_SDA, I2C_SCL);
-debug dbg;
-
 int main()
 {
-    dbg.init( 230400 );
-    dbg.filter( DBG );
-    dbg.tag( 0x1 );
-    dbg.out(  MSG, "Power Monitor : Initialization Starting, Version is 03/28/15\n" );
-    dbg.srt();
-    
-    sensor.begin();
-    
-    dbg.stp("Power Monitor : Initialization");
-    dbg.out( MSG, "Power Monitor : Initialization Complete\n" );
-
-    packet_t packet;
+    Adafruit_INA219 sensor(I2C_SDA, I2C_SCL);
+    packet_t        packet;
+    Timer           timer;
+    debug           dbg;
 
-    packet.header       = 0xFACE;
-    packet.index        = 0;
-    packet.busVoltage   = 0.0f;
-    packet.shuntVoltage = 0.0f;
-    packet.shuntCurrent = 0.0f;
-    packet.zero         = 0;
+    dbg.init( 230400 );
+    sensor.begin();
+    timer.start();
+    
+    unsigned char header[] = { 0xDE, 0xAD };
 
-    Timer timer;
-    timer.start();
-    while(1)
+    while( 1 )
     {
-        packet.busVoltage = sensor.getBusVoltage_V();
+        dbg.inf_pc->putc( header[0] );
+        dbg.inf_pc->putc( header[1] );
+        
+        packet.index        = timer.read_us();
+        packet.busVoltage   = sensor.getBusVoltage_V();
         packet.shuntVoltage = sensor.getShuntVoltage_mV();
         packet.shuntCurrent = sensor.getCurrent_mA();
-        packet.index = timer.read_us();
-        dbg.inf_pc->puts( packet.str );
+
+        for( int i = 0; i < sizeof( packet ); i++ )
+        {
+            dbg.inf_pc->putc( packet.raw[i] );
+        }
+
+        dbg.flip();
+        wait_ms( 1 );
     }
 }
\ No newline at end of file