We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
from recalculateAndTrigger method
function hysteresis(currentTemp, targetValue, thresholdRising, thresholdFalling) { var difference = (targetValue - currentTemp); var newHeaterStatus = (difference < 0 ? "off" : "on"); var threshold = (newHeaterStatus === "off" ? thresholdRising : thresholdFalling); var changeStatus = (Math.abs(difference) >= threshold); if (changeStatus) { return newHeaterStatus; } return null; }
test-case
var targetValue = 22; var thresholdRising = 1; var thresholdFalling = 3; for (let currentTemp = 19; currentTemp < 25; currentTemp++) { console.log(currentTemp, hysteresis(currentTemp, targetValue, thresholdRising, thresholdFalling)); }
result
19 on test.js:17 20 null test.js:17 21 null test.js:17 22 null test.js:17 23 off test.js:17 24 off
The text was updated successfully, but these errors were encountered:
Hi, It's possible, I will take a look. thank you for this scenario.
Sorry, something went wrong.
No branches or pull requests
from recalculateAndTrigger method
test-case
result
The text was updated successfully, but these errors were encountered: