mirror of https://github.com/ArduPilot/ardupilot
AP_LeakDetector: check for valid analog pin
This commit is contained in:
parent
9f04cded3b
commit
5ea72bd371
|
@ -11,8 +11,7 @@ AP_LeakDetector_Analog::AP_LeakDetector_Analog(AP_LeakDetector &_leak_detector,
|
||||||
|
|
||||||
void AP_LeakDetector_Analog::read()
|
void AP_LeakDetector_Analog::read()
|
||||||
{
|
{
|
||||||
if (source != NULL && leak_detector._pin[state.instance] >= 0) {
|
if (source != NULL && leak_detector._pin[state.instance] >= 0 && source->set_pin(leak_detector._pin[state.instance])) {
|
||||||
source->set_pin(leak_detector._pin[state.instance]);
|
|
||||||
state.status = source->voltage_average() > 2.0f;
|
state.status = source->voltage_average() > 2.0f;
|
||||||
state.status = state.status != leak_detector._default_reading[state.instance];
|
state.status = state.status != leak_detector._default_reading[state.instance];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue