aboutsummaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorUri Shaked2020-05-07 13:08:35 +0300
committerUri Shaked2020-05-07 13:08:35 +0300
commitbf27f4ab44c0a94c4ea8a5ad08c4081829d1d3ba (patch)
tree6c9cec23a83e50e58dbf020c9836737c9fca64e1 /demo
parentchore: release 0.8.5 (diff)
downloadavr8js-bf27f4ab44c0a94c4ea8a5ad08c4081829d1d3ba.tar.gz
avr8js-bf27f4ab44c0a94c4ea8a5ad08c4081829d1d3ba.tar.bz2
avr8js-bf27f4ab44c0a94c4ea8a5ad08c4081829d1d3ba.zip
refactor(demo): use pinState() method
Use the `pinState()` method introducd in #8 instead of directly reading from MCU memory
Diffstat (limited to 'demo')
-rw-r--r--demo/src/index.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/demo/src/index.ts b/demo/src/index.ts
index 0e99ece..2d22af7 100644
--- a/demo/src/index.ts
+++ b/demo/src/index.ts
@@ -1,10 +1,11 @@
import '@wokwi/elements';
+import { LEDElement } from '@wokwi/elements';
+import { PinState } from 'avr8js';
import { buildHex } from './compile';
+import { CPUPerformance } from './cpu-performance';
import { AVRRunner } from './execute';
import { formatTime } from './format-time';
import './index.css';
-import { CPUPerformance } from './cpu-performance';
-import { LEDElement } from '@wokwi/elements';
import { EditorHistoryUtil } from './utils/editor-history.util';
let editor: any; // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -63,10 +64,8 @@ function executeProgram(hex: string) {
// Hook to PORTB register
runner.portB.addListener((value) => {
- const D12bit = 1 << 4;
- const D13bit = 1 << 5;
- led12.value = value & D12bit ? true : false;
- led13.value = value & D13bit ? true : false;
+ led12.value = runner.portB.pinState(4) === PinState.High;
+ led13.value = runner.portB.pinState(5) === PinState.High;
});
runner.usart.onByteTransmit = (value) => {
serialOutputText.textContent += String.fromCharCode(value);