123123123123123123123123123

Dependencies:   mbed

compass.h

Committer:
terryLAI
Date:
2014-07-03
Revision:
2:442902ec3aa1
Parent:
1:cbec1283a16a
Child:
3:4306d042af6f

File content as of revision 2:442902ec3aa1:

#ifndef COMPASS_H
#define COMPASS_H

#include "mbed.h"
#include "define.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 RST_MSB          0xC2
#define RST_LSB          0x10

#define RESUME_MSB          0xD1
#define RESUME_LSB          0x10

#define COMPASS_TX      p9
#define COMPASS_RX      p10



#define DECLINATIONANGLE  -0.0457
#define OFFSET 0

#include <math.h>

class COMPASS 
{

public:

   COMPASS(PinName TX, PinName RX);
    uint16_t read();
    
    
private:
     
    MySerial *serial;
    char buffer[2];
    uint16_t degree;
    
    void init();
    void run();
    void stop();
    void resume();
    void reset();
    void write2Bytes(char msb, char lsb);
    
    float declinationAngle;
    int offset;
};

#endif /* COMPASS_H */