Experimental macro/canned-cycle on the SD implemented.

This commit is contained in:
Adrian Bowyer 2013-12-19 23:30:23 +00:00
parent 4feab9afce
commit 4ed66b8b01
6 changed files with 138 additions and 18 deletions

View file

@ -24,7 +24,7 @@ Licence: GPL
#define CONFIGURATION_H
#define NAME "RepRapFirmware"
#define VERSION "0.42"
#define VERSION "0.43"
#define DATE "2013-12-19"
#define LAST_AUTHOR "reprappro.com"

View file

@ -33,6 +33,7 @@ GCodes::GCodes(Platform* p, Webserver* w)
webGCode = new GCodeBuffer(platform, "web: ");
fileGCode = new GCodeBuffer(platform, "file: ");
serialGCode = new GCodeBuffer(platform, "serial: ");
cannedCycleGCode = new GCodeBuffer(platform, "canned: ");
}
void GCodes::Exit()
@ -46,9 +47,11 @@ void GCodes::Init()
webGCode->Init();
fileGCode->Init();
serialGCode->Init();
cannedCycleGCode->Init();
webGCode->SetFinished(true);
fileGCode->SetFinished(true);
serialGCode->SetFinished(true);
cannedCycleGCode->SetFinished(true);
moveAvailable = false;
drivesRelative = true;
axesRelative = false;
@ -58,9 +61,11 @@ void GCodes::Init()
for(int8_t i = 0; i < DRIVES - AXES; i++)
lastPos[i] = 0.0;
fileBeingPrinted = NULL;
saveFileBeingPrinted = NULL;
fileToPrint = NULL;
fileBeingWritten = NULL;
configFile = NULL;
doingCannedCycleFile = false;
eofString = EOF_STRING;
eofStringCounter = 0;
eofStringLength = strlen(eofString);
@ -82,6 +87,26 @@ void GCodes::Init()
dwellTime = longWait;
}
void GCodes::doFilePrint(GCodeBuffer* gb)
{
char b;
if(fileBeingPrinted != NULL)
{
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();
fileBeingPrinted = NULL;
}
}
}
void GCodes::Spin()
{
if(!active)
@ -164,22 +189,8 @@ void GCodes::Spin()
}
}
doFilePrint(fileGCode);
if(fileBeingPrinted != NULL)
{
if(fileBeingPrinted->Read(b))
{
if(fileGCode->Put(b))
fileGCode->SetFinished(ActOnGcode(fileGCode));
} else
{
if(fileGCode->Put('\n')) // In case there wasn't one ending the file
fileGCode->SetFinished(ActOnGcode(fileGCode));
fileBeingPrinted->Close();
fileBeingPrinted = NULL;
}
}
platform->ClassReport("GCodes", longWait);
}
@ -331,6 +342,12 @@ bool GCodes::SetUpMove(GCodeBuffer *gb)
LoadMoveBufferFromGCode(gb, false);
checkEndStops = false;
if(gb->Seen('S'))
{
if(gb->GetIValue() == 1)
checkEndStops = true;
}
moveAvailable = true;
return true;
}
@ -349,6 +366,75 @@ bool GCodes::ReadMove(float m[], bool& ce)
return true;
}
bool GCodes::DoFileCannedCycles(char* fileName)
{
// Have we started the file?
if(!doingCannedCycleFile)
{
// No
if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
return false;
if(fileBeingPrinted != NULL)
{
if(saveFileBeingPrinted != NULL)
{
platform->Message(HOST_MESSAGE, "Canned cycle files cannot be recursive!\n");
return true;
}
saveFileBeingPrinted = fileBeingPrinted;
}
fileBeingPrinted = platform->GetFileStore(platform->GetSysDir(), fileName, false);
if(fileBeingPrinted == NULL)
{
platform->Message(HOST_MESSAGE, "Canned cycle GCode file not found - ");
platform->Message(HOST_MESSAGE, fileName);
platform->Message(HOST_MESSAGE, "\n");
if(saveFileBeingPrinted != NULL)
{
fileBeingPrinted = saveFileBeingPrinted;
saveFileBeingPrinted = NULL;
}
return true;
}
doingCannedCycleFile = true;
cannedCycleGCode->Init();
return false;
}
// Have we finished the file?
if(fileBeingPrinted == NULL)
{
// Yes
doingCannedCycleFile = false;
cannedCycleGCode->Init();
if(saveFileBeingPrinted != NULL)
{
fileBeingPrinted = saveFileBeingPrinted;
saveFileBeingPrinted = NULL;
}
return true;
}
// Do more of the file
if(!cannedCycleGCode->Finished())
{
cannedCycleGCode->SetFinished(ActOnGcode(cannedCycleGCode));
return false;
}
doFilePrint(cannedCycleGCode);
return false;
}
// To execute any move, call this until it returns true.
// moveToDo[] entries corresponding with false entries in action[] will
// be ignored. Recall that moveToDo[DRIVES] should contain the feedrate
@ -1323,7 +1409,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
fileBeingPrinted = NULL;
break;
case 27: // Report print status
case 27: // Report print status - Depricated
if(this->PrintingAFile())
strncpy(reply, "SD printing.", STRING_LENGTH);
else
@ -1411,7 +1497,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
reprap.SetDebug(gb->GetIValue());
break;
case 112: // Emergency stop - aced upon in Webserver
case 112: // Emergency stop - acted upon in Webserver
break;
case 114: // Deprecated
@ -1646,6 +1732,16 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
}
break;
case 900:
result = DoFileCannedCycles("homex.g");
break;
case 901:
result = DoFileCannedCycles("homey.g");
break;
case 906: // Set Motor currents
for(uint8_t i = 0; i < DRIVES; i++)
{

View file

@ -80,8 +80,10 @@ class GCodes
private:
void doFilePrint(GCodeBuffer* gb);
bool AllMovesAreFinishedAndMoveBufferIsLoaded();
bool DoCannedCycleMove(bool ce);
bool DoFileCannedCycles(char* fileName);
bool ActOnGcode(GCodeBuffer* gb);
bool SetUpMove(GCodeBuffer* gb);
bool DoDwell(GCodeBuffer *gb);
@ -115,6 +117,7 @@ class GCodes
GCodeBuffer* webGCode;
GCodeBuffer* fileGCode;
GCodeBuffer* serialGCode;
GCodeBuffer* cannedCycleGCode;
bool moveAvailable;
float moveBuffer[DRIVES+1]; // Last is feedrate
bool checkEndStops;
@ -132,9 +135,11 @@ class GCodes
bool offSetSet;
float distanceScale;
FileStore* fileBeingPrinted;
FileStore* saveFileBeingPrinted;
FileStore* fileToPrint;
FileStore* fileBeingWritten;
FileStore* configFile;
bool doingCannedCycleFile;
char* eofString;
uint8_t eofStringCounter;
uint8_t eofStringLength;

Binary file not shown.

11
SD-image/sys/homex.g Normal file
View file

@ -0,0 +1,11 @@
M120 ; Push
G91
G1 Z5 F200
G90
G1 X-400 F1000 S1
G92 X0
G1 X3 F200
G1 X-30 S1
G92 X0
M121

8
SD-image/sys/homey.g Normal file
View file

@ -0,0 +1,8 @@
M120 ; Push
G91
G1 Y400 F1000 S1
G90
G92 Y200
G1 Y0
M121