Skip to content

DisplayProgressBar: min_value ignored in fill width calculation #954

@matthewgjohnson

Description

@matthewgjohnson

The DisplayProgressBar method in lcd_comm.py calculates the filled width using the raw value rather than the value's offset from min_value:

# Current (line 359)
bar_filled_width = (value / (max_value - min_value) * width) - 1

# Should be
bar_filled_width = ((value - min_value) / (max_value - min_value) * width) - 1

When min_value is 0 (the default), this has no effect — which is why it's gone unnoticed. But for any bar with a non-zero minimum (e.g. a temperature bar with min=25, max=95), the fill is wrong:

value min max buggy fill correct fill
25 25 95 36% 0%
60 25 95 86% 50%
95 25 95 136% (clamped) 100%

DisplayRadialProgressBar already does this correctly on line 560:

pct = (value - min_value) / (max_value - min_value)

Happy to submit a one-line PR if you'd like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions