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

Duplicated Neopixel 'show' #1027

Open
DaveAtKitronik opened this issue Oct 11, 2022 · 3 comments
Open

Duplicated Neopixel 'show' #1027

DaveAtKitronik opened this issue Oct 11, 2022 · 3 comments

Comments

@DaveAtKitronik
Copy link

The neopixel api has show() and write() functions:
image

They appear to do the same thing, but one is for V2 only. This seems unnecessary duplication, with the potential to cause a slightly mystifying failure if a user only has a V1 micro:bit:
image

The autocomplete lists all the things:
image

I haven't managed to find any 'code' implementing the new write function in the micropython repo (https://github.com/bbcmicrobit/micropython) so can't see why there is a V2 version.

Would suggest removing the duplicate write(), and leaving the show() as this has been the API forever.

@microbit-matt-hillsdon
Copy link
Collaborator

Thanks @DaveAtKitronik. I've asked the team for input as I don't know the full context for this addition and will follow up as I find out more.

It's not new in the V3 Python Editor. It was added in MicroPython for micro:bit V2. We think it might have been added to align with other MicroPython ports (example), but I'm not sure of this yet.

What we have in the Python Editor API tab and autocomplete was derived from this documentation which covers both show and write but doesn't give any context.

MicroPython for micro:bit V2 can be found in its own repo. Checking there confirms that the functions are the same.

I'll follow up when I know more. I doubt we can remove it at this point due to backwards compatibility. One thing that would help, that we hope to do in future, is to add Reference tab documentation for Neopixels (in addition to the terser API documentation). That could then prioritise the approach that works on V1 and V2 micro:bits.

@DaveAtKitronik
Copy link
Author

The 'same' functionality isn't the issue - although duplication is not great.
The fact the new one doesn't work for older microbits will cause issues in the classroom - especially where there are mixes of V1 and V2 microbits being used.

I hadn't seen it before yesterday, but that's probably because I don't expect APIs to change, and we have to make as much as possible work on V1 and V2, so wouldn't be looking for V2 only API changes.

@jaustin
Copy link

jaustin commented Oct 24, 2022

We've just confirmed with Damien that, indeed, the V2 write() method is included for compatibility with upstream MicroPython - we expect people to use show() in all cases on micro:bit. I don't think it's worth removing write() because it's useful for people using code shared across other MicroPython boards (on a V2), but when we add 'Reference' documentation for Neopixel, we'll only use V1/V2 compatible APIs for the common features.

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

No branches or pull requests

3 participants