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

[SKiDL Feature Request] Multiple slices to access pin numbers #164

Open
Timot05 opened this issue Nov 8, 2022 · 4 comments
Open

[SKiDL Feature Request] Multiple slices to access pin numbers #164

Timot05 opened this issue Nov 8, 2022 · 4 comments

Comments

@Timot05
Copy link

Timot05 commented Nov 8, 2022

Would be useful to fetch pins in buses that contain multiple numbers slices. For example:

new_bus = Bus('GPIO[26:29]_ADC[0:3]')

@devbisme
Copy link
Owner

devbisme commented Nov 8, 2022

Can you provide an example where this would be used?

@Timot05
Copy link
Author

Timot05 commented Nov 9, 2022

The pin names for the microcontroller that I'm currently using have the following names:

GPIO26_ADC1
GPIO27_ADC2
GPIO28_ADC3
GPIO29_ADC4

@devbisme
Copy link
Owner

I see the problem. There are several solutions using the existing codebase. Here's the simplest one: use the split_pin_names function (introduced in version 1.0.0). If your microcontroller is in a part named mcu, then you can split all the pin names using underscore as the delimiter like so:

mcu.split_pin_names('_')

After that, each pin named GPIOXX_ADCYY will have additional aliases GPIOXX and ADCYY. Then you can access them using mcu['ADC[1:4]'] or mcu['GPIO[26:29]'].

This may cause some problems if you have other pins with underscore-separated names like DO_NOT_USE which would create pin aliases of DO, NOT and USE that may collide across multiple pins. If that's a problem, we'll think of a work-around.

@Timot05
Copy link
Author

Timot05 commented Nov 12, 2022

Thanks! I will give this a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants