Skip to content

Commit 89cb57e

Browse files
authored
Merge pull request #328 from Duet3D/327-display-two-digits-of-axis-only-if-max-axis-value-is-less-or-equal-to-1000
327 display two digits of axis only if max axis value is less or equal to 1000
2 parents 792fb83 + e0b9628 commit 89cb57e

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/PanelDue.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ enum ReceivedDataEvent
294294
rcvMoveAxesHomed,
295295
rcvMoveAxesLetter,
296296
rcvMoveAxesMachinePosition,
297+
rcvMoveAxesMax,
297298
rcvMoveAxesUserPosition,
298299
rcvMoveAxesVisible,
299300
rcvMoveAxesWorkplaceOffsets,
@@ -409,6 +410,7 @@ static FieldTableEntry fieldTable[] =
409410
{ rcvMoveAxesHomed, "move:axes^:homed" },
410411
{ rcvMoveAxesLetter, "move:axes^:letter" },
411412
{ rcvMoveAxesMachinePosition, "move:axes^:machinePosition" },
413+
{ rcvMoveAxesMax, "move:axes^:max" },
412414
{ rcvMoveAxesUserPosition, "move:axes^:userPosition" },
413415
{ rcvMoveAxesVisible, "move:axes^:visible" },
414416
{ rcvMoveAxesWorkplaceOffsets, "move:axes^:workplaceOffsets^" },
@@ -1461,6 +1463,16 @@ static void ProcessReceivedValue(StringRef id, const char data[], const size_t i
14611463
}
14621464
break;
14631465

1466+
case rcvMoveAxesMax:
1467+
{
1468+
float val;
1469+
if (GetFloat(data, val))
1470+
{
1471+
UI::SetAxisMax(indices[0], val);
1472+
}
1473+
}
1474+
break;
1475+
14641476
case rcvMoveAxesUserPosition:
14651477
{
14661478
float fval;

src/UI/Display.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,16 @@ class FloatField : public FieldWithText
288288
changed = true;
289289
}
290290

291+
void SetNumDecimals(uint8_t decimals)
292+
{
293+
if (numDecimals == decimals)
294+
{
295+
return;
296+
}
297+
numDecimals = decimals;
298+
changed = true;
299+
}
300+
291301
void SetLabel(const char* _ecv_array s)
292302
{
293303
if (strcmp(label, s) == 0)

src/UI/UserInterface.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static StaticTextField *areYouSureTextField, *areYouSureQueryField;
8484
static DisplayField *emptyRoot, *baseRoot, *commonRoot, *controlRoot, *printRoot, *messageRoot, *setupRoot;
8585
static SingleButton *homeAllButton, *bedCompButton;
8686
static IconButtonWithText *homeButtons[MaxDisplayableAxes], *toolButtons[MaxSlots];
87+
88+
static float axisMaxVal = 0.0;
8789
static FloatField *controlTabAxisPos[MaxDisplayableAxes];
8890
#if DISPLAY_X == 800
8991
static FloatField *printTabAxisPos[MaxDisplayableAxes];
@@ -388,6 +390,18 @@ static void ChangeBrightness(bool up)
388390
SetBrightness(nvData.GetBrightness() + adjust);
389391
}
390392

393+
394+
void UI::SetAxisMax(size_t index, float val)
395+
{
396+
if (index >= MaxTotalAxes)
397+
{
398+
return;
399+
}
400+
401+
axisMaxVal = max(axisMaxVal, val);
402+
}
403+
404+
391405
// Cycle through available display dimmer types
392406
static void ChangeDisplayDimmerType()
393407
{
@@ -1326,6 +1340,16 @@ namespace UI
13261340
if (axis != nullptr && axis->slot < MaxDisplayableAxes)
13271341
{
13281342
size_t slot = axis->slot;
1343+
1344+
if (axisMaxVal > 1000)
1345+
{
1346+
controlTabAxisPos[slot]->SetNumDecimals(1);
1347+
#if DISPLAY_X == 800
1348+
printTabAxisPos[slot]->SetNumDecimals(1);
1349+
#endif
1350+
movePopupAxisPos[slot]->SetNumDecimals(1);
1351+
}
1352+
13291353
controlTabAxisPos[slot]->SetValue(fval);
13301354
#if DISPLAY_X == 800
13311355
printTabAxisPos[slot]->SetValue(fval);

src/UI/UserInterface.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ namespace UI
103103

104104
extern void SetBabystepOffset(size_t index, float f);
105105
extern void SetAxisLetter(size_t index, char l);
106+
extern void SetAxisMax(size_t index, float val);
106107
extern void SetAxisVisible(size_t index, bool v);
107108
extern void SetAxisWorkplaceOffset(size_t axisIndex, size_t workplaceIndex, float offset);
108109
extern void SetCurrentWorkplaceNumber(uint8_t workplaceNumber);

0 commit comments

Comments
 (0)