generated from cpp-best-practices/gui_starter_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleo_widgets.hpp
46 lines (41 loc) · 1.05 KB
/
leo_widgets.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
#pragma once
#include "imu.hpp"
#include <functional>
#include <limits>
#include <span>
template <typename T> struct decompose;
template <typename Ret, typename T, typename Arg>
struct decompose<Ret (T::*)(Arg) const> {
using arg = std::remove_cvref_t<Arg>;
};
auto getter(auto f) {
return [](void *data, int idx) {
using U = typename decompose<decltype(&decltype(f)::operator())>::arg;
auto dataT = static_cast<const U *>(data);
return std::invoke(decltype(f){}, dataT[idx]);
};
}
struct l_plot {
float history = 10.f;
bool history_limited = true;
float yscale = float(std::numeric_limits<int16_t>::max());
bool scale_limited = true;
};
struct gyro_plot {
struct sample {
float ts;
std::array<float, 3> values;
};
l_plot plt{};
void show(std::span<const imu> data, std::span<const float, 3> dir);
void show(std::span<const sample> data, std::span<const float, 3> dir);
};
struct acc_plot {
struct sample {
float ts;
std::array<float, 3> values;
};
l_plot plt{};
void show(std::span<const imu> data);
void show(std::span<const sample> d);
};