Line data Source code
1 : #include "AP_LeakDetector_Analog.h" 2 : #include <AP_HAL/AP_HAL.h> 3 : 4 : extern const AP_HAL::HAL& hal; 5 : 6 0 : AP_LeakDetector_Analog::AP_LeakDetector_Analog(AP_LeakDetector &_leak_detector, AP_LeakDetector::LeakDetector_State &_state) : 7 0 : AP_LeakDetector_Backend(_leak_detector, _state) 8 : { 9 0 : source = hal.analogin->channel(leak_detector._pin[state.instance]); 10 0 : } 11 : 12 0 : void AP_LeakDetector_Analog::read() 13 : { 14 0 : if (source != NULL && leak_detector._pin[state.instance] >= 0 && source->set_pin(leak_detector._pin[state.instance])) { 15 0 : state.status = source->voltage_average() > 2.0f; 16 0 : state.status = state.status != leak_detector._default_reading[state.instance]; 17 : } else { 18 0 : state.status = false; 19 : } 20 0 : }