-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
411 lines (360 loc) · 26 KB
/
Copy pathindex.html
File metadata and controls
411 lines (360 loc) · 26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Egg Command | Live Demo</title>
<!-- React & ReactDOM -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- Babel for JSX -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Custom Config for Tailwind -->
<script>
tailwind.config = {
theme: {
extend: {
animation: { 'spin-slow': 'spin 3s linear infinite' }
}
}
}
</script>
<style>
/* Smooth gauge transitions */
circle { transition: stroke-dashoffset 0.5s ease-out; }
body { background-color: #030712; }
</style>
</head>
<body class="text-gray-100 font-sans selection:bg-green-500 selection:text-white">
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect, useRef } = React;
// --- ICON SYSTEM (Inline SVGs for single-file portability) ---
const Icons = {
Flame: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-2.246-5.318 6-6.5 1.5 3.5.56 5.5 1.5 7.5a2.5 2.5 0 0 1 0 3.5 2.5 2.5 0 1 1-5 0Z"/><path d="M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7Z"/></svg>,
Fan: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z"/><path d="M12 12v.01"/></svg>,
Thermometer: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z"/></svg>,
Activity: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>,
Settings: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.47a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>,
Mic: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>,
MicOff: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><line x1="2" x2="22" y1="2" y2="22"/><path d="M18.89 13.23A7.12 7.12 0 0 0 19 12v-2"/><path d="M5 10v2a7 7 0 0 0 12 5"/><path d="M15 9.34V5a3 3 0 0 0-5.68-1.33"/><path d="M9 9v3a3 3 0 0 0 5.12 2.63"/><line x1="12" x2="12" y1="19" y2="22"/></svg>,
Download: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>,
TrendingUp: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/></svg>,
Clock: (p) => <svg {...p} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
};
const Icon = ({ name, size = 18, className = "" }) => {
const Component = Icons[name];
return Component ? <Component width={size} height={size} className={className} /> : null;
};
// --- COMPONENTS ---
const Card = ({ children, className = "" }) => (
<div className={`bg-gray-800/50 backdrop-blur-md border border-gray-700 rounded-2xl p-6 ${className}`}>
{children}
</div>
);
const TempGauge = ({ current, target, label, max = 500 }) => {
const radius = 90;
const stroke = 12;
const normalizedRadius = radius - stroke * 2;
const circumference = normalizedRadius * 2 * Math.PI;
const offset = circumference - (current / max) * circumference * 0.75;
const isHot = current > target + 15;
const isCold = current < target - 15;
const color = isHot ? "text-red-500" : isCold ? "text-blue-500" : "text-green-500";
return (
<div className="relative flex flex-col items-center justify-center">
<svg height={radius * 2} width={radius * 2} className="rotate-[135deg]">
<circle stroke="currentColor" fill="transparent" strokeWidth={stroke} strokeDasharray={circumference * 0.75 + " " + circumference * 0.25} r={normalizedRadius} cx={radius} cy={radius} className="text-gray-800" strokeLinecap="round" />
<circle stroke="currentColor" fill="transparent" strokeWidth={stroke} strokeDasharray={circumference} strokeDashoffset={offset} r={normalizedRadius} cx={radius} cy={radius} className={`${color} transition-all duration-1000 ease-out`} strokeLinecap="round" />
</svg>
{/* Center overlay: reduce font-size and remove upward margin so it sits well inside the gauge */}
<div className="absolute inset-0 flex flex-col items-center justify-center">
<span className="text-gray-400 text-xs font-medium uppercase tracking-wider">{label}</span>
<span className={`text-2xl sm:text-3xl md:text-4xl font-bold ${color} tabular-nums leading-none`}>{Math.round(current)}°</span>
<span className="text-gray-500 text-sm mt-1 flex items-center gap-1"><Icon name="Activity" size={12} /> Set: {target}°</span>
</div>
</div>
);
};
// --- Utility: Predict finish time (robust smoothed linear regression)
const predictFinishTime = (history, currentTemp, targetTemp, opts = {}) => {
const minPoints = opts.minPoints || 8;
const smoothWindow = opts.smoothWindow || 3;
if (!history || history.length < minPoints) return null;
if (currentTemp >= targetTemp) return "Done";
const recent = history.slice(-Math.max(minPoints, 12));
// moving average smoothing
const smooth = recent.map((d, i, arr) => {
const start = Math.max(0, i - (smoothWindow - 1));
const window = arr.slice(start, i + 1).map(x => x.meat1);
const avg = window.reduce((a, b) => a + b, 0) / window.length;
return { timestamp: d.timestamp, val: avg };
});
const start = smooth[0].timestamp.getTime();
let sumX = 0, sumY = 0, sumXY = 0, sumXX = 0;
const n = smooth.length;
smooth.forEach(d => {
const x = (d.timestamp.getTime() - start) / 1000;
const y = d.val;
sumX += x; sumY += y; sumXY += x * y; sumXX += x * x;
});
const denom = (n * sumXX - sumX * sumX);
if (!denom) return null;
const slope = (n * sumXY - sumX * sumY) / denom;
if (!isFinite(slope) || slope <= 0.0005) return "Stalled";
const degreesNeeded = targetTemp - currentTemp;
const secondsRemaining = degreesNeeded / slope;
// clamp to a sane maximum to avoid absurd estimates
const maxSeconds = 48 * 3600; // 48 hours
const safeSeconds = Math.min(secondsRemaining, maxSeconds);
const finishDate = new Date(Date.now() + safeSeconds * 1000);
return finishDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
};
const TempChart = ({ data }) => {
const [tooltip, setTooltip] = React.useState({ visible: false, x: 0, y: 0, pit: 0, meat: 0, time: '' });
if (!data || data.length < 2) return <div className="h-40 flex items-center justify-center text-gray-600 text-sm">Collecting simulation data...</div>;
const height = 160;
const width = 600;
const padding = 20;
const allTemps = data.flatMap(d => [d.pit, d.meat1]);
const maxTemp = Math.max(...allTemps) + 10;
const minTemp = Math.min(...allTemps) - 10;
const range = maxTemp - minTemp || 100;
const getX = (index) => (index / (data.length - 1)) * (width - padding * 2) + padding;
const getY = (temp) => height - padding - ((temp - minTemp) / range) * (height - padding * 2);
const makePath = (key, color) => {
const points = data.map((d, i) => `${getX(i)},${getY(d[key])}`).join(" ");
return <polyline points={points} fill="none" stroke={color} strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" />;
};
const handleMouseMove = (e) => {
const rect = e.currentTarget.getBoundingClientRect();
const parentRect = e.currentTarget.parentElement.getBoundingClientRect();
const x = e.clientX - parentRect.left;
const svgX = ((e.clientX - rect.left) / rect.width) * width;
const index = Math.round((svgX - padding) / ((width - padding * 2) / (data.length - 1)));
if (index >= 0 && index < data.length) {
const d = data[index];
setTooltip({
visible: true,
x: x,
y: e.clientY - parentRect.top,
pit: d.pit,
meat: d.meat1,
time: d.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
});
}
};
const handleMouseLeave = () => {
setTooltip({ visible: false, x: 0, y: 0, pit: 0, meat: 0, time: '' });
};
return (
<div className="w-full relative">
<svg viewBox={`0 0 ${width} ${height}`} className="w-full h-40" onMouseMove={handleMouseMove} onMouseLeave={handleMouseLeave}>
<line x1={padding} y1={getY(225)} x2={width-padding} y2={getY(225)} stroke="#EF4444" strokeDasharray="4 4" />
{makePath('meat1', '#F59E0B')}
{makePath('pit', '#10B981')}
</svg>
{tooltip.visible && (
<div style={{ position: 'absolute', left: tooltip.x + 10, top: tooltip.y - 10, background: 'rgba(0,0,0,0.8)', color: 'white', padding: '5px', borderRadius: '3px', fontSize: '12px', pointerEvents: 'none', zIndex: 10 }}>
Pit: {tooltip.pit.toFixed(1)}°<br/>
Meat: {tooltip.meat.toFixed(1)}°<br/>
{tooltip.time}
</div>
)}
</div>
);
};
// --- MAIN APP ---
function App() {
const [status, setStatus] = useState({
pitTemp: 215,
pitSet: 225,
fanSpeed: 20,
probes: [
{ id: 1, name: 'Pork Butt', temp: 150, target: 195 },
{ id: 2, name: 'Brisket Point', temp: 198, target: 203 },
{ id: 3, name: 'Spare', temp: 0, target: 0 },
]
});
const [history, setHistory] = useState([]);
const [prediction, setPrediction] = useState(null);
const [voiceEnabled, setVoiceEnabled] = useState(false);
const [showSettings, setShowSettings] = useState(false);
const [aiEnabled, setAiEnabled] = useState(true);
// Simulation Loop
useEffect(() => {
const interval = setInterval(() => {
setStatus(prev => {
let currentPit = prev.pitTemp;
let currentFan = prev.fanSpeed;
let currentMeat = prev.probes[0].temp;
// Simulate Physics
const diff = 225 - currentPit;
currentPit += (diff * 0.1) + (Math.random() - 0.5) * 2;
if (currentPit < 225) currentFan = Math.min(100, currentFan + 2);
else currentFan = Math.max(0, currentFan - 2);
currentMeat += 0.05 + (Math.random() * 0.1);
const now = new Date();
const newData = { pit: currentPit, meat1: currentMeat, timestamp: now };
setHistory(h => {
const next = [...h.slice(-99), newData];
// read the probe's configured target from the previous status
const target = prev?.probes?.[0]?.target ?? 195;
if (aiEnabled) {
setPrediction(predictFinishTime(next, currentMeat, target, {minPoints: 8, smoothWindow: 3}));
} else {
setPrediction(null);
}
return next;
});
return {
...prev,
pitTemp: currentPit,
fanSpeed: currentFan,
probes: [
{ ...prev.probes[0], temp: currentMeat },
{ ...prev.probes[1], temp: prev.probes[1] + 0.01 }, // Slow rise
prev.probes[2]
]
};
});
}, 1000);
return () => clearInterval(interval);
}, []);
return (
<div className="min-h-screen pb-20">
<header className="bg-gray-900 border-b border-gray-800 sticky top-0 z-50 backdrop-blur-lg bg-opacity-90">
<div className="max-w-6xl mx-auto px-4 h-16 flex items-center justify-between">
<div className="flex items-center gap-3">
<div className="bg-gradient-to-br from-green-500 to-green-700 p-2 rounded-lg shadow-lg shadow-green-900/50">
<Icon name="Flame" className="text-white" size={20} />
</div>
<div>
<h1 className="font-bold text-lg leading-tight tracking-tight">Egg Command</h1>
<div className="flex items-center gap-2">
<p className="text-[10px] text-gray-500 font-medium uppercase tracking-widest">Live Demo</p>
<span className="flex h-2 w-2 rounded-full bg-blue-500 animate-pulse" title="Simulation Mode"></span>
</div>
</div>
</div>
<div className="flex items-center gap-2">
<button onClick={() => setVoiceEnabled(!voiceEnabled)} className={`p-2 rounded-lg transition-colors ${voiceEnabled ? 'bg-indigo-900/30 text-indigo-400 border border-indigo-500/30' : 'text-gray-600 hover:bg-gray-800'}`}>
<Icon name={voiceEnabled ? "Mic" : "MicOff"} size={20} />
</button>
<button onClick={() => setShowSettings(!showSettings)} className="p-2 text-gray-400 hover:bg-gray-800 rounded-lg">
<Icon name="Settings" size={20} />
</button>
</div>
</div>
</header>
{showSettings && (
<div className="max-w-6xl mx-auto px-4 py-4 animate-in slide-in-from-top-4">
<Card className="bg-gray-900 border-gray-800">
<h3 className="text-lg font-bold mb-2 flex items-center gap-2">Demo Configuration</h3>
<p className="text-gray-500 text-sm">This is a static demo. In the full version, you can enter your device IP here.</p>
<div className="mt-4 flex items-center justify-between gap-4">
<div>
<div className="text-sm font-medium text-gray-300">AI Estimator</div>
<div className="text-xs text-gray-500">Toggle the AI time estimator for this demo</div>
</div>
<button onClick={() => setAiEnabled(!aiEnabled)} className={`px-3 py-1 rounded-md text-sm ${aiEnabled ? 'bg-green-600 text-white' : 'bg-gray-700 text-gray-300'}`}>
{aiEnabled ? 'Enabled' : 'Disabled'}
</button>
</div>
</Card>
</div>
)}
<main className="max-w-6xl mx-auto px-4 py-6 space-y-6">
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6">
{/* Gauge Column */}
<div className="lg:col-span-4 space-y-6">
<Card className="flex flex-col items-center relative overflow-hidden h-full min-h-[340px]">
<div className="w-full flex justify-between items-center mb-6">
<span className="font-bold text-gray-400 text-sm tracking-wider">PIT CONTROL</span>
<span className={`px-2 py-0.5 rounded text-[10px] font-bold ${status.fanSpeed > 0 ? 'bg-green-900 text-green-400' : 'bg-gray-700 text-gray-500'}`}>
{status.fanSpeed > 0 ? 'BLOWER ON' : 'IDLE'}
</span>
</div>
<div className="flex-1 flex items-center">
<TempGauge current={status.pitTemp} target={status.pitSet} label={Math.abs(status.pitTemp - status.pitSet) < 5 ? "LOCKED" : "ADJUSTING"} />
</div>
<div className="w-full mt-6">
<div className="flex justify-between items-end mb-2">
<span className="text-xs text-gray-500 font-mono">FAN OUTPUT</span>
<span className="text-xs text-white font-bold">{Math.round(status.fanSpeed)}%</span>
</div>
<div className="h-2 w-full bg-gray-800 rounded-full overflow-hidden">
<div className="h-full bg-gradient-to-r from-green-600 to-emerald-400 transition-all duration-500" style={{ width: `${status.fanSpeed}%` }} />
</div>
</div>
</Card>
</div>
{/* Data Column */}
<div className="lg:col-span-8 flex flex-col gap-6">
<Card className="h-72 flex flex-col justify-between">
<div className="flex justify-between items-start mb-2">
<div>
<h2 className="text-gray-300 font-bold flex items-center gap-2"><Icon name="TrendingUp" size={16}/> Live History</h2>
<p className="text-xs text-gray-500">Simulation Data</p>
</div>
<div className="flex items-center gap-4 text-xs">
<span className="flex items-center gap-1 text-green-400"><div className="w-2 h-2 rounded-full bg-green-500"/> Pit</span>
<span className="flex items-center gap-1 text-amber-400"><div className="w-2 h-2 rounded-full bg-amber-500"/> Meat</span>
</div>
</div>
<TempChart data={history} />
</Card>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<Card className="p-4 relative border-amber-500/20 bg-amber-900/5">
<div className="flex justify-between items-start mb-3">
<div className="flex items-center gap-2">
<span className="bg-amber-500/20 text-amber-500 p-1.5 rounded-lg"><Icon name="Thermometer" size={16} /></span>
<span className="font-bold text-gray-200">{status.probes[0].name}</span>
</div>
<span className="text-3xl font-bold text-white tabular-nums">{Math.round(status.probes[0].temp)}°</span>
</div>
<div className="space-y-1">
{/* AI prediction badge */}
{prediction && (
<div className="mb-2 bg-indigo-900/20 border border-indigo-500/30 rounded-lg p-2 flex items-center justify-between">
<div className="text-xs text-indigo-300 font-medium flex items-center gap-2"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="9"></circle><path d="M12 7v5l3 3"></path></svg> AI Estimate</div>
<div className="text-xs font-bold text-indigo-200">{prediction}</div>
</div>
)}
<div className="flex justify-between text-xs text-gray-500">
<span>Progress</span>
<span>Target: {status.probes[0].target}°</span>
</div>
<div className="h-2 w-full bg-gray-800 rounded-full overflow-hidden">
<div className="h-full bg-amber-500 transition-all duration-1000" style={{ width: `${(status.probes[0].temp / status.probes[0].target) * 100}%` }} />
</div>
</div>
</Card>
<div className="grid gap-4">
{status.probes.slice(1).map(probe => (
<Card key={probe.id} className="p-4 flex items-center justify-between py-5">
<div className="flex items-center gap-3">
<div className="text-xs font-bold text-gray-500 bg-gray-800 px-2 py-1 rounded">#{probe.id}</div>
<div>
<div className="text-sm font-bold text-gray-300">{probe.name}</div>
<div className="text-xs text-gray-500">Secondary Sensor</div>
</div>
</div>
<div className="text-xl font-bold text-gray-400">{probe.temp > 0 ? probe.temp + '°' : '--'}</div>
</Card>
))}
</div>
</div>
</div>
</div>
</main>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
</script>
</body>
</html>