Skip to content

Commit

Permalink
Show pins on wasm frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Dec 15, 2024
1 parent 32c69a0 commit aabef0e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/wasm/infiniemu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const module: EmscriptenModuleFactory<EmscriptenModule & {

_pins_set(pin: Pins, pinNumber: number): void;
_pins_clear(pin: Pins, pinNumber: number): void;
_pins_read_all(pin: Pins): number;

_spinorflash_get_buffer(flash: SPINorFlash): Pointer;
_spinorflash_get_buffer_size(flash: SPINorFlash): number;
Expand Down
2 changes: 1 addition & 1 deletion frontend/wasm/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type MessageFromWorkerType = { replyToId?: number } & (
{ type: "rttData", data: string } |
{ type: "lcdSleeping", data: boolean } |
{ type: "cpuSleeping", data: boolean } |
{ type: "performance", data: { loopTime: number, ips: number, totalSRAM: number } } |
{ type: "performance", data: { loopTime: number, ips: number, totalSRAM: number, pins: number } } |
{ type: "backupData", data: ArrayBuffer } |
{ type: "commandOutput", data: string } |
{ type: "aborted", data: any }
Expand Down
4 changes: 4 additions & 0 deletions frontend/wasm/src/components/Emulator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ template(v-if="!isReady")
div Loop time: {{ performance.loopTime.value.toFixed(0) }} ms
div CPU: {{ isCpuSleeping ? "Sleeping" : "Running" }}
div RAM size: {{ numberFmt.format(performance.sramSize.value) }} bytes
div {{ pins.toString(2) }}

.card.mt-3(v-if="isRunning")
.card-body
Expand Down Expand Up @@ -112,6 +113,8 @@ const isCpuSleeping = ref(false);
const foundRTT = ref(false);
const pins = ref(0);
const consoleLines = ref<Line[]>([]);
function addConsoleLine(text: string, type: Line["type"]) {
Expand Down Expand Up @@ -177,6 +180,7 @@ worker.onmessage = async (event) => {
performance.ips.value = data.ips;
performance.loopTime.value = data.loopTime;
performance.sramSize.value = data.totalSRAM;
pins.value = data.pins;
break;
case "rttFound":
Expand Down
3 changes: 2 additions & 1 deletion frontend/wasm/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Emulator {
screenUpdated = this.doLoop(10000000);
}
else {
while (this.isRunning && !screenUpdated && performance.now() - start < 50) {
while (this.isRunning && !screenUpdated && performance.now() - start < 20) {
screenUpdated ||= this.doLoop(iterations);
}
}
Expand Down Expand Up @@ -176,6 +176,7 @@ class Emulator {
loopTime: end - start,
ips: (this.instructionCount - instructionCountStart) / ((end - start) / 1000),
totalSRAM: this.Module._nrf52832_get_sram_size(this.nrf52),
pins: this.Module._pins_read_all(this.pins),
});
}

Expand Down

0 comments on commit aabef0e

Please sign in to comment.