Skip to content

Commit

Permalink
fixes in coupling and tracking gui
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Apr 8, 2020
1 parent 8e2bc60 commit 8b241ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
18 changes: 18 additions & 0 deletions src/eez/modules/psu/channel_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,24 @@ void setCouplingTypeInPsuThread(CouplingType couplingType) {
if (persist_conf::getMaxChannelIndex() == 1) {
persist_conf::setMaxChannelIndex(0);
}

// disable tracking if only 1 channel left in tracking mode
int numTrackingChannels = 0;
for (int i = 0; i < CH_NUM; i++) {
Channel &channel = Channel::get(i);
if (channel.flags.trackingEnabled) {
numTrackingChannels++;
}
}
if (numTrackingChannels == 1) {
for (int i = 0; i < CH_NUM; i++) {
Channel &channel = Channel::get(i);
if (channel.flags.trackingEnabled) {
channel.flags.trackingEnabled = false;
break;
}
}
}
} else {
if (g_couplingType == COUPLING_TYPE_PARALLEL || g_couplingType == COUPLING_TYPE_SERIES) {
for (int i = 0; i < 2; ++i) {
Expand Down
33 changes: 10 additions & 23 deletions src/eez/modules/psu/gui/page_sys_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ void SysSettingsIOPinsPage::set() {

void SysSettingsTrackingPage::pageAlloc() {
m_trackingEnabled = 0;
for (int i = 0; i < CH_MAX; i++) {
for (int i = 0; i < CH_NUM; i++) {
if (Channel::get(i).flags.trackingEnabled) {
m_trackingEnabled |= 1 << i;
}
Expand All @@ -911,7 +911,7 @@ void SysSettingsTrackingPage::pageAlloc() {
}

int SysSettingsTrackingPage::getDirty() {
return m_trackingEnabled != m_trackingEnabledOrig;
return m_trackingEnabled != m_trackingEnabledOrig && getNumTrackingChannels() != 1;
}

void SysSettingsTrackingPage::set() {
Expand Down Expand Up @@ -977,29 +977,16 @@ void SysSettingsCouplingPage::set() {
int err;
if (channel_dispatcher::setCouplingType(m_couplingType, &err)) {
if (m_couplingType == channel_dispatcher::COUPLING_TYPE_SPLIT_RAILS) {
auto trackingPage = (SysSettingsTrackingPage *)getPage(PAGE_ID_SYS_SETTINGS_TRACKING);
if (trackingPage) {
trackingPage->m_trackingEnabled = 0;
if (m_enableTrackingMode) {
// enable tracking for first two channels
trackingPage->m_trackingEnabled |= (1 << 0);
trackingPage->m_trackingEnabled |= (1 << 1);
}
trackingPage->m_trackingEnabledOrig = trackingPage->m_trackingEnabled;

channel_dispatcher::setTrackingChannels(trackingPage->m_trackingEnabled);
} else {
int trackingEnabled = 0;
if (m_enableTrackingMode) {
// enable tracking for first two channels
trackingEnabled |= (1 << 0);
trackingEnabled |= (1 << 1);
}
channel_dispatcher::setTrackingChannels(trackingEnabled);
int trackingEnabled = 0;
if (m_enableTrackingMode) {
// enable tracking for first two channels
trackingEnabled |= (1 << 0);
trackingEnabled |= (1 << 1);
}
channel_dispatcher::setTrackingChannels(trackingEnabled);
}

popPage();
showPage(PAGE_ID_MAIN);

if (m_couplingType == channel_dispatcher::COUPLING_TYPE_NONE) {
infoMessage("Uncoupled!");
Expand Down

0 comments on commit 8b241ea

Please sign in to comment.