Touch: Migrate touch calibration to persistent memory.

This commit is contained in:
Jared Boone 2016-07-27 15:30:43 -07:00
parent aa1b8f63fc
commit c424bf08f3
5 changed files with 34 additions and 22 deletions

View file

@ -21,6 +21,9 @@
#include "touch.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
#include "utility.hpp"
namespace touch {
@ -76,26 +79,14 @@ ui::Point Calibration::translate(const DigitizerPoint& p) const {
};
}
static const Calibration _default_calibration {
const Calibration default_calibration() {
/* Values derived from one PortaPack H1 unit. */
{ { { 256, 731 }, { 880, 432 }, { 568, 146 } } },
{ { { 32, 48 }, { 208, 168 }, { 120, 288 } } }
return {
{ { { 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;
@ -145,7 +136,7 @@ void Manager::feed(const Frame& frame) {
}
ui::Point Manager::filtered_point() const {
return calibration().translate({ filter_x.value(), filter_y.value() });
return persistent_memory::touch_calibration().translate({ filter_x.value(), filter_y.value() });
}
} /* namespace touch */

View file

@ -149,9 +149,7 @@ private:
int32_t f;
};
void set_calibration(const Calibration& calibration);
const Calibration& calibration();
const Calibration& default_calibration();
const Calibration default_calibration();
template<size_t N>
class Filter {

View file

@ -23,6 +23,9 @@
#include "irq_controls.hpp"
#include "portapack_persistent_memory.hpp"
using namespace portapack;
namespace ui {
TouchCalibrationView::TouchCalibrationView(
@ -151,7 +154,7 @@ void TouchCalibrationView::touch_complete() {
void TouchCalibrationView::on_ok() {
if( phase == Phase::Success ) {
touch::set_calibration(calibration);
persistent_memory::set_touch_calibration(calibration);
nav.pop();
}
if( phase == Phase::Failure ) {