#include "lamp_ir_filter.h"
bool lamp_ir_filter_update(lamp_ir_filter *f,bool available,bool high,uint32_t now) {
    if (!f) return false;
    const bool stalled = f->sample_seen &&
        (uint32_t)(now-f->last_ms)>LAMP_IR_MAX_SAMPLE_GAP_MS;
    f->sample_seen=true;f->last_ms=now;
    if (!available || !high || stalled) f->high_seen=false;
    if (!available || !high) return false;
    if (!f->high_seen) {f->high_seen=true;f->high_since_ms=now;return false;}
    return (uint32_t)(now-f->high_since_ms)>=LAMP_IR_ASSERT_MS;
}
