mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Touch: Use calibration matrix.
This commit is contained in:
parent
e813db16fd
commit
7492d50f0b
@ -111,10 +111,8 @@ void Manager::feed(const Frame& frame) {
|
||||
// TODO: Add touch pressure hysteresis?
|
||||
touch_pressure = (metrics.r < r_touch_threshold);
|
||||
if( touch_pressure ) {
|
||||
const float x = width_pixels * (metrics.x - calib_x_low) / calib_x_range;
|
||||
filter_x.feed(x);
|
||||
const float y = height_pixels * (calib_y_high - metrics.y) / calib_y_range;
|
||||
filter_y.feed(y);
|
||||
filter_x.feed(metrics.x * 1024);
|
||||
filter_y.feed(metrics.y * 1024);
|
||||
}
|
||||
} else {
|
||||
filter_x.reset();
|
||||
@ -146,4 +144,8 @@ void Manager::feed(const Frame& frame) {
|
||||
}
|
||||
}
|
||||
|
||||
ui::Point Manager::filtered_point() const {
|
||||
return calibration().translate({ filter_x.value(), filter_y.value() });
|
||||
}
|
||||
|
||||
} /* namespace touch */
|
||||
|
@ -220,21 +220,10 @@ private:
|
||||
TouchDetected,
|
||||
};
|
||||
|
||||
static constexpr uint32_t width_pixels = 240;
|
||||
static constexpr uint32_t height_pixels = 320;
|
||||
|
||||
static constexpr float r_touch_threshold = 0x1000;
|
||||
static constexpr size_t touch_count_threshold { 4 };
|
||||
static constexpr uint32_t touch_stable_bound { 4 };
|
||||
|
||||
static constexpr float calib_x_low = 0.07f;
|
||||
static constexpr float calib_x_high = 0.94f;
|
||||
static constexpr float calib_x_range = calib_x_high - calib_x_low;
|
||||
|
||||
static constexpr float calib_y_low = 0.04f;
|
||||
static constexpr float calib_y_high = 0.91f;
|
||||
static constexpr float calib_y_range = calib_y_high - calib_y_low;
|
||||
|
||||
// Ensure filter length is equal or less than touch_count_threshold,
|
||||
// or coordinates from the last touch will be in the initial averages.
|
||||
Filter<touch_count_threshold> filter_x;
|
||||
@ -249,12 +238,7 @@ private:
|
||||
&& filter_y.stable(touch_stable_bound);
|
||||
}
|
||||
|
||||
ui::Point filtered_point() const {
|
||||
return {
|
||||
static_cast<ui::Coord>(filter_x.value()),
|
||||
static_cast<ui::Coord>(filter_y.value())
|
||||
};
|
||||
}
|
||||
ui::Point filtered_point() const;
|
||||
|
||||
void touch_started() {
|
||||
fire_event(ui::TouchEvent::Type::Start);
|
||||
|
Loading…
Reference in New Issue
Block a user