Files
esp-emu-peris/sync_www.py
T
darceye a9d26722d7 M0+M1: feasibility probe and peripherals framework
M0 (docs/FEASIBILITY.md, verified against esp-emulator wasm v0.51.0):
- GPIO outputs observable via gpio_state(); gpio_set_input() drives pads
  and raises guest interrupts (button-class peripherals work)
- LEDC PWM and RMT waveforms are NOT visible in the pad registers; duty
  is readable from LEDC registers and WS2812 frames decode from RMT
  channel RAM (per-chip MMIO map in peris/mmio/)
- Node probe + ESP-IDF test firmware (gpio/ledc/rmt three-phase loop)

M1 peripherals framework:
- esp-emu-peris.html entry (stock layout + Peripherals/Debug tabs),
  peris/worker.js (stock worker clone + per-batch pin sampling hooks)
- device plugin API v1 (docs/DEVICE-API.md) with manifest registry:
  add a peripheral = one module + one manifest line
- devices: led, button, touch-button, toggle-switch; wiring config
  import/export + localStorage autosave; pin-conflict reporting
- serve.py merged dev server, sync_www.py publisher (www only gains
  files, stock ones untouched), xterm vendored locally (no CDN)
- tests/m1_smoke.mjs integration smoke (config/LED state/button ISR/
  toggle/conflict/unknown-type) - all green
2026-10-29 19:22:45 +08:00

57 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""
Publish esp-emu-peris into an esp-emu-browser www directory: copies the
entry HTML, the peris/ tree and examples/. Existing stock files
(index.html, app.js, worker.js, pkg/) are never touched.
Usage: python sync_www.py [--www PATH] [--clean]
default www ../_tools/esp-emu-browser/www
--clean removes a previously synced peris/ from www first
"""
import argparse
import os
import shutil
REPO = os.path.dirname(os.path.abspath(__file__))
ITEMS = ['esp-emu-peris.html', 'peris', 'examples']
def sync(www, clean=False):
ok = True
for name in ITEMS:
src = os.path.join(REPO, name)
dst = os.path.join(www, name)
if not os.path.exists(src):
print(f'skip (missing in repo): {name}')
continue
if clean and os.path.isdir(dst):
shutil.rmtree(dst)
try:
if os.path.isdir(src):
shutil.copytree(src, dst, dirs_exist_ok=True)
else:
shutil.copy2(src, dst)
print(f'copied: {name}')
except OSError as e:
print(f'FAILED: {name}: {e}')
ok = False
return ok
def main():
default_www = os.path.normpath(os.path.join(REPO, '..', '_tools', 'esp-emu-browser', 'www'))
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument('--www', default=default_www, help='esp-emu-browser www directory')
ap.add_argument('--clean', action='store_true', help='remove old peris/ in www before copying')
args = ap.parse_args()
if not os.path.isdir(args.www):
raise SystemExit(f'error: {args.www} is not a directory')
ok = sync(args.www, args.clean)
print('done' if ok else 'done with errors')
raise SystemExit(0 if ok else 1)
if __name__ == '__main__':
main()