Skip to content

Commit

Permalink
fixed protection events confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 6, 2019
1 parent b551e00 commit 14eb56a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 44 deletions.
8 changes: 5 additions & 3 deletions src/eez/apps/psu/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,19 @@ void Channel::protectionEnter(ProtectionValue &cpv) {
int bit_mask = reg_get_ques_isum_bit_mask_for_channel_protection_value(cpv);
setQuesBits(bit_mask, true);

int16_t eventId = event_queue::EVENT_ERROR_CH1_OVP_TRIPPED + channelIndex;
int16_t eventId;

if (IS_OVP_VALUE(this, cpv)) {
if (flags.rprogEnabled && channel_dispatcher::getUProtectionLevel(*this) == channel_dispatcher::getUMax(*this)) {
g_rprogAlarm = true;
}
doRemoteProgrammingEnable(false);

eventId = event_queue::EVENT_ERROR_CH1_OVP_TRIPPED + channelIndex;
} else if (IS_OCP_VALUE(this, cpv)) {
eventId += 1;
eventId = event_queue::EVENT_ERROR_CH1_OCP_TRIPPED + channelIndex;
} else {
eventId += 2;
eventId = event_queue::EVENT_ERROR_CH1_OPP_TRIPPED + channelIndex;
}

event_queue::pushEvent(eventId);
Expand Down
46 changes: 12 additions & 34 deletions src/eez/apps/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,46 +1016,13 @@ void selectChannel() {
}
}

static bool isChannelTripLastEvent(int i, event_queue::Event *lastEvent) {
if (lastEvent->eventId == (event_queue::EVENT_ERROR_CH1_OVP_TRIPPED + i) ||
lastEvent->eventId == (event_queue::EVENT_ERROR_CH1_OCP_TRIPPED + i) ||
lastEvent->eventId == (event_queue::EVENT_ERROR_CH1_OPP_TRIPPED + i) ||
lastEvent->eventId == (event_queue::EVENT_ERROR_CH1_OTP_TRIPPED + i))
{
return Channel::get(i).isTripped();
}

return false;
}

void onLastErrorEventAction() {
auto lastEvent = event_queue::getLastErrorEvent();

if (lastEvent) {
if (lastEvent->eventId == event_queue::EVENT_ERROR_AUX_OTP_TRIPPED && temperature::sensors[temp_sensor::AUX].isTripped()) {
showPage(PAGE_ID_SYS_SETTINGS_TEMPERATURE);
return;
}

for (int i = 0; i < CH_NUM; i++) {
if (isChannelTripLastEvent(i, lastEvent)) {
g_channel = &Channel::get(i);
showPage(PAGE_ID_CH_SETTINGS_PROT_CLEAR);
return;
}
}
}

showPage(PAGE_ID_EVENT_QUEUE);
}

} // namespace gui
} // namespace psu

namespace mcu {
namespace display {

uint16_t transformColor(uint16_t color) {
uint16_t transformColorHook(uint16_t color) {
if (color == COLOR_ID_CHANNEL1) {
return color + eez::psu::gui::g_channel->channelIndex;
}
Expand All @@ -1065,6 +1032,17 @@ uint16_t transformColor(uint16_t color) {
}
}

namespace gui {

uint16_t overrideStyleColorHook(const WidgetCursor &widgetCursor, const Style *style) {
if (widgetCursor.widget->type == WIDGET_TYPE_TEXT && widgetCursor.widget->data == DATA_ID_DLOG_VALUE_LABEL) {
return widgetCursor.cursor.i == 0 ? COLOR_ID_BAR_GRAPH_VOLTAGE : COLOR_ID_BAR_GRAPH_CURRENT;
}
return style->color;
}

}

} // namespace eez

#endif
2 changes: 0 additions & 2 deletions src/eez/apps/psu/gui/psu.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ void channelEnableOutput();
void selectChannel();
extern Channel *g_channel;

void onLastErrorEventAction();

extern data::Cursor g_focusCursor;
extern uint16_t g_focusDataId;
extern data::Value g_focusEditValue;
Expand Down
5 changes: 0 additions & 5 deletions src/eez/gui/action_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,6 @@ void action_sys_settings_fan_edit_speed() {
((SysSettingsTemperaturePage *)getActivePage())->editFanSpeed();
}


void action_on_last_error_event_action() {
onLastErrorEventAction();
}

void action_edit_system_password() {
editSystemPassword();
}
Expand Down

0 comments on commit 14eb56a

Please sign in to comment.