Update LED L3 for PID status on every cycle

Check if PID is engaged on any channel every cycle, and match the status
with LED L3.
pull/81/head
atse 2023-08-10 16:41:08 +08:00
parent f29e86310d
commit 6f0acc73b8
2 changed files with 6 additions and 5 deletions

View File

@ -178,7 +178,6 @@ impl Handler {
fn engage_pid (socket: &mut TcpSocket, channels: &mut Channels, leds: &mut Leds, channel: usize) -> Result<Handler, Error> {
channels.channel_state(channel).pid_engaged = true;
leds.g3.on();
send_line(socket, b"{}");
Ok(Handler::Handled)
}
@ -187,10 +186,6 @@ impl Handler {
match pin {
PwmPin::ISet => {
channels.channel_state(channel).pid_engaged = false;
// Only turn off LED when PID is disengaged on all channels
if !channels.pid_engaged() {
leds.g3.off();
}
let current = ElectricCurrent::new::<ampere>(value);
channels.set_i(channel, current);
channels.power_up(channel);

View File

@ -188,6 +188,12 @@ fn main() -> ! {
fan_ctrl.cycle(channels.current_abs_max_tec_i() as f32);
if channels.pid_engaged() {
leds.g3.on();
} else {
leds.g3.off();
}
let instant = Instant::from_millis(i64::from(timer::now()));
cortex_m::interrupt::free(net::clear_pending);
server.poll(instant)