Open FerNadal opened 3 years ago
Thx a lot for this issue. It helped me to find out, why my M5Stack Core2 didn't work properly with rotation. But in the section "case 3" is still a mistake.
The right variables are the following:
case 3:
tftW = TFT_HEIGHT;
tftH = TFT_WIDTH;
break;
Then it works as expected: The buttons (aka the small red circles) are on the top and they react now.
In the calculation of
inv_x
andinv_y
,TFT_WIDTH
andTFT_HEIGHT
must be interchanged according to the rotation of the screen. Otherwise, the resulting coordinates of theZone :: rotate ()
function are wrong and do not correspond to the physical locations of buttons A, B, and C.Demonstration:
Inside Zone :: rotate ():
The zone corresponding to button A would have the coordinates (240,119,280,229), overlapping with the real button B (240,130,280,200).
Correct value:
When the rotation is 2, the screen has a resolution of 240(280)x320 in the rotated x and y directions, so:
inv_x = TFT_WIDTH - 1 - x - w (= 320 - 1 - 10 - 110 = 199 - > Correct !!)
Fixed function:
There are no changes from this line to the end of the function.