diff --git a/libraries/AP_ADC/AP_ADC_HIL.cpp b/libraries/AP_ADC/AP_ADC_HIL.cpp index 5ea1efaba1..d3b04b5bc5 100644 --- a/libraries/AP_ADC/AP_ADC_HIL.cpp +++ b/libraries/AP_ADC/AP_ADC_HIL.cpp @@ -23,6 +23,8 @@ const float AP_ADC_HIL::accelBias[3] = {2025,2025,2025}; // gyroScale = 1/[GyroGain*pi/180] GyroGains (0.4,0.41,0.41) const float AP_ADC_HIL::gyroScale[3] = {143.239, 139.746, 139.746}; const float AP_ADC_HIL::accelScale[3] = {418,418,418}; // adcPerG + +uint16_t AP_ADC_HIL::_count; // number of samples captured AP_ADC_HIL::AP_ADC_HIL() { @@ -45,6 +47,7 @@ AP_ADC_HIL::AP_ADC_HIL() void AP_ADC_HIL::Init( AP_PeriodicProcess * scheduler ) { + scheduler->register_process( AP_ADC_HIL::read ); } // Read one channel value @@ -56,6 +59,8 @@ float AP_ADC_HIL::Ch(unsigned char ch_num) // Read 6 channel values uint32_t AP_ADC_HIL::Ch6(const uint8_t *channel_numbers, float *result) { + _count = 0; + for (uint8_t i=0; i<6; i++) { result[i] = Ch(channel_numbers[i]); } @@ -92,5 +97,5 @@ bool AP_ADC_HIL::new_data_available(const uint8_t *channel_numbers) // Get minimum number of samples read from the sensors uint16_t AP_ADC_HIL::num_samples_available(const uint8_t *channel_numbers) { - return 1; + return _count; } \ No newline at end of file diff --git a/libraries/AP_ADC/AP_ADC_HIL.h b/libraries/AP_ADC/AP_ADC_HIL.h index b44147e891..3899a61907 100644 --- a/libraries/AP_ADC/AP_ADC_HIL.h +++ b/libraries/AP_ADC/AP_ADC_HIL.h @@ -14,6 +14,8 @@ #include #include "AP_ADC.h" + +#include /// // A hardware in the loop model of the ADS7844 analog to digital converter @@ -99,6 +101,13 @@ private: // TODO: implement void setGyroTemp(int16_t val) { } + + // read function that pretends to capture new data + static void read(uint32_t tnow) { + _count++; + } + + static uint16_t _count; // number of samples captured }; #endif