Experimental macro/canned-cycle on the SD implemented.
This commit is contained in:
parent
4feab9afce
commit
4ed66b8b01
6 changed files with 138 additions and 18 deletions
|
@ -24,7 +24,7 @@ Licence: GPL
|
||||||
#define CONFIGURATION_H
|
#define CONFIGURATION_H
|
||||||
|
|
||||||
#define NAME "RepRapFirmware"
|
#define NAME "RepRapFirmware"
|
||||||
#define VERSION "0.42"
|
#define VERSION "0.43"
|
||||||
#define DATE "2013-12-19"
|
#define DATE "2013-12-19"
|
||||||
#define LAST_AUTHOR "reprappro.com"
|
#define LAST_AUTHOR "reprappro.com"
|
||||||
|
|
||||||
|
|
130
GCodes.cpp
130
GCodes.cpp
|
@ -33,6 +33,7 @@ GCodes::GCodes(Platform* p, Webserver* w)
|
||||||
webGCode = new GCodeBuffer(platform, "web: ");
|
webGCode = new GCodeBuffer(platform, "web: ");
|
||||||
fileGCode = new GCodeBuffer(platform, "file: ");
|
fileGCode = new GCodeBuffer(platform, "file: ");
|
||||||
serialGCode = new GCodeBuffer(platform, "serial: ");
|
serialGCode = new GCodeBuffer(platform, "serial: ");
|
||||||
|
cannedCycleGCode = new GCodeBuffer(platform, "canned: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodes::Exit()
|
void GCodes::Exit()
|
||||||
|
@ -46,9 +47,11 @@ void GCodes::Init()
|
||||||
webGCode->Init();
|
webGCode->Init();
|
||||||
fileGCode->Init();
|
fileGCode->Init();
|
||||||
serialGCode->Init();
|
serialGCode->Init();
|
||||||
|
cannedCycleGCode->Init();
|
||||||
webGCode->SetFinished(true);
|
webGCode->SetFinished(true);
|
||||||
fileGCode->SetFinished(true);
|
fileGCode->SetFinished(true);
|
||||||
serialGCode->SetFinished(true);
|
serialGCode->SetFinished(true);
|
||||||
|
cannedCycleGCode->SetFinished(true);
|
||||||
moveAvailable = false;
|
moveAvailable = false;
|
||||||
drivesRelative = true;
|
drivesRelative = true;
|
||||||
axesRelative = false;
|
axesRelative = false;
|
||||||
|
@ -58,9 +61,11 @@ void GCodes::Init()
|
||||||
for(int8_t i = 0; i < DRIVES - AXES; i++)
|
for(int8_t i = 0; i < DRIVES - AXES; i++)
|
||||||
lastPos[i] = 0.0;
|
lastPos[i] = 0.0;
|
||||||
fileBeingPrinted = NULL;
|
fileBeingPrinted = NULL;
|
||||||
|
saveFileBeingPrinted = NULL;
|
||||||
fileToPrint = NULL;
|
fileToPrint = NULL;
|
||||||
fileBeingWritten = NULL;
|
fileBeingWritten = NULL;
|
||||||
configFile = NULL;
|
configFile = NULL;
|
||||||
|
doingCannedCycleFile = false;
|
||||||
eofString = EOF_STRING;
|
eofString = EOF_STRING;
|
||||||
eofStringCounter = 0;
|
eofStringCounter = 0;
|
||||||
eofStringLength = strlen(eofString);
|
eofStringLength = strlen(eofString);
|
||||||
|
@ -82,6 +87,26 @@ void GCodes::Init()
|
||||||
dwellTime = longWait;
|
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()
|
void GCodes::Spin()
|
||||||
{
|
{
|
||||||
if(!active)
|
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);
|
platform->ClassReport("GCodes", longWait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +342,12 @@ bool GCodes::SetUpMove(GCodeBuffer *gb)
|
||||||
LoadMoveBufferFromGCode(gb, false);
|
LoadMoveBufferFromGCode(gb, false);
|
||||||
|
|
||||||
checkEndStops = false;
|
checkEndStops = false;
|
||||||
|
if(gb->Seen('S'))
|
||||||
|
{
|
||||||
|
if(gb->GetIValue() == 1)
|
||||||
|
checkEndStops = true;
|
||||||
|
}
|
||||||
|
|
||||||
moveAvailable = true;
|
moveAvailable = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -349,6 +366,75 @@ bool GCodes::ReadMove(float m[], bool& ce)
|
||||||
return true;
|
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.
|
// To execute any move, call this until it returns true.
|
||||||
// moveToDo[] entries corresponding with false entries in action[] will
|
// moveToDo[] entries corresponding with false entries in action[] will
|
||||||
// be ignored. Recall that moveToDo[DRIVES] should contain the feedrate
|
// be ignored. Recall that moveToDo[DRIVES] should contain the feedrate
|
||||||
|
@ -1323,7 +1409,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
||||||
fileBeingPrinted = NULL;
|
fileBeingPrinted = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 27: // Report print status
|
case 27: // Report print status - Depricated
|
||||||
if(this->PrintingAFile())
|
if(this->PrintingAFile())
|
||||||
strncpy(reply, "SD printing.", STRING_LENGTH);
|
strncpy(reply, "SD printing.", STRING_LENGTH);
|
||||||
else
|
else
|
||||||
|
@ -1411,7 +1497,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
||||||
reprap.SetDebug(gb->GetIValue());
|
reprap.SetDebug(gb->GetIValue());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 112: // Emergency stop - aced upon in Webserver
|
case 112: // Emergency stop - acted upon in Webserver
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 114: // Deprecated
|
case 114: // Deprecated
|
||||||
|
@ -1646,6 +1732,16 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 900:
|
||||||
|
result = DoFileCannedCycles("homex.g");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 901:
|
||||||
|
result = DoFileCannedCycles("homey.g");
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 906: // Set Motor currents
|
case 906: // Set Motor currents
|
||||||
for(uint8_t i = 0; i < DRIVES; i++)
|
for(uint8_t i = 0; i < DRIVES; i++)
|
||||||
{
|
{
|
||||||
|
|
5
GCodes.h
5
GCodes.h
|
@ -80,8 +80,10 @@ class GCodes
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void doFilePrint(GCodeBuffer* gb);
|
||||||
bool AllMovesAreFinishedAndMoveBufferIsLoaded();
|
bool AllMovesAreFinishedAndMoveBufferIsLoaded();
|
||||||
bool DoCannedCycleMove(bool ce);
|
bool DoCannedCycleMove(bool ce);
|
||||||
|
bool DoFileCannedCycles(char* fileName);
|
||||||
bool ActOnGcode(GCodeBuffer* gb);
|
bool ActOnGcode(GCodeBuffer* gb);
|
||||||
bool SetUpMove(GCodeBuffer* gb);
|
bool SetUpMove(GCodeBuffer* gb);
|
||||||
bool DoDwell(GCodeBuffer *gb);
|
bool DoDwell(GCodeBuffer *gb);
|
||||||
|
@ -115,6 +117,7 @@ class GCodes
|
||||||
GCodeBuffer* webGCode;
|
GCodeBuffer* webGCode;
|
||||||
GCodeBuffer* fileGCode;
|
GCodeBuffer* fileGCode;
|
||||||
GCodeBuffer* serialGCode;
|
GCodeBuffer* serialGCode;
|
||||||
|
GCodeBuffer* cannedCycleGCode;
|
||||||
bool moveAvailable;
|
bool moveAvailable;
|
||||||
float moveBuffer[DRIVES+1]; // Last is feedrate
|
float moveBuffer[DRIVES+1]; // Last is feedrate
|
||||||
bool checkEndStops;
|
bool checkEndStops;
|
||||||
|
@ -132,9 +135,11 @@ class GCodes
|
||||||
bool offSetSet;
|
bool offSetSet;
|
||||||
float distanceScale;
|
float distanceScale;
|
||||||
FileStore* fileBeingPrinted;
|
FileStore* fileBeingPrinted;
|
||||||
|
FileStore* saveFileBeingPrinted;
|
||||||
FileStore* fileToPrint;
|
FileStore* fileToPrint;
|
||||||
FileStore* fileBeingWritten;
|
FileStore* fileBeingWritten;
|
||||||
FileStore* configFile;
|
FileStore* configFile;
|
||||||
|
bool doingCannedCycleFile;
|
||||||
char* eofString;
|
char* eofString;
|
||||||
uint8_t eofStringCounter;
|
uint8_t eofStringCounter;
|
||||||
uint8_t eofStringLength;
|
uint8_t eofStringLength;
|
||||||
|
|
Binary file not shown.
11
SD-image/sys/homex.g
Normal file
11
SD-image/sys/homex.g
Normal 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
8
SD-image/sys/homey.g
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
M120 ; Push
|
||||||
|
G91
|
||||||
|
G1 Y400 F1000 S1
|
||||||
|
G90
|
||||||
|
G92 Y200
|
||||||
|
G1 Y0
|
||||||
|
M121
|
||||||
|
|
Reference in a new issue