feat: establish coffee game and grinder baseline

This commit is contained in:
Yanchen
2026-11-11 14:08:47 +08:00
commit 890f3fa5f3
220 changed files with 8361 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>混水温控 · 咖啡机手感实验</title>
<link rel="stylesheet" href="../assets/lab.css?v=20261107-2">
<script src="../assets/instruments.js?v=20261107-2" defer></script>
<script src="../assets/machine.js?v=20261107-2" defer></script>
<script src="../assets/controls.js?v=20261107-2" defer></script>
<script src="page.js?v=20261107-2" defer></script>
</head>
<body>
<header class="lab-header">
<a class="lab-brand" href="../?v=20261107-2"><span class="brand-mark">PC</span><span class="brand-copy">咖啡机<small>手感实验</small></span></a>
<nav class="module-nav" aria-label="测试模块">
<a href="./?v=20261107-2" aria-current="page">01 水温</a><a href="../flow/?v=20261107-2">02 水流</a><a href="../extraction/?v=20261107-2">03 萃取</a>
</nav>
</header>
<main class="workspace temperature-workspace comparison-lab">
<section class="comparison-group" aria-label="15°C冷水对照组">
<h1>15°C<small>固定冷水 · 60% 峰值</small></h1>
<div class="comparison-instruments">
<section class="instrument-card">
<div class="instrument-heading"><h2>出水口温度</h2><span>探头 · 2 s</span></div>
<svg id="temperatureGauge15"></svg>
</section>
<section class="instrument-card">
<div class="instrument-heading"><h2>沸水阀</h2><span>100°C</span></div>
<svg id="hotValve15"></svg>
<div class="control-readout"><span>开度 <output id="hotValveValue15">60%</output></span><span>q<sub>h</sub> <output id="hotFlowValue15">0.010</output><small>mL/s</small></span></div>
</section>
</div>
</section>
<section class="comparison-group" aria-label="20°C冷水对照组">
<h1>20°C<small>固定冷水 · 60% 峰值</small></h1>
<div class="comparison-instruments">
<section class="instrument-card">
<div class="instrument-heading"><h2>出水口温度</h2><span>探头 · 2 s</span></div>
<svg id="temperatureGauge20"></svg>
</section>
<section class="instrument-card">
<div class="instrument-heading"><h2>沸水阀</h2><span>100°C</span></div>
<svg id="hotValve20"></svg>
<div class="control-readout"><span>开度 <output id="hotValveValue20">60%</output></span><span>q<sub>h</sub> <output id="hotFlowValue20">0.010</output><small>mL/s</small></span></div>
</section>
</div>
</section>
</main>
</body>
</html>
+44
View File
@@ -0,0 +1,44 @@
(() => {
const { Gauge } = window.Lab;
const { RotaryValve } = window.MachineControls;
const M = window.CoffeeMachine;
const groups = [
{ key: "15", machine: { ...M.defaults, coldTemp: 15 } },
{ key: "20", machine: { ...M.defaults, coldTemp: 20 } }
];
const gauges = groups.map(group => new Gauge(document.getElementById(`temperatureGauge${group.key}`), {
min: 0, max: 100, unit: "°C", label: "T_s"
}));
const sensorTemperatures = groups.map(group => M.temperature(group.machine, 0.6));
let currentValve = 0.6;
let previousFrame = performance.now();
function synchronize(value) {
currentValve = value;
valves.forEach(valve => valve.setValue(value, false));
groups.forEach(group => {
document.getElementById(`hotValveValue${group.key}`).textContent = `${Math.round(value * 100)}%`;
document.getElementById(`hotFlowValue${group.key}`).textContent = M.hotFlow(group.machine, value).toFixed(3);
});
}
const valves = groups.map(group => new RotaryValve(document.getElementById(`hotValve${group.key}`), {
value: currentValve,
label: `${group.key}°C 冷水 · 60% 峰值沸水阀门角度`,
onChange: synchronize
}));
function frame(now) {
const dt = Math.min(0.1, Math.max(0, (now - previousFrame) / 1000));
previousFrame = now;
groups.forEach((group, index) => {
sensorTemperatures[index] = M.probeStep(group.machine, sensorTemperatures[index], currentValve, dt);
gauges[index].update(sensorTemperatures[index]);
});
requestAnimationFrame(frame);
}
document.addEventListener("visibilitychange", () => { previousFrame = performance.now(); });
synchronize(currentValve);
requestAnimationFrame(frame);
})();