Skip to content

Commit

Permalink
#42
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jun 25, 2021
1 parent 51428ca commit 8f1cc80
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 11 deletions.
14 changes: 13 additions & 1 deletion src/eez/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ int getXScroll(const WidgetCursor &widgetCursor) {
return value.getType() == VALUE_TYPE_INT ? value.getInt() : 0;
}

void getSloatAndSubchannelIndex(Cursor cursor, int16_t id, int &slotIndex, int &subchannelIndex) {
void getSlotAndSubchannelIndex(Cursor cursor, int16_t id, int &slotIndex, int &subchannelIndex) {
Value value;
DATA_OPERATION_FUNCTION(id, DATA_OPERATION_GET_SLOT_AND_SUBCHANNEL_INDEX, cursor, value);
if (value.getType() == VALUE_TYPE_UINT32) {
Expand All @@ -905,6 +905,18 @@ void getSloatAndSubchannelIndex(Cursor cursor, int16_t id, int &slotIndex, int &
}
}

bool isMicroAmperAllowed(Cursor cursor, int16_t id) {
Value value;
DATA_OPERATION_FUNCTION(id, DATA_OPERATION_IS_MICRO_AMPER_ALLOWED, cursor, value);
return value.getInt() == 1;
}

bool isAmperAllowed(Cursor cursor, int16_t id) {
Value value;
DATA_OPERATION_FUNCTION(id, DATA_OPERATION_IS_AMPER_ALLOWED, cursor, value);
return value.getInt() == 1;
}

} // namespace gui
} // namespace eez

Expand Down
9 changes: 7 additions & 2 deletions src/eez/gui/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ enum DataOperationEnum {
DATA_OPERATION_GET_CANVAS_DRAW_FUNCTION,
DATA_OPERATION_GET_TEXT_CURSOR_POSITION,
DATA_OPERATION_GET_X_SCROLL,
DATA_OPERATION_GET_SLOT_AND_SUBCHANNEL_INDEX
DATA_OPERATION_GET_SLOT_AND_SUBCHANNEL_INDEX,
DATA_OPERATION_IS_MICRO_AMPER_ALLOWED,
DATA_OPERATION_IS_AMPER_ALLOWED
};

int count(int16_t id);
Expand Down Expand Up @@ -485,7 +487,10 @@ void ytDataTouchDrag(Cursor cursor, int16_t id, TouchDrag *touchDrag);
int getTextCursorPosition(Cursor cursor, int16_t id);
int getXScroll(const WidgetCursor &widgetCursor);

void getSloatAndSubchannelIndex(Cursor cursor, int16_t id, int &slotIndex, int &subchannelIndex);
void getSlotAndSubchannelIndex(Cursor cursor, int16_t id, int &slotIndex, int &subchannelIndex);

