qEcho/source/distancethread.cpp

19 lines
284 B
C++
Raw Permalink Normal View History

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