This commit is contained in:
1 parent
31a47346ea
commit
8b6c9593e1
17 files changed
+446
-57
No files matched your search
+37
-7
@@ -2341,13 +2341,9 @@ async function validateJsonEditor() {
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
const out = await apiPost("/analyze", { payload: parsed });
|
||||
el.jsonFeedback.textContent = `Validation: ${out.errors.length} errors, ${out.warnings.length} warnings.`;
|
||||
if (!out.errors.length && !out.warnings.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const first = out.errors[0] ?? out.warnings[0];
|
||||
el.jsonFeedback.textContent += ` First issue: ${first.message}`;
|
||||
const firstPath = first?.path ? ` (${first.path})` : "";
|
||||
el.jsonFeedback.textContent = `Validation: ${out.errors.length} errors, ${out.warnings.length} warnings.${first ? ` First issue: ${first.message}${firstPath}` : ""}`;
|
||||
} catch (err) {
|
||||
const p = parseJsonPositionError(text, err);
|
||||
if (p.line != null) {
|
||||
@@ -2365,6 +2361,28 @@ async function validateJsonEditor() {
|
||||
}
|
||||
}
|
||||
|
||||
async function analyzeModelForImport(parsed, sourceName = "JSON") {
|
||||
const out = await apiPost("/analyze", { payload: parsed });
|
||||
if (out.errors.length) {
|
||||
const first = out.errors[0];
|
||||
const path = first.path ? ` (${first.path})` : "";
|
||||
const msg = `${sourceName} blocked by validation: ${out.errors.length} error(s), ${out.warnings.length} warning(s). First error: ${first.message}${path}`;
|
||||
return { ok: false, out, message: msg };
|
||||
}
|
||||
|
||||
const firstWarn = out.warnings[0];
|
||||
if (firstWarn) {
|
||||
const path = firstWarn.path ? ` (${firstWarn.path})` : "";
|
||||
return {
|
||||
ok: true,
|
||||
out,
|
||||
message: `${sourceName} validated: ${out.errors.length} errors, ${out.warnings.length} warnings. First warning: ${firstWarn.message}${path}`
|
||||
};
|
||||
}
|
||||
|
||||
return { ok: true, out, message: `${sourceName} validated: 0 errors, 0 warnings.` };
|
||||
}
|
||||
|
||||
async function runLayoutAction(path) {
|
||||
if (!state.model) {
|
||||
return;
|
||||
@@ -3570,6 +3588,11 @@ function setupEvents() {
|
||||
el.applyJsonBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
const parsed = JSON.parse(el.jsonEditor.value);
|
||||
const analyzed = await analyzeModelForImport(parsed, "Apply JSON");
|
||||
el.jsonFeedback.textContent = analyzed.message;
|
||||
if (!analyzed.ok) {
|
||||
return;
|
||||
}
|
||||
const before = state.model ? clone(state.model) : null;
|
||||
if (state.model) {
|
||||
pushHistory("apply-json");
|
||||
@@ -3579,7 +3602,7 @@ function setupEvents() {
|
||||
state.selectedNet = null;
|
||||
state.selectedPin = null;
|
||||
await compileModel(parsed, { fit: true });
|
||||
el.jsonFeedback.textContent = summarizeModelDelta(before, state.model);
|
||||
el.jsonFeedback.textContent = `${summarizeModelDelta(before, state.model)} ${analyzed.out.warnings.length ? `Validation warnings: ${analyzed.out.warnings.length}.` : "Validation clean."}`;
|
||||
} catch (err) {
|
||||
const p = parseJsonPositionError(el.jsonEditor.value, err);
|
||||
el.jsonFeedback.textContent = `Apply failed: ${p.message}`;
|
||||
@@ -3634,6 +3657,12 @@ function setupEvents() {
|
||||
try {
|
||||
const content = await file.text();
|
||||
const parsed = JSON.parse(content);
|
||||
const analyzed = await analyzeModelForImport(parsed, "Import JSON");
|
||||
if (!analyzed.ok) {
|
||||
el.jsonFeedback.textContent = analyzed.message;
|
||||
return;
|
||||
}
|
||||
const before = state.model ? clone(state.model) : null;
|
||||
if (state.model) {
|
||||
pushHistory("import-json");
|
||||
}
|
||||
@@ -3641,6 +3670,7 @@ function setupEvents() {
|
||||
state.selectedNet = null;
|
||||
state.selectedPin = null;
|
||||
await compileModel(parsed, { fit: true });
|
||||
el.jsonFeedback.textContent = `${summarizeModelDelta(before, state.model)} Imported from file (${analyzed.out.warnings.length} warnings).`;
|
||||
} catch (err) {
|
||||
setStatus(`Import failed: ${err.message}`, false);
|
||||
}
|
||||
|
||||
+107
-37
@@ -1,91 +1,161 @@
|
||||
{
|
||||
"meta": {
|
||||
"title": "ESP32 Audio Path"
|
||||
"title": "ESP32 Smart Audio + Sensing Node"
|
||||
},
|
||||
"symbols": {
|
||||
"esp32_s3_supermini": {
|
||||
"symbol_id": "esp32_s3_supermini",
|
||||
"category": "microcontroller",
|
||||
"body": { "width": 160, "height": 240 },
|
||||
"body": { "width": 180, "height": 280 },
|
||||
"pins": [
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 30, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 60, "type": "ground" },
|
||||
{ "name": "GPIO5", "number": "10", "side": "right", "offset": 40, "type": "output" },
|
||||
{ "name": "GPIO6", "number": "11", "side": "right", "offset": 70, "type": "output" },
|
||||
{ "name": "GPIO7", "number": "12", "side": "right", "offset": 100, "type": "output" }
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 24, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 56, "type": "ground" },
|
||||
{ "name": "GPIO5", "number": "10", "side": "right", "offset": 36, "type": "output" },
|
||||
{ "name": "GPIO6", "number": "11", "side": "right", "offset": 66, "type": "output" },
|
||||
{ "name": "GPIO7", "number": "12", "side": "right", "offset": 96, "type": "output" },
|
||||
{ "name": "GPIO8", "number": "13", "side": "right", "offset": 126, "type": "input" },
|
||||
{ "name": "GPIO9", "number": "14", "side": "right", "offset": 156, "type": "bidirectional" },
|
||||
{ "name": "GPIO10", "number": "15", "side": "right", "offset": 186, "type": "bidirectional" },
|
||||
{ "name": "GPIO11", "number": "16", "side": "right", "offset": 216, "type": "output" },
|
||||
{ "name": "GPIO12", "number": "17", "side": "right", "offset": 246, "type": "output" }
|
||||
],
|
||||
"graphics": {
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 160, "h": 240 }]
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 180, "h": 280 }]
|
||||
}
|
||||
},
|
||||
"dac_i2s": {
|
||||
"symbol_id": "dac_i2s",
|
||||
"category": "audio",
|
||||
"body": { "width": 140, "height": 180 },
|
||||
"body": { "width": 160, "height": 200 },
|
||||
"pins": [
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 20, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 50, "type": "ground" },
|
||||
{ "name": "BCLK", "number": "3", "side": "left", "offset": 80, "type": "input" },
|
||||
{ "name": "LRCLK", "number": "4", "side": "left", "offset": 110, "type": "input" },
|
||||
{ "name": "DIN", "number": "5", "side": "left", "offset": 140, "type": "input" },
|
||||
{ "name": "AOUT", "number": "6", "side": "right", "offset": 90, "type": "analog" }
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 24, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 54, "type": "ground" },
|
||||
{ "name": "BCLK", "number": "3", "side": "left", "offset": 86, "type": "input" },
|
||||
{ "name": "LRCLK", "number": "4", "side": "left", "offset": 116, "type": "input" },
|
||||
{ "name": "DIN", "number": "5", "side": "left", "offset": 146, "type": "input" },
|
||||
{ "name": "AOUT", "number": "6", "side": "right", "offset": 96, "type": "analog" }
|
||||
],
|
||||
"graphics": {
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 140, "h": 180 }]
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 160, "h": 200 }]
|
||||
}
|
||||
},
|
||||
"amp": {
|
||||
"symbol_id": "amp",
|
||||
"category": "output",
|
||||
"body": { "width": 120, "height": 120 },
|
||||
"body": { "width": 130, "height": 130 },
|
||||
"pins": [
|
||||
{ "name": "5V", "number": "1", "side": "left", "offset": 20, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 50, "type": "ground" },
|
||||
{ "name": "IN", "number": "3", "side": "left", "offset": 80, "type": "input" },
|
||||
{ "name": "SPK", "number": "4", "side": "right", "offset": 70, "type": "output" }
|
||||
{ "name": "5V", "number": "1", "side": "left", "offset": 22, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 52, "type": "ground" },
|
||||
{ "name": "IN", "number": "3", "side": "left", "offset": 84, "type": "input" },
|
||||
{ "name": "SPK", "number": "4", "side": "right", "offset": 74, "type": "output" }
|
||||
],
|
||||
"graphics": {
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 120, "h": 120 }]
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 130, "h": 130 }]
|
||||
}
|
||||
},
|
||||
"psu": {
|
||||
"symbol_id": "psu",
|
||||
"category": "power",
|
||||
"body": { "width": 120, "height": 120 },
|
||||
"body": { "width": 140, "height": 140 },
|
||||
"pins": [
|
||||
{ "name": "5V_OUT", "number": "1", "side": "right", "offset": 30, "type": "power_out" },
|
||||
{ "name": "3V3_OUT", "number": "2", "side": "right", "offset": 60, "type": "power_out" },
|
||||
{ "name": "GND", "number": "3", "side": "right", "offset": 90, "type": "ground" }
|
||||
{ "name": "5V_OUT", "number": "1", "side": "right", "offset": 34, "type": "power_out" },
|
||||
{ "name": "3V3_OUT", "number": "2", "side": "right", "offset": 70, "type": "power_out" },
|
||||
{ "name": "GND", "number": "3", "side": "right", "offset": 104, "type": "ground" }
|
||||
],
|
||||
"graphics": {
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 120, "h": 120 }]
|
||||
"primitives": [{ "type": "rect", "x": 0, "y": 0, "w": 140, "h": 140 }]
|
||||
}
|
||||
},
|
||||
"imu_i2c": {
|
||||
"symbol_id": "imu_i2c",
|
||||
"category": "sensor",
|
||||
"body": { "width": 140, "height": 120 },
|
||||
"pins": [
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 18, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 44, "type": "ground" },
|
||||
{ "name": "SCL", "number": "3", "side": "left", "offset": 70, "type": "bidirectional" },
|
||||
{ "name": "SDA", "number": "4", "side": "left", "offset": 96, "type": "bidirectional" }
|
||||
]
|
||||
},
|
||||
"oled_i2c": {
|
||||
"symbol_id": "oled_i2c",
|
||||
"category": "display",
|
||||
"body": { "width": 140, "height": 120 },
|
||||
"pins": [
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 18, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 44, "type": "ground" },
|
||||
{ "name": "SCL", "number": "3", "side": "left", "offset": 70, "type": "bidirectional" },
|
||||
{ "name": "SDA", "number": "4", "side": "left", "offset": 96, "type": "bidirectional" }
|
||||
]
|
||||
},
|
||||
"mic_pre": {
|
||||
"symbol_id": "mic_pre",
|
||||
"category": "analog",
|
||||
"body": { "width": 150, "height": 120 },
|
||||
"pins": [
|
||||
{ "name": "3V3", "number": "1", "side": "left", "offset": 20, "type": "power_in" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 48, "type": "ground" },
|
||||
{ "name": "OUT", "number": "3", "side": "right", "offset": 62, "type": "analog" },
|
||||
{ "name": "EN", "number": "4", "side": "left", "offset": 90, "type": "input" }
|
||||
]
|
||||
},
|
||||
"debug_header": {
|
||||
"symbol_id": "debug_header",
|
||||
"category": "connector",
|
||||
"body": { "width": 130, "height": 80 },
|
||||
"pins": [
|
||||
{ "name": "1", "number": "1", "side": "right", "offset": 24, "type": "bidirectional" },
|
||||
{ "name": "GND", "number": "2", "side": "left", "offset": 24, "type": "ground" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"instances": [
|
||||
{ "ref": "U1", "symbol": "esp32_s3_supermini", "properties": { "value": "ESP32-S3" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U2", "symbol": "dac_i2s", "properties": { "value": "DAC" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U3", "symbol": "amp", "properties": { "value": "Amp" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U4", "symbol": "psu", "properties": { "value": "Power" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } }
|
||||
{ "ref": "U3", "symbol": "amp", "properties": { "value": "Class-D Amp" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U4", "symbol": "psu", "properties": { "value": "5V/3V3 Power" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U5", "symbol": "imu_i2c", "properties": { "value": "IMU" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U6", "symbol": "oled_i2c", "properties": { "value": "OLED" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "U7", "symbol": "mic_pre", "properties": { "value": "Mic Preamp" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "J1", "symbol": "debug_header", "properties": { "value": "Debug Header" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "R1", "part": "resistor", "properties": { "value": "10k" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "R2", "part": "resistor", "properties": { "value": "10k" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "C1", "part": "capacitor", "properties": { "value": "100nF" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "C2", "part": "capacitor", "properties": { "value": "100nF" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
|
||||
{ "ref": "C3", "part": "capacitor", "properties": { "value": "1uF" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } }
|
||||
],
|
||||
"nets": [
|
||||
{ "name": "3V3", "class": "power", "nodes": [{ "ref": "U4", "pin": "3V3_OUT" }, { "ref": "U1", "pin": "3V3" }, { "ref": "U2", "pin": "3V3" }] },
|
||||
{ "name": "3V3", "class": "power", "nodes": [{ "ref": "U4", "pin": "3V3_OUT" }, { "ref": "U1", "pin": "3V3" }, { "ref": "U2", "pin": "3V3" }, { "ref": "U5", "pin": "3V3" }, { "ref": "U6", "pin": "3V3" }, { "ref": "U7", "pin": "3V3" }, { "ref": "R1", "pin": "1" }, { "ref": "R2", "pin": "1" }, { "ref": "C1", "pin": "1" }, { "ref": "C2", "pin": "1" }, { "ref": "C3", "pin": "1" }] },
|
||||
{ "name": "5V", "class": "power", "nodes": [{ "ref": "U4", "pin": "5V_OUT" }, { "ref": "U3", "pin": "5V" }] },
|
||||
{ "name": "GND", "class": "ground", "nodes": [{ "ref": "U4", "pin": "GND" }, { "ref": "U1", "pin": "GND" }, { "ref": "U2", "pin": "GND" }, { "ref": "U3", "pin": "GND" }] },
|
||||
{ "name": "GND", "class": "ground", "nodes": [{ "ref": "U4", "pin": "GND" }, { "ref": "U1", "pin": "GND" }, { "ref": "U2", "pin": "GND" }, { "ref": "U3", "pin": "GND" }, { "ref": "U5", "pin": "GND" }, { "ref": "U6", "pin": "GND" }, { "ref": "U7", "pin": "GND" }, { "ref": "J1", "pin": "GND" }, { "ref": "R1", "pin": "2" }, { "ref": "R2", "pin": "2" }, { "ref": "C1", "pin": "2" }, { "ref": "C2", "pin": "2" }, { "ref": "C3", "pin": "2" }] },
|
||||
{ "name": "I2S_BCLK", "class": "clock", "nodes": [{ "ref": "U1", "pin": "GPIO5" }, { "ref": "U2", "pin": "BCLK" }] },
|
||||
{ "name": "I2S_LRCLK", "class": "clock", "nodes": [{ "ref": "U1", "pin": "GPIO6" }, { "ref": "U2", "pin": "LRCLK" }] },
|
||||
{ "name": "I2S_DOUT", "class": "signal", "nodes": [{ "ref": "U1", "pin": "GPIO7" }, { "ref": "U2", "pin": "DIN" }] },
|
||||
{ "name": "AUDIO_ANALOG", "class": "analog", "nodes": [{ "ref": "U2", "pin": "AOUT" }, { "ref": "U3", "pin": "IN" }] }
|
||||
{ "name": "AUDIO_ANALOG", "class": "analog", "nodes": [{ "ref": "U2", "pin": "AOUT" }, { "ref": "U3", "pin": "IN" }] },
|
||||
{ "name": "I2C_SCL", "class": "clock", "nodes": [{ "ref": "U1", "pin": "GPIO9" }, { "ref": "U5", "pin": "SCL" }, { "ref": "U6", "pin": "SCL" }] },
|
||||
{ "name": "I2C_SDA", "class": "signal", "nodes": [{ "ref": "U1", "pin": "GPIO10" }, { "ref": "U5", "pin": "SDA" }, { "ref": "U6", "pin": "SDA" }] },
|
||||
{ "name": "MIC_ADC", "class": "analog", "nodes": [{ "ref": "U7", "pin": "OUT" }, { "ref": "U1", "pin": "GPIO8" }, { "ref": "C3", "pin": "1" }] },
|
||||
{ "name": "MIC_EN", "class": "signal", "nodes": [{ "ref": "U1", "pin": "GPIO11" }, { "ref": "U7", "pin": "EN" }] },
|
||||
{ "name": "DEBUG_TX", "class": "signal", "nodes": [{ "ref": "U1", "pin": "GPIO12" }, { "ref": "J1", "pin": "1" }] }
|
||||
],
|
||||
"constraints": {
|
||||
"groups": [
|
||||
{ "name": "power_stage", "members": ["U4"], "layout": "cluster" },
|
||||
{ "name": "compute", "members": ["U1", "U2"], "layout": "cluster" }
|
||||
{ "name": "power_stage", "members": ["U4", "C1", "C2"], "layout": "cluster" },
|
||||
{ "name": "compute_audio", "members": ["U1", "U2", "U3", "U7"], "layout": "cluster" },
|
||||
{ "name": "i2c_peripherals", "members": ["U5", "U6", "R1", "R2"], "layout": "cluster" },
|
||||
{ "name": "debug", "members": ["J1"], "layout": "cluster" }
|
||||
],
|
||||
"alignment": [{ "left_of": "U1", "right_of": "U2" }],
|
||||
"near": [{ "component": "U2", "target_pin": { "ref": "U1", "pin": "GPIO5" } }]
|
||||
"alignment": [
|
||||
{ "left_of": "U1", "right_of": "U2" },
|
||||
{ "left_of": "U2", "right_of": "U3" }
|
||||
],
|
||||
"near": [
|
||||
{ "component": "C1", "target_pin": { "ref": "U1", "pin": "3V3" } },
|
||||
{ "component": "C2", "target_pin": { "ref": "U2", "pin": "3V3" } },
|
||||
{ "component": "C3", "target_pin": { "ref": "U7", "pin": "OUT" } }
|
||||
]
|
||||
},
|
||||
"annotations": [
|
||||
{ "text": "I2S audio chain" }
|
||||
{ "text": "Smart audio + sensing node with I2S DAC, class-D amp, I2C peripherals, and mic ADC front-end." }
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user