jkristell / infrared

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

Unexpected Sender Behavior When Trying to Send the Same Received Signal #111

Open mahdi1-kh opened 7 months ago

mahdi1-kh commented 7 months ago

I have written a code that receives IR signals using MultiReceiver's event_iter and then sends the same received commands using transmitter.load:

    #[task(binds = EXTI9_5, local = [mono, receiver,transmitter])]
    fn button_click4(mut ctx: button_click4::Context) {
    unsafe {
        static mut LAST: Option<Instant> = None;

        let now = ctx.local.mono.now();

        if let Some(dt) = LAST.map(|i| i.elapsed()) {
            if let Ok(cmds) = ctx.local.receiver.event_iter(dt) {
                for cmd in cmds {
                    if let MultiReceiverCommand::Nec(c) = cmd {
                        hprintln!("cmd: {:?}",c);
                        ctx.local.transmitter.tick();
                        ctx.local.transmitter.load::<Nec>(&c);
                    }
                }
            }
        }
        LAST.replace(now);
    }
    ctx.local.receiver.pin().clear_interrupt_pending_bit();
}

But the signal that is generated by the sender is completely different from the signal that is being sent to the receiver when I check them using oscilloscope.

This is the signal that I send to my receiver:

photo_2024-03-16_18-22-10 Which causes the sender to start making these signals continuously:

photo_2024-03-16_18-22-39

Until the second time that I send that same signal to my receiver and then the sender stops signaling.