Has errors but sync
This commit is contained in:
parent
4903d45e4b
commit
44aa5576d5
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"*.js": "javascript",
|
||||
"*.h": "cpp",
|
||||
"string": "cpp"
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
[env:mega2560]
|
||||
platform = atmelavr
|
||||
platform = atmelave
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
lib_extra_dirs = ~/Documents/Arduino/libraries
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduino_FreeRTOS.h>
|
||||
#include "MotorControlPart.h"
|
||||
#include "ZCodeParser.h"
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
setupMotor();
|
||||
// setupMotor();
|
||||
|
||||
// Create tasks
|
||||
xTaskCreate(MotorControlTask, "Motor", 200, NULL, 10, NULL);
|
||||
// xTaskCreate(MotorControlTask, "Motor", 200, NULL, 10, NULL);
|
||||
ZCodeParser::ParseString("G0 Z2 ", void, void);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#include <Arduino.h>
|
||||
#include <vector>
|
||||
|
||||
typedef struct {
|
||||
char Axis;
|
||||
int time;
|
||||
} MoveCommand;
|
||||
|
||||
class ZCodeParser
|
||||
{
|
||||
private:
|
||||
public:
|
||||
static void ParseString(String inString, MoveCommand *outMovecommands, int *numOfCommands);
|
||||
};
|
||||
|
||||
void ZCodeParser::ParseString(String inString, MoveCommand *outMovecommands, int *numOfCommands){
|
||||
// G0 = move, no block
|
||||
// G1 = move, block
|
||||
// ; = comments
|
||||
// \n = new command
|
||||
|
||||
std::vector<String> stringCommands;
|
||||
int startIndex = 0;
|
||||
int endIndex;
|
||||
while (true)
|
||||
{
|
||||
endIndex = inString.indexOf('\n', startIndex);
|
||||
|
||||
if (endIndex == -1){
|
||||
break;
|
||||
}
|
||||
|
||||
stringCommands.push_back(inString.substring(startIndex, endIndex));
|
||||
startIndex = endIndex;
|
||||
}
|
||||
|
||||
Serial.println("Parsed: ");
|
||||
for (size_t i = 0; i < stringCommands.size(); i++)
|
||||
{
|
||||
Serial.print(stringCommands[i]);
|
||||
Serial.print(", ");
|
||||
}
|
||||
Serial.println("\n");
|
||||
|
||||
}
|
Loading…
Reference in New Issue