AnalogIn.cpp 598 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "AnalogIn.h"
  2. using namespace Empty;
  3. AnalogSource::AnalogSource(float v) :
  4. _v(v)
  5. {}
  6. float AnalogSource::read_average() {
  7. return _v;
  8. }
  9. float AnalogSource::voltage_average() {
  10. return 5.0f * _v / 1024.0f;
  11. }
  12. float AnalogSource::voltage_latest() {
  13. return 5.0f * _v / 1024.0f;
  14. }
  15. float AnalogSource::read_latest() {
  16. return _v;
  17. }
  18. void AnalogSource::set_pin(uint8_t p)
  19. {}
  20. AnalogIn::AnalogIn()
  21. {}
  22. void AnalogIn::init()
  23. {}
  24. AP_HAL::AnalogSource* AnalogIn::channel(int16_t n) {
  25. return new AnalogSource(1.11);
  26. }
  27. float AnalogIn::board_voltage(void)
  28. {
  29. return 5.0f;
  30. }