bool isMicroAmperAllowed(Cursor cursor, int16_t id);
bool isAmperAllowed(Cursor cursor, int16_t id);

} // namespace gui
} // namespace eez
6 changes: 3 additions & 3 deletions src/eez/modules/psu/dlog_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ bool getNextWriteBuffer(const uint8_t *&buffer, uint32_t &bufferSize, bool flush
if (i <= 0) {
i = 0;
} else {
#if defined(EEZ_PLATFORM_STM32)
taskEXIT_CRITICAL();
#endif
#if defined(EEZ_PLATFORM_STM32)
taskEXIT_CRITICAL();
#endif
abortAfterBufferOverflowError(0);
return false;
}
Expand Down
12 changes: 10 additions & 2 deletions src/eez/modules/psu/gui/channel_calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,11 @@ void data_calibration_point_set_value(DataOperationEnum operation, Cursor cursor
}
} else if (operation == DATA_OPERATION_SET) {
editPage->setDacValue(value.getFloat());
}
} else if (operation == DATA_OPERATION_IS_MICRO_AMPER_ALLOWED) {
value = g_slots[slotIndex]->isMicroAmperAllowed(subchannelIndex);
} else if (operation == DATA_OPERATION_IS_AMPER_ALLOWED) {
value = g_slots[slotIndex]->isAmperAllowed(subchannelIndex);
}
} else {
auto viewPage = (ChSettingsCalibrationViewPage *)getPage(PAGE_ID_CH_SETTINGS_CALIBRATION_VIEW);
if (operation == DATA_OPERATION_GET) {
Expand Down Expand Up @@ -1190,7 +1194,11 @@ void data_calibration_point_measured_value(DataOperationEnum operation, Cursor c
}
} else if (operation == DATA_OPERATION_SET) {
editPage->setMeasuredValue(value.getFloat());
}
} else if (operation == DATA_OPERATION_IS_MICRO_AMPER_ALLOWED) {
value = g_slots[slotIndex]->isMicroAmperAllowed(subchannelIndex);
} else if (operation == DATA_OPERATION_IS_AMPER_ALLOWED) {
value = g_slots[slotIndex]->isAmperAllowed(subchannelIndex);
}
} else {
auto viewPage = (ChSettingsCalibrationViewPage *)getPage(PAGE_ID_CH_SETTINGS_CALIBRATION_VIEW);
if (operation == DATA_OPERATION_GET) {
Expand Down
2 changes: 1 addition & 1 deletion src/eez/modules/psu/gui/edit_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void enter(int tabIndex, bool setFocus) {
slotIndex = channel.slotIndex;
subchannelIndex = channel.subchannelIndex;
} else {
getSloatAndSubchannelIndex(cursor, g_focusDataId, slotIndex, subchannelIndex);
getSlotAndSubchannelIndex(cursor, g_focusDataId, slotIndex, subchannelIndex);
}
edit_mode_keypad::enter(slotIndex, subchannelIndex, g_editValue, getAllowZero(getFocusCursor(), g_focusDataId), g_minValue, g_maxValue);
} else {
Expand Down
20 changes: 18 additions & 2 deletions src/eez/modules/psu/gui/keypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,22 @@ void NumericKeypad::switchToMega() {
m_options.editValueUnit = getMegaUnit();
}

bool NumericKeypad::isMicroAmperAllowed() {
if (m_options.slotIndex != -1 && m_options.subchannelIndex != -1) {
return g_slots[m_options.slotIndex]->isMicroAmperAllowed(m_options.subchannelIndex);
}

return eez::gui::isMicroAmperAllowed(g_focusCursor, g_focusDataId);
}

bool NumericKeypad::isAmperAllowed() {
if (m_options.slotIndex != -1 && m_options.subchannelIndex != -1) {
return g_slots[m_options.slotIndex]->isAmperAllowed(m_options.subchannelIndex);
}

return eez::gui::isAmperAllowed(g_focusCursor, g_focusDataId);
}

Unit NumericKeypad::getSwitchToUnit() {
if (m_options.editValueUnit == UNIT_VOLT)
return UNIT_MILLI_VOLT;
Expand All @@ -679,14 +695,14 @@ Unit NumericKeypad::getSwitchToUnit() {
if (m_options.editValueUnit == UNIT_AMPER)
return UNIT_MILLI_AMPER;
if (m_options.editValueUnit == UNIT_MILLI_AMPER) {
if (m_options.slotIndex != -1 && m_options.subchannelIndex != -1 && g_slots[m_options.slotIndex]->isMicroAmperAllowed(m_options.subchannelIndex)) {
if (isMicroAmperAllowed()) {
return UNIT_MICRO_AMPER;
} else {
return UNIT_AMPER;
}
}
if (m_options.editValueUnit == UNIT_MICRO_AMPER) {
if (m_options.slotIndex != -1 && m_options.subchannelIndex != -1 && g_slots[m_options.slotIndex]->isAmperAllowed(m_options.subchannelIndex)) {
if (isAmperAllowed()) {
return UNIT_AMPER;
} else {
return UNIT_MILLI_AMPER;
Expand Down
3 changes: 3 additions & 0 deletions src/eez/modules/psu/gui/keypad.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ class NumericKeypad : public Keypad {
void onEncoder(int counter) override;
#endif

bool isMicroAmperAllowed();
bool isAmperAllowed();

Unit getSwitchToUnit() override;

virtual int getCursorPostion() override;
Expand Down

0 comments on commit 8f1cc80

Please sign in to comment.