diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index 5722725..a4b3e22 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -349,10 +349,19 @@ void GCodes::Spin() case GCodeState::m109ToolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools) and run tpost reprap.SelectTool(newToolNumber); gb.AdvanceState(); - if (reprap.GetTool(newToolNumber) != nullptr && AllAxesAreHomed() && (toolChangeParam & TPostBit) != 0) + if (AllAxesAreHomed()) { - scratchString.printf("tpost%d.g", newToolNumber); - DoFileMacro(gb, scratchString.Pointer(), false); + if (reprap.GetTool(newToolNumber) != nullptr && (toolChangeParam & TPostBit) != 0) + { + scratchString.printf("tpost%d.g", newToolNumber); + DoFileMacro(gb, scratchString.Pointer(), false); + } + } + else + { + // Tool offsets may have changed, but as some axes have not been homed we should avoid moving those axes when the next movement command is given. + // So adjust the current user position to reflect the actual position of the tool. + ToolOffsetInverseTransform(moveBuffer.coords, currentUserPosition); } break; @@ -1490,10 +1499,12 @@ bool GCodes::DoStraightMove(GCodeBuffer& gb, StringRef& reply) // Deal with XYZ movement const float initialX = currentUserPosition[X_AXIS]; const float initialY = currentUserPosition[Y_AXIS]; + bool includesAxisMovement = (rp != nullptr); for (size_t axis = 0; axis < numVisibleAxes; axis++) { if (gb.Seen(axisLetters[axis])) { + includesAxisMovement = true; const float moveArg = gb.GetFValue() * distanceScale; if (moveBuffer.moveType != 0) { @@ -1528,20 +1539,25 @@ bool GCodes::DoStraightMove(GCodeBuffer& gb, StringRef& reply) // Deal with extrusion and feed rate LoadExtrusionAndFeedrateFromGCode(gb, moveBuffer.moveType); + // Set up the move. We must assign segmentsLeft last, so that when we move to RTOS, the move won't be picked up by the Move process before it is complete. + // Note that if this is an extruder-only move, we don't do axis movements to allow for tool offset changes, we defer those until an axis moves. if (moveBuffer.moveType != 0) { // It's a raw motor move, so do it in a single segment and wait for it to complete segmentsLeft = 1; gb.SetState(GCodeState::waitingForMoveToComplete); } + else if (!includesAxisMovement) + { + segmentsLeft = 1; // extruder-only movement + } else { - // Apply tool offset, baby stepping, Z hop and axis scaling - ToolOffsetTransform(currentUserPosition, moveBuffer.coords, true); + ToolOffsetTransform(currentUserPosition, moveBuffer.coords, true); // apply tool offset, baby stepping, Z hop and axis scaling uint32_t effectiveAxesHomed = axesHomed; if (doingManualBedProbe) { - effectiveAxesHomed &= ~(1 << Z_AXIS); // if doing a manual Z probe, son't limit the Z movement + effectiveAxesHomed &= ~(1 << Z_AXIS); // if doing a manual Z probe, don't limit the Z movement } if (limitAxes && reprap.GetMove().GetKinematics().LimitPosition(moveBuffer.coords, numVisibleAxes, effectiveAxesHomed)) { @@ -3568,7 +3584,7 @@ bool GCodes::AdvanceHash(StringRef &reply) bool GCodes::AllAxesAreHomed() const { - const uint32_t allAxes = (1u << numTotalAxes) - 1; + const uint32_t allAxes = (1u << numVisibleAxes) - 1; return (axesHomed & allAxes) == allAxes; } @@ -3616,32 +3632,32 @@ bool GCodes::WriteConfigOverrideFile(StringRef& reply, const char *fileName) con void GCodes::GenerateTemperatureReport(StringRef& reply) const { Heat& heat = reprap.GetHeat(); - const int8_t bedHeater = heat.GetBedHeater(); - const int8_t chamberHeater = heat.GetChamberHeater(); - reply.copy("T:"); - for (int heater = 0; heater < (int)Heaters; heater++) + + // Pronterface, Repetier etc. expect the temperatures to be reported for T0, T1 etc. + // So scan the tool list and report the temperature of the heaters associated with each tool. + // If the user configures tools T0, T1 etc. with 1 heater each, that will return what these programs expect. + reply.copy("T"); + char sep = ':'; + for (const Tool *tool = reprap.GetFirstTool(); tool != nullptr; tool = tool->Next()) { - if (heater != bedHeater && heater != chamberHeater) + for (size_t i = 0; i < tool->HeaterCount(); ++i) { - Heat::HeaterStatus hs = heat.GetStatus(heater); - if (hs != Heat::HS_off && hs != Heat::HS_fault) - { - reply.catf("%.1f ", heat.GetTemperature(heater)); - } + const int heater = tool->Heater(i); + reply.catf("%c%.1f /%.1f", sep, heat.GetTemperature(heater), heat.GetTargetTemperature(heater)); + sep = ' '; } } + + const int bedHeater = heat.GetBedHeater(); if (bedHeater >= 0) { - reply.catf("B:%.1f", heat.GetTemperature(bedHeater)); + reply.catf(" B:%.1f /%.1f", heat.GetTemperature(bedHeater), heat.GetTargetTemperature(bedHeater)); } - else + + const int chamberHeater = heat.GetChamberHeater(); + if (chamberHeater >= 0) { - // I'm not sure whether Pronterface etc. can handle a missing bed temperature, so return zero - reply.cat("B:0.0"); - } - if (chamberHeater >= 0.0) - { - reply.catf(" C:%.1f", heat.GetTemperature(chamberHeater)); + reply.catf(" C:%.1f /%.1f", heat.GetTemperature(chamberHeater), heat.GetTargetTemperature(chamberHeater)); } } diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp index eb5b5ff..4b4224f 100644 --- a/src/Heating/Heat.cpp +++ b/src/Heating/Heat.cpp @@ -225,11 +225,21 @@ float Heat::GetTemperatureLimit(int8_t heater) const return (heater >= 0 && heater < (int)Heaters) ? pids[heater]->GetTemperatureLimit() : ABS_ZERO; } +// Get the current temperature of a heater float Heat::GetTemperature(int8_t heater) const { return (heater >= 0 && heater < (int)Heaters) ? pids[heater]->GetTemperature() : ABS_ZERO; } +// Get the target temperature of a heater +float Heat::GetTargetTemperature(int8_t heater) const +{ + const Heat::HeaterStatus hs = GetStatus(heater); + return (hs == HS_active) ? GetActiveTemperature(heater) + : (hs == HS_standby) ? GetStandbyTemperature(heater) + : 0.0; +} + void Heat::Activate(int8_t heater) { if (heater >= 0 && heater < (int)Heaters) diff --git a/src/Heating/Heat.h b/src/Heating/Heat.h index 3ebb5c6..ef3998a 100644 --- a/src/Heating/Heat.h +++ b/src/Heating/Heat.h @@ -68,6 +68,7 @@ public: void Activate(int8_t heater); // Turn on a heater void Standby(int8_t heater); // Set a heater idle float GetTemperature(int8_t heater) const; // Get the temperature of a heater + float GetTargetTemperature(int8_t heater) const; // Get the target temperature HeaterStatus GetStatus(int8_t heater) const; // Get the off/standby/active status void SwitchOff(int8_t heater); // Turn off a specific heater void SwitchOffAll(); // Turn all heaters off diff --git a/src/Platform.cpp b/src/Platform.cpp index d82d707..62dd6db 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -2857,15 +2857,11 @@ void Platform::SendAlert(MessageType mt, const char *message, const char *title, switch (mt) { case HTTP_MESSAGE: - // Make the RepRap class cache this message until it's picked up by the HTTP clients + case AUX_MESSAGE: + // Make the RepRap class cache this message until it's picked up by the HTTP clients and/or PanelDue reprap.SetAlert(message, title, sParam, tParam, zParam); break; - case AUX_MESSAGE: -// Until the PanelDue firmware changes are implemented, use the default code -// qq; -// break; - default: if (strlen(title) > 0) { @@ -2878,7 +2874,7 @@ void Platform::SendAlert(MessageType mt, const char *message, const char *title, } else if (sParam == 3) { - Message(mt, "Send M292 to continue or M292 S1 to cancel\n"); + Message(mt, "Send M292 to continue or M292 P1 to cancel\n"); } break; } diff --git a/src/RepRap.cpp b/src/RepRap.cpp index 2307fdd..146cab9 100644 --- a/src/RepRap.cpp +++ b/src/RepRap.cpp @@ -1336,7 +1336,29 @@ OutputBuffer *RepRap::GetLegacyStatusResponse(uint8_t type, int seq) } // Short messages are now pushed directly to PanelDue, so don't include them here as well - // We no longer send the amount of http buffer space here because the web interface doesn't use these formns of status response + // We no longer send the amount of http buffer space here because the web interface doesn't use these forms of status response + + // Deal with the message box, if there is one + float timeLeft = 0.0; + if (displayMessageBox && boxTimer != 0) + { + timeLeft = (float)(boxTimeout) / 1000.0 - (float)(millis() - boxTimer) / 1000.0; + displayMessageBox = (timeLeft > 0.0); + } + + if (displayMessageBox) + { + response->catf(",\"msgBox.mode\":%d,\"msgBox.timeout\":%.1f,\"msgBox.showZ\":%d", + boxMode, timeLeft, boxZControls ? 1 : 0); + response->cat(",\"msgBox.msg\":"); + response->EncodeString(boxMessage, ARRAY_SIZE(boxMessage), false); + response->cat(",\"msgBox.title\":"); + response->EncodeString(boxTitle, ARRAY_SIZE(boxTitle), false); + } + else + { + response->cat(",\"msgBox.mode\":-1"); // tell PanelDue that there is no active message box + } if (type == 2) { diff --git a/src/RepRap.h b/src/RepRap.h index dad7299..6437610 100644 --- a/src/RepRap.h +++ b/src/RepRap.h @@ -61,6 +61,7 @@ public: Tool* GetCurrentTool() const; Tool* GetTool(int toolNumber) const; Tool* GetCurrentOrDefaultTool() const; + const Tool* GetFirstTool() const { return toolList; } // Return the lowest-numbered tool uint32_t GetCurrentXAxes() const; // Get the current axes used as X axes void SetToolVariables(int toolNumber, const float* standbyTemperatures, const float* activeTemperatures); bool IsHeaterAssignedToTool(int8_t heater) const; @@ -124,7 +125,7 @@ private: PortControl *portControl; #endif - Tool* toolList; + Tool* toolList; // the tool list is sorted in order of increasing tool number Tool* currentTool; uint32_t lastWarningMillis; // When we last sent a warning message for things that can happen very often diff --git a/src/Tools/Tool.cpp b/src/Tools/Tool.cpp index c4eb5cd..d65bd89 100644 --- a/src/Tools/Tool.cpp +++ b/src/Tools/Tool.cpp @@ -125,7 +125,11 @@ Tool * Tool::freelist = nullptr; t->standbyTemperatures[heater] = ABS_ZERO; } - t->GetFilament()->LoadAssignment(); + if (t->filament != nullptr) + { + t->filament->LoadAssignment(); + } + return t; } diff --git a/src/Tools/Tool.h b/src/Tools/Tool.h index fb86614..7aa36b6 100644 --- a/src/Tools/Tool.h +++ b/src/Tools/Tool.h @@ -42,10 +42,10 @@ public: const float *GetOffset() const; void SetOffset(const float offs[MaxAxes]); size_t DriveCount() const; - int Drive(int driveNumber) const; + int Drive(size_t driveNumber) const; bool ToolCanDrive(bool extrude); size_t HeaterCount() const; - int Heater(int heaterNumber) const; + int Heater(size_t heaterNumber) const; const char *GetName() const; int Number() const; void SetVariables(const float* standby, const float* active); @@ -60,14 +60,13 @@ public: uint32_t GetXAxisMap() const { return xMapping; } uint32_t GetFanMapping() const { return fanMapping; } Filament *GetFilament() const { return filament; } + Tool *Next() const { return next; } float virtualExtruderPosition; friend class RepRap; protected: - - Tool* Next() const; void Activate(Tool* currentlyActive); void Standby(); void FlagTemperatureFault(int8_t dudHeater); @@ -103,7 +102,7 @@ private: volatile bool displayColdExtrudeWarning; }; -inline int Tool::Drive(int driveNumber) const +inline int Tool::Drive(size_t driveNumber) const { return drives[driveNumber]; } @@ -113,16 +112,11 @@ inline size_t Tool::HeaterCount() const return heaterCount; } -inline int Tool::Heater(int heaterNumber) const +inline int Tool::Heater(size_t heaterNumber) const { return heaters[heaterNumber]; } -inline Tool* Tool::Next() const -{ - return next; -} - inline const char *Tool::GetName() const { return name; diff --git a/src/Version.h b/src/Version.h index 6979008..32f7004 100644 --- a/src/Version.h +++ b/src/Version.h @@ -9,11 +9,11 @@ #define SRC_VERSION_H_ #ifndef VERSION -# define VERSION "1.19beta7+1" +# define VERSION "1.19beta7+2" #endif #ifndef DATE -# define DATE "2017-06-25" +# define DATE "2017-06-26" #endif #define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman"