This code to rotate a pixel from the virtual, rotated coordinate to physical screen coordinates is repeated many times.
int16_t t;
switch (rotation) {
case 1:
t = x;
x = WIDTH - 1 - y;
y = t;
break;
case 2:
x = WIDTH - 1 - x;
y = HEIGHT - 1 - y;
break;
case 3:
t = x;
x = y;
y = HEIGHT - 1 - t;
break;
}
I think there should be a function applyRotation(x, y) that goes from virtual, rotated coordinates to physical screen coordinates. I think there should also be a function that does the inverse. Something like undoRotation(x, y) that goes from physical screen coordinates to virtual, rotated coordinates. This is useful when using touch screens, so you can transform the touch event's coordinates into the virtual coordinates.
Would you accept a pull request generalizing all of the places this code is repeated into a single function and adding the inverse function?
This code to rotate a pixel from the virtual, rotated coordinate to physical screen coordinates is repeated many times.
I think there should be a function
applyRotation(x, y)
that goes from virtual, rotated coordinates to physical screen coordinates. I think there should also be a function that does the inverse. Something likeundoRotation(x, y)
that goes from physical screen coordinates to virtual, rotated coordinates. This is useful when using touch screens, so you can transform the touch event's coordinates into the virtual coordinates.Would you accept a pull request generalizing all of the places this code is repeated into a single function and adding the inverse function?