Skip to content

Commit 53fcbec

Browse files
committed
Changed getDistance() to getDistanceCentimeters()
Changed the name of the ScanPacket method getDistance() to getDistanceCentimeters() to indicate the unit of measurement of the returned value. This name is also parallel with the method getAngleDegrees(). Also, updated keywords.txt, the readme, and the Arduino sketches accordingly.
1 parent e304fc9 commit 53fcbec

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ uint16_t getAngleRaw() const
223223
Returns the angle of this reading as the raw 16-bit fixed point value. The scaling factor of this value is 16; this means that the angle in degrees is obtained by dividing the raw value by 16.
224224

225225
```c++
226-
uint16_t getDistance() const
226+
uint16_t getDistanceCentimeters() const
227227
```
228228

229229
Returns the distance of this reading, in centimeters.

Sweep/Examples/MegaDistanceBlink/MegaDistanceBlink.ino

100755100644
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,12 @@ bool gatherDistanceInfo()
192192
if (reading.getAngleDegrees() > 360 - FOV)
193193
{
194194
// only consider valid readings (sensor will report distance of 1 for failed readings)
195-
if (reading.getDistance() > 1)
195+
uint16_t dist = reading.getDistanceCentimeters();
196+
if (dist > 1)
196197
{
197198
// check if this reading is closer than anything seen so far
198-
if (reading.getDistance() < closestDistanceInSpecifiedFOV)
199-
closestDistanceInSpecifiedFOV = reading.getDistance();
199+
if (dist < closestDistanceInSpecifiedFOV)
200+
closestDistanceInSpecifiedFOV = dist;
200201
}
201202
}
202203
}
@@ -244,4 +245,4 @@ void reset()
244245
ledState = LOW;
245246
digitalWrite(LED_BUILTIN, ledState); // turn the LED off by making the voltage LOW
246247
device.reset();
247-
}
248+
}

Sweep/Examples/MegaSerialPrinter/MegaSerialPrinter.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void gatherSensorReading()
206206
// store the info for this sample
207207
syncValues[sampleCount] = reading.isSync();
208208
angles[sampleCount] = reading.getAngleDegrees();
209-
distances[sampleCount] = reading.getDistance();
209+
distances[sampleCount] = reading.getDistanceCentimeters();
210210
signalStrengths[sampleCount] = reading.getSignalStrength();
211211

212212
// increment sample count

Sweep/ScanPacket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ uint16_t ScanPacket::getAngleRaw() const
2020
return _rawAngle;
2121
}
2222

23-
uint16_t ScanPacket::getDistance() const
23+
uint16_t ScanPacket::getDistanceCentimeters() const
2424
{
2525
return _distance;
2626
}

Sweep/ScanPacket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class ScanPacket
2222
// Returns the angle as a raw fixed point value
2323
uint16_t getAngleRaw() const;
2424

25-
// Returns the range measurement
26-
uint16_t getDistance() const;
25+
// Returns the range measurement in centimeters
26+
uint16_t getDistanceCentimeters() const;
2727

2828
// Returns the signal strength as an integer value between 0 and 255
2929
uint8_t getSignalStrength() const;

Sweep/keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ reset KEYWORD2
2626
isSync KEYWORD2
2727
getAngleDegrees KEYWORD2
2828
getAngleRaw KEYWORD2
29-
getDistance KEYWORD2
29+
getDistanceCentimeters KEYWORD2
3030
getSignalStrength KEYWORD2
3131

3232
#######################################

0 commit comments

Comments
 (0)