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

Minimal examples for almost every API call #31

Merged
merged 13 commits into from
May 3, 2022
Merged

Conversation

microbit-matt-hillsdon
Copy link
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon commented Apr 25, 2022

I kept them very concise.

I didn't worry about them generating output (e.g. using print or display.scroll all over the place).

I didn't give examples where there wasn't anything to add, e.g. for temperature() (on the assumption folks are using `from microbit import * as our docs recommend).

I have written examples for e.g. display.read_light_level() on the basis that having the display. is useful. I'm not so sure that this was worthwhile and am considering removing them. You encounter them via autocomplete or signature help, in which case you have the display by definition, or in the V3 Python editor API docs, which could chose to make display. clearer in some other way. It feels like repetition there at the moment. See the preview: https://review-python-editor-next.microbit.org/examples/

I haven't attempted to use return values, with one exception. I've unpacked tuples where a small fixed number of values are returned, e.g. x, y, z = accelerometer.get_values(). This seems worthwhile to me as if you miss that then the return value is harder to work with.

I'd appreciate input on the i2c, uart and spi modules with a view to making the examples more meaningful if we can (e.g. a real accessory init line).

Outstanding queries/feedback:

  • Remove trivial module.get_value() examples?
  • Better examples spi, uart, i2c

Raised #33 which was spotted along the way.

@microbit-matt-hillsdon microbit-matt-hillsdon marked this pull request as draft April 25, 2022 14:19
We'll try out displaying these and see what folks think.
@microbit-matt-hillsdon microbit-matt-hillsdon changed the title Minimal examples for microbit & display. Minimal examples for almost every API call Apr 27, 2022
@microbit-matt-hillsdon microbit-matt-hillsdon marked this pull request as ready for review May 3, 2022 08:27
@microbit-matt-hillsdon
Copy link
Contributor Author

Updated the editor PR with changes to 0ec829d in microbit-foundation/python-editor-v3@3339392

@microbit-robert
Copy link
Contributor

@microbit-matt-hillsdon This all looks good, and I'm happy to approve, unless you wanted to wait for further input on the i2c, uart and spi modules?

@microbit-matt-hillsdon
Copy link
Contributor Author

@microbit-matt-hillsdon This all looks good, and I'm happy to approve, unless you wanted to wait for further input on the i2c, uart and spi modules?

I have some comments from Carlos re i2c to incorporate but I'll track that separately as realistically most of the value is from the more commonly used APIs. Raised #34

Thanks for the review.

@microbit-matt-hillsdon microbit-matt-hillsdon merged commit 329652a into main May 3, 2022
@microbit-matt-hillsdon microbit-matt-hillsdon deleted the examples branch May 3, 2022 12:39
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

Successfully merging this pull request may close these issues.

2 participants