roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
calibration.cpp
Go to the documentation of this file.
2
4
5namespace roo_display {
6
8 if (orientation_.isXYswapped()) {
9 std::swap(p.x, p.y);
10 std::swap(p.vx, p.vy);
11 }
12 if (p.x < bounds_.xMin()) p.x = bounds_.xMin();
13 if (p.x > bounds_.xMax()) p.x = bounds_.xMax();
14 if (p.y < bounds_.yMin()) p.y = bounds_.yMin();
15 if (p.y > bounds_.yMax()) p.y = bounds_.yMax();
16 int16_t w = bounds_.width();
17 int16_t h = bounds_.height();
18 p.x = ((int32_t)4096 * (p.x - bounds_.xMin()) + w / 2) / w;
19 p.y = ((int32_t)4096 * (p.y - bounds_.yMin()) + h / 2) / h;
20 p.vx = ((int32_t)4096 * p.vx + w / 2) / w;
21 p.vy = ((int32_t)4096 * p.vy + h / 2) / h;
22 if (orientation_.isRightToLeft()) {
23 p.x = 4095 - p.x;
24 p.vx = -p.vx;
25 }
26 if (orientation_.isBottomToTop()) {
27 p.y = 4095 - p.y;
28 p.vy = -p.vy;
29 }
30}
31
32} // namespace roo_display
int16_t width() const
Width in pixels (inclusive coordinates).
Definition box.h:77
int16_t xMin() const
Minimum x (inclusive).
Definition box.h:65
int16_t xMax() const
Maximum x (inclusive).
Definition box.h:71
int16_t height() const
Height in pixels (inclusive coordinates).
Definition box.h:80
int16_t yMax() const
Maximum y (inclusive).
Definition box.h:74
int16_t yMin() const
Minimum y (inclusive).
Definition box.h:68
bool isRightToLeft() const
Return whether horizontal direction is right-to-left.
bool isBottomToTop() const
Return whether vertical direction is bottom-to-top.
bool isXYswapped() const
Return whether x maps to the vertical direction.
Definition orientation.h:90
void Calibrate(TouchPoint &point)
Apply calibration and orientation to the given touch point.
Defines 140 opaque HTML named colors.
A single touch point returned by a touch controller.
Definition device.h:390