static void update_input_voltage_current_temperature(int voltage_raw, int current_raw, int temperature_raw) { static const int ALPHA_RCPR = 7; // A power of two minus one (1, 3, 7) _state.input_voltage_raw = LOWPASS(_state.input_voltage_raw, voltage_raw, ALPHA_RCPR); _state.input_current = LOWPASS(_state.input_current, current_raw, ALPHA_RCPR); _state.temperature_raw = LOWPASS(_state.temperature_raw, temperature_raw, ALPHA_RCPR); }
static void update_input_voltage_current(const struct motor_adc_sample* sample) { static const int ALPHA_RCPR = 7; // A power of two minus one (1, 3, 7) _state.input_voltage = LOWPASS(_state.input_voltage, sample->input_voltage, ALPHA_RCPR); _state.input_current = LOWPASS(_state.input_current, sample->input_current, ALPHA_RCPR); }