summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-20 21:56:57 -0700
committerJacob Palecki <[email protected]>2020-09-20 21:56:57 -0700
commite45daaceb233a1e67d1411109ad4b2785bf0c4e6 (patch)
treec6a2b4d1d767a8a750f0163cfca7ac6c02ce1604
parentAdd icon and second experiment (diff)
downloadrawaccel-e45daaceb233a1e67d1411109ad4b2785bf0c4e6.tar.xz
rawaccel-e45daaceb233a1e67d1411109ad4b2785bf0c4e6.zip
conditional around lookup map
-rw-r--r--common/accel-experimenttwo.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/common/accel-experimenttwo.hpp b/common/accel-experimenttwo.hpp
index 8359cc2..73428f7 100644
--- a/common/accel-experimenttwo.hpp
+++ b/common/accel-experimenttwo.hpp
@@ -37,7 +37,12 @@ namespace rawaccel {
inline int map(double speed)
{
- return speed > 0 ? (int)floor(200*log10(speed)+402) : 0;
+ int index = speed > 0 ? (int)floor(200*log10(speed)+402) : 0;
+
+ if (index < 0) return 0;
+ if (index > 1200) return 1200;
+
+ return index;
}
inline double fill(double* lookup)