From 0792d0d59d21b036d72f17f0b31a36eb31f52c0e Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 26 Dec 2022 20:55:21 +0100 Subject: [PATCH] add scheduler.now to get phase starting from 0 --- packages/core/cyclist.mjs | 3 +++ packages/core/zyklus.mjs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/cyclist.mjs b/packages/core/cyclist.mjs index 562a91b0..59755a44 100644 --- a/packages/core/cyclist.mjs +++ b/packages/core/cyclist.mjs @@ -49,6 +49,9 @@ export class Cyclist { getPhase() { return this.getTime() - this.origin - this.latency; } + now() { + return this.getTime() - this.origin + this.clock.minLatency; + } setStarted(v) { this.started = v; this.onToggle?.(v); diff --git a/packages/core/zyklus.mjs b/packages/core/zyklus.mjs index 3d45b741..e66d8e2e 100644 --- a/packages/core/zyklus.mjs +++ b/packages/core/zyklus.mjs @@ -44,6 +44,6 @@ function createClock( }; const getPhase = () => phase; // setCallback - return { setDuration, start, stop, pause, duration, getPhase }; + return { setDuration, start, stop, pause, duration, getPhase, minLatency }; } export default createClock;