Module relais USB HID : pilotage projecteurs + alim Canon + eclairage auto
Pilote backend/relais.py (hidapi/ctypes) pour module LCUS 5131:2007. Relais 1-2 = projecteurs (NO), relais 3 = alim Canon (NF). API : status, on/off par nom, power-cycle, config seuils. Eclairage auto : analyse luminosite visage → allume projecteurs selon seuils. Admin : onglet eclairage enrichi avec boutons relais + seuils configurables. Note : power-cycle Canon par relais ne redémarre pas le DSLR (contact capot batterie). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1823,3 +1823,73 @@ async function sauvegarderSurprise() {
|
||||
});
|
||||
afficherStatut('Surprise sauvegardee', 'succes');
|
||||
}
|
||||
|
||||
// === RELAIS ===
|
||||
|
||||
async function chargerRelaisStatus() {
|
||||
try {
|
||||
const data = await apiGet('/api/relais');
|
||||
const el = document.getElementById('relais-status');
|
||||
if (!el) return;
|
||||
if (!data.connecte) {
|
||||
el.textContent = 'Module relais non connecte';
|
||||
el.style.color = '#f44';
|
||||
return;
|
||||
}
|
||||
const proj_g = data.projecteur_gauche ? '🟢' : '⚫';
|
||||
const proj_d = data.projecteur_droit ? '🟢' : '⚫';
|
||||
const canon = data.canon ? '🟢' : '🔴';
|
||||
el.innerHTML = `Proj G: ${proj_g} | Proj D: ${proj_d} | Canon: ${canon} (alim)`;
|
||||
el.style.color = '#4caf50';
|
||||
} catch (e) {
|
||||
console.warn('Erreur relais status:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function chargerRelaisConfig() {
|
||||
try {
|
||||
const data = await apiGet('/api/relais/config');
|
||||
const tog = document.getElementById('tog-eclairage-auto');
|
||||
if (tog) tog.checked = !!data.eclairage_auto;
|
||||
const s1 = document.getElementById('relais-seuil-proj1');
|
||||
if (s1) s1.value = data.seuil_proj1 ?? 45;
|
||||
const s2 = document.getElementById('relais-seuil-proj2');
|
||||
if (s2) s2.value = data.seuil_proj2 ?? 30;
|
||||
const soff = document.getElementById('relais-seuil-off');
|
||||
if (soff) soff.value = data.seuil_off ?? 65;
|
||||
} catch (e) {
|
||||
console.warn('Erreur relais config:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function sauvegarderRelaisConfig() {
|
||||
const eclairage_auto = document.getElementById('tog-eclairage-auto')?.checked || false;
|
||||
const seuil_proj1 = parseInt(document.getElementById('relais-seuil-proj1')?.value) || 45;
|
||||
const seuil_proj2 = parseInt(document.getElementById('relais-seuil-proj2')?.value) || 30;
|
||||
const seuil_off = parseInt(document.getElementById('relais-seuil-off')?.value) || 65;
|
||||
await apiPost('/api/relais/config', { eclairage_auto, seuil_proj1, seuil_proj2, seuil_off });
|
||||
afficherStatut('Config relais sauvegardee', 'succes');
|
||||
}
|
||||
|
||||
async function relaisAction(nom, action) {
|
||||
try {
|
||||
if (nom === 'canon/power-cycle') {
|
||||
await fetch('/api/relais/canon/power-cycle', {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({duree: 3})
|
||||
});
|
||||
afficherStatut('Power-cycle Canon lance (3s)', 'succes');
|
||||
} else {
|
||||
await fetch(`/api/relais/${nom}/${action}`, { method: 'POST' });
|
||||
afficherStatut(`${nom} ${action}`, 'succes');
|
||||
}
|
||||
setTimeout(chargerRelaisStatus, 500);
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur relais', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
function demarrerEclairageLiveExt() {
|
||||
chargerRelaisStatus();
|
||||
chargerRelaisConfig();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user