Went back to an average filter on the ir processing. Note that the control_motion is also doing a 'filtering' operation, by checking that the sensors values remain relatively stable on two consecutive cycles.