Skip to content
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
4 changes: 2 additions & 2 deletions examples_pio/Wasm_Advanced/wasm_apps/assemblyscript/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function setup(): void {
}

function run(): void {
const t = dev.millis();
dev.println(t.toString());
const time = dev.millis();
dev.println(time.toString());

dev.digitalWrite(LED, dev.HIGH);
dev.delay(100);
Expand Down
20 changes: 11 additions & 9 deletions examples_pio/Wasm_Advanced/wasm_apps/assemblyscript/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@ export const INPUT = 0x0;
export const OUTPUT = 0x1;
export const INPUT_PULLUP = 0x2;


export declare function millis(): u32;
export declare function delay(ms: u32): void;
export declare function pinMode(pin: u32, mode: u32): void;
export declare function digitalWrite(pin: u32, value: u32): void;
export declare function getPinLED(): u32;

@external("getGreeting") declare function _getGreeting(ptr: usize, maxlen: usize): void;
@external("print") declare function _print(ptr: usize, len: usize): void;
@external("getGreeting")
declare function _getGreeting(ptr: usize, maxlen: usize): void;

@external("print")
declare function _print(ptr: usize, len: usize): void;

export function print(str: string): void {
const buff = String.UTF8.encode(str)
_print(changetype<usize>(buff), buff.byteLength)
const buffer = String.UTF8.encode(str);
_print(changetype<usize>(buffer), buffer.byteLength);
}

export function println(str: string): void {
print(str + '\n')
print(str + '\n');
}

export function getGreeting(): string {
const arr = new ArrayBuffer(64)
_getGreeting(changetype<usize>(arr), 64)
return String.UTF8.decode(arr, true)
const arr = new ArrayBuffer(64);
_getGreeting(changetype<usize>(arr), 64);
return String.UTF8.decode(arr, true);
}
8 changes: 4 additions & 4 deletions wasm_apps/assemblyscript/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export const INPUT = 0x0;
export const OUTPUT = 0x1;
export const INPUT_PULLUP = 0x2;


export declare function millis(): u32;
export declare function delay(ms: u32): void;
export declare function pinMode(pin: u32, mode: u32): void;
export declare function digitalWrite(pin: u32, value: u32): void;
export declare function getPinLED(): u32;

@external("print") declare function _print(ptr: usize): void;
@external("print")
declare function _print(ptr: usize): void;

export function print(str: string): void {
_print(changetype<usize>(String.UTF8.encode(str, true)))
_print(changetype<usize>(String.UTF8.encode(str, true)));
}

export function println(str: string): void {
print(str + '\n')
print(str + '\n');
}