Using average sensor values for edge detection.

Prior to this was taking the initial reading from the sensor for
both calibration and edge detection. Was getting some flaky results
where edges were being detected when they shouldn't and edges not
detected when they should. Averaging made a big difference.