diff --git a/frontend/public/components-metadata.json b/frontend/public/components-metadata.json index e683dd14..5f8a90a4 100644 --- a/frontend/public/components-metadata.json +++ b/frontend/public/components-metadata.json @@ -3762,7 +3762,7 @@ "name": "lux", "type": "number", "defaultValue": 500, - "control": "range", + "control": "number", "min": 0, "max": 100000, "description": "Illumination in lux" diff --git a/frontend/src/simulation/parts/SensorParts.ts b/frontend/src/simulation/parts/SensorParts.ts index b88cbafc..dc1dc392 100644 --- a/frontend/src/simulation/parts/SensorParts.ts +++ b/frontend/src/simulation/parts/SensorParts.ts @@ -4,6 +4,7 @@ * Implements: * - tilt-switch * - ntc-temperature-sensor + * - photodiode * - gas-sensor (MQ-series) * - flame-sensor * - heart-beat-sensor @@ -99,6 +100,28 @@ PartSimulationRegistry.register('ntc-temperature-sensor', { }, }); +// ─── Photodiode ────────────────────────────────────────────────────────────── + +/** + * Photodiode — 2-terminal passive, reverse-biased light sensor. The SPICE + * emitter (componentToSpice.ts) reads `properties.lux` and drives a current + * source (100 nA/lux). This handler wires the SensorControlPanel slider so + * moving it updates the store → netlist rebuild → re-solve. + */ +PartSimulationRegistry.register('photodiode', { + attachEvents: (_element, _simulator, _getArduinoPinHelper, componentId) => { + registerSensorUpdate(componentId, (values) => { + if ('lux' in values) { + emitPropertyChange(componentId, 'lux', values.lux); + } + }); + + return () => { + unregisterSensorUpdate(componentId); + }; + }, +}); + // ─── Gas Sensor (MQ-series) ────────────────────────────────────────────────── /** diff --git a/frontend/src/simulation/sensorControlConfig.ts b/frontend/src/simulation/sensorControlConfig.ts index e4020d76..096d511d 100644 --- a/frontend/src/simulation/sensorControlConfig.ts +++ b/frontend/src/simulation/sensorControlConfig.ts @@ -226,6 +226,24 @@ export const SENSOR_CONTROLS: Record = { defaultValues: { lux: 500 }, }, + // ── Photodiode ──────────────────────────────────────────────────────────── + photodiode: { + title: 'Photodiode', + controls: [ + { + type: 'slider', + key: 'lux', + label: 'Illumination', + min: 0, + max: 1000, + step: 1, + unit: 'lux', + defaultValue: 500, + }, + ], + defaultValues: { lux: 500 }, + }, + // ── PIR Motion Sensor ───────────────────────────────────────────────────── 'pir-motion-sensor': { title: 'PIR Motion Sensor', diff --git a/scripts/component-overrides.json b/scripts/component-overrides.json index df94f77d..1da9bb50 100644 --- a/scripts/component-overrides.json +++ b/scripts/component-overrides.json @@ -1026,7 +1026,7 @@ "name": "lux", "type": "number", "defaultValue": 500, - "control": "range", + "control": "number", "min": 0, "max": 100000, "description": "Illumination in lux"