forked from M-Labs/thermostat
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.
This commit is contained in:
parent
f29e86310d
commit
6f0acc73b8
|
@ -178,7 +178,6 @@ impl Handler {
|
||||||
|
|
||||||
fn engage_pid (socket: &mut TcpSocket, channels: &mut Channels, leds: &mut Leds, channel: usize) -> Result<Handler, Error> {
|
fn engage_pid (socket: &mut TcpSocket, channels: &mut Channels, leds: &mut Leds, channel: usize) -> Result<Handler, Error> {
|
||||||
channels.channel_state(channel).pid_engaged = true;
|
channels.channel_state(channel).pid_engaged = true;
|
||||||
leds.g3.on();
|
|
||||||
send_line(socket, b"{}");
|
send_line(socket, b"{}");
|
||||||
Ok(Handler::Handled)
|
Ok(Handler::Handled)
|
||||||
}
|
}
|
||||||
|
@ -187,10 +186,6 @@ impl Handler {
|
||||||
match pin {
|
match pin {
|
||||||
PwmPin::ISet => {
|
PwmPin::ISet => {
|
||||||
channels.channel_state(channel).pid_engaged = false;
|
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);
|
let current = ElectricCurrent::new::<ampere>(value);
|
||||||
channels.set_i(channel, current);
|
channels.set_i(channel, current);
|
||||||
channels.power_up(channel);
|
channels.power_up(channel);
|
||||||
|
|
|
@ -188,6 +188,12 @@ fn main() -> ! {
|
||||||
|
|
||||||
fan_ctrl.cycle(channels.current_abs_max_tec_i() as f32);
|
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()));
|
let instant = Instant::from_millis(i64::from(timer::now()));
|
||||||
cortex_m::interrupt::free(net::clear_pending);
|
cortex_m::interrupt::free(net::clear_pending);
|
||||||
server.poll(instant)
|
server.poll(instant)
|
||||||
|
|
Loading…
Reference in New Issue