pimoroni / flotilla-python

Python library for the Pimoroni Flotilla plug-and-play electronics ecosystem
MIT License
25 stars 15 forks source link

Client.first doesn't return the "first" one #31

Closed veryalien closed 6 years ago

veryalien commented 6 years ago

After all these years. I've finally (officially) noticed that Client.first(x) doesn't return the first module of type x. It returns the first available module of type x. That isn't always the first x module by channel, just the first one of type x in the available list. You need to either sort the available list by channel, or return the first module of type x connected in channel order. Or just do something extremely similar to finding the nth module by type as in cookbook where, in this case, n is 1 (as in first).

Gadgetoid commented 6 years ago

You're right- it should probably be the first module by channel to eliminate the confusion that would arise otherwise. Looks like I've got enough issues to do a small sprint on Flotilla and bash the rough edges off this library. Thank you!