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

-

parent 6fcd2a0a
No related merge requests found
......@@ -53,8 +53,8 @@ void UltrasonicSensor::updateSensor(const AsyncState::Ptr & state)
int UltrasonicSensor::readDistance() const
{
//wiringPiI2CWrite(fd, 0x02);
int distance = wiringPiI2CReadReg16(fd, RESULT_LOW_BYTE);
distance += wiringPiI2CReadReg16(fd, RESULT_HIGH_BYTE) << 8;
int distance = wiringPiI2CReadReg8(fd, RESULT_LOW_BYTE);
distance += wiringPiI2CReadReg8(fd, RESULT_HIGH_BYTE) << 8;
//if (distance == 0) // 0 means distance too far
//distance = 255;
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