Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement idea: bool WouldCompute() #76

Open
Nanowires opened this issue Feb 29, 2024 · 0 comments
Open

Improvement idea: bool WouldCompute() #76

Nanowires opened this issue Feb 29, 2024 · 0 comments

Comments

@Nanowires
Copy link

I have the use case, where the input is not a simple read, but a bit more complex calculations.
So instead of doing the maths on every loop, just to ignore the outcome, because the timer, or the time window wasn't exceeded yet, it would be a good idea to test beforehand, if I need to calculate the input again.

I.e.:
Instead of

unsigned long msNow = millis();
Input = calculations();
if (myPID.Compute()) {
    windowStartTime = msNow;
}
handleOutput();

Something like

if (myPID.WouldCompute()) {
  unsigned long msNow = millis();
  Input = calculations();
  if (myPID.Compute()) {
      windowStartTime = msNow;
  }
}
handleOutput();
@Nanowires Nanowires changed the title Improvement idea: WouldCompute() Improvement idea: bool WouldCompute() Feb 29, 2024
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

No branches or pull requests

1 participant