pololu / pololu-3pi-2040-robot

Example code for the Pololu 3pi+ 2040 Robot
MIT License
15 stars 7 forks source link

Reduce QTR PIO program size #7

Closed adamgreen closed 9 months ago

adamgreen commented 1 year ago

I moved the initialization of the OSR, Y, and X registers from the start of the PIO program and put it into the QTRSensors.run() method before starting each sensor read. This reduced the size of the PIO code by 3 instructions.

NOTE: This change requires a more recent build of MicroPython which extends the rp2.StateMachine.exec() method to accept pre-encoded machine code. The commit which adds this functionality can now be found in this MicroPython master branch commit: https://github.com/micropython/micropython/commit/f9958417d8adb21147de776361a4414073cf7c77

pdg137 commented 9 months ago

Hi! Thanks for this improvement. I finally merged it in https://github.com/pololu/pololu-3pi-2040-robot/commit/6ddb719da080c21d9d1fb03e9f92007a12848f24 (though that's a cherry-pick commit from the Zumo repo so it doesn't show up like a merge).

It seems to work but I would appreciate it if you could take a look too!

adamgreen commented 9 months ago

Ok. I will pull things together and test it on Friday.

adamgreen commented 9 months ago

Looks good to me:

pdg137 commented 9 months ago

Thank you for checking!