summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-07-21 05:52:09 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-07-21 05:52:09 +0200
commit5151e045095f4387fa5027c3b4fb3d115059d448 (patch)
treeb77a7e7cdeb4a70d9359a4eb59b8aa5dffbe1226
parent45e6b4f1539b4ed68ff1d4136897827111d00396 (diff)
tracker/freepie: cleanup
- indent - use clamp from util.hpp - rename vaguely-named variables
-rw-r--r--tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
index e5667ebb..3f717682 100644
--- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
+++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
@@ -1,11 +1,11 @@
#include "ftnoir_tracker_freepie-udp.h"
#include "api/plugin-api.hpp"
+#include "compat/util.hpp"
#include <cinttypes>
#include <algorithm>
#include <cmath>
-
tracker_freepie::tracker_freepie() : pose { 0,0,0, 0,0,0 }
{
}
@@ -16,16 +16,6 @@ tracker_freepie::~tracker_freepie()
wait();
}
-template<typename t>
-static const t bound(t datum, t least, t max)
-{
- if (datum < least)
- return least;
- if (datum > max)
- return max;
- return datum;
-}
-
void tracker_freepie::run() {
#pragma pack(push, 1)
struct {
@@ -34,7 +24,9 @@ void tracker_freepie::run() {
float fl[12];
} data;
#pragma pack(pop)
- enum F {
+
+ enum F
+ {
flag_Raw = 1 << 0,
flag_Orient = 1 << 1,
Mask = flag_Raw | flag_Orient
@@ -44,11 +36,13 @@ void tracker_freepie::run() {
while (!isInterruptionRequested())
{
- int order[] = {
- bound<int>(s.idx_x, 0, 2),
- bound<int>(s.idx_y, 0, 2),
- bound<int>(s.idx_z, 0, 2)
+ int order[] =
+ {
+ clamp(s.idx_x, 0, 2),
+ clamp(s.idx_y, 0, 2),
+ clamp(s.idx_z, 0, 2)
};
+
double orient[3] = {0, 0, 0};
bool filled = false;
@@ -81,23 +75,29 @@ void tracker_freepie::run() {
if (filled)
{
- static const int add_cbx[] = {
+ static constexpr int add_cbx[] =
+ {
0,
90,
-90,
180,
-180,
};
- int indices[] = { s.add_yaw, s.add_pitch, s.add_roll };
+
+ int add_indices[] = { s.add_yaw, s.add_pitch, s.add_roll };
+
QMutexLocker foo(&mtx);
+
static constexpr double r2d = 180 / M_PI;
+
for (int i = 0; i < 3; i++)
{
- int val = 0;
- int idx = indices[order[i]];
- if (idx >= 0 && idx < (int)(sizeof(add_cbx) / sizeof(*add_cbx)))
- val = add_cbx[idx];
- pose[Yaw + i] = r2d * orient[order[i]] + val;
+ const int axis = order[i];
+ const int add_idx = add_indices[i];
+ int add = 0;
+ if (add_idx >= 0 && add_idx < (int)(sizeof(add_cbx) / sizeof(*add_cbx)))
+ add = add_cbx[add_idx];
+ pose[Yaw + i] = r2d * orient[axis] + add;
}
}
usleep(4000);