-
Notifications
You must be signed in to change notification settings - Fork 9
Performance boost and simpletest update #8
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
Changes from 2 commits
dd1c9a3
81be954
ace28ff
8921a7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,10 @@ | |
|
||
current_progress = 0.0 | ||
while True: | ||
while current_progress <= 1.0: | ||
print("Progress: {}%".format(current_progress * 100)) | ||
progress_bar.progress = current_progress | ||
current_progress += 0.05 | ||
if current_progress >= 1.0: | ||
current_progress = 0.0 | ||
time.sleep(0.01) | ||
for current_progress in range(0, 21): | ||
print("Progress: {}%".format(current_progress * 0.05)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This outputs 0 -> 1%. I changed it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch thank you. I'll push a new commit to fix this soon. |
||
progress_bar.progress = current_progress * 0.05 | ||
time.sleep(0.02) | ||
time.sleep(0.3) | ||
progress_bar.progress = 0.0 | ||
time.sleep(0.3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't entirely understand the range ending in 21 as 100% It's more intuitive to me for 100% to be... well... 100 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I get what you are doing now that i've read through it a few times. I think the prior example was more intuitive to a newbie (myself) as it made me think in percentages but it does expose the float issue. Maybe leave both in as examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change allowed us to count by integers instead of floating point numbers. There was some more discussion about it in the #circuitpython channel on discord this morning if you are interested in learning more about it. http://adafru.it/discord
I think you are right though it would be more clear if it ended on 100. however if it counts by 1 it will be somewhat slower than it is now. we can step by 5 in the range loop though to get the same speed. I'll make this change too. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being just the example, I think the slower counting to 100 makes more sense. Maybe include a comment mentioning performance? Thank you for fixing this!