2012-12-17 15:07:26 -04:00
|
|
|
#include "AnalogIn.h"
|
|
|
|
|
|
|
|
using namespace Empty;
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
AnalogSource::AnalogSource(float v) :
|
2012-12-17 15:07:26 -04:00
|
|
|
_v(v)
|
|
|
|
{}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
float AnalogSource::read_average() {
|
2012-12-17 15:07:26 -04:00
|
|
|
return _v;
|
|
|
|
}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
float AnalogSource::voltage_average() {
|
2014-07-08 07:27:13 -03:00
|
|
|
return 5.0f * _v / 1024.0f;
|
2013-03-03 01:13:04 -04:00
|
|
|
}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
float AnalogSource::voltage_latest() {
|
2014-07-08 07:27:13 -03:00
|
|
|
return 5.0f * _v / 1024.0f;
|
2013-09-12 00:23:04 -03:00
|
|
|
}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
float AnalogSource::read_latest() {
|
2012-12-17 15:07:26 -04:00
|
|
|
return _v;
|
|
|
|
}
|
|
|
|
|
2021-09-22 16:48:11 -03:00
|
|
|
bool AnalogSource::set_pin(uint8_t p) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-12-17 15:07:26 -04:00
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
AnalogIn::AnalogIn()
|
2012-12-17 15:07:26 -04:00
|
|
|
{}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
void AnalogIn::init()
|
2012-12-17 15:07:26 -04:00
|
|
|
{}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
AP_HAL::AnalogSource* AnalogIn::channel(int16_t n) {
|
|
|
|
return new AnalogSource(1.11);
|
2012-12-17 15:07:26 -04:00
|
|
|
}
|
|
|
|
|
2015-12-07 14:53:55 -04:00
|
|
|
float AnalogIn::board_voltage(void)
|
2014-02-13 02:07:32 -04:00
|
|
|
{
|
2015-12-19 20:28:29 -04:00
|
|
|
return 5.0f;
|
2014-02-13 02:07:32 -04:00
|
|
|
}
|