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