30 uint16_t timeout = TIMEOUT;
34 if (timeout == 0)
return (
false);
39 while (m_echo.
is_set() && timeout--) count++;
41 if (timeout == 0)
return (
false);
44 distance = (count * 100L) / COUNT_PER_DM;
49 HCSR04::on_event(uint8_t type, uint16_t value)
56 if (!
read(distance) || (m_distance == distance))
return;
virtual void on_change(uint16_t distance)
bool read(uint16_t &distance)
void pulse(uint16_t us) const
uint16_t distance() const