-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
92 lines (82 loc) · 3.63 KB
/
index.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="dist/index.js"></script>
<script type="text/javascript" src="customfunctions.js"></script>
<script type="text/javascript">
async function compileAndRun() {
let e = await AVR8js.build(document.getElementById("code").value, []);
console.log(e);
if (e.stderr) {
let msgs = []
for(let i = 0; i<name.length; i++) {
msgs.push([])
}
let iter = e.stderr.matchAll(/(\w+\.\w+):(\d+):(\d+): ([^:]+):(.+)/g)
for(let err=iter.next(); !err.done; err=iter.next()) {
msgs[name.findIndex((e) => e==err.value[1])].push({
row : parseInt(err.value[2]) - 1,
column : parseInt(err.value[3]),
text : err.value[5],
type : err.value[4]
})
}
throw new Error(e.stderr + " " + msgs);
} else {
console.debug(e.stdout);
if (e.hex) {
let runner = AVR8js.execute(e.hex, console.log, "leId", undefined, document.getElementById("cyclesPerFrame").value*1, document.getElementById("frameDelayMilliseconds").value*1);
} else {
throw new Error("no hex!");
}
}
}
</script>
</head>
<body onload='try {new Function("(a = 0) => a")} catch(e) {alert("Your browser does not support ES6! Please update")}'>
<h1>Test</h1>
<textarea id="code" rows="30" cols="50">
byte leds[] = {13, 12, 11, 10};
void setup() {
Serial.begin(115200);
for (byte i = 0; i < sizeof(leds); i++) {
pinMode(leds[i], OUTPUT);
}
}
int i = 0;
void loop() {
Serial.print("LED: ");
Serial.println(i);
digitalWrite(leds[i], HIGH);
delay(250);
digitalWrite(leds[i], LOW);
i = (i + 1) % sizeof(leds);
}
</textarea><br>
<div id="leId">
cyclesPerFrame:<input type="text" id="cyclesPerFrame" value="100000"><br>
interFrameDelayMilliseconds:<input type="text" id="frameDelayMilliseconds" value="0"><br>
<input type="button" value="RUN" onclick="this.disabled=true; compileAndRun()"><br>
<wokwi-led color="red" pin="13" label="13"></wokwi-led>
<wokwi-led color="green" pin="12" label="12"></wokwi-led>
<wokwi-led color="blue" pin="11" label="11"></wokwi-led>
<wokwi-led color="blue" pin="10" label="10"></wokwi-led>
<span id="simulation-time"></span><br>
<b>PORTB: </b><memout-element type="bin" address="0x25"></memout-element> <b>DDRB: </b><memout-element type="bin" address="0x24"></memout-element><br>
<b>PORTC: </b><memout-element type="bin" address="0x28"></memout-element> <b>DDRC: </b><memout-element type="bin" address="0x27"></memout-element><br>
<b>PORTD: </b><memout-element type="bin" address="0x2B"></memout-element> <b>DDRD: </b><memout-element type="bin" address="0x2A"></memout-element><br>
<b>led 13: </b>
<memout-element type="custom" output="extractBit(data[0x25],5)"></memout-element><br>
<memout-element
type="diagram2"
outputs="[ extractBit(data[0x25],5), extractBit(data[0x25],4)+1.5, extractBit(data[0x25],3)+3, extractBit(data[0x25],2)+4.5 ]"
color="red"
interval="20000000"
title="Hallo liebe Welt, ich bin ein Diagram!"
width="1000"
height="500"
></memout-element>
<!--memout-element type="diagram" address="0x25" color="red" interval="20000000"></memout-element-->
</div>
</body>
</html>