synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
22
README.md
22
README.md
@@ -1,3 +1,21 @@
|
|||||||
# ploxion-photion
|
# 💡 Photion
|
||||||
|
|
||||||
PLOXION · Envoyer des commandes/tsoins par la LUMIÈRE : un écran clignote un morse binaire, une caméra le décode. Sans réseau, sur tout téléphone. · fournit: light-channel, vlc, tsoin-transport
|
Envoyer des commandes/tsoins par la LUMIÈRE : un écran clignote un morse binaire, une caméra le décode. Sans réseau, sur tout téléphone.
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `photion` |
|
||||||
|
| fournit | `light-channel` `vlc` `tsoin-transport` |
|
||||||
|
| bions qu'il nomme | `jOSApps` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/photion/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=photion — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre photion` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||||
|
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||||
|
|
||||||
|
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||||
|
|
||||||
|
© 2026 chill-tekk · ne pas nuire
|
||||||
|
|||||||
159
app.blade.php
Normal file
159
app.blade.php
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
{{-- PL0XI0N photion 💡 — canal de commande par la LUMIÈRE (RS-7 : « avec des photons, comme du morse
|
||||||
|
mais ultra rapide, pour des commandes simples »). Un écran CLIGNOTE une trame binaire ; une CAMÉRA
|
||||||
|
la lit (luminance) et décode → commande. Marche sur tout tel (iPhone inclus, pas besoin d'IR).
|
||||||
|
Déterministe (encoder→transmettre→décoder = machine-à-tsoins/Babel en photons). Offline, sans réseau.
|
||||||
|
Protocole : START (blanc long) · 8 bits data (blanc=1/noir=0, T ms/bit) · PARITÉ · STOP (noir long). --}}
|
||||||
|
<style>
|
||||||
|
.px-pho{display:flex;flex-direction:column;height:100%;background:var(--xr-bg,#05070d);color:var(--xr-text,#e8ecf8);font-family:var(--xr-font-ui,ui-sans-serif,system-ui)}
|
||||||
|
.px-pho .tabs{display:flex;border-bottom:1px solid var(--xr-border,#18213f)}
|
||||||
|
.px-pho .tabs button{flex:1;background:none;border:0;color:var(--xr-muted,#8aa0c8);padding:11px;font-size:.85rem;cursor:pointer;border-bottom:2px solid transparent}
|
||||||
|
.px-pho .tabs button.on{color:var(--xr-accent,#ffe08a);border-bottom-color:var(--xr-accent,#ffe08a)}
|
||||||
|
.px-pho .pane{flex:1;overflow:auto;padding:12px;display:none;flex-direction:column;gap:10px}
|
||||||
|
.px-pho .pane.on{display:flex}
|
||||||
|
.px-pho .cmds{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:8px}
|
||||||
|
.px-pho .cmds button{padding:14px 6px;border-radius:12px;border:1px solid var(--xr-border,#2b3a68);background:var(--xr-surface,#101a34);color:var(--xr-text,#cfe0ff);font-size:.82rem;cursor:pointer}
|
||||||
|
.px-pho .cmds button.sel{border-color:var(--xr-accent,#ffe08a);background:#241f0a;color:var(--xr-accent,#ffe08a)}
|
||||||
|
.px-pho .big{padding:15px;border:0;border-radius:12px;background:linear-gradient(135deg,#8a6a00,#ffe08a);color:#000;font-weight:800;font-size:1rem;cursor:pointer}
|
||||||
|
.px-pho .big.stop{background:#3a1010;color:#ff8a8a}
|
||||||
|
.px-pho .row{display:flex;gap:10px;align-items:center;font-size:.78rem;color:var(--xr-muted,#8aa0c8)}
|
||||||
|
.px-pho input[type=range]{flex:1}
|
||||||
|
.px-pho video{width:100%;border-radius:12px;background:#000;transform:scaleX(-1)}
|
||||||
|
.px-pho .meter{height:10px;border-radius:6px;background:var(--xr-surface,#101a34);overflow:hidden}
|
||||||
|
.px-pho .meter i{display:block;height:100%;background:linear-gradient(90deg,#2a5ad0,#ffe08a)}
|
||||||
|
.px-pho .out{font-family:ui-monospace,monospace;font-size:.82rem;color:#7fd0a0;background:var(--xr-surface,#0a1020);border-radius:8px;padding:10px;min-height:2.4em;white-space:pre-wrap}
|
||||||
|
.px-pho .muted{color:var(--xr-muted,#6f83b8);font-size:.72rem;line-height:1.4}
|
||||||
|
/* flasher plein écran */
|
||||||
|
.px-pho .flash{position:fixed;inset:0;z-index:2147483647;background:#000;display:none;align-items:flex-end;justify-content:center;padding-bottom:40px}
|
||||||
|
.px-pho .flash.on{display:flex}
|
||||||
|
.px-pho .flash .lbl{background:rgba(0,0,0,.5);color:#fff;mix-blend-mode:difference;font-size:.8rem;padding:8px 14px;border-radius:20px}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
// Table de commandes (code 0..255 → commande télécommande). Simple, extensible.
|
||||||
|
var CMDS = [
|
||||||
|
['/home', '/home'], ['/browser', 'open:browser'], ['🧠 braindump', 'open:braindump'], ['💬 coord', 'open:chat'],
|
||||||
|
['⛶ plein écran', 'fullscreen'], ['↑ défiler', 'scroll-up'], ['↓ défiler', 'scroll-down'], ['← retour', 'back'],
|
||||||
|
['🎛 ploxions', 'open:browser'], ['🚀 space', 'open:space'], ['🌌 carte', 'open:carte-espace'], ['📡 remote', 'open:remote']
|
||||||
|
];
|
||||||
|
function mount(container, ctx) {
|
||||||
|
container.innerHTML =
|
||||||
|
'<div class="px-pho">' +
|
||||||
|
'<div class="tabs"><button data-t="emit" class="on">💡 Émettre</button><button data-t="capt">📷 Capter</button></div>' +
|
||||||
|
'<div class="pane emit on" data-p="emit">' +
|
||||||
|
'<div class="muted">Choisis une commande, mets ce téléphone face à la caméra de l\'autre écran, et <b>Émettre</b> : l\'écran clignote le morse-photons.</div>' +
|
||||||
|
'<div class="cmds" data-cmds></div>' +
|
||||||
|
'<div class="row">vitesse <input type="range" data-speed min="60" max="260" value="140"> <span data-sp>140ms/bit</span></div>' +
|
||||||
|
'<button class="big" data-emit disabled>💡 Émettre en boucle</button>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="pane capt" data-p="capt">' +
|
||||||
|
'<div class="muted">Pointe cette caméra vers l\'écran qui clignote. Le décodeur lit la luminance et sort la commande.</div>' +
|
||||||
|
'<video data-video playsinline muted></video>' +
|
||||||
|
'<div class="meter"><i data-lvl style="width:0"></i></div>' +
|
||||||
|
'<div class="row"><button class="big" data-cam style="flex:1">📷 démarrer la caméra</button><label style="display:flex;gap:5px;align-items:center"><input type="checkbox" data-exec> exécuter</label></div>' +
|
||||||
|
'<div class="out" data-out>en attente…</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="flash" data-flash><div class="lbl" data-flabel></div></div>' +
|
||||||
|
'</div>';
|
||||||
|
var root = container.querySelector('.px-pho');
|
||||||
|
var sel = 0, emitting = false, T = 140, emitTimer = null;
|
||||||
|
var flash = root.querySelector('[data-flash]'), flabel = root.querySelector('[data-flabel]');
|
||||||
|
var emitBtn = root.querySelector('[data-emit]');
|
||||||
|
|
||||||
|
// ---- tabs ----
|
||||||
|
root.querySelectorAll('[data-t]').forEach(function (b) { b.onclick = function () {
|
||||||
|
root.querySelectorAll('[data-t]').forEach(function (x) { x.classList.toggle('on', x === b); });
|
||||||
|
root.querySelectorAll('.pane').forEach(function (p) { p.classList.toggle('on', p.getAttribute('data-p') === b.getAttribute('data-t')); });
|
||||||
|
}; });
|
||||||
|
|
||||||
|
// ---- table commandes ----
|
||||||
|
var cmdsEl = root.querySelector('[data-cmds]');
|
||||||
|
CMDS.forEach(function (c, i) { var b = document.createElement('button'); b.textContent = c[0]; if (i === 0) b.classList.add('sel');
|
||||||
|
b.onclick = function () { sel = i; cmdsEl.querySelectorAll('button').forEach(function (x, k) { x.classList.toggle('sel', k === i); }); emitBtn.disabled = false; }; cmdsEl.appendChild(b); });
|
||||||
|
emitBtn.disabled = false;
|
||||||
|
var speed = root.querySelector('[data-speed]');
|
||||||
|
speed.oninput = function () { T = +speed.value; root.querySelector('[data-sp]').textContent = T + 'ms/bit'; };
|
||||||
|
|
||||||
|
// ---- ÉMETTEUR : trame = START(blanc 3T) + 8 bits + parité + STOP(noir 3T) ----
|
||||||
|
function frameBits(code) {
|
||||||
|
var bits = []; var ones = 0;
|
||||||
|
for (var i = 7; i >= 0; i--) { var b = (code >> i) & 1; bits.push(b); ones += b; }
|
||||||
|
bits.push(ones & 1); // parité paire
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
function emitLoop() {
|
||||||
|
if (!emitting) return;
|
||||||
|
var bits = frameBits(sel), seq = [], i;
|
||||||
|
seq.push({ w: 1, d: 3 }); // START blanc long
|
||||||
|
for (i = 0; i < bits.length; i++) seq.push({ w: bits[i], d: 1 });
|
||||||
|
seq.push({ w: 0, d: 3 }); // STOP noir long
|
||||||
|
var k = 0;
|
||||||
|
(function step() {
|
||||||
|
if (!emitting) return;
|
||||||
|
if (k >= seq.length) { emitTimer = setTimeout(emitLoop, T); return; } // petite pause puis reboucle
|
||||||
|
var s = seq[k++];
|
||||||
|
flash.style.background = s.w ? '#fff' : '#000';
|
||||||
|
emitTimer = setTimeout(step, s.d * T);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
emitBtn.onclick = function () {
|
||||||
|
emitting = !emitting;
|
||||||
|
if (emitting) { flash.classList.add('on'); flabel.textContent = '💡 ' + CMDS[sel][0] + ' — touche pour arrêter'; emitBtn.textContent = '⏹ arrêter'; emitBtn.classList.add('stop'); emitLoop(); }
|
||||||
|
else stopEmit();
|
||||||
|
};
|
||||||
|
function stopEmit() { emitting = false; clearTimeout(emitTimer); flash.classList.remove('on'); emitBtn.textContent = '💡 Émettre en boucle'; emitBtn.classList.remove('stop'); }
|
||||||
|
flash.onclick = stopEmit;
|
||||||
|
|
||||||
|
// ---- RÉCEPTEUR : caméra → luminance → décodage ----
|
||||||
|
var stream = null, raf = null, video = root.querySelector('[data-video]');
|
||||||
|
var cv = document.createElement('canvas'); cv.width = 32; cv.height = 24; var cx = cv.getContext('2d', { willReadFrequently: true });
|
||||||
|
var outEl = root.querySelector('[data-out]'), lvlEl = root.querySelector('[data-lvl]');
|
||||||
|
var samples = [], loMax = { lo: 40, hi: 210 }, lastBit = -1, state = 'idle', highRun = 0, bitAcc = [], bitClock = 0;
|
||||||
|
|
||||||
|
function classifyExec(code) {
|
||||||
|
var cmd = CMDS[code]; var txt = cmd ? cmd[0] + ' → ' + cmd[1] : 'code ' + code + ' (inconnu)';
|
||||||
|
outEl.textContent = '✓ reçu : ' + txt;
|
||||||
|
if (cmd && root.querySelector('[data-exec]').checked) { try {
|
||||||
|
var c = cmd[1];
|
||||||
|
if (c.indexOf('open:') === 0 && window.jOS && window.jOS.openPloxion) window.jOS.openPloxion(c.slice(5));
|
||||||
|
else if (c === 'fullscreen' && window.jOS && window.jOS.tileFull) window.jOS.tileFull();
|
||||||
|
} catch (e) {} }
|
||||||
|
}
|
||||||
|
// Décodeur simple : détecte START (blanc soutenu ≥ ~2.5T), puis échantillonne 8 bits + parité au rythme T.
|
||||||
|
function loop() {
|
||||||
|
if (!video.videoWidth) { raf = requestAnimationFrame(loop); return; }
|
||||||
|
cx.drawImage(video, 0, 0, cv.width, cv.height);
|
||||||
|
var d = cx.getImageData(0, 0, cv.width, cv.height).data, sum = 0;
|
||||||
|
for (var p = 0; p < d.length; p += 4) sum += (d[p] + d[p + 1] + d[p + 2]);
|
||||||
|
var lum = sum / (d.length / 4) / 3; // 0..255
|
||||||
|
loMax.lo = Math.min(loMax.lo * 1.01, lum) ; loMax.hi = Math.max(loMax.hi * 0.99, lum);
|
||||||
|
var mid = (loMax.lo + loMax.hi) / 2, bit = lum > mid ? 1 : 0;
|
||||||
|
lvlEl.style.width = Math.min(100, lum / 255 * 100) + '%';
|
||||||
|
var now = performance.now ? performance.now() : Date.now();
|
||||||
|
|
||||||
|
if (state === 'idle') {
|
||||||
|
if (bit === 1) highRun += (now - (loop.last || now)); else highRun = 0;
|
||||||
|
if (highRun > 2.4 * T) { state = 'read'; bitAcc = []; bitClock = now + 3 * T + T / 2; } // fin START, centre du 1er bit
|
||||||
|
} else if (state === 'read') {
|
||||||
|
if (now >= bitClock) { bitAcc.push(bit); bitClock += T; if (bitAcc.length >= 9) { decodeFrame(bitAcc); state = 'idle'; highRun = 0; } }
|
||||||
|
}
|
||||||
|
loop.last = now;
|
||||||
|
raf = requestAnimationFrame(loop);
|
||||||
|
}
|
||||||
|
function decodeFrame(bits) {
|
||||||
|
var code = 0, ones = 0; for (var i = 0; i < 8; i++) { code = (code << 1) | bits[i]; ones += bits[i]; }
|
||||||
|
if ((ones & 1) === bits[8]) classifyExec(code); else outEl.textContent = '✗ trame corrompue (parité) — rapproche/stabilise';
|
||||||
|
}
|
||||||
|
root.querySelector('[data-cam]').onclick = function () {
|
||||||
|
if (stream) { stream.getTracks().forEach(function (t) { t.stop(); }); stream = null; cancelAnimationFrame(raf); root.querySelector('[data-cam]').textContent = '📷 démarrer la caméra'; outEl.textContent = 'caméra coupée'; return; }
|
||||||
|
navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } }).then(function (s) {
|
||||||
|
stream = s; video.srcObject = s; video.play(); root.querySelector('[data-cam]').textContent = '⏹ couper la caméra'; outEl.textContent = 'lecture… pointe vers l\'écran qui clignote'; loop();
|
||||||
|
}).catch(function () { outEl.textContent = 'caméra refusée / indispo'; });
|
||||||
|
};
|
||||||
|
|
||||||
|
return { unmount: function () { stopEmit(); if (stream) stream.getTracks().forEach(function (t) { t.stop(); }); cancelAnimationFrame(raf); if (flash.parentNode) flash.remove(); container.innerHTML = ''; } };
|
||||||
|
}
|
||||||
|
window.jOSApps = window.jOSApps || {};
|
||||||
|
window.jOSApps['photion'] = { manifest: { id: 'photion', name: 'Photion', icon: '💡' }, mount: mount };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user