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:
@@ -383,7 +383,7 @@
|
||||
<button class="onglet" data-onglet="fonctions">Fonctions</button>
|
||||
<button class="onglet" data-onglet="personnalisation">Personnalisation</button>
|
||||
<button class="onglet" data-onglet="videos-admin" onclick="chargerVideosAdmin()">Videos</button>
|
||||
<button class="onglet" data-onglet="eclairage" onclick="demarrerEclairageLive()">Eclairage</button>
|
||||
<button class="onglet" data-onglet="eclairage" onclick="demarrerEclairageLive();demarrerEclairageLiveExt()">Eclairage</button>
|
||||
<button class="onglet" data-onglet="wifi" onclick="chargerWifi()">WiFi</button>
|
||||
<button class="onglet" data-onglet="infos" onclick="chargerInfosSysteme()">Infos</button>
|
||||
</div>
|
||||
@@ -890,6 +890,33 @@
|
||||
<div id="eclairage-visages" style="font-size:.9rem;color:#aaa">--</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 style="margin-top:1.5rem">Relais</h3>
|
||||
<div id="relais-status" style="margin-bottom:1rem;padding:0.5rem;background:#111;border-radius:6px;font-size:0.85rem;color:#aaa">Non connecte</div>
|
||||
<div style="display:flex;gap:0.5rem;flex-wrap:wrap;margin-bottom:1rem">
|
||||
<button class="btn-action btn-petit" onclick="relaisAction('projecteurs','on')">Projecteurs ON</button>
|
||||
<button class="btn-secondaire btn-petit" onclick="relaisAction('projecteurs','off')">Projecteurs OFF</button>
|
||||
<button class="btn-danger btn-petit" onclick="relaisAction('canon/power-cycle','on')">Power-cycle Canon</button>
|
||||
</div>
|
||||
<h4>Eclairage automatique</h4>
|
||||
<div class="champ">
|
||||
<label class="toggle"><input type="checkbox" id="tog-eclairage-auto"><span class="toggle-slider"></span> Allumer les projecteurs automatiquement selon la luminosite</label>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Seuil projecteur 1 (score <)</label>
|
||||
<input type="number" id="relais-seuil-proj1" min="0" max="100" value="45" step="5">
|
||||
<span style="font-size:0.75rem;color:#888">1 seul projecteur s'allume</span>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Seuil projecteur 2 (score <)</label>
|
||||
<input type="number" id="relais-seuil-proj2" min="0" max="100" value="30" step="5">
|
||||
<span style="font-size:0.75rem;color:#888">Les 2 projecteurs s'allument</span>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Seuil extinction (score >)</label>
|
||||
<input type="number" id="relais-seuil-off" min="0" max="100" value="65" step="5">
|
||||
<span style="font-size:0.75rem;color:#888">Projecteurs s'eteignent</span>
|
||||
</div>
|
||||
<button class="btn-action" onclick="sauvegarderRelaisConfig()">Sauvegarder</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-panneau" id="panneau-infos">
|
||||
@@ -1057,6 +1084,6 @@
|
||||
<script src="/js/effects.js?v=4"></script>
|
||||
<script src="/js/gallery.js?v=4"></script>
|
||||
<script src="/js/share.js?v=8"></script>
|
||||
<script src="/js/admin.js?v=12"></script>
|
||||
<script src="/js/admin.js?v=13"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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