You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the calculation of inv_x and inv_y, TFT_WIDTH and TFT_HEIGHT must be interchanged according to the rotation of the screen. Otherwise, the resulting coordinates of the Zone :: rotate () function are wrong and do not correspond to the physical locations of buttons A, B, and C.
Demonstration:
M5.Lcd.setRotation(2);
...
BtnA(10,240,110,40..);
Inside Zone :: rotate ():
inv_x = TFT_WIDTH - 1 - x - w (= 240 - 1 - 10 - 110 = 119 -> Wrong!!)
...
switch (m) {
...
case 2:
x = normal_y;
y = inv_x;
break;
...
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:
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.
The text was updated successfully, but these errors were encountered: