diff options
| author | Uri Shaked | 2019-12-01 15:18:25 +0200 |
|---|---|---|
| committer | Uri Shaked | 2019-12-01 15:18:25 +0200 |
| commit | 2fd9e6d4c040d4a54456b153f4523cab05adbf02 (patch) | |
| tree | af194f254e818c1922efe6e135a071879821b32a /demo/src/index.ts | |
| parent | chore: release 0.3.3 (diff) | |
| download | avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.tar.gz avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.tar.bz2 avr8js-2fd9e6d4c040d4a54456b153f4523cab05adbf02.zip | |
feat: initial implementation of USART
#6
Diffstat (limited to '')
| -rw-r--r-- | demo/src/index.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/demo/src/index.ts b/demo/src/index.ts index e51cbbc..7b6f9b1 100644 --- a/demo/src/index.ts +++ b/demo/src/index.ts @@ -10,10 +10,12 @@ const BLINK_CODE = ` // Red LED connected to pin 12. Enjoy! void setup() { + Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); } void loop() { + Serial.println("Blink"); digitalWrite(LED_BUILTIN, HIGH); delay(500); digitalWrite(LED_BUILTIN, LOW); @@ -50,6 +52,7 @@ const stopButton = document.querySelector('#stop-button'); stopButton.addEventListener('click', stopCode); const statusLabel = document.querySelector('#status-label'); const compilerOutputText = document.querySelector('#compiler-output-text'); +const serialOutputText = document.querySelector('#serial-output-text'); function executeProgram(hex: string) { runner = new AVRRunner(hex); @@ -62,6 +65,9 @@ function executeProgram(hex: string) { led12.value = value & D12bit ? true : false; led13.value = value & D13bit ? true : false; }); + runner.usart.onByteTransmit = (value) => { + serialOutputText.textContent += String.fromCharCode(value); + }; runner.execute((cpu) => { const time = formatTime(cpu.cycles / MHZ); statusLabel.textContent = 'Simulation time: ' + time; @@ -73,6 +79,7 @@ async function compileAndRun() { led13.value = false; runButton.setAttribute('disabled', '1'); + serialOutputText.textContent = ''; try { statusLabel.textContent = 'Compiling...'; const result = await buildHex(editor.getModel().getValue()); |
