-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtroubleshooting.js
More file actions
63 lines (56 loc) · 2.61 KB
/
troubleshooting.js
File metadata and controls
63 lines (56 loc) · 2.61 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
export class TroubleshootingHandler {
constructor(ws, store) {
this.ws = ws;
this.store = store;
this.lastPins = "";
}
/**
* Update the visual state of pin indicators
* @param {string} pins - The Pn: string from grblHAL status report (e.g. "PXYZ")
*/
updatePins(pins) {
if (pins === this.lastPins) return;
this.lastPins = pins;
// All grblHAL Pn: signals
// Limit switches: X, Y, Z, A, B, C, U, V, W
// Probe: P (triggered), O (disconnected)
// Control: D (door), R (reset), H (hold), S (start), E (e-stop), L (block delete), T (optional stop), Q (single step)
// Motor: M (warning), F (fault)
const pinChars = ['X', 'Y', 'Z', 'A', 'B', 'C', 'U', 'V', 'W', 'P', 'O', 'D', 'R', 'H', 'S', 'E', 'L', 'T', 'Q', 'M', 'F'];
pinChars.forEach(char => {
const el = document.getElementById(`pin-indicator-${char}`);
if (!el) return;
const isActive = pins.includes(char);
// Troubleshooting tab uses the .signal-badge class
if (isActive) {
el.classList.remove('signal-off');
el.classList.add('signal-on');
el.textContent = 'ON';
// Color overrides for critical/warning pins
if (['E', 'F'].includes(char)) {
// Critical Error (Red)
el.style.cssText = 'background:#fee2e2;color:#dc2626;border-color:#fca5a5;box-shadow:0 0 8px rgba(220,38,38,0.25)';
} else if (['M', 'O'].includes(char)) {
// Warning (Yellow)
el.style.cssText = 'background:#fef9c3;color:#ca8a04;border-color:#fde047;box-shadow:0 0 8px rgba(202,138,4,0.2)';
} else if (['X', 'Y', 'Z', 'A', 'B', 'C', 'U', 'V', 'W', 'D'].includes(char)) {
// Input/Safety (Soft Red)
el.style.cssText = 'background:#fee2e2;color:#dc2626;border-color:#fca5a5;box-shadow:0 0 8px rgba(220,38,38,0.2)';
} else {
// Normal Active (Green)
el.style.cssText = '';
}
} else {
el.classList.remove('signal-on');
el.classList.add('signal-off');
el.textContent = 'OFF';
el.style.cssText = '';
}
});
}
refresh() {
// Troubleshooting is passive (updates from status reports),
// but we could request a full status here if needed.
if (window.requestFullStatus) window.requestFullStatus();
}
}