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

AnyTouchPin, type erased GPIO pin that implements TouchPin #2948

Open
Bahex opened this issue Jan 14, 2025 · 1 comment
Open

AnyTouchPin, type erased GPIO pin that implements TouchPin #2948

Bahex opened this issue Jan 14, 2025 · 1 comment
Labels
peripheral:gpio GPIO peripheral peripheral:touch Touch peripheral

Comments

@Bahex
Copy link

Bahex commented Jan 14, 2025

Motivations

Statically allocating space for multiple gpio pins is easy with AnyPin, but there is currently no equivalent for the TouchPin trait.

Also, it makes any async function that needs to work with TouchPin generic, meaning if invoked with different pins, futures it returns are different types.

Solution

A TouchPin::degrade(self) -> AnyTouchPin method, analogous to Pin::degrade(self) -> AnyPin.

Alternatives

Currently I'm just dealing with generics, using function signatures similar to this:

fn foo<T0, T1, T2> (..., pins: (T0, T1, T2))
where
  T0: TouchPin,
  T1: TouchPin,
  T2: TouchPin
{}

Additional context

@Bahex Bahex added the status:needs-attention This should be prioritized label Jan 14, 2025
@bugadani
Copy link
Contributor

Good idea, I think. If we do this, we should also add the same for the rest of the pin types (AnalogPin, RtcPin, but not InputPin/OutputPin). Internally, we can just convert back to AnyPin so it wouldn't be too much change, either.

@MabezDev MabezDev added peripheral:gpio GPIO peripheral peripheral:touch Touch peripheral and removed status:needs-attention This should be prioritized labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
peripheral:gpio GPIO peripheral peripheral:touch Touch peripheral
Projects
Status: Todo
Development

No branches or pull requests

3 participants