recantha / picopicorder

The Picorder project, redux, on a Raspberry Pi Pico
8 stars 1 forks source link

Touchscreen unresponsive due to no interrupts and buffering #2

Open recantha opened 3 years ago

recantha commented 3 years ago

As described here: https://www.recantha.co.uk/blog/?page_id=20924 The touchscreen (and this is the main flaw!) is extremely sluggish to register the touches. Now, to explain: CircuitPython does not have “interrupts”. So, I cannot just say “when there’s a touch, do something”, I have to keep on checking to see if there’s a touch each time around the main control loop. The trouble is, when the sensors are being interrogated, I can’t see the state of the touchscreen! So, for instance, on the first screen, you end up with: Check touchscreen. Check a sensor and output the sensor reading (x5) Check touchscreen. This means that I’m only checking the touchscreen once every half-to-three-quarter seconds. Unfortunately, the touchscreen chip also buffers the touches, so I’m checking the coordinates of the touch on the screen as it was when I touched it… that number of seconds ago. In the meantime, it’s buffered a good dozen or more readings. This could mean that I’m touching the bottom-right of the screen, but the code thinks I’m still touching top-left, like I was X seconds ago. Talk about frustrating! Due to these factors, I might have to rewrite completely using MicroPython which does have interrupts! ARGH!