diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-04-17 01:44:47 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-04-17 01:44:55 +0200 |
commit | 9958d784532c43e46df19e67c6f4513e332b7acd (patch) | |
tree | 3a10cc92a94b5f5283df4a1e7c0424eda24378cb /filter-accela | |
parent | f218f1ea6258e18af38aee6469c70c787ff6de01 (diff) |
filter/accela: revert -180->180 fix
Does more harm than good. For 360' inertial devices, recommend
other or no filter at all.
Issue: #600
Diffstat (limited to 'filter-accela')
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 44 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.h | 8 |
2 files changed, 16 insertions, 36 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index ccf74b7e..ea4dfcbd 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -25,32 +25,6 @@ accela::accela() : first_run(true) s.make_splines(spline_rot, spline_pos); } -double accela::get_rot_delta(double val, double prev, double& degen) -{ - using std::fabs; - using std::copysign; - - // HACK: don't set degen to 180 on startup - if (fabs(prev) < 128) - { - degen = 0; - return val - prev; - } - - const double a = fabs(val - prev), b = fabs(val + prev); - - if (b < a) - { - degen = copysign(360, -b); - return val + prev; - } - else - { - degen = 0; - return val - prev; - } -} - template <typename T> static inline constexpr T signum(T x) { @@ -127,7 +101,6 @@ void accela::filter(const double* input, double *output) const double rot_dz = s.rot_deadzone.to<double>(); const double pos_dz = s.pos_deadzone.to<double>(); const double nl = s.rot_nonlinearity.to<double>(); - double deltas[6]; for (unsigned i = 0; i < 6; i++) smoothed_input[i] = smoothed_input[i] * (1-alpha) + input[i] * alpha; @@ -136,11 +109,14 @@ void accela::filter(const double* input, double *output) for (unsigned i = 3; i < 6; i++) { - double degen; - double d = get_rot_delta(smoothed_input[i], last_output[i], degen); - d += copysign(rot_dz, -d); + double d = smoothed_input[i] - last_output[i]; + + if (fabs(d) > rot_dz) + d -= copysign(rot_dz, d); + else + d = 0; + deltas[i] = d / rot_thres; - last_output[i] += degen; } if (nl > 1.) @@ -161,7 +137,11 @@ void accela::filter(const double* input, double *output) for (unsigned i = 0; i < 3; i++) { double d = smoothed_input[i] - last_output[i]; - d += copysign(pos_dz, -d); + if (fabs(d) > pos_dz) + d -= copysign(pos_dz, d); + else + d = 0; + deltas[i] = d / pos_thres; } diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index b23b8e88..34e12d26 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -5,10 +5,12 @@ * copyright notice and this permission notice appear in all copies. */ #pragma once + +#include "ui_ftnoir_accela_filtercontrols.h" + #include "accela-settings.hpp" #include "api/plugin-api.hpp" #include "compat/timer.hpp" -#include "ui_ftnoir_accela_filtercontrols.h" #include <atomic> #include <QMutex> @@ -24,11 +26,9 @@ public: private: settings_accela s; bool first_run; - double last_output[6]; + double last_output[6], deltas[6]; double smoothed_input[6]; Timer t; - - static double get_rot_delta(double val, double prev, double& degen); }; class dialog_accela: public IFilterDialog |