-
Notifications
You must be signed in to change notification settings - Fork 182
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
Support for different PWM pins configurations out of the box #124
Conversation
This PR doesn't includes doc updates yet. |
Looks pretty similar to my attempt in #120, except yours is shorter and easier to read 👍. Is there a reason you decided to use a trait for the remap stuff instead of just passing the bytes to the macro directly? I think that would be more readable. |
Hmm, maybe. It seems it looks like most obvious solution. |
My solution is not optimal because I introduced special type for mapping (remap). Becaue it hard to solve using macro rules so I defined types for mappings to complettely avoid this problem. |
I think you can get rid of the extra Remap trait by doing this: ( $( $TIMX:ident: $REMAP:expr ( $( ( $($PINX:ident),+ ), ( $($ENCHX:ident),+ ), ( $($DISCHX:ident),* ); )+ ); )+ ) => {
$( $(
impl Pins<$TIMX> for $($PINX<Alternate<PushPull>>,)+
{
const REMAP: u8 = $REMAP;
$(const $ENCHX: bool = true;)+
$(const $DISCHX: bool = false;)*
type Channels = ($(Pwm<$TIMX, $ENCHX>),+);
}
)+ )+ With that change, and the docs update, this will be good to merge in my eyes |
This doesn't work because as I say before it produces same implementations of Pins trait for similar mappings with different pin sets. |
Ah, makes sense. So users would have to specify the remap trait? Could you do something similar to what I did in my PR where there is a special |
Of course, I tried to write something similar to it, but in a result it is tricky or not so clear macros. Maybe enumerating all available configurations in macro invocation is a trade-of solution in this case. |
I think that's fine. This macro won't be seen by users, and I don't think we'll be modifying it much |
Since #147 which does the same thing is now merged, i'll close this in favour of that |
I think this is quite usable thing here.