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

Refactor the entire project #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Refactor the entire project #6

wants to merge 2 commits into from

Conversation

Devinaut
Copy link
Collaborator

The refactor clarifies some function details, uses docstrings instead of comment blocks, and simplifies functions with documented intention-value converstion equations (such as set_position). The appropriate version bump was already pushed to master.

It has not been tested because I cannot test it because I do not own the required hardware. I would buy it, but I don't have any use for it besides about 20 minutes of testing this single commit.

Several other subtle changes were made: functions and parameters have been type hinted, the high byte mask-and-shift in send_data has been replaced with a simple shift, the value range check in send_data was streamlined via comparison operator chaining, and the stroke and USB ID values have been checked for negatives.

The most important change is a proper implementation of the stroke value. Previously, it was just specified as part of a handful of equations the user had to calculate. Instead, it is now a required constructor parameter, and is used in these equations automatically. This prevents accidental inconsistency errors on the users' behalf and enables the aforementioned simplification of equation-based functions like set_position.

Additionally, the packet echo from sending data over USB has been implemented as function returns, in case any users want that echo. It proves especially useful in the case of set_position and get_feedback because those functions do not simply echo the sent packet.

Several comments as well as the readme have also been de-cringed.

Devinaut added 2 commits July 12, 2021 16:05
- clarify function details
- use docstrings instead of comment blocks
- simplify functions with documented intention-value converstion equations
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

Successfully merging this pull request may close these issues.

1 participant