feat: CLK toggles on Step, add pan/zoom (arrows, +/-, wheel, 0=reset)

This commit is contained in:
Jose Luis Montañes
2026-03-19 22:06:03 +01:00
parent 7409a96cf1
commit d5de328898
5 changed files with 141 additions and 27 deletions

View File

@@ -52,9 +52,23 @@ export function forceRecordSample() {
}
export function manualStep() {
// Toggle all CLOCK gates on each step (same as simTick)
state.gates.forEach(g => {
if (g.type === 'CLOCK') {
g.value = g.value ? 0 : 1;
}
});
// Use the lazy-loaded evaluateAll to avoid circular imports
if (_evaluateAll) _evaluateAll();
forceRecordSample();
}
// Lazy reference to evaluateAll (set by gates.js to break circular dep)
let _evaluateAll = null;
export function setEvaluateAll(fn) {
_evaluateAll = fn;
}
export function updateWaveInfo() {
const totalSamples = Object.values(state.waveData).reduce((sum, arr) => sum + arr.length, 0);
document.getElementById('wave-info').textContent = `T=${state.timeStep} | ${totalSamples} samples`;