Skip to content

Commit 61c90b4

Browse files
committed
pwm: Make identify frame passthrough configurable per destination.
1 parent 31a9716 commit 61c90b4

24 files changed

+49
-11
lines changed

LibDmd.Test/Stubs/DestinationAlphaNumeric.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class DestinationAlphaNumeric : IAlphaNumericDestination
88
public string Name => "Destination[Fixed/Gray2]";
99
public bool IsAvailable => true;
1010
public bool NeedsDuplicateFrames => false;
11+
public bool NeedsIdentificationFrames => false;
1112

1213
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
1314

LibDmd.Test/Stubs/DestinationDynamic.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace LibDmd.Test.Stubs
88
public abstract class DestinationDynamic<TFrame> : IResizableDestination, ITestDestination<TFrame>
99
{
1010
public IConnectableObservable<TFrame> Frame { get; private set; }
11+
12+
public bool NeedsIdentificationFrames => false;
1113

1214
protected Subject<TFrame> LastFrame = new Subject<TFrame>();
1315

LibDmd.Test/Stubs/DestinationFixed.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace LibDmd.Test.Stubs
99
public abstract class DestinationFixed<TFrame> : IFixedSizeDestination, ITestDestination<TFrame>
1010
{
1111
public IConnectableObservable<TFrame> Frame { get; private set; }
12+
public bool NeedsIdentificationFrames => false;
1213

1314
public Dimensions FixedSize { get; }
1415

LibDmd/Common/InteropUtil.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace LibDmd.Common
55
{
6-
public class InteropUtil
6+
public static class InteropUtil
77
{
88
public static ushort[] ReadUInt16Array(IntPtr data, int length)
99
{
@@ -16,5 +16,17 @@ public static ushort[] ReadUInt16Array(IntPtr data, int length)
1616
}
1717
return buffer;
1818
}
19+
20+
public static ushort[] ReadByteArray(IntPtr data, int length)
21+
{
22+
var buffer = new ushort[length];
23+
var uint16Buffer = new byte[length * 2];
24+
Marshal.Copy(data, uint16Buffer, 0, length * 2);
25+
var pos = 0;
26+
for (var i = 0; i < length * 2; i += 2) {
27+
buffer[pos++] = BitConverter.ToUInt16(uint16Buffer, i);
28+
}
29+
return buffer;
30+
}
1931
}
2032
}

LibDmd/Frame/DmdFrame.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DmdFrame : BaseFrame, ICloneable, IEqualityComparer<DmdFrame>
3232
/// These frames are used for colorization and should never be rendered (if they exist, that means
3333
/// there's a gray-8 frame to be rendered).
3434
/// </summary>
35-
public bool IsIdentifyFrame { get; protected set; }
35+
public bool IsIdentifyFrame { get; private set; }
3636

3737
/// <summary>
3838
/// The bit length of each pixel.

LibDmd/Output/FileOutput/BitmapOutput.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class BitmapOutput : IBitmapDestination
2121
public string Name { get; } = "File Writer";
2222
public bool IsAvailable { get; } = true;
2323
public bool NeedsDuplicateFrames => false;
24+
public bool NeedsIdentificationFrames => false;
2425

2526
private int _counter;
2627
private readonly HashSet<string> _hashes = new HashSet<string>();

LibDmd/Output/FileOutput/GifOutput.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class GifOutput : IBitmapDestination
1414
public string Name { get; } = "GIF Writer";
1515
public bool IsAvailable { get; } = true;
1616
public bool NeedsDuplicateFrames => false;
17+
public bool NeedsIdentificationFrames => false;
1718

1819
private readonly GifWriter _outputGif;
1920

LibDmd/Output/FileOutput/RawOutput.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class RawOutput : IGray2Destination, IGray4Destination, IResizableDestina
1111
public string Name => "Raw Output";
1212
public bool IsAvailable => !string.IsNullOrEmpty(_gameName);
1313
public bool NeedsDuplicateFrames => false;
14+
public bool NeedsIdentificationFrames => false;
1415

1516
private string _gameName;
1617

LibDmd/Output/FileOutput/VideoOutput.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class VideoOutput : IRgb24Destination, IFixedSizeDestination
2222
public string Name { get; } = "Video Writer";
2323
public bool IsAvailable { get; } = true;
2424
public bool NeedsDuplicateFrames => false;
25+
public bool NeedsIdentificationFrames => false;
2526

2627
private AviWriter _writer;
2728
private IAviVideoStream _stream;

LibDmd/Output/IDestination.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public interface IDestination : IDisposable
2727
/// </summary>
2828
bool NeedsDuplicateFrames { get; }
2929

30+
/// <summary>
31+
/// If true, send identification instead of PWM frames to this destination.
32+
/// </summary>
33+
bool NeedsIdentificationFrames { get; }
34+
3035
/// <summary>
3136
/// Clears the display.
3237
/// </summary>

0 commit comments

Comments
 (0)