AP_RangeFinder: use enum-class for RangeFinder function

This commit is contained in:
Peter Barker 2019-11-01 14:06:21 +11:00 committed by Peter Barker
parent db36ef3433
commit 1989decbc1
2 changed files with 8 additions and 8 deletions

View File

@ -86,19 +86,19 @@ void AP_RangeFinder_analog::update(void)
float dist_m = 0;
float scaling = params.scaling;
float offset = params.offset;
RangeFinder::RangeFinder_Function function = (RangeFinder::RangeFinder_Function)params.function.get();
RangeFinder::Function function = (RangeFinder::Function)params.function.get();
int16_t _max_distance_cm = params.max_distance_cm;
switch (function) {
case RangeFinder::FUNCTION_LINEAR:
case RangeFinder::Function::LINEAR:
dist_m = (v - offset) * scaling;
break;
case RangeFinder::FUNCTION_INVERTED:
case RangeFinder::Function::INVERTED:
dist_m = (offset - v) * scaling;
break;
case RangeFinder::FUNCTION_HYPERBOLA:
case RangeFinder::Function::HYPERBOLA:
if (v <= offset) {
dist_m = 0;
} else {

View File

@ -79,10 +79,10 @@ public:
BenewakeTF03 = 27,
};
enum RangeFinder_Function {
FUNCTION_LINEAR = 0,
FUNCTION_INVERTED = 1,
FUNCTION_HYPERBOLA = 2
enum class Function {
LINEAR = 0,
INVERTED = 1,
HYPERBOLA = 2
};
enum RangeFinder_Status {