Skip to content

Commit e0b951e

Browse files
author
Jasper van Bourgognie
committed
SmartScopeSettings: cover case where setting digital trigger null
1 parent 5d1371d commit e0b951e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Devices/SmartScopeSettings.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,16 @@ private Dictionary<DigitalChannel, DigitalTriggerValue> TriggerDigital
414414
{
415415
set
416416
{
417-
this.triggerDigital = value;
418-
int rising = value.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.R ? 1 : 0) << x.Key.Value));
419-
int falling = value.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.F ? 1 : 0) << x.Key.Value));
420-
int high = value.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.H ? 1 : 0) << x.Key.Value));
421-
int low = value.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.L ? 1 : 0) << x.Key.Value));
417+
if(value == null) {
418+
this.triggerDigital = new Dictionary<DigitalChannel, DigitalTriggerValue>();
419+
foreach(DigitalChannel ch in DigitalChannel.List)
420+
this.triggerDigital[ch] = DigitalTriggerValue.X;
421+
} else
422+
this.triggerDigital = value;
423+
int rising = this.triggerDigital.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.R ? 1 : 0) << x.Key.Value));
424+
int falling = this.triggerDigital.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.F ? 1 : 0) << x.Key.Value));
425+
int high = this.triggerDigital.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.H ? 1 : 0) << x.Key.Value));
426+
int low = this.triggerDigital.Aggregate(0, (r, x) => r + ((x.Value == DigitalTriggerValue.L ? 1 : 0) << x.Key.Value));
422427
FpgaSettingsMemory[REG.DIGITAL_TRIGGER_RISING].Set((byte)rising);
423428
FpgaSettingsMemory[REG.DIGITAL_TRIGGER_FALLING].Set((byte)falling);
424429
FpgaSettingsMemory[REG.DIGITAL_TRIGGER_HIGH].Set((byte)high);

0 commit comments

Comments
 (0)