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.
49 lines
1.1 KiB
49 lines
1.1 KiB
10 years ago
|
#ifndef __ADS1115AnalogIn_H__
|
||
|
#define __ADS1115AnalogIn_H__
|
||
10 years ago
|
|
||
10 years ago
|
#include "AP_HAL_Linux.h"
|
||
|
#include <AP_ADC/AP_ADC.h>
|
||
10 years ago
|
|
||
10 years ago
|
#define ADS1115_ADC_MAX_CHANNELS 6
|
||
10 years ago
|
|
||
10 years ago
|
class ADS1115AnalogSource: public AP_HAL::AnalogSource {
|
||
10 years ago
|
public:
|
||
10 years ago
|
friend class ADS1115AnalogIn;
|
||
|
ADS1115AnalogSource(int16_t pin);
|
||
10 years ago
|
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;
|
||
|
};
|
||
|
|
||
10 years ago
|
class ADS1115AnalogIn: public AP_HAL::AnalogIn {
|
||
10 years ago
|
public:
|
||
10 years ago
|
ADS1115AnalogIn();
|
||
10 years ago
|
void init(void* implspecific);
|
||
|
AP_HAL::AnalogSource* channel(int16_t n);
|
||
|
|
||
|
/* Board voltage is not available */
|
||
|
float board_voltage(void)
|
||
|
{
|
||
|
return 0.0f;
|
||
|
}
|
||
|
private:
|
||
|
AP_ADC_ADS1115 *_adc;
|
||
10 years ago
|
ADS1115AnalogSource *_channels[ADS1115_ADC_MAX_CHANNELS];
|
||
10 years ago
|
|
||
|
uint8_t _channels_number;
|
||
|
|
||
|
void _update();
|
||
|
|
||
|
uint32_t _last_update_timestamp;
|
||
|
};
|
||
|
|
||
|
#endif
|