-
-
Notifications
You must be signed in to change notification settings - Fork 437
[PXCT-779] MicroPython Runtime Package tutorial #2457
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
base: main
Are you sure you want to change the base?
Conversation
- added all examples (and tested) - added API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small detail but looks good!
content/micropython/00.first-steps/03.runtime-package/runtime-package.md
Outdated
Show resolved
Hide resolved
…package.md Co-authored-by: pedromsousalima <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the great work, hope my suggestions come in handy :)
|
||
- `analog_read(pin)` | ||
|
||
Analog read is a classic example where you read the voltage from an analog pin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add: "[...] pin and print it to the console."
|
||
- `digital_read(pin)` | ||
|
||
Reads a digital pin and returns a HIGH (1) or LOW (0) value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add: "We print this value in the console."
|
||
| Function | Description | Parameters | Returns | Alias | | ||
| ------------------- | ---------------------------------------------- | ------------------------------------------------------------- | ------------------------ | ---------------- | | ||
| `start` | Begins main loop with hooks | `preload`, `setup`, `loop`, `cleanup` | None | None | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preload
is added to the end because it's only needed in very specific cases.
We want to allow the user to
start(setup, loop, cleanup)
as a basic, friendly flow.
| `create_sketch` | Creates new sketch from template | `sketch_name`, `destination_path`, `overwrite`, `source_path` | Created sketch path | None | | ||
| `copy_sketch` | Copies existing sketch to new location | `source_path`, `destination_path`, `name`, `overwrite` | Copied sketch path | None | | ||
|
||
### start(setup=None, loop=None, cleanup=None, preload=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per the last comment :)
Begins the main execution loop, calling user-defined hooks. | ||
|
||
- **Parameters:** | ||
- `preload`: Function run once before setup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reorder placing this to the bottom of the list
|
||
The [Arduino Runtime Package](https://github.com/arduino/arduino-runtime-mpy/tree/main) is a MicroPython package that allows you to write and program your board using the classic `setup()` and `loop()` constructs. | ||
|
||
The package was designed to make it easier to create programs, particularly for those familiar with the Arduino C++ environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: "[...] environment, but it also adds a few interesting tricks to better help your program run and stop."
micropython_type: test | ||
--- | ||
|
||
The [Arduino Runtime Package](https://github.com/arduino/arduino-runtime-mpy/tree/main) is a MicroPython package that allows you to write and program your board using the classic `setup()` and `loop()` constructs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change: "Arduino Runtime for MicroPython is a library that [...]"
suggestion: "[...] using the familiar [...]"
suggestion: "[...] construct. It also adds a few helpers along the way."
@@ -0,0 +1,367 @@ | |||
--- | |||
title: "Arduino MicroPython Runtime" | |||
description: "Learn how to use the Arduino MicroPython runtime package, which allows you to write MicroPython code in a familiar Arduino style." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change: "Arduino Runtime for MicroPython"
suggestion: "[...] familiar Arduino style and adds a few helpers"
def loop(): | ||
value = digital_read(pin) | ||
print(value) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always add a small delay not to flood the REPL and render the editor unresponsive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
50ms is enough
- **Returns:** The interpolated value. | ||
- **Alias:** None. | ||
|
||
### pin_mode(pin, mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move pin_mode
etc above map()
, constrain()
and such commands, which should be under a section "helpers"
What This PR Changes
Contribution Guidelines