generated from cpp-best-practices/gui_starter_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgps.hpp
59 lines (49 loc) · 1.14 KB
/
gps.hpp
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
#pragma once
#include <cstdint>
#include <limits>
#include <numbers>
#include <string_view>
constexpr auto to_degs_per_sec(int16_t gyr_point, float fullscale) {
return fullscale * float(gyr_point) /
-float(std::numeric_limits<int16_t>::min());
}
constexpr auto to_increment(float degs_per_sec, float period) {
return degs_per_sec * period;
}
constexpr auto to_radians(float degs) {
return (degs / 180.f) * std::numbers::pi_v<float>;
}
enum class lat_dir { N = 1, S = -1 };
enum class lon_dir { E = 1, W = -1 };
struct DMM {
uint16_t deg;
uint16_t min;
uint32_t decimal;
constexpr auto to_deg() const {
return deg + (min + float(decimal) / 1'000'000.f) / 60.f;
}
};
struct MercatorePos {
float x;
float y;
};
struct DegPos {
float lat;
float lon;
explicit operator MercatorePos() const;
};
struct DMMPos {
DMM lat;
lat_dir latdir;
DMM lon;
lon_dir londir;
explicit operator DegPos() const;
};
struct gps_hybrid {
// gpsrmc; 193035; 41; 54; 829100; N; 12; 30; 96900; E; 410; 212830; 210400;
// 1460
uint32_t ts;
DMMPos pos;
};
auto is_gps_hybrid(std::string_view sv) -> bool;
auto to_gps_hybrid(std::string_view sv) -> gps_hybrid;