Skip to content

Commit

Permalink
Fix various UI element issues
Browse files Browse the repository at this point in the history
- Order of enums in dropdowns
- Random brightness range for MiniCam LEDs
- Etc.
  • Loading branch information
jonnew committed Nov 7, 2024
1 parent 8147354 commit dc48e89
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<UseArtifactsOutput>true</UseArtifactsOutput>
<PackageIcon>icon.png</PackageIcon>
<VersionPrefix>0.3.1</VersionPrefix>
<VersionPrefix>0.3.2</VersionPrefix>
<VersionSuffix></VersionSuffix>
<LangVersion>10.0</LangVersion>
<Features>strict</Features>
Expand Down
5 changes: 3 additions & 2 deletions OpenEphys.Miniscope/UclaMiniCam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public enum GainMiniCam
[Description("The index of the camera from which to acquire images.")]
public int Index { get; set; } = 0;

[Range(0, 26)] //
[Range(0, 100)]
[Precision(1, 0.1)]
[Editor(DesignTypes.SliderEditor, typeof(UITypeEditor))]
[Description("LED brightness (percent of max).")]
public double LedBrightness { get; set; } = 0;
Expand All @@ -43,7 +44,7 @@ public enum GainMiniCam

[Description("Frames captured per second.")]
[Range(5, 47)]
[Editor(DesignTypes.SliderEditor, typeof(UITypeEditor))]
[Editor(DesignTypes.NumericUpDownEditor, typeof(UITypeEditor))]
public int FramesPerSecond { get; set; } = 30;

// State
Expand Down
77 changes: 61 additions & 16 deletions OpenEphys.Miniscope/UclaMiniscopeV4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,7 @@ namespace OpenEphys.Miniscope
[Description("Produces a data sequence from a UCLA Miniscope V4.")]
public class UclaMiniscopeV4 : Source<UclaMiniscopeV4Frame>
{
// NB: Needs a unique name, even though its a class member, for de/serilizaiton without issues
public enum GainV4
{
Low = 225,
Medium = 228,
High = 36,
};

// NB: Needs a unique name, even though its a class member, for de/serilizaiton without issues
public enum FrameRateV4
{
Fps10 = 39 & 0x000000FF | 16 << 8,
Fps15 = 26 & 0x000000FF | 11 << 8,
Fps20 = 19 & 0x000000FF | 136 << 8,
Fps25 = 15 & 0x000000FF | 160 << 8,
Fps30 = 12 & 0x000000FF | 228 << 8,
};

// Frame size
const int Width = 608;
Expand All @@ -41,19 +25,23 @@ public enum FrameRateV4
[Description("The index of the camera from which to acquire images.")]
public int Index { get; set; } = 0;

[Precision(1, 0.1)]
[Range(0, 100)]
[Editor(DesignTypes.SliderEditor, typeof(UITypeEditor))]
[Description("Excitation LED brightness (percent of max).")]
public double LedBrightness { get; set; } = 0;

[Precision(1, 0.1)]
[Range(-100, 100)]
[Editor(DesignTypes.SliderEditor, typeof(UITypeEditor))]
[Description("Electro-wetting lens focal plane adjustment (percent of range around nominal).")]
public double Focus { get; set; } = 0;

[TypeConverter(typeof(GainV4TypeConverter))]
[Description("Image sensor gain setting.")]
public GainV4 SensorGain { get; set; } = GainV4.Low;

[TypeConverter(typeof(FrameRateV4TypeConverter))]
[Description("Frames captured per second.")]
public FrameRateV4 FramesPerSecond { get; set; } = FrameRateV4.Fps30;

Expand Down Expand Up @@ -258,4 +246,61 @@ public override IObservable<UclaMiniscopeV4Frame> Generate()
return source;
}
}

// NB: Needs a unique name, even though its a class member, for de/serilizaiton without issues
public enum GainV4
{
Low = 225,
Medium = 228,
High = 36,
}

class GainV4TypeConverter : EnumConverter
{
internal GainV4TypeConverter()
: base(typeof(GainV4))
{
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(new[]
{
GainV4.Low,
GainV4.Medium,
GainV4.High,
});
}
}

// NB: Needs a unique name, even though its a class member, for de/serilizaiton without issues
public enum FrameRateV4
{
Fps10 = 39 & 0x000000FF | 16 << 8,
Fps15 = 26 & 0x000000FF | 11 << 8,
Fps20 = 19 & 0x000000FF | 136 << 8,
Fps25 = 15 & 0x000000FF | 160 << 8,
Fps30 = 12 & 0x000000FF | 228 << 8,
};


class FrameRateV4TypeConverter : EnumConverter
{
internal FrameRateV4TypeConverter()
: base(typeof(FrameRateV4))
{
}

public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(new[]
{
FrameRateV4.Fps10,
FrameRateV4.Fps15,
FrameRateV4.Fps20,
FrameRateV4.Fps25,
FrameRateV4.Fps30,
});
}
}
}

0 comments on commit dc48e89

Please sign in to comment.