Fixed nested file bug, other minor changes
Fixed a bug when one file was called from another M111 S2 command now displays time since last reset M106 'I' parameter now only inverts fan PWM when >0 Non-homing moves when bed probing are now done at max speed M999 reset command now delays 0.5 second to allow response to be sent back to browser, otherwise it may retry the reset
This commit is contained in:
parent
81b213752b
commit
406a0c074f
7 changed files with 75 additions and 43 deletions
|
@ -24,8 +24,8 @@ Licence: GPL
|
|||
#define CONFIGURATION_H
|
||||
|
||||
#define NAME "RepRapFirmware"
|
||||
#define VERSION "0.58c-dc42"
|
||||
#define DATE "2014-04-28"
|
||||
#define VERSION "0.58d-dc42"
|
||||
#define DATE "2014-04-29"
|
||||
#define LAST_AUTHOR "dc42"
|
||||
|
||||
// Other firmware that we might switch to be compatible with.
|
||||
|
|
43
GCodes.cpp
43
GCodes.cpp
|
@ -34,7 +34,6 @@ GCodes::GCodes(Platform* p, Webserver* w)
|
|||
fileGCode = new GCodeBuffer(platform, "file: ");
|
||||
serialGCode = new GCodeBuffer(platform, "serial: ");
|
||||
cannedCycleGCode = new GCodeBuffer(platform, "macro: ");
|
||||
coolingInverted = false;
|
||||
}
|
||||
|
||||
void GCodes::Exit()
|
||||
|
@ -69,6 +68,7 @@ void GCodes::Init()
|
|||
dwellTime = longWait;
|
||||
axisIsHomed[X_AXIS] = axisIsHomed[Y_AXIS] = axisIsHomed[Z_AXIS] = false;
|
||||
fanMaxPwm = 1.0;
|
||||
coolingInverted = false;
|
||||
}
|
||||
|
||||
// This is called from Init and when doing an emergency stop
|
||||
|
@ -106,12 +106,16 @@ void GCodes::doFilePrint(GCodeBuffer* gb)
|
|||
if (fileBeingPrinted.Read(b))
|
||||
{
|
||||
if (gb->Put(b))
|
||||
{
|
||||
gb->SetFinished(ActOnGcode(gb));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gb->Put('\n')) // In case there wasn't one ending the file
|
||||
{
|
||||
gb->SetFinished(ActOnGcode(gb));
|
||||
}
|
||||
fileBeingPrinted.Close();
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +280,7 @@ bool GCodes::Push()
|
|||
drivesRelativeStack[stackPointer] = drivesRelative;
|
||||
axesRelativeStack[stackPointer] = axesRelative;
|
||||
feedrateStack[stackPointer] = gFeedRate;
|
||||
fileStack[stackPointer].MoveFrom(fileBeingPrinted);
|
||||
fileStack[stackPointer].CopyFrom(fileBeingPrinted);
|
||||
stackPointer++;
|
||||
platform->PushMessageIndent();
|
||||
return true;
|
||||
|
@ -298,7 +302,7 @@ bool GCodes::Pop()
|
|||
stackPointer--;
|
||||
drivesRelative = drivesRelativeStack[stackPointer];
|
||||
axesRelative = axesRelativeStack[stackPointer];
|
||||
fileBeingPrinted.MoveFrom(fileStack[stackPointer]);
|
||||
fileBeingPrinted.CopyFrom(fileStack[stackPointer]);
|
||||
platform->PopMessageIndent();
|
||||
// Remember for next time if we have just been switched
|
||||
// to absolute drive moves
|
||||
|
@ -686,7 +690,7 @@ bool GCodes::DoSingleZProbeAtPoint()
|
|||
case 0: // Raise Z to 5mm. This only does anything on the first move; on all the others Z is already there
|
||||
moveToDo[Z_AXIS] = Z_DIVE;
|
||||
activeDrive[Z_AXIS] = true;
|
||||
moveToDo[DRIVES] = platform->HomeFeedRate(Z_AXIS);
|
||||
moveToDo[DRIVES] = platform->MaxFeedrate(Z_AXIS);
|
||||
activeDrive[DRIVES] = true;
|
||||
reprap.GetMove()->SetZProbing(false);
|
||||
if (DoCannedCycleMove(false))
|
||||
|
@ -700,7 +704,7 @@ bool GCodes::DoSingleZProbeAtPoint()
|
|||
activeDrive[X_AXIS] = true;
|
||||
activeDrive[Y_AXIS] = true;
|
||||
// NB - we don't use the Z value
|
||||
moveToDo[DRIVES] = platform->HomeFeedRate(X_AXIS);
|
||||
moveToDo[DRIVES] = platform->MaxFeedrate(X_AXIS);
|
||||
activeDrive[DRIVES] = true;
|
||||
reprap.GetMove()->SetZProbing(false);
|
||||
if (DoCannedCycleMove(false))
|
||||
|
@ -726,7 +730,7 @@ bool GCodes::DoSingleZProbeAtPoint()
|
|||
case 3: // Raise the head 5mm
|
||||
moveToDo[Z_AXIS] = Z_DIVE;
|
||||
activeDrive[Z_AXIS] = true;
|
||||
moveToDo[DRIVES] = platform->HomeFeedRate(Z_AXIS);
|
||||
moveToDo[DRIVES] = platform->MaxFeedrate(Z_AXIS);
|
||||
activeDrive[DRIVES] = true;
|
||||
reprap.GetMove()->SetZProbing(false);
|
||||
if (DoCannedCycleMove(false))
|
||||
|
@ -856,7 +860,9 @@ bool GCodes::DoMultipleZProbe()
|
|||
}
|
||||
|
||||
if (DoSingleZProbeAtPoint())
|
||||
{
|
||||
probeCount++;
|
||||
}
|
||||
if (probeCount >= reprap.GetMove()->NumberOfXYProbePoints())
|
||||
{
|
||||
probeCount = 0;
|
||||
|
@ -1110,11 +1116,16 @@ bool GCodes::DoDwell(GCodeBuffer *gb)
|
|||
|
||||
float dwell = 0.001 * (float) gb->GetLValue(); // P values are in milliseconds; we need seconds
|
||||
|
||||
// Wait for all the queued moves to stop
|
||||
// Wait for all the queued moves to stop
|
||||
|
||||
if (!reprap.GetMove()->AllMovesAreFinished())
|
||||
return false;
|
||||
|
||||
return DoDwellTime(dwell);
|
||||
}
|
||||
|
||||
bool GCodes::DoDwellTime(float dwell)
|
||||
{
|
||||
// Are we already in the dwell?
|
||||
|
||||
if (dwellWaiting)
|
||||
|
@ -1563,7 +1574,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
|||
case 1: // Sleep
|
||||
if (fileBeingPrinted.IsLive())
|
||||
{
|
||||
fileToPrint.MoveFrom(fileBeingPrinted);
|
||||
fileToPrint.CopyFrom(fileBeingPrinted);
|
||||
}
|
||||
if (!DisableDrives())
|
||||
return false;
|
||||
|
@ -1598,11 +1609,11 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
|||
case 24: // Print/resume-printing the selected file
|
||||
if (fileBeingPrinted.IsLive())
|
||||
break;
|
||||
fileBeingPrinted.MoveFrom(fileToPrint);
|
||||
fileBeingPrinted.CopyFrom(fileToPrint);
|
||||
break;
|
||||
|
||||
case 25: // Pause the print
|
||||
fileToPrint.MoveFrom(fileBeingPrinted);
|
||||
fileToPrint.CopyFrom(fileBeingPrinted);
|
||||
break;
|
||||
|
||||
case 27: // Report print status - Deprecated
|
||||
|
@ -1712,14 +1723,18 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
|||
}
|
||||
if (gb->Seen('I'))
|
||||
{
|
||||
coolingInverted = (gb->GetIValue() != 0);
|
||||
coolingInverted = (gb->GetIValue() > 0);
|
||||
}
|
||||
if (gb->Seen('S'))
|
||||
{
|
||||
if (coolingInverted)
|
||||
{
|
||||
platform->CoolingFan(1.0 - fmax(gb->GetFValue(), 0.0)/fanMaxPwm);
|
||||
}
|
||||
else
|
||||
{
|
||||
platform->CoolingFan(fmax(gb->GetFValue(), 0.0)/fanMaxPwm);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2027,7 +2042,11 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
|||
break;
|
||||
|
||||
case 999:
|
||||
platform->SoftwareReset(SoftwareResetReason::user); // doesn't return
|
||||
result = DoDwellTime(0.5); // wait half a second to allow the response to be sent back to the web server, otherwise it may retry
|
||||
if (result)
|
||||
{
|
||||
platform->SoftwareReset(SoftwareResetReason::user); // doesn't return
|
||||
}
|
||||
break;
|
||||
|
||||
case 117: // in Marlin mode this means display message on LCD. We don't have an LCD so just return OK.
|
||||
|
|
10
GCodes.h
10
GCodes.h
|
@ -90,12 +90,15 @@ public:
|
|||
return f->Read(b);
|
||||
}
|
||||
|
||||
// Assignment operator. This clears out the FileData object we are assigning from.
|
||||
void MoveFrom(FileData& other)
|
||||
// Assignment operator
|
||||
void CopyFrom(const FileData& other)
|
||||
{
|
||||
Close();
|
||||
f = other.f;
|
||||
other.Init();
|
||||
if (f != NULL)
|
||||
{
|
||||
f->Duplicate();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -149,6 +152,7 @@ class GCodes
|
|||
bool ActOnGcode(GCodeBuffer* gb);
|
||||
int SetUpMove(GCodeBuffer* gb);
|
||||
bool DoDwell(GCodeBuffer *gb);
|
||||
bool DoDwellTime(float dwell);
|
||||
bool DoHome(char *reply, bool& error);
|
||||
bool DoSingleZProbeAtPoint();
|
||||
bool DoSingleZProbe();
|
||||
|
|
56
Platform.cpp
56
Platform.cpp
|
@ -754,9 +754,12 @@ void Platform::PrintMemoryUsage()
|
|||
reprap.GetWebserver()->AppendReply(scratchString);
|
||||
Message(HOST_MESSAGE, scratchString);
|
||||
|
||||
// Show the reason for the last reset
|
||||
// Show the up time and reason for the last reset
|
||||
const uint32_t now = (uint32_t)Time(); // get up time in seconds
|
||||
const char* resetReasons[8] = { "power up", "backup", "watchdog", "software", "external", "?", "?", "?" };
|
||||
snprintf(scratchString, STRING_LENGTH, "Last reset reason: %s\n", resetReasons[(REG_RSTC_SR & RSTC_SR_RSTTYP_Msk) >> RSTC_SR_RSTTYP_Pos]);
|
||||
snprintf(scratchString, STRING_LENGTH, "Last reset %02d:%02d:%02d ago, cause: %s\n",
|
||||
(unsigned int)(now/3600), (unsigned int)((now % 3600)/60), (unsigned int)(now % 60),
|
||||
resetReasons[(REG_RSTC_SR & RSTC_SR_RSTTYP_Msk) >> RSTC_SR_RSTTYP_Pos]);
|
||||
reprap.GetWebserver()->AppendReply(scratchString);
|
||||
Message(HOST_MESSAGE, scratchString);
|
||||
|
||||
|
@ -1036,18 +1039,6 @@ MassStorage* Platform::GetMassStorage()
|
|||
return massStorage;
|
||||
}
|
||||
|
||||
void Platform::ReturnFileStore(FileStore* fs)
|
||||
{
|
||||
for (int i = 0; i < MAX_FILES; i++)
|
||||
{
|
||||
if (files[i] == fs)
|
||||
{
|
||||
files[i]->inUse = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Platform::Message(char type, const char* message)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -1297,9 +1288,8 @@ bool MassStorage::Delete(const char* directory, const char* fileName)
|
|||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
FileStore::FileStore(Platform* p)
|
||||
FileStore::FileStore(Platform* p) : platform(p)
|
||||
{
|
||||
platform = p;
|
||||
}
|
||||
|
||||
void FileStore::Init()
|
||||
|
@ -1308,6 +1298,7 @@ void FileStore::Init()
|
|||
inUse = false;
|
||||
writing = false;
|
||||
lastBufferEntry = 0;
|
||||
openCount = 0;
|
||||
}
|
||||
|
||||
// Open a local file (for example on an SD card).
|
||||
|
@ -1353,20 +1344,39 @@ bool FileStore::Open(const char* directory, const char* fileName, bool write)
|
|||
}
|
||||
|
||||
inUse = true;
|
||||
openCount = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileStore::Duplicate()
|
||||
{
|
||||
if (!inUse)
|
||||
{
|
||||
platform->Message(HOST_MESSAGE, "Attempt to dup a non-open file.\n");
|
||||
return;
|
||||
}
|
||||
++openCount;
|
||||
}
|
||||
|
||||
void FileStore::Close()
|
||||
{
|
||||
if (writing)
|
||||
if (!inUse)
|
||||
{
|
||||
WriteBuffer();
|
||||
platform->Message(HOST_MESSAGE, "Attempt to close a non-open file.\n");
|
||||
return;
|
||||
}
|
||||
--openCount;
|
||||
if (openCount == 0)
|
||||
{
|
||||
if (writing)
|
||||
{
|
||||
WriteBuffer();
|
||||
}
|
||||
f_close(&file);
|
||||
inUse = false;
|
||||
writing = false;
|
||||
lastBufferEntry = 0;
|
||||
}
|
||||
f_close(&file);
|
||||
platform->ReturnFileStore(this);
|
||||
inUse = false;
|
||||
writing = false;
|
||||
lastBufferEntry = 0;
|
||||
}
|
||||
|
||||
void FileStore::Seek(unsigned long pos)
|
||||
|
|
|
@ -334,6 +334,7 @@ public:
|
|||
void Seek(unsigned long pos);
|
||||
void GoToEnd(); // Position the file at the end (so you can write on the end).
|
||||
unsigned long Length(); // File size in bytes
|
||||
void Duplicate();
|
||||
|
||||
friend class Platform;
|
||||
|
||||
|
@ -356,6 +357,7 @@ private:
|
|||
Platform* platform;
|
||||
bool writing;
|
||||
unsigned int lastBufferEntry;
|
||||
unsigned int openCount;
|
||||
};
|
||||
|
||||
|
||||
|
@ -593,9 +595,6 @@ public:
|
|||
const PidParameters& GetPidParameters(size_t heater);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
protected:
|
||||
|
||||
void ReturnFileStore(FileStore* f);
|
||||
|
||||
private:
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Reference in a new issue