diff --git a/eez_psu_sketch/gui.cpp b/eez_psu_sketch/gui.cpp index b6991808..73f105fe 100644 --- a/eez_psu_sketch/gui.cpp +++ b/eez_psu_sketch/gui.cpp @@ -1048,7 +1048,6 @@ void channelEnableOutput() { } void standBy() { - showEnteringStandbyPage(); changePowerState(false); } diff --git a/eez_psu_sketch/psu.cpp b/eez_psu_sketch/psu.cpp index 098355c2..ced62d78 100644 --- a/eez_psu_sketch/psu.cpp +++ b/eez_psu_sketch/psu.cpp @@ -75,7 +75,7 @@ static MaxCurrentLimitCause g_maxCurrentLimitCause; ontime::Counter g_powerOnTimeCounter(ontime::ON_TIME_COUNTER_POWER); volatile bool g_insideInterruptHandler = false; -static bool g_shutdownOnNextTick; +static bool g_powerDownOnNextTick; RLState g_rlState = RL_STATE_LOCAL; @@ -832,6 +832,9 @@ bool changePowerState(bool up) { profile::save(); } else { +#if OPTION_DISPLAY + gui::showEnteringStandbyPage(); +#endif g_powerIsUp = false; profile::saveImmediately(); g_powerIsUp = true; @@ -847,8 +850,16 @@ bool changePowerState(bool up) { return true; } +void schedulePowerDown() { + g_powerDownOnNextTick = true; +} + void powerDownBySensor() { if (g_powerIsUp) { +#if OPTION_DISPLAY + gui::showEnteringStandbyPage(); +#endif + for (int i = 0; i < CH_NUM; ++i) { Channel::get(i).outputEnable(false); } @@ -887,7 +898,7 @@ void onProtectionTripped() { if (isPowerUp()) { if (persist_conf::isShutdownWhenProtectionTrippedEnabled()) { if (g_insideInterruptHandler) { - g_shutdownOnNextTick = true; + g_powerDownOnNextTick = true; disableChannels(); } else { powerDownBySensor(); @@ -905,8 +916,8 @@ void onProtectionTripped() { void tick() { ++g_mainLoopCounter; - if (g_shutdownOnNextTick) { - g_shutdownOnNextTick = false; + if (g_powerDownOnNextTick) { + g_powerDownOnNextTick = false; powerDownBySensor(); } diff --git a/eez_psu_sketch/psu.h b/eez_psu_sketch/psu.h index b15255ea..8f06a973 100644 --- a/eez_psu_sketch/psu.h +++ b/eez_psu_sketch/psu.h @@ -67,6 +67,7 @@ bool powerUp(); void powerDown(); bool isPowerUp(); bool changePowerState(bool up); +void schedulePowerDown(); void powerDownBySensor(); bool reset(); diff --git a/eez_psu_sketch/trigger.cpp b/eez_psu_sketch/trigger.cpp index f1339752..ec91aa1d 100644 --- a/eez_psu_sketch/trigger.cpp +++ b/eez_psu_sketch/trigger.cpp @@ -166,7 +166,9 @@ void onTriggerFinished(Channel &channel) { switch (channel.getTriggerOnListStop()) { case TRIGGER_ON_LIST_STOP_OUTPUT_OFF: - channel.outputEnable(false); + channel_dispatcher::setVoltage(channel, 0); + channel_dispatcher::setCurrent(channel, 0); + channel_dispatcher::outputEnable(channel, false); break; case TRIGGER_ON_LIST_STOP_SET_TO_FIRST_STEP: if (!list::setListValue(channel, 0, &err)) { @@ -179,7 +181,10 @@ void onTriggerFinished(Channel &channel) { } break; case TRIGGER_ON_LIST_STOP_STANDBY: - changePowerState(false); + channel_dispatcher::setVoltage(channel, 0); + channel_dispatcher::setCurrent(channel, 0); + channel_dispatcher::outputEnable(channel, false); + schedulePowerDown(); break; } }