Skip to content

Commit

Permalink
current range fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Aug 12, 2019
1 parent faf6c82 commit 135b567
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 34,511 deletions.
20 changes: 13 additions & 7 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@
{
"name": "channel.ranges.currentlySelected",
"type": "string",
"defaultValue": "50mA"
"defaultValue": "High"
},
{
"name": "textMessage",
Expand Down Expand Up @@ -40009,11 +40009,12 @@
"activeStyle": {
"inheritFrom": "default"
},
"data": "channel.ranges.currentlySelected",
"left": 96,
"top": 34,
"width": 46,
"height": 32,
"text": "High"
"text": ""
},
{
"type": "Text",
Expand Down Expand Up @@ -40707,11 +40708,12 @@
"activeStyle": {
"inheritFrom": "default"
},
"data": "channel.ranges.currentlySelected",
"left": 96,
"top": 34,
"width": 46,
"height": 32,
"text": "High"
"text": ""
},
{
"type": "BarGraph",
Expand Down Expand Up @@ -41034,11 +41036,12 @@
"activeStyle": {
"inheritFrom": "default"
},
"data": "channel.ranges.currentlySelected",
"left": 0,
"top": 68,
"width": 66,
"height": 32,
"text": "High"
"text": ""
},
{
"type": "Text",
Expand Down Expand Up @@ -59175,11 +59178,12 @@
"activeStyle": {
"inheritFrom": "default"
},
"data": "channel.ranges.currentlySelected",
"left": 96,
"top": 34,
"width": 46,
"height": 32,
"text": "High"
"text": ""
}
]
},
Expand Down Expand Up @@ -60210,11 +60214,12 @@
"activeStyle": {
"inheritFrom": "default"
},
"data": "channel.ranges.currentlySelected",
"left": 96,
"top": 34,
"width": 46,
"height": 32,
"text": "High"
"text": ""
}
]
},
Expand Down Expand Up @@ -60770,11 +60775,12 @@
"activeStyle": {
"inheritFrom": "default"
},
"data": "channel.ranges.currentlySelected",
"left": 0,
"top": 68,
"width": 66,
"height": 32,
"text": "High"
"text": ""
},
{
"type": "DisplayData",
Expand Down
4 changes: 1 addition & 3 deletions src/eez/apps/psu/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,7 @@ void Channel::doSetCurrent(float value) {
setCurrentRange(CURRENT_RANGE_HIGH);
} else if (!calibration::isEnabled()) {
if (flags.currentRangeSelectionMode == CURRENT_RANGE_SELECTION_USE_BOTH) {
setCurrentRange(eez::greater(value, 0.05f, getPrecision(UNIT_AMPER))
? CURRENT_RANGE_HIGH
: CURRENT_RANGE_LOW);
setCurrentRange(eez::greater(value, 0.05f, getPrecision(UNIT_AMPER)) ? CURRENT_RANGE_HIGH : CURRENT_RANGE_LOW);
} else if (flags.currentRangeSelectionMode == CURRENT_RANGE_SELECTION_ALWAYS_HIGH) {
setCurrentRange(CURRENT_RANGE_HIGH);
} else {
Expand Down
12 changes: 7 additions & 5 deletions src/eez/apps/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ EnumItem g_triggerSourceEnumDefinition[] = { { trigger::SOURCE_BUS, "Bus" },

EnumItem g_channelCurrentRangeSelectionModeEnumDefinition[] = {
{ CURRENT_RANGE_SELECTION_USE_BOTH, "Best (default)" },
{ CURRENT_RANGE_SELECTION_ALWAYS_HIGH, "5A" },
{ CURRENT_RANGE_SELECTION_ALWAYS_LOW, "50mA" },
{ CURRENT_RANGE_SELECTION_ALWAYS_HIGH, "High (5A)" },
{ CURRENT_RANGE_SELECTION_ALWAYS_LOW, "Low (50mA)" },
{ 0, 0 }
};

EnumItem g_channelCurrentRangeEnumDefinition[] = { { CURRENT_RANGE_HIGH, "5A" },
{ CURRENT_RANGE_LOW, "50mA" },
EnumItem g_channelCurrentRangeEnumDefinition[] = { { CURRENT_RANGE_HIGH, "High" },
{ CURRENT_RANGE_LOW, "Low" },
{ 0, 0 } };

EnumItem g_channelTriggerOnListStopEnumDefinition[] = {
Expand Down Expand Up @@ -3337,7 +3337,9 @@ void data_channel_ranges_auto_ranging(data::DataOperationEnum operation, data::C
void data_channel_ranges_currently_selected(data::DataOperationEnum operation, data::Cursor &cursor,
data::Value &value) {
if (operation == data::DATA_OPERATION_GET) {
value = MakeEnumDefinitionValue(g_channel->flags.currentCurrentRange,
int iChannel = cursor.i >= 0 ? cursor.i : (g_channel ? (g_channel->index - 1) : 0);
Channel &channel = Channel::get(iChannel);
value = MakeEnumDefinitionValue(channel.flags.currentCurrentRange,
ENUM_DEFINITION_CHANNEL_CURRENT_RANGE);
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/eez/apps/psu/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ void recallChannelsFromProfile(Parameters *profile, int location) {
trigger::setCurrent(channel, profile->channels[i].i_triggerValue);
list::setListCount(channel, profile->channels[i].listCount);

channel.flags.currentRangeSelectionMode =
profile->channels[i].flags.currentRangeSelectionMode;
channel.flags.autoSelectCurrentRange =
profile->channels[i].flags.autoSelectCurrentRange;
channel.flags.currentRangeSelectionMode = profile->channels[i].flags.currentRangeSelectionMode;
channel.flags.autoSelectCurrentRange = profile->channels[i].flags.autoSelectCurrentRange;

#if OPTION_SD_CARD
loadProfileList(*profile, channel, location);
Expand Down Expand Up @@ -287,8 +285,7 @@ void fillProfile(Parameters *pProfile) {
profile.channels[i].i_triggerValue = trigger::getCurrent(channel);
profile.channels[i].listCount = list::getListCount(channel);

profile.channels[i].flags.currentRangeSelectionMode =
channel.flags.currentRangeSelectionMode;
profile.channels[i].flags.currentRangeSelectionMode = channel.flags.currentRangeSelectionMode;
profile.channels[i].flags.autoSelectCurrentRange = channel.flags.autoSelectCurrentRange;
}
else {
Expand Down
Loading

0 comments on commit 135b567

Please sign in to comment.