This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
reprapfirmware-dc42/GCodes.ino
2013-02-21 19:13:28 +00:00

56 lines
1.2 KiB
C++

/****************************************************************************************************
RepRapFirmware - G Codes
This class interprets G Codes from one or more sources, and calls the functions in Move, Heat etc
that drive the machine to do what the G Codes command.
-----------------------------------------------------------------------------------------------------
Version 0.1
13 February 2013
Adrian Bowyer
RepRap Professional Ltd
http://reprappro.com
Licence: GPL
****************************************************************************************************/
#include "RepRapFirmware.h"
GCodes::GCodes(Platform* p, Move* m, Heat* h, Webserver* w)
{
Serial.println("GCodes constructor");
platform = p;
move = m;
heat = h;
webserver = w;
lastTime = platform->time();
gcodePointer = 0;
}
void GCodes::ActOnGcode()
{
platform->Message(HOST_MESSAGE, "GCode: ");
platform->Message(HOST_MESSAGE, gcodeBuffer);
platform->Message(HOST_MESSAGE, "\n\n");
}
void GCodes::spin()
{
if(webserver->Available())
{
gcodeBuffer[gcodePointer] = webserver->Read();
if(!gcodeBuffer[gcodePointer])
{
gcodePointer = 0;
ActOnGcode();
gcodeBuffer[0] = 0;
} else
gcodePointer++;
}
}