Skip to content

Commit

Permalink
sensor: ping360: ensure valid settings in set_speed_of_sound
Browse files Browse the repository at this point in the history
copied the same logic from set_range
  • Loading branch information
jaxxzer committed Oct 11, 2024
1 parent 22cba07 commit 3d296d1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sensor/ping360.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,20 @@ class Ping360 : public PingSensor {
double desiredRange = round(range());
_speed_of_sound = speed_of_sound;
_sensorSettings.sample_period = calculateSamplePeriod(desiredRange);

// reduce _sample period until we are within operational parameters
// maximize the number of points
while (_sensorSettings.sample_period < _firmwareMinSamplePeriod) {
_sensorSettings.num_points--;
_sensorSettings.sample_period = calculateSamplePeriod(desiredRange);
}

emit numberOfPointsChanged();
emit speedOfSoundChanged();
emit samplePeriodChanged();
emit rangeChanged();
emit rangeChanged(); // does this belong here?
emit transmitDurationMaxChanged();
adjustTransmitDuration();
}
}
Q_PROPERTY(int speed_of_sound READ speed_of_sound WRITE set_speed_of_sound NOTIFY speedOfSoundChanged)
Expand Down

0 comments on commit 3d296d1

Please sign in to comment.