qEcho/source/distancethread.cpp

19 lines
284 B
C++

#include "distancethread.h"
DistanceThread::DistanceThread(unsigned int triggerPin, unsigned int echoPin)
: m_hcsr04(triggerPin, echoPin)
{
}
void DistanceThread::run()
{
m_hcsr04.run();
while (true)
{
emit distanceUpdated(m_hcsr04.getDistance());
msleep(100);
}
}