Skip to content
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

Typing band colors in reverse causes issues #1

Closed
benjamin051000 opened this issue Dec 23, 2023 · 2 comments
Closed

Typing band colors in reverse causes issues #1

benjamin051000 opened this issue Dec 23, 2023 · 2 comments

Comments

@benjamin051000
Copy link

Cool project! I typed some band colors in backwards, just for fun.

ohm on ξ‚  trunk is πŸ“¦ v1.0.0 via πŸ¦€ v1.69.0 
❯ ./target/release/ohm brown black red gold
Identification: -[┃┃┃  ┃ ]-
Resistance: 1000.0 Ξ© Β± 5.0% (min: 950.0 Ξ©, max: 1050.0 Ξ©)

ohm on ξ‚  trunk is πŸ“¦ v1.0.0 via πŸ¦€ v1.69.0 
❯ ./target/release/ohm gold red black brown
error: band Gold is not allowed as a digit

Technically, it's the same resistor. While I understand that intuitively I should know that gold is a tolerance value and therefore should come last, beginners may not realize this. Would it be possible to check the reverse before erroring out? Perhaps printing a message like "Hint: You got it backwards" for educational purposes?

Great little project! Way easier than looking up yet another website, so I'm definitely adding this to my toolbox. 🀠

@chaseruskin
Copy link
Owner

This is a great idea. So when an error is encountered during resistor band decoding, the decoding function is again called but with the inputted bands in reverse order. If this decoding was correct, an additional hint is displayed in the error message:

error: band Gold is not allowed as a digit (hint: try reversing the band order)

If this reversed decoding was also an error, the user just entered an illegal resistor color code combination and the original error will be displayed.

Thanks for trying it out and liking the project!

@chaseruskin
Copy link
Owner

Fixed with commit c4860bb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants