feat(photodiode): add lux control in sensor panel and property dialog
The SPICE emitter already reads properties.lux (default 500, 100 nA/lux) but the UI had no way to set it — the static dialog rejected the "range" control type and there was no entry in SENSOR_CONTROLS for the live panel. - Add photodiode entry in SENSOR_CONTROLS (slider 0-1000 lux) - Register a minimal PartSimulationRegistry handler that forwards slider values via emitPropertyChange so the netlist memo invalidates - Switch the photodiode lux control from "range" to "number" so the static ComponentPropertyDialog renders an editable input
This commit is contained in:
parent
4708d54195
commit
7e026179aa
|
|
@ -3762,7 +3762,7 @@
|
|||
"name": "lux",
|
||||
"type": "number",
|
||||
"defaultValue": 500,
|
||||
"control": "range",
|
||||
"control": "number",
|
||||
"min": 0,
|
||||
"max": 100000,
|
||||
"description": "Illumination in lux"
|
||||
|
|
|
|||
|
|
@ -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) ──────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -226,6 +226,24 @@ export const SENSOR_CONTROLS: Record<string, SensorControlDef> = {
|
|||
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',
|
||||
|
|
|
|||
|
|
@ -1026,7 +1026,7 @@
|
|||
"name": "lux",
|
||||
"type": "number",
|
||||
"defaultValue": 500,
|
||||
"control": "range",
|
||||
"control": "number",
|
||||
"min": 0,
|
||||
"max": 100000,
|
||||
"description": "Illumination in lux"
|
||||
|
|
|
|||
Loading…
Reference in New Issue