Skip to content

Commit b41a7c2

Browse files
committed
Add new ascii example from docs
1 parent 5a58720 commit b41a7c2

File tree

7 files changed

+127
-43
lines changed

7 files changed

+127
-43
lines changed

examples/assemblyscript/asconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"entries": [
3-
"src/main.ts"
3+
"main/ascii.ts"
44
],
55
"targets": {
66
"debug": {

examples/assemblyscript/main/ascii.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {print} from "as-warduino/assembly";
2+
3+
export function main(): void {
4+
print("ASCII Table ~ Character Map\n");
5+
let byte: i32 = 33;
6+
7+
while (byte !== 126) {
8+
print(String.fromCharCode(byte));
9+
10+
print(", dec: " + byte.toString());
11+
print(", hex: " + byte.toString(16));
12+
print(", oct: " + byte.toString(8));
13+
print(", bin: " + byte.toString(2) + "\n");
14+
15+
if (byte == 126) {
16+
while (true) {
17+
continue;
18+
}
19+
}
20+
21+
byte++;
22+
}
23+
}

examples/assemblyscript/package-lock.json

Lines changed: 66 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/assemblyscript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "as-examples",
33
"version": "1.0.0",
44
"description": "WARDuino examples in AssemblyScript",
5-
"main": "src/analog.ts",
5+
"main": "main/blink.ts",
66
"type": "module",
77
"scripts": {
88
"build": "npm run build:debug && npm run build:release",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[build]
2+
target = "wasm32-unknown-unknown"
3+
rustflags = [
4+
"-C", "link-args=-zstack-size=2048 -s",
5+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "examples"
3+
version = "0.1.0"
4+
authors = ["Tom Lauwaerts <[email protected]>"]
5+
edition = "2018"
6+
7+
[lib]
8+
path = "main/main.rs"
9+
crate-type = ["cdylib"]
10+
11+
[dependencies]
12+
warduino = { path = "../../lib/warduino" }
13+
14+
[profile.dev]
15+
panic = "abort"
16+
opt-level = 2
17+
18+
[profile.release]
19+
panic = "abort"
20+
opt-level = 3
21+
debug = true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use warduino::{print};
2+
3+
#[no_mangle]
4+
pub fn main() {
5+
print("ASCII Table ~ Character Map\n");
6+
7+
for byte in 33..=125 {
8+
print(&format!("{}, dec: {}, hex: {:x}, oct: {:o}, bin: {:b}\n", char::from_u32(byte).unwrap(), byte, byte, byte, byte).to_string());
9+
}
10+
}

0 commit comments

Comments
 (0)