Account for swapped current limits

This commit is contained in:
atse 2024-09-23 14:50:52 +08:00
parent ce4fb6090a
commit 2dd01f8a15

View File

@ -204,11 +204,19 @@ impl Handler {
} }
PwmPin::MaxIPos => { PwmPin::MaxIPos => {
let current = ElectricCurrent::new::<ampere>(value); let current = ElectricCurrent::new::<ampere>(value);
channels.set_max_i_pos(channel, current); if channels.channel_state(channel).polarity_swapped {
channels.set_max_i_neg(channel, current);
} else {
channels.set_max_i_pos(channel, current);
}
} }
PwmPin::MaxINeg => { PwmPin::MaxINeg => {
let current = ElectricCurrent::new::<ampere>(value); let current = ElectricCurrent::new::<ampere>(value);
channels.set_max_i_neg(channel, current); if channels.channel_state(channel).polarity_swapped {
channels.set_max_i_pos(channel, current);
} else {
channels.set_max_i_neg(channel, current);
}
} }
} }
send_line(socket, b"{}"); send_line(socket, b"{}");