Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/MenuItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ uint16_t MenuItem::getId() const
return (isInfoProgMem()) ? get_info_uint(&info->id) : info->id;
}

uint16_t MenuItem::getMinimumValue() const
{
return (isInfoProgMem()) ? get_info_uint(&info->minValue) : info->minValue;
}

uint16_t MenuItem::getMaximumValue() const
{
if (isMenuRuntime(this)) {
Expand Down Expand Up @@ -292,6 +297,9 @@ void ValueMenuItem::setCurrentValue(uint16_t val, bool silent) {
if (val == currentValue || val > getMaximumValue()) {
return;
}
if (val < getMinimumValue()) {
val = getMinimumValue();
}
currentValue = val;
changeOccurred(silent);
}
Expand Down
6 changes: 6 additions & 0 deletions src/MenuItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct AnyMenuInfo {
menuid_t id;
/** eeprom address for this item or -1 if not stored */
uint16_t eepromAddr;
/** minimum value that this type can store */
uint16_t minValue;
/** maximum value that this type can store */
uint16_t maxValue;
/** the callback function */
Expand All @@ -70,6 +72,8 @@ struct AnalogMenuInfo {
menuid_t id;
/** eeprom address for this item or -1 if not stored */
uint16_t eepromAddr;
/** minimum value that this type can store */
uint16_t minValue;
/** maximum value that this type can store */
uint16_t maxValue;
/** the callback function */
Expand Down Expand Up @@ -355,6 +359,8 @@ class MenuItem {
uint8_t copyNameToBuffer(char* sz, int offset, int size) const;
/** Retrieves the ID from the info block */
menuid_t getId() const;
/** Retrieves the minimum value for this menu type */
uint16_t getMinimumValue() const;
/** Retrieves the maximum value for this menu type */
uint16_t getMaximumValue() const;
/** Retrieves the eeprom storage position for this menu (or 0xffff if not applicable) */
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/DialogRuntimeEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DialogMultiPartEditor : BaseDialogController {
private:
MenuBasedDialog *dialog;
EditableMultiPartMenuItem* menuItemBeingEdited;
AnalogMenuInfo scrollingInfo = {"Item Value", nextRandomId(), 0xffff, 1, onScrollingChanged, 0, 1, "" };
AnalogMenuInfo scrollingInfo = {"Item Value", nextRandomId(), 0xffff, 0, 1, onScrollingChanged, 0, 1, "" };
AnalogMenuItem scrollingEditor = AnalogMenuItem(&scrollingInfo, 0, nullptr, INFO_LOCATION_RAM);

public:
Expand Down