Turn off LED L3 only when all channels have no PID #78
@ -475,6 +475,15 @@ impl Channels {
|
|||||||
serde_json_core::to_vec(&summaries)
|
serde_json_core::to_vec(&summaries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pid_engaged(&mut self) -> bool {
|
||||||
|
for channel in 0..CHANNELS {
|
||||||
|
if self.channel_state(channel).pid_engaged {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn pwm_summary(&mut self, channel: usize) -> PwmSummary {
|
fn pwm_summary(&mut self, channel: usize) -> PwmSummary {
|
||||||
PwmSummary {
|
PwmSummary {
|
||||||
channel,
|
channel,
|
||||||
|
@ -187,7 +187,10 @@ 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() {
|
||||||
atse marked this conversation as resolved
Outdated
|
|||||||
leds.g3.off();
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user
channel ^ 1
while quick, would cause weird behavior if e.g. we create a new version of the thermostat with more than two channels and re-used the code.My suggestion would be make a function in
Channels
for checking the PID state of all channels.Thanks for the suggestion, the latest force push loops through all channels to check their PID state.