AP_Arming: add board voltage checks

This commit is contained in:
Randy Mackay 2015-10-16 12:13:53 +09:00
parent f5f31e4b31
commit 342651cc9b
2 changed files with 22 additions and 0 deletions

View File

@ -18,6 +18,9 @@
#include <AP_Notify/AP_Notify.h> #include <AP_Notify/AP_Notify.h>
#include <GCS_MAVLink/GCS.h> #include <GCS_MAVLink/GCS.h>
#define AP_ARMING_BOARD_VOLTAGE_MIN 4.3f
#define AP_ARMING_BOARD_VOLTAGE_MAX 5.8f
extern const AP_HAL::HAL& hal; extern const AP_HAL::HAL& hal;
const AP_Param::GroupInfo AP_Arming::var_info[] PROGMEM = { const AP_Param::GroupInfo AP_Arming::var_info[] PROGMEM = {
@ -348,6 +351,22 @@ bool AP_Arming::manual_transmitter_checks(bool report)
return true; return true;
} }
bool AP_Arming::board_voltage_checks(bool report)
{
// check board voltage
if ((checks_to_perform & ARMING_CHECK_ALL) || (checks_to_perform & ARMING_CHECK_VOLTAGE)) {
if(!is_zero(hal.analogin->board_voltage()) &&
((hal.analogin->board_voltage() < AP_ARMING_BOARD_VOLTAGE_MIN) || (hal.analogin->board_voltage() > AP_ARMING_BOARD_VOLTAGE_MAX))) {
if (report) {
GCS_MAVLINK::send_statustext_all(MAV_SEVERITY_CRITICAL,PSTR("PreArm: Check Board Voltage"));
}
return false;
}
}
return true;
}
bool AP_Arming::pre_arm_checks(bool report) bool AP_Arming::pre_arm_checks(bool report)
{ {
bool ret = true; bool ret = true;
@ -365,6 +384,7 @@ bool AP_Arming::pre_arm_checks(bool report)
ret &= battery_checks(report); ret &= battery_checks(report);
ret &= logging_checks(report); ret &= logging_checks(report);
ret &= manual_transmitter_checks(report); ret &= manual_transmitter_checks(report);
ret &= board_voltage_checks(report);
return ret; return ret;
} }

View File

@ -100,6 +100,8 @@ protected:
bool hardware_safety_check(bool report); bool hardware_safety_check(bool report);
bool board_voltage_checks(bool report);
bool manual_transmitter_checks(bool report); bool manual_transmitter_checks(bool report);
}; };