Skip to content

Update actions documentation #11

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

Merged
merged 9 commits into from
Jul 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions warduino/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ export default defineConfig({
collapsed: true,
items: [
{ text: 'Overview', link: '/reference/actions/' },
{ text: 'Digital I/O',
collapsed: true,
items: [
{ text: 'Pin mode', link: '/reference/actions/digital/mode' },
{ text: 'Digital read', link: '/reference/actions/digital/read' },
{ text: 'Digital write', link: '/reference/actions/digital/write' },
]
},
]
},
{ text: 'Debug Protocol', link: '/reference/debug-protocol' },
Expand Down
6 changes: 4 additions & 2 deletions warduino/blog/multiverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Diverse categories of embedded software for microcontrollers can be debugged usi

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

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

## Binary Counter with LEDs

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 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.

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/).

## Lego Mindstorms Color Dial

Expand Down
55 changes: 55 additions & 0 deletions warduino/reference/actions/digital/mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Pin mode ⏪

This action changes the mode of a digital I/O pin to either `INPUT` or `OUTPUT`.

---

| | Emulator | Arduino | ESP IDF | Zephyr |
|:------------------- |:--------:|:---------------------:|:---------------------:|:---------------------:|
| Support | ⏪ | ✅ | ✅ | ⏪ |

## Interface

::: code-group

```wasm [WebAssembly]
(func chip_pin_mode (param $pin i32) (param $mode i32))
```

```ts [AS]
function pinMode(pin: i32, mode: PinMode): void
```

```rust [Rust]
fn pin_mode(pin: u32, mode: PinMode)
```
:::

## Parameters

### WebAssembly

- **pin**: must be a valid I/O pin number of the microcontroller
- **mode**: either 0 (input) or 2 (output)

### AssemblyScript

```ts [AS]
enum PinMode {
/** Input mode for digital pins */
INPUT = 0x0,
/** Output mode for digital pins */
OUTPUT = 0x2,
}
```

### Rust

```rust [Rust]
enum PinMode {
/** Input mode for digital pins */
INPUT = 0x0,
/** Output mode for digital pins */
OUTPUT = 0x2,
}
```
61 changes: 61 additions & 0 deletions warduino/reference/actions/digital/read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Digital read ⏪

This action changes changes the signal of a digital I/O pin to either `LOW` or `HIGH`.

---

| | Emulator | Arduino | ESP IDF | Zephyr |
|:------------------- |:--------:|:---------------------:|:---------------------:|:---------------------:|
| Support | ⏪ | ✅ | ✅ | ⏪ |

## Interface

::: code-group

```wasm [WebAssembly]
(func chip_digital_read (param $pin i32) (result i32))
```

```ts [AS]
function digitalRead(pin: i32, value: PinVoltage): void
```

```rust [Rust]
fn digital_read(pin: u32, value: PinVoltage)
```
:::

## Parameters

### WebAssembly

- **pin**: must be a valid I/O pin number of the microcontroller

## Return value

### WebAssembly

- a unsigned 32 integer, either 0 (low) or 1 (high)


### AssemblyScript

```ts [AS]
enum PinVoltage {
/** Low voltage on a digital I/O pin */
LOW = 0,
/** High voltage on a digital I/O pin */
HIGH = 1,
}
```

### Rust

```rust [Rust]
enum PinVoltage {
/** Low voltage on a digital I/O pin */
LOW = 0,
/** High voltage on a digital I/O pin */
HIGH = 1,
}
```
56 changes: 56 additions & 0 deletions warduino/reference/actions/digital/write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Digital write ⏪


This action changes changes the signal of a digital I/O pin to either `LOW` or `HIGH`.

---

| | Emulator | Arduino | ESP IDF | Zephyr |
|:------------------- |:--------:|:---------------------:|:---------------------:|:---------------------:|
| Support | ⏪ | ✅ | ✅ | ⏪ |

## Interface

::: code-group

```wasm [WebAssembly]
(func chip_digital_write (param $pin i32) (param $value i32))
```

```ts [AS]
function digitalWrite(pin: i32, value: PinVoltage): void
```

```rust [Rust]
fn digital_write(pin: u32, value: PinVoltage)
```
:::

## Parameters

### WebAssembly

- **pin**: must be a valid I/O pin number of the microcontroller
- **value**: either 0 (low) or 1 (high)

### AssemblyScript

```ts [AS]
enum PinVoltage {
/** Low voltage on a digital I/O pin */
LOW = 0,
/** High voltage on a digital I/O pin */
HIGH = 1,
}
```

### Rust

```rust [Rust]
enum PinVoltage {
/** Low voltage on a digital I/O pin */
LOW = 0,
/** High voltage on a digital I/O pin */
HIGH = 1,
}
```
9 changes: 8 additions & 1 deletion warduino/reference/actions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.

## WebAssembly Actions
## Modules

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

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

## Overview

**Digital I/O**

- [pin mode](/reference/actions/digital/mode)
- [digital write](/reference/actions/digital/write)
- [digital read](/reference/actions/digital/read)
Loading