-
Notifications
You must be signed in to change notification settings - Fork 34
/
MechaQMC5883.h
61 lines (34 loc) · 1017 Bytes
/
MechaQMC5883.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef Mecha_QMC5883
#define Mecha_QMC5883
#include "Arduino.h"
#include "Wire.h"
#define QMC5883_ADDR 0x0D
//REG CONTROL
//0x09
#define Mode_Standby 0b00000000
#define Mode_Continuous 0b00000001
#define ODR_10Hz 0b00000000
#define ODR_50Hz 0b00000100
#define ODR_100Hz 0b00001000
#define ODR_200Hz 0b00001100
#define RNG_2G 0b00000000
#define RNG_8G 0b00010000
#define OSR_512 0b00000000
#define OSR_256 0b01000000
#define OSR_128 0b10000000
#define OSR_64 0b11000000
class MechaQMC5883{
public:
void setAddress(uint8_t addr);
void init(); //init qmc5883
void setMode(uint16_t mode,uint16_t odr,uint16_t rng,uint16_t osr); // setting
void softReset(); //soft RESET
int read(int* x,int* y,int* z); //reading
int read(int* x,int* y,int* z,int* a);
int read(int* x,int* y,int* z,float* a);
float azimuth(int* a,int* b);
private:
void WriteReg(uint8_t Reg,uint8_t val);
uint8_t address = QMC5883_ADDR;
};
#endif