Skip to content

Commit 1d3ffee

Browse files
authored
Update actions documentation (#11)
* Update multiverse blog * Create digital/mode.md * Add table to pin mode docs * Fix mode.md * Create digital write * Create digital read * Add link to docs in blog * Update action index * Fix mistakes
1 parent e75125f commit 1d3ffee

File tree

7 files changed

+222
-152
lines changed

7 files changed

+222
-152
lines changed

warduino/.vitepress/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export default defineConfig({
9191
collapsed: true,
9292
items: [
9393
{ text: 'Overview', link: '/reference/actions/' },
94+
{ text: 'Digital I/O',
95+
collapsed: true,
96+
items: [
97+
{ text: 'Pin mode', link: '/reference/actions/digital/mode' },
98+
{ text: 'Digital read', link: '/reference/actions/digital/read' },
99+
{ text: 'Digital write', link: '/reference/actions/digital/write' },
100+
]
101+
},
94102
]
95103
},
96104
{ text: 'Debug Protocol', link: '/reference/debug-protocol' },

warduino/blog/multiverse.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Diverse categories of embedded software for microcontrollers can be debugged usi
1010

1111
<span style="font-size: var(--vp-custom-block-font-size);">
1212
<b>Tom Lauwaerts and Maarten Steevens · <a href="https://github.com/tolauwae">@tolauwae</a> <a href="https://github.com/MaartenS11">@MaartenS11</a></b><br>
13-
November 14, 2024 | 4 min read
13+
November 14, 2024 | _Last updated_ 5 July, 2025 | 4 min read
1414
</span>
1515

1616
***
@@ -19,7 +19,9 @@ In this blog post, we discuss the wide applicability of the [MIO multiverse debu
1919

2020
## Binary Counter with LEDs
2121

22-
The binary counter is a simple program that uses 4 LEDs and two buttons. One button counts up and one button counts down. The LEDs show the state of 4 bit counter.
22+
The binary counter is a simple program that uses 4 LEDs and two buttons. One button counts up and one button counts down. The LEDs show the state of 4 bit counter. The example shows how static output like LEDs are easily reversible.
23+
24+
The program is written in AssemblyScript using the WARDuino library, and only its digital I/O actions for manipulating digital pins. The documentation can be found [here](/reference/actions/).
2325

2426
## Lego Mindstorms Color Dial
2527

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Pin mode ⏪
2+
3+
This action changes the mode of a digital I/O pin to either `INPUT` or `OUTPUT`.
4+
5+
---
6+
7+
| | Emulator | Arduino | ESP IDF | Zephyr |
8+
|:------------------- |:--------:|:---------------------:|:---------------------:|:---------------------:|
9+
| Support |||||
10+
11+
## Interface
12+
13+
::: code-group
14+
15+
```wasm [WebAssembly]
16+
(func chip_pin_mode (param $pin i32) (param $mode i32))
17+
```
18+
19+
```ts [AS]
20+
function pinMode(pin: i32, mode: PinMode): void
21+
```
22+
23+
```rust [Rust]
24+
fn pin_mode(pin: u32, mode: PinMode)
25+
```
26+
:::
27+
28+
## Parameters
29+
30+
### WebAssembly
31+
32+
- **pin**: must be a valid I/O pin number of the microcontroller
33+
- **mode**: either 0 (input) or 2 (output)
34+
35+
### AssemblyScript
36+
37+
```ts [AS]
38+
enum PinMode {
39+
/** Input mode for digital pins */
40+
INPUT = 0x0,
41+
/** Output mode for digital pins */
42+
OUTPUT = 0x2,
43+
}
44+
```
45+
46+
### Rust
47+
48+
```rust [Rust]
49+
enum PinMode {
50+
/** Input mode for digital pins */
51+
INPUT = 0x0,
52+
/** Output mode for digital pins */
53+
OUTPUT = 0x2,
54+
}
55+
```
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Digital read ⏪
2+
3+
This action changes changes the signal of a digital I/O pin to either `LOW` or `HIGH`.
4+
5+
---
6+
7+
| | Emulator | Arduino | ESP IDF | Zephyr |
8+
|:------------------- |:--------:|:---------------------:|:---------------------:|:---------------------:|
9+
| Support |||||
10+
11+
## Interface
12+
13+
::: code-group
14+
15+
```wasm [WebAssembly]
16+
(func chip_digital_read (param $pin i32) (result i32))
17+
```
18+
19+
```ts [AS]
20+
function digitalRead(pin: i32, value: PinVoltage): void
21+
```
22+
23+
```rust [Rust]
24+
fn digital_read(pin: u32, value: PinVoltage)
25+
```
26+
:::
27+
28+
## Parameters
29+
30+
### WebAssembly
31+
32+
- **pin**: must be a valid I/O pin number of the microcontroller
33+
34+
## Return value
35+
36+
### WebAssembly
37+
38+
- a unsigned 32 integer, either 0 (low) or 1 (high)
39+
40+
41+
### AssemblyScript
42+
43+
```ts [AS]
44+
enum PinVoltage {
45+
/** Low voltage on a digital I/O pin */
46+
LOW = 0,
47+
/** High voltage on a digital I/O pin */
48+
HIGH = 1,
49+
}
50+
```
51+
52+
### Rust
53+
54+
```rust [Rust]
55+
enum PinVoltage {
56+
/** Low voltage on a digital I/O pin */
57+
LOW = 0,
58+
/** High voltage on a digital I/O pin */
59+
HIGH = 1,
60+
}
61+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Digital write ⏪
2+
3+
4+
This action changes changes the signal of a digital I/O pin to either `LOW` or `HIGH`.
5+
6+
---
7+
8+
| | Emulator | Arduino | ESP IDF | Zephyr |
9+
|:------------------- |:--------:|:---------------------:|:---------------------:|:---------------------:|
10+
| Support |||||
11+
12+
## Interface
13+
14+
::: code-group
15+
16+
```wasm [WebAssembly]
17+
(func chip_digital_write (param $pin i32) (param $value i32))
18+
```
19+
20+
```ts [AS]
21+
function digitalWrite(pin: i32, value: PinVoltage): void
22+
```
23+
24+
```rust [Rust]
25+
fn digital_write(pin: u32, value: PinVoltage)
26+
```
27+
:::
28+
29+
## Parameters
30+
31+
### WebAssembly
32+
33+
- **pin**: must be a valid I/O pin number of the microcontroller
34+
- **value**: either 0 (low) or 1 (high)
35+
36+
### AssemblyScript
37+
38+
```ts [AS]
39+
enum PinVoltage {
40+
/** Low voltage on a digital I/O pin */
41+
LOW = 0,
42+
/** High voltage on a digital I/O pin */
43+
HIGH = 1,
44+
}
45+
```
46+
47+
### Rust
48+
49+
```rust [Rust]
50+
enum PinVoltage {
51+
/** Low voltage on a digital I/O pin */
52+
LOW = 0,
53+
/** High voltage on a digital I/O pin */
54+
HIGH = 1,
55+
}
56+
```

warduino/reference/actions/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The WARDuino virtual machine includes built-in actions (sometimes we refer to these as primitives) that provide access to hardware and IoT specific functionality in WebAssembly programs.
44

5-
## WebAssembly Actions
5+
## Modules
66

77
The built-in actions are implemented seperately for each hardware platform.
88
We group the built-in actions into modules, which are listed in the table below.
@@ -37,3 +37,10 @@ The actions can be imported in WebAssembly from the `env` module.
3737

3838
The WARDuino virtual machine is open-source, and developers are encouraged to extend the existing primitives with their own functionality.
3939

40+
## Overview
41+
42+
**Digital I/O**
43+
44+
- [pin mode](/reference/actions/digital/mode)
45+
- [digital write](/reference/actions/digital/write)
46+
- [digital read](/reference/actions/digital/read)

0 commit comments

Comments
 (0)