f1_dual: fix aux pwm outputs (#119)

Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
This commit is contained in:
rusefillc 2022-07-16 02:02:02 -04:00 committed by GitHub
parent 55f65ad02d
commit 700d763c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -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? */