From 5e5417b45695411ea8d5cf96c15cbc459614fc1e Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Jul 2016 14:03:06 -0700 Subject: [PATCH] Touch: Default and active calibration API of sorts. --- firmware/application/touch.cpp | 20 ++++++++++++++++++++ firmware/application/touch.hpp | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/firmware/application/touch.cpp b/firmware/application/touch.cpp index 13efb236..2e01803e 100644 --- a/firmware/application/touch.cpp +++ b/firmware/application/touch.cpp @@ -74,6 +74,26 @@ ui::Point Calibration::translate(const DigitizerPoint& p) const { }; } +static const Calibration _default_calibration { + /* Values derived from one PortaPack H1 unit. */ + { { { 256, 731 }, { 880, 432 }, { 568, 146 } } }, + { { { 32, 48 }, { 208, 168 }, { 120, 288 } } } +}; + +static Calibration _calibration = _default_calibration; + +void set_calibration(const Calibration& value) { + _calibration = value; +} + +const Calibration& calibration() { + return _calibration; +} + +const Calibration& default_calibration() { + return _default_calibration; +} + void Manager::feed(const Frame& frame) { // touch_debounce.feed(touch_raw); const auto touch_raw = frame.touch; diff --git a/firmware/application/touch.hpp b/firmware/application/touch.hpp index e4b0f363..cf7ea62b 100644 --- a/firmware/application/touch.hpp +++ b/firmware/application/touch.hpp @@ -149,6 +149,10 @@ private: int32_t f; }; +void set_calibration(const Calibration& calibration); +const Calibration& calibration(); +const Calibration& default_calibration(); + template class Filter { public: