Skip to content

Commit

Permalink
Fix MiniCam frame rate
Browse files Browse the repository at this point in the history
- The frame rate settings, copied for the Qt software, were completely non functional
  • Loading branch information
jonnew committed Nov 4, 2024
1 parent 08a1aeb commit 1bb46ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 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.2.0</VersionPrefix>
<VersionPrefix>0.3.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<LangVersion>10.0</LangVersion>
<Features>strict</Features>
Expand Down
22 changes: 10 additions & 12 deletions OpenEphys.Miniscope/UclaMiniCam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ public enum GainMiniCam
Maximum = 6240,
};

// NB: Needs a unique name, even though its a class member, for de/serilizaiton without issues
public enum FrameRateMiniCam
{
Fps10 = 2048,
Fps40 = 1536,
Fps50 = 6240,
};

// Frame size
const int Width = 1024;
const int Height = 768;
Expand All @@ -50,7 +42,9 @@ public enum FrameRateMiniCam
public GainMiniCam SensorGain { get; set; } = GainMiniCam.Low;

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

// State
readonly IObservable<UclaMiniCamFrame> source;
Expand Down Expand Up @@ -82,7 +76,7 @@ static internal AbusedUvcRegisters IssueStartCommands(Capture capture)
Helpers.SendConfig(capture, Helpers.CreateCommand(176, 15, 2)); // Speed up I2c bus timer to 50u Max
Helpers.SendConfig(capture, Helpers.CreateCommand(176, 30, 10)); // Decrease BCC timeout, units in 2 ms
Helpers.SendConfig(capture, Helpers.CreateCommand(192, 8, 186, 108)); // Set aliases for MT9P031 and LM3509
Helpers.SendConfig(capture, Helpers.CreateCommand(192, 16, 186, 108)); // Set aliasesor MT9P031 and LM3509
Helpers.SendConfig(capture, Helpers.CreateCommand(192, 16, 186, 108)); // Set aliases for MT9P031 and LM3509
Helpers.SendConfig(capture, Helpers.CreateCommand(186, 3, 5, 255)); // Set height to 1535 rows
Helpers.SendConfig(capture, Helpers.CreateCommand(186, 4, 7, 255)); // Set width to 2047 colums
Helpers.SendConfig(capture, Helpers.CreateCommand(186, 34, 0, 17)); // 2x subsamp and binning 1
Expand Down Expand Up @@ -142,8 +136,12 @@ public UclaMiniCam()

if (FramesPerSecond != lastFps || !initialized)
{
byte vl = (byte)((int)FramesPerSecond & 0x00000FF);
byte vh = (byte)(((int)FramesPerSecond & 0x000FF00) >> 8);
// This was found empirically.
var reg = 37000 / FramesPerSecond;
if (reg < 0) reg = 0;

byte vl = (byte)(reg & 0x00000FF);
byte vh = (byte)((reg & 0x000FF00) >> 8);
Helpers.SendConfig(capture, Helpers.CreateCommand(186, 9, vh, vl));
lastFps = FramesPerSecond;
}
Expand Down

0 comments on commit 1bb46ff

Please sign in to comment.