forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNecSignalDecoder.cs
44 lines (40 loc) · 1.59 KB
/
NecSignalDecoder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//
namespace InfraredRemote
{
/// <summary>
/// Nec protocol signal decoder.
/// </summary>
public class NecSignalDecoder : Decoder
{
/// <summary>
/// Creates instance of <see cref="NecSignalDecoder"/>.</typeparam>
/// </summary>
/// <param name="signalLengthTolerance">Tolerance of signal length represented as percentage value.</param>
public NecSignalDecoder(double signalLengthTolerance)
: base(signalLengthTolerance)
{
}
protected override int PulseLengthInMicroseconds => 560;
protected override int HeaderMark => PulseLengthInMicroseconds * 16;
protected override int HeaderSpace => PulseLengthInMicroseconds * 8;
protected override int RepeatSpace => PulseLengthInMicroseconds * 4;
protected override int ZeroSpace => PulseLengthInMicroseconds;
protected override int OneSpace => PulseLengthInMicroseconds * 3;
protected override Protocol Protocol => Protocol.Nec;
protected override int SignalLength => 34;
protected override bool UseLessSignificantBitFirst => true;
protected override int AddressBits => 16;
protected override int CommandBits => 16;
protected override string ExtractCommand(string message)
{
return message.Substring(16, 8);
}
protected override string ExtractAddress(string message)
{
return message.Substring(0, 8);
}
}
}