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

Unused pin rework #17

Merged
merged 4 commits into from
Jun 6, 2024
Merged

Unused pin rework #17

merged 4 commits into from
Jun 6, 2024

Conversation

dmadison
Copy link
Owner

@dmadison dmadison commented Jun 6, 2024

This PR changes the way pins are handled internally with the library.

  • All pins now use the PinNum type, rather than uint8_t. This makes it more obvious what each argument expects and allows for changing all pin types together. The PinNum type is currently int16_t.
  • All NOT_A_PIN references, which used the macro from the AVR core, have been replaced with a new constant, UnusedPin. The NOT_A_PIN macro wasn't really meant for this usage, and this change makes the library more portable.
  • Pin assignments are now sanitized, so that invalid (i.e. negative) pin numbers will be caught and changed to UnusedPin.
  • Argument names for pins have been refactored to all use 'pin' as a prefix, rather than a mix of prefix and suffix as before.
  • Pin number constants as class members have been changed to be mutable, to allow for copying.

The end result is (hopefully) that pins which are unused are more robustly ignored, and the library is more portable.

dmadison added 4 commits June 6, 2024 14:41
Using a value we control rather than the platform-specific define (which isn't really meant for this purpose anyways).
Treating all negative numbers as invalid pins, sanitized to UnusedPin on assignment.
Removing const from pin number members to allow copying, and changing argument names so that 'pin' is the prefix rather than the suffix in all cases.

This should not affect any user code.
@dmadison dmadison merged commit 41403d1 into master Jun 6, 2024
2 checks passed
@dmadison dmadison deleted the unused-pin branch June 6, 2024 19:55
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