AP_RangeFinder: benewake logic reordering

this should be a non-functional change
This commit is contained in:
Randy Mackay 2018-11-08 21:34:35 +09:00
parent a09cd8411d
commit 35be68348d

View File

@ -109,11 +109,13 @@ bool AP_RangeFinder_Benewake::get_reading(uint16_t &reading_cm)
}
// if checksum matches extract contents
if ((uint8_t)(checksum & 0xFF) == linebuf[BENEWAKE_FRAME_LENGTH-1]) {
// calculate distance and add to sum
// calculate distance
uint16_t dist = ((uint16_t)linebuf[3] << 8) | linebuf[2];
if (dist < BENEWAKE_DIST_MAX_CM) {
if (dist >= BENEWAKE_DIST_MAX_CM) {
// this reading is out of range
count_out_of_range++;
} else if (model_type == BENEWAKE_TFmini) {
// TFmini has short distance mode (mm)
if (model_type == BENEWAKE_TFmini) {
if (linebuf[6] == 0x02) {
dist *= 0.1f;
}
@ -131,10 +133,6 @@ bool AP_RangeFinder_Benewake::get_reading(uint16_t &reading_cm)
count_out_of_range++;
}
}
} else {
// this reading is out of range
count_out_of_range++;
}
}
// clear buffer
linebuf_len = 0;