diff --git a/.gitignore b/.gitignore index 0def275..c80c859 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ *.exe *.out *.app +/Release +/spec.d +/arduino diff --git a/Command.cpp b/Command.cpp new file mode 100644 index 0000000..cc0bd7c --- /dev/null +++ b/Command.cpp @@ -0,0 +1,24 @@ +#include "Command.h" + +const char axisCodes[3] = { 'X', 'Y', 'Z' }; +const char feedRate = 'F'; +const char extrusionAmount = 'E'; + +Command::Command(String commandString) { + char charBuf[commandString.length()]; + char* charPointer; + commandString.toCharArray(charBuf, commandString.length()); + + charPointer = strtok(charBuf," "); + + if(charPointer[0] == 'G') { + Serial.println("G command found:" + *charPointer); + return; + } + while(charPointer != NULL) { + Serial.println(charPointer); + charPointer = strtok(NULL, " "); + } + +} + diff --git a/Command.h b/Command.h new file mode 100644 index 0000000..85e5d19 --- /dev/null +++ b/Command.h @@ -0,0 +1,18 @@ +#include "Arduino.h" +#include "string.h" +enum CommandCodeEnum +{ + G00 = 0, + G01, + G02, + G03, + G04 +}; + +#define NULL 0 + +class Command { + CommandCodeEnum codeEnum; +public: + Command(String); +}; diff --git a/README.md b/README.md index ac7ad7d..349f5a0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -farmbot_arduino_controller +farmbot-arduino-controller ========================== +Created with eclipseArduino V2 diff --git a/farmbot_arduino_controller.cpp b/farmbot_arduino_controller.cpp new file mode 100644 index 0000000..b8c38ec --- /dev/null +++ b/farmbot_arduino_controller.cpp @@ -0,0 +1,19 @@ +// Do not remove the include below +#include "farmbot_arduino_controller.h" + +static char commandEndChar = 0x0A; + +//The setup function is called once at startup of the sketch +void setup() { + Serial.begin(115200); +} + +// The loop function is called in an endless loop +void loop() { + String commandString = Serial.readStringUntil(commandEndChar); + if (commandString && commandString.length() > 0) { + Serial.print("Board 1 received : "); + Command* command = new Command(commandString); + } + delay(100); +} diff --git a/farmbot_arduino_controller.h b/farmbot_arduino_controller.h new file mode 100644 index 0000000..6c02699 --- /dev/null +++ b/farmbot_arduino_controller.h @@ -0,0 +1,29 @@ +// Only modify this file to include +// - function definitions (prototypes) +// - include files +// - extern variable definitions +// In the appropriate section + +#ifndef _farmbot_arduino_controller_H_ +#define _farmbot_arduino_controller_H_ +#include "Arduino.h" +//add your includes for the project farmbot_arduino_controller here +#include "Command.h" + +//end of add your includes here +#ifdef __cplusplus +extern "C" { +#endif +void loop(); +void setup(); +#ifdef __cplusplus +} // extern "C" +#endif + +//add your function definitions for the project farmbot_arduino_controller here + + + + +//Do not add code below this line +#endif /* _farmbot_arduino_controller_H_ */