Skip to content

Commit

Permalink
#117 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Apr 28, 2017
1 parent d7a45c3 commit aeda27b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
1 change: 0 additions & 1 deletion eez_psu_sketch/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ void channelEnableOutput() {
}

void standBy() {
showEnteringStandbyPage();
changePowerState(false);
}

Expand Down
19 changes: 15 additions & 4 deletions eez_psu_sketch/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -887,7 +898,7 @@ void onProtectionTripped() {
if (isPowerUp()) {
if (persist_conf::isShutdownWhenProtectionTrippedEnabled()) {
if (g_insideInterruptHandler) {
g_shutdownOnNextTick = true;
g_powerDownOnNextTick = true;
disableChannels();
} else {
powerDownBySensor();
Expand All @@ -905,8 +916,8 @@ void onProtectionTripped() {
void tick() {
++g_mainLoopCounter;

if (g_shutdownOnNextTick) {
g_shutdownOnNextTick = false;
if (g_powerDownOnNextTick) {
g_powerDownOnNextTick = false;
powerDownBySensor();
}

Expand Down
1 change: 1 addition & 0 deletions eez_psu_sketch/psu.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ bool powerUp();
void powerDown();
bool isPowerUp();
bool changePowerState(bool up);
void schedulePowerDown();
void powerDownBySensor();

bool reset();
Expand Down
9 changes: 7 additions & 2 deletions eez_psu_sketch/trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
}
}
Expand Down

0 comments on commit aeda27b

Please sign in to comment.