-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmain.ts
More file actions
34 lines (28 loc) · 1.02 KB
/
main.ts
File metadata and controls
34 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Blinking LED example
@external("env", "chip_pin_mode") export declare function pinMode(pin: u32, mode: u32): void;
@external("env", "chip_digital_write") export declare function digitalWrite(pin: u32, value: u32): void;
@external("env", "chip_delay") export declare function delay(ms: u32): void;
@external("env", "display_init") export declare function initDisplay(): void;
@external("env", "display_draw_rect") export declare function displayDrawRect(x:i32,y:i32,w:i32,h:i32): void;
enum PinVoltage {
/** Low voltage on a digital I/O pin */
LOW = 0,
/** High voltage on a digital I/O pin */
HIGH = 1,
}
export function main(): void {
const led: u32 = 4;
const pause: u32 = 1000;
const OUTPUT: u32 = 3;
let x:i32 = 0;
pinMode(led, OUTPUT);
initDisplay();
while (true) {
digitalWrite(led, PinVoltage.HIGH);
delay(pause);
digitalWrite(led, PinVoltage.LOW);
delay(pause);
displayDrawRect(x,0,150,150);
x = x+10;
}
}