-
Notifications
You must be signed in to change notification settings - Fork 71
Remove unneeded variables and conditions #63
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
Conversation
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 do think my preference is to leave the if statements as is. The expression version is yet another form someone has to learn.
For the RGB case, is there any time x, y or z is something that can't be converted to an int? The if checks may be guarding against bad data.
d3fc1cb
to
999ca3c
Compare
Hi Scott. Thanks for having a look. I removed the if expression commit from the branch. About the 9 lines of code (with three “if”s) to possibly ignore unreasonable values, how likely is that? Perhaps I’ll go follow the code and see what
I’m looking for this now. (This is a fascinating learning experience!) I think it’s here. I see nothing indicating this returns anything other than a tuple of floats. Please educate me if I’m wrong. |
You know, I probably should have started by asking @kattni the reason for the “if”s. |
I can't remember why they are there. Hopefully she does. If not, we can always try it and see if it breaks. :-) |
If the |
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 think the idea was to be able to set a baseline value if you wanted for R
, G
and B
.
Thanks, @kattni. What’s best to do here? Would you prefer to leave the file as it is? |
Is it worth maintaining that functionality by retaining the
Turns into a lot of parens, but allows for increasing the overall brightness of things by allowing increased baseline RGB values. Or does setting I haven't tested either of those, I'm simply suggesting here. @dcbriccetti What do you think? |
I think there’s value in explicitly showing the mapping between acceleration components and RGB components. |
a9d5a97
to
c27ddbf
Compare
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 what you've done here. If the intention was to simplify the code, I feel that we've moved away from the initial intention. You've introduced a significant number of new concepts. These examples, for the most part, are meant to be simple demonstrations of using the Circuit Playground Express library.
If you'd like to, I would suggest submitting your current iteration as an entirely new example. I don't want to entirely do away with the simple version which updating to this would do.
if z: | ||
B = B + abs(int(z)) | ||
cpx.pixels.fill((R, G, B)) | ||
def color_amount(accel_component): |
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.
We typically include def
s before the loop at the top of the code below the import
s. Consider moving this.
Where’s the embarrassed emoji? :-) Yes, I sensed this was going the wrong direction. |
c27ddbf
to
999ca3c
Compare
999ca3c
to
1784060
Compare
OK, I like that idea. |
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.
Looks great! Thanks for sticking with us through this!
Glad to be working with you to help with education. Do you think there’s much value to the Adafruit audience of my more complicated version? I can always just use it with my students, and maybe make a YouTube video explaining it. |
@dcbriccetti I think there's value to having multiple options. I would suggest explaining it thoroughly though, as it was unclear to me, so I imagine it will be unclear to many. If you make a video explaining it, you could include a link in a comment. |
The video is here, https://youtu.be/eNpPLbYx-iA, and I’ll make a new pull request for the new program. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 2.1.1 from 2.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#63 from dcbriccetti/simplify-and-improve > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#64 from hexthat/patch-4 > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#61 from brettcannon/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_Crickit to 2.1.6 from 2.1.5: > Merge pull request adafruit/Adafruit_CircuitPython_Crickit#20 from caternuson/iss19
I’ve recently discovered these helpful examples. I’d like to offer some code simplifications.
Accelerometer
If I’m not mistaken, x, y, and z are never (or extremely rarely) 0, so the “if”s are not needed, and then the R, G, B variables are not needed. Did I miss something?
ButtonsI find my new Python students are comfortable with conditional expressions, but if theconsensus here is that the if statement is preferred, I can remove that commit.