From 700d763c29245f895b98fa270821d2abdc0612eb Mon Sep 17 00:00:00 2001 From: rusefillc <48498823+rusefillc@users.noreply.github.com> Date: Sat, 16 Jul 2022 02:02:02 -0400 Subject: [PATCH] f1_dual: fix aux pwm outputs (#119) Co-authored-by: Andrey Gusakov --- firmware/auxout.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/auxout.cpp b/firmware/auxout.cpp index b94681f..53bd68a 100644 --- a/firmware/auxout.cpp +++ b/firmware/auxout.cpp @@ -28,6 +28,13 @@ PWMConfig auxPwmConfig = { static Pwm auxDac(AUXOUT_DAC_PWM_DEVICE); +static const uint8_t auxOutPwmCh[] = { + AUXOUT_DAC_PWM_CHANNEL_0, +#if (AFR_CHANNELS > 1) + AUXOUT_DAC_PWM_CHANNEL_1, +#endif +}; + extern float clampF(float min, float clamp, float max); void SetAuxDac(int channel, float voltage) @@ -37,7 +44,7 @@ void SetAuxDac(int channel, float voltage) duty = 1.0 - duty; duty = clampF(0, duty, 1); - auxDac.SetDuty(channel ? AUXOUT_DAC_PWM_CHANNEL_1 : AUXOUT_DAC_PWM_CHANNEL_0, duty); + auxDac.SetDuty(auxOutPwmCh[channel], duty); } /* TODO: merge with some other communication thread? */