Skip to content

Minor PID controller improvement: use cache millis instead of calling…#11439

Open
DzikuVx wants to merge 1 commit intomaintenance-10.xfrom
dzikuvx-cache-millis-in-pid-controller
Open

Minor PID controller improvement: use cache millis instead of calling…#11439
DzikuVx wants to merge 1 commit intomaintenance-10.xfrom
dzikuvx-cache-millis-in-pid-controller

Conversation

@DzikuVx
Copy link
Member

@DzikuVx DzikuVx commented Mar 17, 2026

… millis() multiple times in the loop.

@DzikuVx DzikuVx added this to the 10.0 milestone Mar 17, 2026
@DzikuVx DzikuVx requested a review from Copilot March 17, 2026 08:58
@github-actions
Copy link

Test firmware build ready — commit cb27687

Download firmware for PR #11439

225 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR caches the result of millis() at the start of the PID controller loop into a static variable pidLoopNowMs, replacing multiple millis() calls within the loop with reads of that cached value. This ensures time consistency within a single PID loop iteration and avoids redundant system calls.

Changes:

  • Added a new static EXTENDED_FASTRAM variable pidLoopNowMs to cache the current time at the start of each PID loop iteration.
  • Replaced two millis() calls in iTermLockApply() with reads from the cached pidLoopNowMs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants