From 2dd01f8a150e888b397e67ed5f44d71c60502223 Mon Sep 17 00:00:00 2001 From: atse Date: Mon, 23 Sep 2024 14:50:52 +0800 Subject: [PATCH] Account for swapped current limits --- src/command_handler.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/command_handler.rs b/src/command_handler.rs index 01a6fec..0ec4100 100644 --- a/src/command_handler.rs +++ b/src/command_handler.rs @@ -204,11 +204,19 @@ impl Handler { } PwmPin::MaxIPos => { let current = ElectricCurrent::new::(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 => { let current = ElectricCurrent::new::(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"{}");