Faster button polling? Rapid presses bringing slower variable changes

Hi, I'm the maker of Mash Gadget. I recently, finally got a real Playdate, and the game doesn't run as well as in the simulator! Shocking, right?

The main gameplay mode is where you press A or B as rapidly as you can to increment a score (int), but playing this on device is jankier than expected. I would like the number to update at least as fast as the Shooting Watch it's mimicking (here's a video of ideal performance), but ironically, it appears that the faster the button's pressed, the less often the number updates -- to the naked eye, every other press or so.

The game modes run in update() states, and originally I had an if-then inside this mode that checked buttonJustPressed then just adds 1 to the score. (I realize that's per update, but again, it was fast enough in the simulator...!) On device, if you press A & B alternately, the score increases as rapidly as I'd like it to be with one button (though that's for novices anyway!) Similarly, if we try the if-then with buttonIsPressed and I hold the button, the score's naturally increasing every tick, so I imagine this can be done on a single-rapid-press basis.

An attempted solution was moving the score-changing outside update() to an AButtonDown() function, which might be more efficient but didn't change anything. I then tried a test script with the bare essentials -- AButtonDown changing a number and a three-line update() -- but no change. Using buttonIsPressed and checking button states that way also wasn't working.

There were some other dead-end tries that maybe I did or didn't do correctly, but I'm out of theories. Is this a hardware issue? Do we need to integrate C? I'm very much a neophyte as you can tell by the simple game, but any insight here would be helpful. This is Lua on Windows, btw. Thanks.

(Attached is my test script. )
buttontest0.lua.zip (480 Bytes)

Thanks Matt, some good things to think on for now! I didn't want to flood the post with every detail and attempted fix, but since you bring some up...

I did consider an input handler but it didn't seem like the right fit, though it looks like the one "textbook approach" I haven't tried yet, so worth a shot.
I did also play with refresh rate, (50) and (0) and still no noticeable change (at 0, the FPS readout reached 82). That just reinforced my confusion around the fact that the other button methods (the A&B mashing; the holding buttonIsPressed) were as fast as desired, but hyper-tapping one button wasn't, so I'm still a bit hung up on that.

Nevertheless, given what you've said about line drawing and sprites/text, there could be something there. The digits are indeed drawn as fonts ('big' and 'small') and may be too large, so maybe I'll look into using them as sprites. Till next post!

Perhaps it's debounce after all...?

To be continued in Feature Requests