update frontend components and cargo config
This commit is contained in:
@@ -46,6 +46,13 @@
|
||||
dtsMs: number;
|
||||
}
|
||||
|
||||
interface DevKitPztAngleEvent {
|
||||
seq: number;
|
||||
timestampMs: number;
|
||||
dtsMs: number;
|
||||
angle: number;
|
||||
}
|
||||
|
||||
const copyByLocale: Record<LocaleCode, HudCopy> = {
|
||||
"zh-CN": {
|
||||
appName: "JE-Skin",
|
||||
@@ -230,6 +237,7 @@
|
||||
let summary: HudSummary = buildEmptySummary();
|
||||
let pressureMatrix: number[] | null = null;
|
||||
let spatialForce: HudSpatialForce | null = null;
|
||||
let devkitSpatialForce: HudSpatialForce | null = null;
|
||||
let matrixRows = 12;
|
||||
let matrixCols = 7;
|
||||
let rangeMin = DEFAULT_PRESSURE_RANGE_MIN;
|
||||
@@ -270,6 +278,7 @@
|
||||
rowsKept: number;
|
||||
} | null = null;
|
||||
let devkitStatusTimer: number | null = null;
|
||||
let devkitSpatialForceClearTimer: number | null = null;
|
||||
let sessionStartedAt: number = Date.now();
|
||||
|
||||
$: uiCopy = copyByLocale[locale];
|
||||
@@ -297,6 +306,31 @@
|
||||
return typeof window !== "undefined" && "__TAURI_INTERNALS__" in window;
|
||||
}
|
||||
|
||||
function clearDevkitSpatialForce(): void {
|
||||
devkitSpatialForce = null;
|
||||
if (devkitSpatialForceClearTimer != null && typeof window !== "undefined") {
|
||||
window.clearTimeout(devkitSpatialForceClearTimer);
|
||||
devkitSpatialForceClearTimer = null;
|
||||
}
|
||||
hasSignalData = signalPanels.length > 0 || summary.points.length > 0 || spatialForce !== null;
|
||||
}
|
||||
|
||||
function scheduleDevkitSpatialForceClear(): void {
|
||||
if (typeof window === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (devkitSpatialForceClearTimer != null) {
|
||||
window.clearTimeout(devkitSpatialForceClearTimer);
|
||||
}
|
||||
|
||||
devkitSpatialForceClearTimer = window.setTimeout(() => {
|
||||
devkitSpatialForce = null;
|
||||
devkitSpatialForceClearTimer = null;
|
||||
hasSignalData = signalPanels.length > 0 || summary.points.length > 0 || spatialForce !== null;
|
||||
}, 420);
|
||||
}
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, value));
|
||||
}
|
||||
@@ -720,6 +754,7 @@
|
||||
function resetReplayVisualState(): void {
|
||||
pressureMatrix = buildZeroMatrix();
|
||||
spatialForce = null;
|
||||
clearDevkitSpatialForce();
|
||||
signalPanels = buildInactivePanels();
|
||||
summary = buildEmptySummary();
|
||||
hasSignalData = false;
|
||||
@@ -756,6 +791,7 @@
|
||||
replayProgress = replayFrames.length > 1 ? safeIndex / (replayFrames.length - 1) : 1;
|
||||
pressureMatrix = frameValuesToMatrix(replayFrames[safeIndex].values);
|
||||
spatialForce = null;
|
||||
clearDevkitSpatialForce();
|
||||
signalPanels = buildInactivePanels();
|
||||
summary = buildReplaySummaryAt(safeIndex);
|
||||
hasSignalData = true;
|
||||
@@ -1011,7 +1047,11 @@
|
||||
}
|
||||
pressureMatrix = packet.pressureMatrix;
|
||||
spatialForce = packet.spatialForce ?? null;
|
||||
hasSignalData = signalPanels.length > 0 || packet.summary.points.length > 0 || spatialForce !== null;
|
||||
hasSignalData =
|
||||
signalPanels.length > 0 ||
|
||||
packet.summary.points.length > 0 ||
|
||||
spatialForce !== null ||
|
||||
devkitSpatialForce !== null;
|
||||
}
|
||||
|
||||
function clearHudPanels(): void {
|
||||
@@ -1020,6 +1060,7 @@
|
||||
summary = buildEmptySummary();
|
||||
pressureMatrix = null;
|
||||
spatialForce = null;
|
||||
clearDevkitSpatialForce();
|
||||
}
|
||||
|
||||
function startMockFeed(push: (packet: HudPacket) => void): () => void {
|
||||
@@ -1794,12 +1835,25 @@
|
||||
.catch((error) => {
|
||||
console.error("Failed to listen for hud_stream:", error);
|
||||
});
|
||||
void listen<{ seq: number; timestampMs: number; dtsMs: number; angle: number }>(
|
||||
"devkit_pzt_angle",
|
||||
(event) => {
|
||||
console.log("[devkit_pzt_angle]", event.payload);
|
||||
void listen<DevKitPztAngleEvent>("devkit_pzt_angle", (event) => {
|
||||
const angleDeg = Number(event.payload.angle);
|
||||
if (!Number.isFinite(angleDeg)) {
|
||||
clearDevkitSpatialForce();
|
||||
return;
|
||||
}
|
||||
)
|
||||
|
||||
devkitSpatialForce = {
|
||||
angleDeg,
|
||||
magnitude: 0,
|
||||
confidence: 0
|
||||
};
|
||||
scheduleDevkitSpatialForceClear();
|
||||
hasSignalData =
|
||||
signalPanels.length > 0 ||
|
||||
summary.points.length > 0 ||
|
||||
spatialForce !== null ||
|
||||
devkitSpatialForce !== null;
|
||||
})
|
||||
.then((unlisten) => {
|
||||
if (disposed) {
|
||||
unlisten();
|
||||
@@ -1818,6 +1872,7 @@
|
||||
return () => {
|
||||
disposed = true;
|
||||
pauseReplayPlayback();
|
||||
clearDevkitSpatialForce();
|
||||
stopMockFeed?.();
|
||||
unlistenHudStream?.();
|
||||
unlistenDevkitPztAngle?.();
|
||||
@@ -1937,6 +1992,7 @@
|
||||
rightPanels={rightSignalPanels}
|
||||
{pressureMatrix}
|
||||
{spatialForce}
|
||||
{devkitSpatialForce}
|
||||
showConfigPanel={isConfigPanelOpen}
|
||||
showPrecisionTestPanel={isPrecisionTestOpen}
|
||||
{summary}
|
||||
|
||||
Reference in New Issue
Block a user