Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2019-05-03 17:19:37 +0300
committerDavid Crocker <dcrocker@eschertech.com>2019-05-03 17:19:37 +0300
commitd35f50196ac0a11088d3f2df933648767da3dd80 (patch)
tree0a71459d32ce9669796b225ece6717ff0cc3fb5b /src/Display
parent6814c342969a471fa3b32c5e859f66b528de1131 (diff)
Version 2.03RC1 provisional
Use new CoreNG API Removed endstop mapping and M574 A parameter so that M585 works again Added 12864 menu items 534-537 M203 now waits for movement to stop M291 now unlocks movement if it is locked Status response now includes workplace coordinate system number Bug fix: in resurrect.g file, use absolute babystepping in M290 command, and quote the filename in M23 command Bug fix: W5500 chip could not be reset on Duet Maestro Bug fix: M109 did not run the tool change files if on tool was active initially Fix for issue with Fan 1 on Duet085
Diffstat (limited to 'src/Display')
-rw-r--r--src/Display/MenuItem.cpp190
-rw-r--r--src/Display/MenuItem.h22
2 files changed, 165 insertions, 47 deletions
diff --git a/src/Display/MenuItem.cpp b/src/Display/MenuItem.cpp
index e0a9e511..a1c7cead 100644
--- a/src/Display/MenuItem.cpp
+++ b/src/Display/MenuItem.cpp
@@ -221,7 +221,7 @@ PixelNumber ButtonMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, P
}
ValueMenuItem::ValueMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, bool adj, unsigned int v, unsigned int d)
- : MenuItem(r, c, ((w != 0) ? w : DefaultWidth), a, fn, vis), valIndex(v), currentValue(0.0), decimals(d), adjusting(AdjustMode::displaying), adjustable(adj)
+ : MenuItem(r, c, ((w != 0) ? w : DefaultWidth), a, fn, vis), valIndex(v), currentFormat(PrintFormat::undefined), decimals(d), adjusting(AdjustMode::displaying), adjustable(adj)
{
}
@@ -236,13 +236,54 @@ void ValueMenuItem::CorePrint(Lcd7920& lcd)
{
lcd.print("***");
}
- else if (textValue != nullptr)
- {
- lcd.print(textValue);
- }
else
{
- lcd.print(currentValue, decimals);
+ switch (currentFormat)
+ {
+ case PrintFormat::asFloat:
+ lcd.print(currentValue.f, decimals);
+ break;
+
+ case PrintFormat::asPercent:
+ lcd.print(currentValue.f, decimals);
+ lcd.print('%');
+ break;
+
+ case PrintFormat::asUnsigned:
+ lcd.print(currentValue.u);
+ break;
+
+ case PrintFormat::asSigned:
+ lcd.print(currentValue.i);
+ break;
+
+ case PrintFormat::asText:
+ lcd.print(textValue);
+ break;
+
+ case PrintFormat::asIpAddress:
+ lcd.print(currentValue.u & 0x000000FF);
+ lcd.print(':');
+ lcd.print((currentValue.u >> 8) & 0x0000000FF);
+ lcd.print(':');
+ lcd.print((currentValue.u >> 16) & 0x0000000FF);
+ lcd.print(':');
+ lcd.print((currentValue.u >> 24) & 0x0000000FF);
+ break;
+
+ case PrintFormat::asTime:
+ lcd.print(currentValue.u/3600);
+ lcd.print(':');
+ lcd.print((currentValue.u / 60) % 60);
+ lcd.print(':');
+ lcd.print(currentValue.u % 60);
+ break;
+
+ case PrintFormat::undefined:
+ default:
+ lcd.print("***");
+ break;
+ }
}
}
@@ -256,47 +297,52 @@ void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
// Item 501 is a special case because it is text, not a number. We store the current message sequence number in currentValue.
uint16_t newSeq;
textValue = reprap.GetLatestMessage(newSeq);
- if (newSeq != (unsigned int)currentValue)
+ if (newSeq != currentValue.u)
{
itemChanged = true;
- currentValue = (float)newSeq;
+ currentValue.u = newSeq;
+ currentFormat = PrintFormat::asText;
}
}
else if (adjusting != AdjustMode::adjusting)
{
const unsigned int itemNumber = valIndex % 100;
- const float oldValue = currentValue;
+ const Value oldValue = currentValue;
+ currentFormat = PrintFormat::asFloat;
switch (valIndex/100)
{
case 0: // heater current temperature
- currentValue = max<float>(reprap.GetGCodes().GetItemCurrentTemperature(itemNumber), 0.0f);
+ currentValue.f = max<float>(reprap.GetGCodes().GetItemCurrentTemperature(itemNumber), 0.0f);
break;
case 1: // heater active temperature
- currentValue = max<float>(reprap.GetGCodes().GetItemActiveTemperature(itemNumber), 0.0f);
+ currentValue.f = max<float>(reprap.GetGCodes().GetItemActiveTemperature(itemNumber), 0.0f);
break;
case 2: // heater standby temperature
- currentValue = max<float>(reprap.GetGCodes().GetItemStandbyTemperature(itemNumber), 0.0f);
+ currentValue.f = max<float>(reprap.GetGCodes().GetItemStandbyTemperature(itemNumber), 0.0f);
break;
case 3: // fan %
- currentValue = ((itemNumber == 99)
+ currentValue.f = ((itemNumber == 99)
? reprap.GetGCodes().GetMappedFanSpeed()
: reprap.GetPlatform().GetFanValue(itemNumber)
) * 100.0;
+ currentFormat = PrintFormat::asPercent;
break;
case 4: // extruder %
- currentValue = reprap.GetGCodes().GetExtrusionFactor(itemNumber);
+ currentValue.f = reprap.GetGCodes().GetExtrusionFactor(itemNumber);
+ currentFormat = PrintFormat::asPercent;
break;
case 5: // misc
switch (itemNumber)
{
case 0:
- currentValue = reprap.GetGCodes().GetSpeedFactor();
+ currentValue.f = reprap.GetGCodes().GetSpeedFactor();
+ currentFormat = PrintFormat::asPercent;
break;
// case 1 is the latest message sent by M117, but it handled at the start
@@ -307,15 +353,16 @@ void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
case 13: // U
case 14: // V
case 15: // W
- currentValue = reprap.GetGCodes().GetUserPosition()[itemNumber - 10];
+ currentValue.f = reprap.GetGCodes().GetUserPosition()[itemNumber - 10];
break;
case 20:
- currentValue = reprap.GetCurrentToolNumber();
+ currentValue.i = reprap.GetCurrentToolNumber();
+ currentFormat = PrintFormat::asSigned;
break;
- case 21: // Z baby-step
- currentValue = reprap.GetGCodes().GetTotalBabyStepOffset(Z_AXIS);
+ case 21: // Z baby-step
+ currentValue.f = reprap.GetGCodes().GetTotalBabyStepOffset(Z_AXIS);
break;
// Platform's IP address is the "planned", Network's IP address is the "actual"
@@ -323,7 +370,34 @@ void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
case 31:
case 32:
case 33:
- currentValue = reprap.GetNetwork().GetIPAddress(0).GetQuad(itemNumber - 30);
+ currentValue.u = reprap.GetNetwork().GetIPAddress(0).GetQuad(itemNumber - 30);
+ currentFormat = PrintFormat::asUnsigned;
+ break;
+
+ case 34: // IP address in one go
+ currentValue.u = reprap.GetNetwork().GetIPAddress(0).GetV4LittleEndian();
+ currentFormat = PrintFormat::asIpAddress;
+ break;
+
+ case 35: // Percentage of file that has been processed
+ currentValue.f = (reprap.GetPrintMonitor().IsPrinting())
+ ? reprap.GetGCodes().FractionOfFilePrinted() * 100.0
+ : 0;
+ currentFormat = PrintFormat::asPercent;
+ break;
+
+ case 36: // Print time remaining, file-based
+ currentValue.u = (reprap.GetPrintMonitor().IsPrinting())
+ ? static_cast<int>(reprap.GetPrintMonitor().EstimateTimeLeft(PrintEstimationMethod::fileBased))
+ : 0;
+ currentFormat = PrintFormat::asTime;
+ break;
+
+ case 37: // Print time remaining, filament-based
+ currentValue.u = (reprap.GetPrintMonitor().IsPrinting())
+ ? static_cast<int>(reprap.GetPrintMonitor().EstimateTimeLeft(PrintEstimationMethod::filamentBased))
+ : 0;
+ currentFormat = PrintFormat::asTime;
break;
default:
@@ -336,10 +410,44 @@ void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
break;
}
- if (error || currentValue != oldValue)
+ if (error)
{
itemChanged = true;
}
+ else
+ {
+ switch (currentFormat)
+ {
+ case PrintFormat::undefined:
+ itemChanged = true;
+ break;
+
+ case PrintFormat::asFloat:
+ if (currentValue.f != oldValue.f)
+ {
+ itemChanged = true;
+ }
+ break;
+
+ case PrintFormat::asSigned:
+ if (currentValue.i != oldValue.i)
+ {
+ itemChanged = true;
+ }
+ break;
+
+ case PrintFormat::asUnsigned:
+ case PrintFormat::asIpAddress:
+ case PrintFormat::asText:
+ case PrintFormat::asTime:
+ default:
+ if (currentValue.u != oldValue.u)
+ {
+ itemChanged = true;
+ }
+ break;
+ }
+ }
}
if (itemChanged || (highlight != highlighted))
@@ -383,9 +491,9 @@ bool ValueMenuItem::Adjust_SelectHelper()
switch (valIndex/100)
{
case 1: // heater active temperature
- if (1 > currentValue) // 0 is off
+ if (1.0 > currentValue.f) // 0 is off
{
- reprap.GetGCodes().SetItemActiveTemperature(itemNumber, -273.15f);
+ reprap.GetGCodes().SetItemActiveTemperature(itemNumber, -273.15);
}
else // otherwise ensure the tool is made active at the same time (really only matters for 79)
{
@@ -393,38 +501,38 @@ bool ValueMenuItem::Adjust_SelectHelper()
{
reprap.SelectTool(itemNumber, false);
}
- reprap.GetGCodes().SetItemActiveTemperature(itemNumber, currentValue);
+ reprap.GetGCodes().SetItemActiveTemperature(itemNumber, currentValue.f);
}
break;
case 2: // heater standby temperature
- reprap.GetGCodes().SetItemStandbyTemperature(itemNumber, (1 > currentValue) ? -273.15f : currentValue);
+ reprap.GetGCodes().SetItemStandbyTemperature(itemNumber, (1.0 > currentValue.f) ? -273.15 : currentValue.f);
break;
case 3: // fan %
if (itemNumber == 99)
{
- reprap.GetGCodes().SetMappedFanSpeed(currentValue * 0.01);
+ reprap.GetGCodes().SetMappedFanSpeed(currentValue.f * 0.01);
}
else
{
- reprap.GetPlatform().SetFanValue(itemNumber, currentValue * 0.01);
+ reprap.GetPlatform().SetFanValue(itemNumber, currentValue.f * 0.01);
}
break;
case 4: // extruder %
- reprap.GetGCodes().SetExtrusionFactor(itemNumber, currentValue);
+ reprap.GetGCodes().SetExtrusionFactor(itemNumber, currentValue.f);
break;
case 5: // misc.
switch (itemNumber)
{
case 0:
- reprap.GetGCodes().SetSpeedFactor(currentValue);
+ reprap.GetGCodes().SetSpeedFactor(currentValue.f);
break;
case 20:
- reprap.SelectTool(currentValue, false);
+ reprap.SelectTool(currentValue.i, false);
break;
default:
@@ -477,40 +585,40 @@ bool ValueMenuItem::Adjust_AlterHelper(int clicks)
// Also cap the maximum
if (0 > clicks) // decrementing
{
- currentValue += clicks;
- if (95.0 > currentValue)
+ currentValue.f += (float)clicks;
+ if (95.0 > currentValue.f)
{
- currentValue = 0;
+ currentValue.f = 0.0;
}
}
else // incrementing
{
- if (0.0 == currentValue)
+ if (0.0 == currentValue.f)
{
- currentValue = 95.0 - 1.0;
+ currentValue.f = 95.0 - 1.0;
}
- currentValue = min<int>(currentValue + clicks, reprap.GetHeat().GetHighestTemperatureLimit(reprap.GetTool(itemNumber)->Heater(0)));
+ currentValue.f = min<int>(currentValue.f + (float)clicks, reprap.GetHeat().GetHighestTemperatureLimit(reprap.GetTool(itemNumber)->Heater(0)));
}
}
else
{
- currentValue += (float)clicks;
+ currentValue.f += (float)clicks;
}
break;
case 3: // fan %
- currentValue = constrain<int>(currentValue + (float)clicks, 0, 100);
+ currentValue.f = constrain<float>(currentValue.f + (float)clicks, 0.0, 100.0);
break;
case 5: // misc.
switch (itemNumber)
{
case 0: // 500 Feed Rate
- currentValue = constrain<float>(currentValue + (float)clicks, 10, 500);
+ currentValue.f = constrain<float>(currentValue.f + (float)clicks, 10.0, 500.0);
break;
case 20: // 520 Tool Selection
- currentValue = (float)constrain<int>((int)currentValue + clicks, -1, 255);
+ currentValue.i = constrain<int>((int)currentValue.f + clicks, -1, 255);
break;
case 21: // 521 baby stepping
@@ -536,7 +644,7 @@ bool ValueMenuItem::Adjust_AlterHelper(int clicks)
break;
default:
- currentValue += (float)clicks;
+ currentValue.f += (float)clicks;
break;
}
diff --git a/src/Display/MenuItem.h b/src/Display/MenuItem.h
index 7bba6fac..4cab46ad 100644
--- a/src/Display/MenuItem.h
+++ b/src/Display/MenuItem.h
@@ -95,7 +95,7 @@ private:
MenuItem *next;
};
-class TextMenuItem : public MenuItem
+class TextMenuItem final : public MenuItem
{
public:
void* operator new(size_t sz) { return Allocate<TextMenuItem>(); }
@@ -112,7 +112,7 @@ private:
const char *text;
};
-class ButtonMenuItem : public MenuItem
+class ButtonMenuItem final : public MenuItem
{
public:
void* operator new(size_t sz) { return Allocate<ButtonMenuItem>(); }
@@ -134,7 +134,7 @@ private:
const char *m_acFile; // used when action ("command") is "menu"
};
-class ValueMenuItem : public MenuItem
+class ValueMenuItem final : public MenuItem
{
public:
void* operator new(size_t sz) { return Allocate<ValueMenuItem>(); }
@@ -156,6 +156,7 @@ protected:
private:
enum class AdjustMode : uint8_t { displaying, adjusting, liveAdjusting };
+ enum class PrintFormat : uint8_t { undefined, asFloat, asUnsigned, asSigned, asPercent, asText, asIpAddress, asTime };
bool Adjust_SelectHelper();
bool Adjust_AlterHelper(int clicks);
@@ -163,15 +164,24 @@ private:
static constexpr PixelNumber DefaultWidth = 25; // default numeric field width
const unsigned int valIndex;
- float currentValue;
const char *textValue; // for temporary use when printing
+
+ // Variables currentValue, currentFormat and decimals together define the display format of the item
+ union Value
+ { float f;
+ uint32_t u;
+ int32_t i;
+ };
+
+ Value currentValue;
+ PrintFormat currentFormat;
uint8_t decimals;
AdjustMode adjusting;
bool adjustable;
bool error; // for temporary use when printing
};
-class FilesMenuItem : public MenuItem
+class FilesMenuItem final : public MenuItem
{
public:
void* operator new(size_t sz) { return Allocate<FilesMenuItem>(); }
@@ -214,7 +224,7 @@ private:
MassStorage *const m_oMS;
};
-class ImageMenuItem : public MenuItem
+class ImageMenuItem final : public MenuItem
{
public:
void* operator new(size_t sz) { return Allocate<ImageMenuItem>(); }