Rearrange and normalize private members#18
Merged
Conversation
Contributor
Author
|
It would be an API breaking change, but I'd also strongly encourage:
|
cleishm
commented
Oct 13, 2025
| this->encoderPinB = encoderPinB; | ||
| this->encoderPinButton = encoderPinButton; | ||
| this->encoderPinVcc = encoderPinVcc; | ||
| this->encoderTripPoint = encoderSteps - 1; |
Contributor
Author
There was a problem hiding this comment.
There was a subtle error here - an underflow when encoderSteps is 0, which would set encoderTripPoint to 255. This is fixed by avoiding the subtraction and by setting encoderSteps to default when 0.
Normalize the declaration, initialization, and documentation of private members. - Remove doc on private members (it was mostly missing, empty or obvious) - Add const declarations where appropriate - Use `encoderSteps` (with `>=`/`<=`) instead of `encoderTripPoint` (with `<`/`>`) to avoid type narrowing (`uint8_t` -> `int8_t`) caused by subtraction. - Use types over #def's for constants to also avoid narrowing warnings. - Move `timerCallback` to source rather than header, as it does not need to be exposed (and could potentially lead to multiple implementations).
cd34c3e to
8e65a57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Normalize the declaration, initialization, and documentation of private members.
encoderSteps(with>=/<=) instead ofencoderTripPoint(with</>) to avoid type narrowing (uint8_t->int8_t) caused by subtraction.timerCallbackto source rather than header, as it does not need to be exposed (and could potentially lead to multiple implementations).Resolves #16