From 090c02e6bdb2755e1047ef0fb6e025e4bb9d448e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 9 Nov 2015 08:47:45 +1100 Subject: [PATCH] AP_Common: rename is_bounded() to is_bounded_int32() and make inclusive we will probably want float versions in future, and inclusive is better for the RC_Channel case --- libraries/AP_Common/AP_Common.cpp | 9 +++++---- libraries/AP_Common/AP_Common.h | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libraries/AP_Common/AP_Common.cpp b/libraries/AP_Common/AP_Common.cpp index eb29870f7c..b56838efa3 100644 --- a/libraries/AP_Common/AP_Common.cpp +++ b/libraries/AP_Common/AP_Common.cpp @@ -24,12 +24,13 @@ extern const AP_HAL::HAL& hal; /* - Return true if value is between lower and upper bound. False otherwise. + Return true if value is between lower and upper bound inclusive. + False otherwise. */ -bool is_bounded(int32_t value, int32_t lower_bound, int32_t upper_bound) +bool is_bounded_int32(int32_t value, int32_t lower_bound, int32_t upper_bound) { - if ((lower_bound < upper_bound) && - (value > lower_bound) && (value < upper_bound)) { + if ((lower_bound <= upper_bound) && + (value >= lower_bound) && (value <= upper_bound)) { return true; } diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index ea17cd1a75..8bbaf914f1 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -155,7 +155,10 @@ enum HomeState { #define AP_PRODUCT_ID_MPU9250 0x103 // MPU9250 #define AP_PRODUCT_ID_VRBRAIN 0x150 // VRBRAIN on NuttX - -bool is_bounded(int32_t value, int32_t lower_bound, int32_t upper_bound); +/* + Return true if value is between lower and upper bound inclusive. + False otherwise. +*/ +bool is_bounded_int32(int32_t value, int32_t lower_bound, int32_t upper_bound); #endif // _AP_COMMON_H