Skip to content

Commit a1f31f1

Browse files
committed
gui fixes
1 parent ea2f980 commit a1f31f1

File tree

12 files changed

+232
-230
lines changed

12 files changed

+232
-230
lines changed

modular-psu-firmware.eez-project

Lines changed: 197 additions & 194 deletions
Large diffs are not rendered by default.

src/eez/gui/action_impl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,6 @@ void action_ch_settings_trigger_edit_list_count() {
731731
((ChSettingsTriggerPage *)getActivePage())->editListCount();
732732
}
733733

734-
void action_ch_settings_trigger_toggle_output_state() {
735-
((ChSettingsTriggerPage *)getActivePage())->toggleOutputState();
736-
}
737-
738734
void action_ch_settings_trigger_edit_on_list_stop() {
739735
((ChSettingsTriggerPage *)getActivePage())->editTriggerOnListStop();
740736
}

src/eez/gui/data.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ void FLOAT_value_to_text(const Value &value, char *text, int count) {
118118
if (fabs(floatValue) < 1) {
119119
unit = UNIT_MILLI_WATT;
120120
floatValue *= 1000.0f;
121-
floatValue = roundPrec(floatValue, 1.0f);
122-
} else if (fabs(floatValue) < 100) {
123-
floatValue = roundPrec(floatValue, 0.01f);
124-
} else {
125-
floatValue = roundPrec(floatValue, 0.1f);
126121
}
127122
} else if (unit == UNIT_SECOND) {
128123
if (fabs(floatValue) < 1) {
@@ -133,7 +128,11 @@ void FLOAT_value_to_text(const Value &value, char *text, int count) {
133128
}
134129

135130
if (!isNaN(floatValue)) {
136-
strcatFloat(text, floatValue);
131+
if (unit == UNIT_WATT || unit == UNIT_MILLI_WATT) {
132+
strcatFloat(text, floatValue, 2);
133+
} else {
134+
strcatFloat(text, floatValue);
135+
}
137136
removeTrailingZerosFromFloat(text);
138137
strcat(text, getUnitName(unit));
139138
} else {

src/eez/gui/draw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void drawText(const char *text, int textLength, int x, int y, int w, int h, cons
9090
if (styleIsHorzAlignLeft(style))
9191
x_offset = x1 + style->padding_left;
9292
else if (styleIsHorzAlignRight(style))
93-
x_offset = x2 - style->padding_left - width;
93+
x_offset = x2 - style->padding_right - width;
9494
else
9595
x_offset = x1 + ((x2 - x1 + 1) - width) / 2;
9696
if (x_offset < 0)
@@ -100,7 +100,7 @@ void drawText(const char *text, int textLength, int x, int y, int w, int h, cons
100100
if (styleIsVertAlignTop(style))
101101
y_offset = y1 + style->padding_top;
102102
else if (styleIsVertAlignBottom(style))
103-
y_offset = y2 - style->padding_top - height;
103+
y_offset = y2 - style->padding_bottom - height;
104104
else
105105
y_offset = y1 + ((y2 - y1 + 1) - height) / 2;
106106
if (y_offset < 0)

src/eez/modules/dcpX05/channel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,13 @@ struct Channel : ChannelInterface {
547547
void setDacVoltageFloat(int subchannelIndex, float value) {
548548
psu::Channel &channel = psu::Channel::getBySlotIndex(slotIndex);
549549

550+
float previousUSet = uSet;
551+
552+
uSet = value;
553+
550554
if (channel.params.features & CH_FEATURE_HW_OVP) {
551555
if (channel.isOutputEnabled()) {
552-
if (value < uSet) {
556+
if (value < previousUSet) {
553557
fallingEdge = true;
554558
if (channel.isHwOvpEnabled()) {
555559
// deactivate HW OVP
@@ -565,8 +569,6 @@ struct Channel : ChannelInterface {
565569
dac.setDacVoltage(0);
566570
}
567571

568-
uSet = value;
569-
570572
uBeforeBalancing = NAN;
571573
restoreCurrentToValueBeforeBalancing(psu::Channel::getBySlotIndex(slotIndex));
572574
}

src/eez/modules/psu/gui/data.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ void data_channel_protection_ocp_limit(data::DataOperationEnum operation, data::
24372437
} else if (operation == data::DATA_OPERATION_GET_MIN) {
24382438
value = MakeValue(channel_dispatcher::getIMin(channel), UNIT_AMPER);
24392439
} else if (operation == data::DATA_OPERATION_GET_MAX) {
2440-
value = MakeValue(channel_dispatcher::getIMax(channel), UNIT_AMPER);
2440+
value = MakeValue(channel_dispatcher::getIMaxLimit(channel), UNIT_AMPER);
24412441
} else if (operation == data::DATA_OPERATION_SET) {
24422442
channel_dispatcher::setCurrentLimit(channel, value.getFloat());
24432443
} else if (operation == data::DATA_OPERATION_GET_NAME) {
@@ -3744,12 +3744,6 @@ void data_channel_trigger_mode(data::DataOperationEnum operation, data::Cursor &
37443744
}
37453745
}
37463746

3747-
void data_channel_trigger_output_state(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
3748-
if (operation == data::DATA_OPERATION_GET) {
3749-
value = channel_dispatcher::getTriggerOutputState(*g_channel);
3750-
}
3751-
}
3752-
37533747
void data_channel_trigger_on_list_stop(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
37543748
if (operation == data::DATA_OPERATION_GET) {
37553749
value = MakeEnumDefinitionValue(channel_dispatcher::getTriggerOnListStop(*g_channel),
@@ -4534,6 +4528,17 @@ void data_channel_history_values(data::DataOperationEnum operation, data::Cursor
45344528
}
45354529
}
45364530

4531+
void data_dlog_enabled(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
4532+
#if OPTION_SD_CARD
4533+
if (operation == data::DATA_OPERATION_GET) {
4534+
value = (
4535+
channel_dispatcher::getCouplingType() == channel_dispatcher::COUPLING_TYPE_PARALLEL ||
4536+
channel_dispatcher::getCouplingType() == channel_dispatcher::COUPLING_TYPE_SERIES
4537+
) && cursor.i == 1 ? 0 : 1;
4538+
}
4539+
#endif
4540+
}
4541+
45374542
void data_dlog_voltage_enabled(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
45384543
#if OPTION_SD_CARD
45394544
if (operation == data::DATA_OPERATION_GET) {

src/eez/modules/psu/gui/edit_mode_keypad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void enter(int channelIndex, const eez::gui::data::Value &editValue, const eez::
5959

6060
options.enableMaxButton();
6161
options.enableMinButton();
62-
options.flags.signButtonEnabled = true;
62+
options.flags.signButtonEnabled = options.min < 0;
6363
options.flags.dotButtonEnabled = true;
6464

6565
g_keypad->init(0, editValue, options, onKeypadOk, 0, 0);

src/eez/modules/psu/gui/numeric_keypad.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,13 @@ Unit NumericKeypad::getSwitchToUnit() {
259259
return UNIT_AMPER;
260260
}
261261
}
262-
if (m_options.editValueUnit == UNIT_MICRO_AMPER)
262+
if (m_options.editValueUnit == UNIT_MICRO_AMPER) {
263263
if (m_options.channelIndex == -1 || Channel::get(m_options.channelIndex).isAmperAllowed()) {
264264
return UNIT_AMPER;
265265
} else {
266266
return UNIT_MILLI_AMPER;
267267
}
268+
}
268269
if (m_options.editValueUnit == UNIT_WATT)
269270
return UNIT_MILLI_WATT;
270271
if (m_options.editValueUnit == UNIT_MILLI_WATT)

src/eez/modules/psu/gui/page_ch_settings_trigger.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,18 @@ void ChSettingsTriggerPage::onFinishTriggerModeSet() {
4545
trigger::abort();
4646
channel_dispatcher::setVoltageTriggerMode(*g_channel, (TriggerMode)g_newTriggerMode);
4747
channel_dispatcher::setCurrentTriggerMode(*g_channel, (TriggerMode)g_newTriggerMode);
48+
channel_dispatcher::setTriggerOutputState(*g_channel, true);
4849
profile::save();
4950
}
5051

5152
void ChSettingsTriggerPage::onTriggerModeSet(uint16_t value) {
5253
popPage();
5354

54-
if (channel_dispatcher::getVoltageTriggerMode(*g_channel) != value ||
55-
channel_dispatcher::getCurrentTriggerMode(*g_channel) != value) {
55+
if (channel_dispatcher::getVoltageTriggerMode(*g_channel) != value || channel_dispatcher::getCurrentTriggerMode(*g_channel) != value) {
5656
g_newTriggerMode = (uint8_t)value;
5757

5858
if (trigger::isInitiated() || list::isActive()) {
59-
yesNoDialog(PAGE_ID_YES_NO, "Trigger is active. Are you sure?", onFinishTriggerModeSet,
60-
0, 0);
59+
yesNoDialog(PAGE_ID_YES_NO, "Trigger is active. Are you sure?", onFinishTriggerModeSet, 0, 0);
6160
} else {
6261
onFinishTriggerModeSet();
6362
}
@@ -116,12 +115,6 @@ void ChSettingsTriggerPage::editCurrentTriggerValue() {
116115
NumericKeypad::start(0, MakeValue(trigger::getCurrent(*g_channel), UNIT_AMPER), options, onCurrentTriggerValueSet, 0, 0);
117116
}
118117

119-
void ChSettingsTriggerPage::toggleOutputState() {
120-
channel_dispatcher::setTriggerOutputState(
121-
*g_channel, !channel_dispatcher::getTriggerOutputState(*g_channel));
122-
profile::save();
123-
}
124-
125118
void ChSettingsTriggerPage::onTriggerOnListStopSet(uint16_t value) {
126119
popPage();
127120
channel_dispatcher::setTriggerOnListStop(*g_channel, (TriggerOnListStop)value);

src/eez/modules/psu/gui/page_ch_settings_trigger.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class ChSettingsTriggerPage : public Page {
3535
void editVoltageTriggerValue();
3636
void editCurrentTriggerValue();
3737

38-
void toggleOutputState();
39-
4038
void editTriggerOnListStop();
4139

4240
void editListCount();

0 commit comments

Comments
 (0)