Skip to content
Snippets Groups Projects
Commit 6fcd2a0a authored by Hoop77's avatar Hoop77 Committed by lenoelda
Browse files

-

parent 3abcaf8f
Branches
No related merge requests found
...@@ -52,8 +52,9 @@ void UltrasonicSensor::updateSensor(const AsyncState::Ptr & state) ...@@ -52,8 +52,9 @@ void UltrasonicSensor::updateSensor(const AsyncState::Ptr & state)
int UltrasonicSensor::readDistance() const int UltrasonicSensor::readDistance() const
{ {
wiringPiI2CWrite(fd, 0x02); //wiringPiI2CWrite(fd, 0x02);
int distance = wiringPiI2CRead(fd); int distance = wiringPiI2CReadReg16(fd, RESULT_LOW_BYTE);
distance += wiringPiI2CReadReg16(fd, RESULT_HIGH_BYTE) << 8;
//if (distance == 0) // 0 means distance too far //if (distance == 0) // 0 means distance too far
//distance = 255; //distance = 255;
return distance; return distance;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment