jkristell / infrared

Infrared remote control library for embedded Rust
Apache License 2.0
56 stars 10 forks source link

How to match CmdEnum when using MultiReceiver? #86

Closed riskable closed 2 years ago

riskable commented 2 years ago

I got MultiReceiver working (in my RTIC-using code) but it doesn't look like there's a way to match against the cmd...

if let Ok(cmds) = ir_recv.event_iter(elapsed_us) {
    for cmd in cmds {
        defmt::println!("IR: {:?}", cmd); // TEMP
        match cmd {
            <what do I put here?>
        }
    }
}

The problem is that infrared::receiver::multireceiver is private, therefore infrared::receiver::multireceiver::CmdEnum is also private. So even if I wanted to do something like:

match cmd {
    infrared::receiver::multireceiver::CmdEnum::Nec(_) => {},
    (_) => {},
}

...I can't. I'm still pretty new to Rust though so maybe I'm missing something?

jkristell commented 2 years ago

That's probably something I overlooked. CmdEnum should be accessible. Will fix it before the next release, that should be any day now. Just needs to find some time to do the release.

Thanks for testing!

jkristell commented 2 years ago

CmdEnum renamed to MultiReceiverCommand and is now exported.

riskable commented 2 years ago

Excellent! That works, thanks 👍