Motion detection with an intelligent optical sensor with on-chip analogue memory