Data acquisition is managed by PID
Context While preparing for the Hackathon, we've realized that the data acquisition module is called by the PID function and thus cannot be called by other functions. This is an issue since the data will be inevitably needed elsewhere to implement higher level funcitons.
Description
The function opalib_pid_voltage_calculation_and_pwm_update starts as:
void opalib_pid_voltage_calculation_and_pwm_update()
{
// Acquire and convert data
uint32_t v1_low_count;
uint32_t v_high_count;
uint16_t* v1_low_buffer = data_acquisition_get_v1_low_values(&v1_low_count);
uint16_t* v_high_buffer = data_acquisition_get_v_high_values(&v_high_count);
...
}
These calls above empty the buffer and mean that the data cannot be used elsewhere.
Solution
It is necessary to change this logic and create a function that manages the data elsewhere. Potentially a function that itself calls opalib_pid_voltage_calculation_and_pwm_update but handles it the data it needs to do its pid.