adafruit / Adafruit_CircuitPython_ProgressBar

Dynamic progress bar widget for CircuitPython displays
MIT License
6 stars 9 forks source link

Add ability to use "full" values rather than float #23

Closed hugodahl closed 3 years ago

hugodahl commented 3 years ago

To make using the progress bar easier for users, it would be nice to have the ability to specify a minimum and maximum value for the control (which represent the values 0% and 100%). This would remove the need to compute the percentage from the user, particularly when their range values don't neatly fit in a 0..1, 0..10, 0..100 and other such "easy" ranges.

Example


progress_bar = ProgressBar(..., min=20, max=50, ...)

# Some work happens . . . 

# Update the progress bar to the new value...
progress_bar.progress = 22  # Let the control figure out "6.67%"

progress_bar.max = 60  # This would NOT be valid. "min" and "max" are fixed at initialization
hugodahl commented 3 years ago

This will be addressed as part of the changes in #21

The property name for the value will be more instinctive as value. Setting it would then look like

progress_bar = ProgressBar(..., min=20, max=50, ...)

# Some work happens . . . 

# Update the progress bar to the new value...
progress_bar.progress = 42  # Let the control figure out "73.33%"