terry LAI / Mbed 2 deprecated ESDC2014-pwm

Dependencies:   mbed

Fork of ESDC2014 by terry LAI

Revision:
4:a377ecb9364f
Parent:
3:4306d042af6f
--- a/compass.h	Thu Jul 03 14:52:44 2014 +0000
+++ b/compass.h	Fri Jul 04 13:05:15 2014 +0000
@@ -1,65 +1,61 @@
-#ifndef COMPASS_H
-#define COMPASS_H
+#ifndef _COMPASS_H
+#define _COMPASS_H
 
 #include "mbed.h"
 #include "define.h"
+#include "math.h"
 
-#define RUN_MSB          0xC7
-#define RUN_LSB          0x10
 
-#define STOP_MSB          0xC6
-#define STOP_LSB          0x10
-
-#define RESUME_MSB          0xD1
-#define RESUME_LSB          0x10
+#define RUN_MSB     0xC7
+#define RUN_LSB     0x10
+#define ACK_RUN_MSB     0xC7
+#define ACK_RUN_LSB     0x10
 
-#define RST_MSB          0xC2
-#define RST_LSB          0x10
+#define STOP_MSB    0xC6
+#define STOP_LSB    0x10
+#define ACK_STOP_MSB    0xD6
+#define ACK_STOP_LSB    0x01
 
-#define RESUME_MSB          0xD1
-#define RESUME_LSB          0x10
+#define RESUME_MSB      0xD1
+#define RESUME_LSB      0x10
+#define ACK_RESUME_MSB      0xD1
+#define ACK_RESUME_LSB      0x10
 
-#define COMPASS_TX      p9
-#define COMPASS_RX      p10
-
-#define _BUFFER_SIZE 512
+#define RST_MSB     0xC2
+#define RST_LSB     0x10    
 
 #define DECLINATIONANGLE  -0.0457
-#define OFFSET 0
 
-#include <math.h>
+#define DATA_BUFFER_SIZE 256
 
-class COMPASS 
+class Compass
 {
 public:
-    COMPASS(MySerial* serial);
-    uint16_t read();
-    void putToBuffer(uint8_t data);
+    Compass(MySerial _compassSerial);
+    ~Compass();
+    void putToBuffer(uint8_t _x);
+    void clearBuffer();
+    int read();
 
+private:
+    MySerial* _compassSerial;
+    MySerial* temp;
+    uint8_t* buffer;
+    uint8_t _MSB;
+    uint8_t _LSB;
+
+    uint8_t _in;
+    uint8_t _out;
     
-private:
-    MySerial* _serial;
+    uint32_t add;
+
     uint16_t _degree;
-    uint8_t flag;
-    uint8_t count;
-    float declinationAngle;
-    int offset;
-    uint16_t buffer_count;
-    char temp[2];
-    char buffer[_BUFFER_SIZE];
-    uint16_t twobytes;
-    uint8_t hundreds,tens,digits;
     
-    void init();
     void write2Bytes(char msb, char lsb);
-    
     void run();
     void stop();
     void resume();
     void reset();
-    
-  //  void check_time_out();
-//    void time_out_init();
 };
 
-#endif /* COMPASS_H */
\ No newline at end of file
+#endif
\ No newline at end of file