Skip to content

refactor(battery_simulator): clean up param SIM_BAT_ENABLE#26823

Open
mbjd wants to merge 8 commits intomainfrom
pr-remove-sim-bat-enable
Open

refactor(battery_simulator): clean up param SIM_BAT_ENABLE#26823
mbjd wants to merge 8 commits intomainfrom
pr-remove-sim-bat-enable

Conversation

@mbjd
Copy link
Copy Markdown
Contributor

@mbjd mbjd commented Mar 19, 2026

Solved Problem

The param SIM_BAT_ENABLE provides very niche functionality (no battery sim at all).

Solution

Remove it. Instead, disable the battery sim completely by setting SIM_BAT_DRAIN <= 0.

Also, add protection against division by 0 - in case somebody does run the battery sim but at runtime sets SIM_BAT_DRAIN=0.

Docs, param description, and lower limit updated accordingly.

Changelog Entry

Battery simulator: Remove parameter SIM_BAT_ENABLE. Disable battery simulator with SIM_BAT_DRAIN <= 0.

@mbjd mbjd requested a review from dagar March 19, 2026 15:05
@mbjd mbjd force-pushed the pr-remove-sim-bat-enable branch from cdb320a to 1f4a575 Compare March 19, 2026 15:11
@github-actions
Copy link
Copy Markdown

No broken links found in changed files.

disable instead with SIM_BAT_DRAIN <= 0
@mbjd mbjd force-pushed the pr-remove-sim-bat-enable branch from 1f4a575 to b73d5ff Compare March 20, 2026 08:02
@mbjd
Copy link
Copy Markdown
Contributor Author

mbjd commented Mar 20, 2026

Rebased on main (146f2b2)

@mbjd mbjd requested a review from dakejahl March 25, 2026 08:09
Copy link
Copy Markdown
Contributor

@dakejahl dakejahl left a comment

Choose a reason for hiding this comment

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

CI failures are unrelated

default: 60
min: 1
min: 0
max: 86400
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this isn't correct since the source code is constraining it to a max of 1

Copy link
Copy Markdown
Contributor Author

@mbjd mbjd Apr 9, 2026

Choose a reason for hiding this comment

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

The min of 0 is needed to turn it off when 0, so the code does not run in that case.

But the constraining in the first place is not needed anymore since we changed from disable on -1 to disable on 0, so I removed it. 6380c4f (we are safe from division by zero as param compare has a tolerance of 1e-7)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was referring to the max value, but I was confused about what this parameter does. We should indeed add the clamp in source so avoid a divide by zero.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah okay, sorry for the persistent misunderstandings!

  • I think we can get rid of the max entirely actually, no reason to limit it at an arbitrary value.
  • Added back the constraining to a min of 1 (you're right there are still cases where it is beneficial: starting the module and then changing the param to 0...)
  • Commited your rewordings, thanks!

now that SIM_BAT_DRAIN=0 means the module is not started we are safe
from division by zero again (param compare has a tolerance of 1e-7)
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

No broken links found in changed files.

default: 60
min: 1
min: 0
max: 86400
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was referring to the max value, but I was confused about what this parameter does. We should indeed add the clamp in source so avoid a divide by zero.

mbjd and others added 4 commits April 10, 2026 08:51
to avoid division by zero.

This reverts commit 6380c4f.
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
@mbjd mbjd force-pushed the pr-remove-sim-bat-enable branch from ac6dbed to 8e1285a Compare April 10, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants