Skip to content

Commit

Permalink
New function Decoder.decodeIrSignalWithFallback(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
bengtmartensson committed Jun 1, 2024
1 parent 977c2b4 commit b9510d1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/harctoolbox/irp/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,18 @@ public AbstractDecodesCollection<? extends ElementaryDecode> decodeLoose(IrSigna
return decodeIrSignal(irSignal, decoderParams);
}

public AbstractDecodesCollection<? extends ElementaryDecode> decodeIrSignalWithFallback(IrSignal irSignal, DecoderParameters decoderParams) {
SimpleDecodesSet decodes = decodeIrSignal(irSignal, decoderParams);
if (!decodes.isEmpty())
return decodes;

if (decoderParams.ignoreLeadingGarbage || (!decoderParams.strict && (irSignal.introOnly() || irSignal.repeatOnly()))) {
ModulatedIrSequence sequence = irSignal.toModulatedIrSequence();
return decode(sequence, decoderParams);
}
return decodes; // empty
}

public static final class DecoderParameters {

private boolean strict;
Expand Down

0 comments on commit b9510d1

Please sign in to comment.