-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCompass.h
36 lines (25 loc) · 910 Bytes
/
Compass.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
//
// Created by Misha on 1/23/2022.
//
#ifndef AUTOCYCLE_STABILITY_FIRMWARE_COMPASS_H
#define AUTOCYCLE_STABILITY_FIRMWARE_COMPASS_H
#include <Adafruit_LIS3MDL.h>
#define HARD_IRON_X (-46.25)
#define HARD_IRON_Y (41.23)
#define HARD_IRON_Z (-31.99)
#define MPS_2_DEGLATPS (1.0f / (1852.0f * 60.0f)) // Meters per second to degrees of latitude per second conversion factor
// A nautical mile is a minute of arc and is 1852.
#define MPS_2_DEGLONPS(lat) (1.0f / (1852.0f * 60.0f * cos((lat) * ((float)PI/180.0f)))) // Meters per second to degrees of longitude per second conversion factor
// Linear distance between degrees of longitude is latitude dependent
class Compass {
public:
Compass();
void start();
void update();
float angle;
float rotation;
float declination, deviation;
private:
Adafruit_LIS3MDL magnetometer;
};
#endif //AUTOCYCLE_STABILITY_FIRMWARE_COMPASS_H