diff --git a/Configuration.h b/Configuration.h index 4e175a3..d92dc2b 100644 --- a/Configuration.h +++ b/Configuration.h @@ -24,8 +24,8 @@ Licence: GPL #define CONFIGURATION_H #define NAME "RepRapFirmware" -#define VERSION "0.78r-alpha-dc42" -#define DATE "2014-08-31" +#define VERSION "0.78r-dc42" +#define DATE "2014-09-06" #define AUTHORS "reprappro, dc42, zpl" // Other firmware that we might switch to be compatible with. diff --git a/GCodes.cpp b/GCodes.cpp index c89ba36..887a506 100644 --- a/GCodes.cpp +++ b/GCodes.cpp @@ -1923,8 +1923,13 @@ bool GCodes::HandleMcode(GCodeBuffer* gb) break; case 80: // ATX power on + platform->SetAtxPower(true); + break; + case 81: // ATX power off - platform->SetAtxPower(code == 80); + if (!AllMovesAreFinishedAndMoveBufferIsLoaded()) + return false; + platform->SetAtxPower(false); break; case 82: // Use absolute extruder positioning @@ -2856,6 +2861,17 @@ bool GCodes::HandleMcode(GCodeBuffer* gb) } break; + case 570: // Set/report heater timeout + if(gb->Seen('S')) + { + platform->SetTimeToHot(gb->GetFValue()); + } + else + { + reply.printf("Time allowed to get to temperature: %.1f seconds.", platform->TimeToHot()); + } + break; + case 906: // Set/report Motor currents { bool seen = false; diff --git a/Heat.cpp b/Heat.cpp index 45c2ef8..ed0d1ee 100644 --- a/Heat.cpp +++ b/Heat.cpp @@ -184,7 +184,7 @@ void PID::Spin() if(temperature < tmp) { float tim = platform->Time() - timeSetHeating; - if(tim > TIME_TO_HOT) + if(tim > platform->TimeToHot()) { platform->SetHeater(heater, 0.0); temperatureFault = true; diff --git a/Move.cpp b/Move.cpp index 3727416..6b9fdd2 100644 --- a/Move.cpp +++ b/Move.cpp @@ -460,10 +460,6 @@ void Move::DoLookAhead() if(LookAheadRingEmpty()) return; - LookAhead* n0; - LookAhead* n1; - LookAhead* n2; - // If there are a reasonable number of moves in there (LOOK_AHEAD), or if we are // doing single moves with no other move immediately following on, run up and down // the moves using the DDA Init() function to reduce the start or the end speed @@ -475,10 +471,9 @@ void Move::DoLookAhead() // Run up the moves - n1 = lookAheadRingGetPointer; - n0 = n1->Previous(); - n2 = n1->Next(); - while(n2 != lookAheadRingAddPointer) + LookAhead* n1 = lookAheadRingGetPointer; + LookAhead* n0 = n1->Previous(); + while(n1 != lookAheadRingAddPointer) { if(!(n1->Processed() & complete)) { @@ -494,8 +489,7 @@ void Move::DoLookAhead() } } n0 = n1; - n1 = n2; - n2 = n2->Next(); + n1 = n1->Next(); } // Now run down @@ -516,7 +510,6 @@ void Move::DoLookAhead() n1->SetProcessed(complete); } } - n2 = n1; n1 = n0; n0 = n0->Previous(); } while(n0 != lookAheadRingGetPointer); @@ -528,9 +521,9 @@ void Move::DoLookAhead() if(addNoMoreMoves || !gCodes->HaveIncomingData() || lookAheadRingCount > 1) { - n1 = lookAheadRingGetPointer; - n0 = n1->Previous(); - n2 = n1->Next(); + LookAhead* n1 = lookAheadRingGetPointer; + LookAhead* n0 = n1->Previous(); + LookAhead* n2 = n1->Next(); while(n2 != lookAheadRingAddPointer) { if(n1->Processed() == unprocessed) diff --git a/Platform.cpp b/Platform.cpp index 6bf0236..3b6e6f6 100644 --- a/Platform.cpp +++ b/Platform.cpp @@ -227,6 +227,7 @@ void Platform::Init() activeTemperatures = ACTIVE_TEMPERATURES; coolingFanPin = COOLING_FAN_PIN; coolingFanRpmPin = COOLING_FAN_RPM_PIN; + timeToHot = TIME_TO_HOT; lastRpmResetTime = 0.0; webDir = WEB_DIR; @@ -807,13 +808,12 @@ void Platform::Diagnostics() AppendMessage(BOTH_MESSAGE, "Error status: %u\n", errorCodeBits); // Show the current probe position heights - scratchString.copy("Bed probe heights:"); + AppendMessage(BOTH_MESSAGE, "Bed probe heights:"); for (size_t i = 0; i < NUMBER_OF_PROBE_POINTS; ++i) { - scratchString.catf(" %.3f", reprap.GetMove()->ZBedProbePoint(i)); + AppendMessage(BOTH_MESSAGE, " %.3f", reprap.GetMove()->ZBedProbePoint(i)); } - scratchString.cat("\n"); - AppendMessage(BOTH_MESSAGE, scratchString); + AppendMessage(BOTH_MESSAGE, "\n"); // Show the number of free entries in the file table unsigned int numFreeFiles = 0; @@ -1351,10 +1351,7 @@ void MassStorage::Init() int mounted = f_mount(0, &fileSystem); if (mounted != FR_OK) { - platform->Message(HOST_MESSAGE, "Can't mount filesystem 0: code "); - snprintf(scratchString, STRING_LENGTH, "%d", mounted); - platform->Message(HOST_MESSAGE, scratchString); - platform->Message(HOST_MESSAGE, "\n"); + platform->Message(HOST_MESSAGE, "Can't mount filesystem 0: code %d\n", mounted); } } @@ -1508,7 +1505,7 @@ bool MassStorage::Delete(const char* directory, const char* fileName) : fileName; if (f_unlink(location) != FR_OK) { - platform->Message(BOTH_MESSAGE, "Can't delete file %s\n, location"); + platform->Message(BOTH_MESSAGE, "Can't delete file %s\n", location); return false; } return true; diff --git a/Platform.h b/Platform.h index 047a9c4..e742d6f 100644 --- a/Platform.h +++ b/Platform.h @@ -164,7 +164,7 @@ const float defaultPidKis[HEATERS] = {5.0, 0.1, 0.1, 0.1, 0.1, 0.1}; // Integ const float defaultPidKds[HEATERS] = {500.0, 100.0, 100.0, 100.0, 100.0, 100.0}; // Derivative PID constants const float defaultPidKps[HEATERS] = {-1.0, 10.0, 10.0, 10.0, 10.0, 10.0}; // Proportional PID constants, negative values indicate use bang-bang instead of PID const float defaultPidKts[HEATERS] = {2.7, 0.25, 0.25, 0.25, 0.25, 0.25}; // approximate PWM value needed to maintain temperature, per degC above room temperature -const float defaultPidKss[HEATERS] = {1.0, 0.9, 0.9, 0.9, 0.9, 0.9}; // PWM scaling factor, to allow for variation in heater power and supply voltage +const float defaultPidKss[HEATERS] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; // PWM scaling factor, to allow for variation in heater power and supply voltage const float defaultFullBand[HEATERS] = {5.0, 30.0, 30.0, 30.0, 30.0, 30.0}; // errors larger than this cause heater to be on or off const float defaultPidMin[HEATERS] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // minimum value of I-term const float defaultPidMax[HEATERS] = {255, 180, 180, 180, 180, 180}; // maximum value of I-term, must be high enough to reach 245C for ABS printing @@ -654,6 +654,8 @@ public: float GetFanRPM(); void SetPidParameters(size_t heater, const PidParameters& params); const PidParameters& GetPidParameters(size_t heater); + float TimeToHot() const; + void SetTimeToHot(float t); //------------------------------------------------------------------------------------------------------- @@ -756,6 +758,7 @@ private: float activeTemperatures[HEATERS]; int8_t coolingFanPin; int8_t coolingFanRpmPin; + float timeToHot; float lastRpmResetTime; // Serial/USB @@ -1051,6 +1054,16 @@ inline void Platform::SetHeatSampleTime(float st) heatSampleTime = st; } +inline float Platform::TimeToHot() const +{ + return timeToHot; +} + +inline void Platform::SetTimeToHot(float t) +{ + timeToHot = t; +} + inline const byte* Platform::IPAddress() const { return nvData.ipAddress; diff --git a/Release/RepRapFirmware-065j-dc42.bin b/Release/RepRapFirmware-065j-dc42.bin deleted file mode 100644 index 4c4b641..0000000 Binary files a/Release/RepRapFirmware-065j-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078f-dc42.bin b/Release/RepRapFirmware-078f-dc42.bin deleted file mode 100644 index 7ec0f62..0000000 Binary files a/Release/RepRapFirmware-078f-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078h-dc42.bin b/Release/RepRapFirmware-078h-dc42.bin deleted file mode 100644 index 134ee77..0000000 Binary files a/Release/RepRapFirmware-078h-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078j-dc42.bin b/Release/RepRapFirmware-078j-dc42.bin deleted file mode 100644 index 6c37967..0000000 Binary files a/Release/RepRapFirmware-078j-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078k-dc42.bin b/Release/RepRapFirmware-078k-dc42.bin deleted file mode 100644 index 5cad559..0000000 Binary files a/Release/RepRapFirmware-078k-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078m-dc42.bin b/Release/RepRapFirmware-078m-dc42.bin deleted file mode 100644 index f328503..0000000 Binary files a/Release/RepRapFirmware-078m-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078n-dc42.bin b/Release/RepRapFirmware-078n-dc42.bin deleted file mode 100644 index 52f9a7b..0000000 Binary files a/Release/RepRapFirmware-078n-dc42.bin and /dev/null differ diff --git a/Release/RepRapFirmware-078r-alpha-dc42.bin b/Release/RepRapFirmware-078r-dc42.bin similarity index 59% rename from Release/RepRapFirmware-078r-alpha-dc42.bin rename to Release/RepRapFirmware-078r-dc42.bin index 4796bc7..9fadfad 100644 Binary files a/Release/RepRapFirmware-078r-alpha-dc42.bin and b/Release/RepRapFirmware-078r-dc42.bin differ diff --git a/Webserver.cpp b/Webserver.cpp index ffd7f7f..d35a6d2 100644 --- a/Webserver.cpp +++ b/Webserver.cpp @@ -1557,10 +1557,9 @@ bool Webserver::HttpInterpreter::ProcessMessage() platform->Message(HOST_MESSAGE, "HTTP request:"); for (unsigned int i = 0; i < numCommandWords; ++i) { - platform->Message(HOST_MESSAGE, " "); - platform->Message(HOST_MESSAGE, commandWords[i]); + platform->AppendMessage(HOST_MESSAGE, " %s", commandWords[i]); } - platform->Message(HOST_MESSAGE, "\n"); + platform->AppendMessage(HOST_MESSAGE, "\n"); } if (numCommandWords < 2) @@ -1598,9 +1597,7 @@ bool Webserver::HttpInterpreter::ProcessMessage() // Reject the current message. Always returns true to indicate that we should stop reading the message. bool Webserver::HttpInterpreter::RejectMessage(const char* response, unsigned int code) { - platform->Message(HOST_MESSAGE, "Webserver: rejecting message with: "); - platform->Message(HOST_MESSAGE, response); - platform->Message(HOST_MESSAGE, "\n"); + platform->Message(HOST_MESSAGE, "Webserver: rejecting message with: %s\n", response); Network *net = reprap.GetNetwork(); RequestState *req = net->GetRequest(); @@ -1734,7 +1731,7 @@ bool Webserver::FtpInterpreter::CharFromClient(char c) if (DebugEnabled()) { - platform->Message(DEBUG_MESSAGE, "FtpInterpreter::ProcessLine call finished."); + platform->Message(DEBUG_MESSAGE, "FtpInterpreter::ProcessLine call finished.\n"); } clientPointer = 0; @@ -2505,6 +2502,7 @@ bool Webserver::GetFileInfo(const char *directory, const char *fileName, GcodeFi // Look for layer height foundLayerHeight = FindLayerHeight(buf, sizeToRead, info.layerHeight); + // Look for slicer generated-by comment program const char* generatedByString = "; generated by "; const char* pos = strstr(buf, generatedByString); size_t generatedByLength = ARRAY_SIZE(info.generatedBy); @@ -2529,6 +2527,31 @@ bool Webserver::GetFileInfo(const char *directory, const char *fileName, GcodeFi info.generatedBy[i] = 0; } + // Look for Cura comment + const char* slicedAtString = ";Sliced at: "; + pos = strstr(buf, slicedAtString); + if (pos != NULL) + { + pos += strlen(slicedAtString); + strcpy(info.generatedBy, "Cura at "); + size_t i = 8; + while (i < ARRAY_SIZE(info.generatedBy) - 1 && *pos >= ' ') + { + char c = *pos++; + if (c == '"' || c == '\\') + { + // Need to escape the quote-mark for JSON + if (i > ARRAY_SIZE(info.generatedBy) - 3) + { + break; + } + info.generatedBy[i++] = '\\'; + } + info.generatedBy[i++] = c; + } + info.generatedBy[i] = 0; + } + // Add code to look for other values here... } } @@ -2612,7 +2635,7 @@ bool Webserver::GetFileInfo(const char *directory, const char *fileName, GcodeFi bool Webserver::FindHeight(const char* buf, size_t len, float& height) { //debugPrintf("Scanning %u bytes starting %.100s\n", len, buf); - if (len >= 5) + if (len >= 5) // need to check this here to prevent arithmetic underflow later on { size_t i = len - 5; for(;;) @@ -2652,18 +2675,34 @@ bool Webserver::FindHeight(const char* buf, size_t len, float& height) // Scan the buffer for the layer height. The buffer is null-terminated. bool Webserver::FindLayerHeight(const char *buf, size_t len, float& layerHeight) { - const char* layerHeightString = "; layer_height "; - const char *pos = strstr(buf, layerHeightString); + // Look for layer_height as generated by Slic3r + const char* layerHeightStringSlic3r = "; layer_height "; + const char *pos = strstr(buf, layerHeightStringSlic3r); if (pos != NULL) { - pos += strlen(layerHeightString); - while (strchr(" \t=", *pos)) + pos += strlen(layerHeightStringSlic3r); + while (strchr(" \t=:", *pos)) { ++pos; } layerHeight = strtod(pos, NULL); return true; } + + // Look for layer height as generated by Cura + const char* layerHeightStringCura = "Layer height: "; + pos = strstr(buf, layerHeightStringCura); + if (pos != NULL) + { + pos += strlen(layerHeightStringCura); + while (strchr(" \t=:", *pos)) + { + ++pos; + } + layerHeight = strtod(pos, NULL); + return true; + } + return false; }