Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

327 display two digits of axis only if max axis value is less or equal to 1000 #328

Merged
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
12 changes: 12 additions & 0 deletions src/PanelDue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ enum ReceivedDataEvent
rcvMoveAxesHomed,
rcvMoveAxesLetter,
rcvMoveAxesMachinePosition,
rcvMoveAxesMax,
rcvMoveAxesUserPosition,
rcvMoveAxesVisible,
rcvMoveAxesWorkplaceOffsets,
Expand Down Expand Up @@ -409,6 +410,7 @@ static FieldTableEntry fieldTable[] =
{ rcvMoveAxesHomed, "move:axes^:homed" },
{ rcvMoveAxesLetter, "move:axes^:letter" },
{ rcvMoveAxesMachinePosition, "move:axes^:machinePosition" },
{ rcvMoveAxesMax, "move:axes^:max" },
{ rcvMoveAxesUserPosition, "move:axes^:userPosition" },
{ rcvMoveAxesVisible, "move:axes^:visible" },
{ rcvMoveAxesWorkplaceOffsets, "move:axes^:workplaceOffsets^" },
Expand Down Expand Up @@ -1461,6 +1463,16 @@ static void ProcessReceivedValue(StringRef id, const char data[], const size_t i
}
break;

case rcvMoveAxesMax:
{
float val;
if (GetFloat(data, val))
{
UI::SetAxisMax(indices[0], val);
}
}
break;

case rcvMoveAxesUserPosition:
{
float fval;
Expand Down
10 changes: 10 additions & 0 deletions src/UI/Display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,16 @@ class FloatField : public FieldWithText
changed = true;
}

void SetNumDecimals(uint8_t decimals)
{
if (numDecimals == decimals)
{
return;
}
numDecimals = decimals;
changed = true;
}

void SetLabel(const char* _ecv_array s)
{
if (strcmp(label, s) == 0)
Expand Down
24 changes: 24 additions & 0 deletions src/UI/UserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ static StaticTextField *areYouSureTextField, *areYouSureQueryField;
static DisplayField *emptyRoot, *baseRoot, *commonRoot, *controlRoot, *printRoot, *messageRoot, *setupRoot;
static SingleButton *homeAllButton, *bedCompButton;
static IconButtonWithText *homeButtons[MaxDisplayableAxes], *toolButtons[MaxSlots];

static float axisMaxVal = 0.0;
static FloatField *controlTabAxisPos[MaxDisplayableAxes];
#if DISPLAY_X == 800
static FloatField *printTabAxisPos[MaxDisplayableAxes];
Expand Down Expand Up @@ -388,6 +390,18 @@ static void ChangeBrightness(bool up)
SetBrightness(nvData.GetBrightness() + adjust);
}


void UI::SetAxisMax(size_t index, float val)
{
if (index >= MaxTotalAxes)
{
return;
}

axisMaxVal = max(axisMaxVal, val);
}


// Cycle through available display dimmer types
static void ChangeDisplayDimmerType()
{
Expand Down Expand Up @@ -1326,6 +1340,16 @@ namespace UI
if (axis != nullptr && axis->slot < MaxDisplayableAxes)
{
size_t slot = axis->slot;

if (axisMaxVal > 1000)
{
controlTabAxisPos[slot]->SetNumDecimals(1);
#if DISPLAY_X == 800
printTabAxisPos[slot]->SetNumDecimals(1);
#endif
movePopupAxisPos[slot]->SetNumDecimals(1);
}

controlTabAxisPos[slot]->SetValue(fval);
#if DISPLAY_X == 800
printTabAxisPos[slot]->SetValue(fval);
Expand Down
1 change: 1 addition & 0 deletions src/UI/UserInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace UI

extern void SetBabystepOffset(size_t index, float f);
extern void SetAxisLetter(size_t index, char l);
extern void SetAxisMax(size_t index, float val);
extern void SetAxisVisible(size_t index, bool v);
extern void SetAxisWorkplaceOffset(size_t axisIndex, size_t workplaceIndex, float offset);
extern void SetCurrentWorkplaceNumber(uint8_t workplaceNumber);
Expand Down