Is there any reason that the last two line here do not call “set_output_pwm_trimmed” instead? I haven’t tested it yet, but it looks like this would yield the desired functionality.
However, the behavior wasn’t what I expected; I realise now that there is some unintended mixing between the elevator and aileron channels when in manual mode, as they are assumed to be passthrough, but are actually mixed when ELEVON_OUTPUT is configured, and that mixing assumes a 1500 centre (trim) value, which may not be correct.