Browse Source

AP_ADC_AnalogSource: fix for new AnalogIn interface

master
Pat Hickey 12 years ago committed by Andrew Tridgell
parent
commit
8f99a12374
  1. 12
      libraries/AP_ADC_AnalogSource/AP_ADC_AnalogSource.cpp
  2. 3
      libraries/AP_ADC_AnalogSource/AP_ADC_AnalogSource.h

12
libraries/AP_ADC_AnalogSource/AP_ADC_AnalogSource.cpp

@ -1,12 +1,22 @@ @@ -1,12 +1,22 @@
#include "AP_ADC_AnalogSource.h"
float AP_ADC_AnalogSource::read() {
/* Unfortunately we don't have a valid implementaton for read_latest - we
* only have access to the average from the ADC driver. Not really a big deal
* in our application currently. */
float AP_ADC_AnalogSource::read_latest() {
return read_average();
}
float AP_ADC_AnalogSource::read_average() {
float fullscale = _adc->Ch(_ch);
float scaled = _prescale * fullscale;
return scaled;
}
void AP_ADC_AnalogSource::set_pin(uint8_t machtnichts) {
/* it would be an error to call this
* but for now we'll leave it a no-op. */

3
libraries/AP_ADC_AnalogSource/AP_ADC_AnalogSource.h

@ -11,7 +11,8 @@ public: @@ -11,7 +11,8 @@ public:
AP_ADC_AnalogSource( AP_ADC * adc, uint8_t ch, float prescale = 1.0 ) :
_adc(adc), _ch(ch), _prescale(prescale)
{}
float read(void);
float read_average(void);
float read_latest(void);
void set_pin(uint8_t);
private:

Loading…
Cancel
Save