Brain touch screen errors [RMS Python]

Hi, my team made a menu that pretty much consists of 8 square buttons evenly distributed, nothing special. We just adapted a RobotMesh Studio example from here: Basically, “if the x of the press is to the left of this vertical line and the y is to the top of that horizontal line, then run this auton, else if…” type of deal.

Most of the time things work, but sometimes the press does not register properly, resulting in wrong autonomous code being called. We traced it to the fact that the Y position of the press is not always accurate and sometimes shows as 241 no matter where the finger press is. 241 is outside the screen? If we keep the circles generated at the position of press as in the example linked, you can clearly see a bunch of circles accumulated at the bottom of the screen.

The only “different” thing we do is we use the screen flipped (properly selected in setup) for design reasons.

We also tried to play with the sys.sleep() in the example (just a pause after a press is detected) but results are weird. We noticed that if we press firmly and keep the finger on for half a second, it is a bit more consistent, but who remembers to do that?

Why would brain.screen.y_position() be 241 on a press? - brain.screen.x_position() registers correctly 100% of the time.


does it work if the screen is not flipped ?

Didn’t test that (why would anyone test trivial things first?) we just discovered the issue last night while the kids were putting everything together inside the competition template and decided to print touched x and y after wrong autonomous was selected. Competition is tomorrow, I will recommend that they try to run with upside down screen if this will cause major grief.

I can however confidently report that another team used the same exact code on their non-flipped brain screen and did not complain about any inconsistencies. Not sure if it is the flipping or our brain (we have latest firmware).

Will test more this weekend. That’s what competition is for, testing.

@roboballer Until we pin down the cause, you can avoid jumpy initial values by waiting until the screen is no longer pressed and then read the final touch location value.

@John TYler:
We just added this to the code to contain the weird 241 values:

if brain.screen.pressing() and brain.screen.y_position() < 240:

This ran quite successfully throughout an entire competition. Sometimes you need to poke at a menu item several times but that’s ok. Will run some tests during next session.

We should have some improvement for invalid touch coordinates in vexos 1.0.4, that’s due out this coming week.