You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1007 B
42 lines
1007 B
#pragma once |
|
|
|
#include "AP_HAL_Linux.h" |
|
#include <AP_ADC/AP_ADC.h> |
|
|
|
#define ADS1115_ADC_MAX_CHANNELS 6 |
|
|
|
class AnalogSource_ADS1115: public AP_HAL::AnalogSource { |
|
public: |
|
friend class AnalogIn_ADS1115; |
|
AnalogSource_ADS1115(int16_t pin); |
|
float read_average(); |
|
float read_latest(); |
|
void set_pin(uint8_t p); |
|
void set_stop_pin(uint8_t p) {} |
|
void set_settle_time(uint16_t settle_time_ms){} |
|
float voltage_average(); |
|
float voltage_latest(); |
|
float voltage_average_ratiometric(); |
|
private: |
|
int16_t _pin; |
|
float _value; |
|
}; |
|
|
|
class AnalogIn_ADS1115: public AP_HAL::AnalogIn { |
|
public: |
|
AnalogIn_ADS1115(); |
|
|
|
void init() override; |
|
AP_HAL::AnalogSource *channel(int16_t n) override; |
|
|
|
/* Board voltage is not available */ |
|
float board_voltage() override { return 5.0f; } |
|
|
|
private: |
|
uint8_t _channels_number; |
|
void _update(); |
|
|
|
AP_ADC_ADS1115 *_adc; |
|
AnalogSource_ADS1115 *_channels[ADS1115_ADC_MAX_CHANNELS]; |
|
uint32_t _last_update_timestamp; |
|
};
|
|
|