/** * Background task that goes through the list of ultrasonic sensors and pings each one in turn. The counter * is configured to read the timing of the returned echo pulse. * * DANGER WILL ROBINSON, DANGER WILL ROBINSON: * This code runs as a task and assumes that none of the ultrasonic sensors will change while it's * running. If one does, then this will certainly break. Make sure to disable automatic mode before changing * anything with the sensors!! */ void Ultrasonic::UltrasonicChecker() { Ultrasonic *u = NULL; while (m_automaticEnabled) { if (u == NULL) u = m_firstSensor; if (u == NULL) return; if (u->IsEnabled()) u->m_pingChannel->Pulse(kPingTime); // do the ping u = u->m_nextSensor; Wait(0.1); // wait for ping to return } }