2014-05-05 12:50:13 -06:00
|
|
|
// Do not remove the include below
|
|
|
|
#include "farmbot_arduino_controller.h"
|
2014-05-15 11:44:28 -06:00
|
|
|
#include "pins.h"
|
2014-05-16 14:27:16 -06:00
|
|
|
#include "Config.h"
|
2014-05-05 12:50:13 -06:00
|
|
|
|
2014-11-04 15:14:35 -07:00
|
|
|
#include "ServoControl.h"
|
|
|
|
|
2014-05-05 12:50:13 -06:00
|
|
|
static char commandEndChar = 0x0A;
|
2014-05-15 11:44:28 -06:00
|
|
|
static GCodeProcessor* gCodeProcessor = new GCodeProcessor();
|
2014-05-05 12:50:13 -06:00
|
|
|
|
|
|
|
//The setup function is called once at startup of the sketch
|
|
|
|
void setup() {
|
2014-07-13 11:26:29 -06:00
|
|
|
pinMode(X_STEP_PIN , OUTPUT);
|
|
|
|
pinMode(X_DIR_PIN , OUTPUT);
|
2014-05-15 11:44:28 -06:00
|
|
|
pinMode(X_ENABLE_PIN, OUTPUT);
|
2014-07-13 11:26:29 -06:00
|
|
|
pinMode(X_MIN_PIN , INPUT );
|
|
|
|
pinMode(X_MAX_PIN , INPUT );
|
2014-05-15 15:46:47 -06:00
|
|
|
|
2014-07-13 11:26:29 -06:00
|
|
|
pinMode(Y_STEP_PIN , OUTPUT);
|
|
|
|
pinMode(Y_DIR_PIN , OUTPUT);
|
2014-05-15 15:46:47 -06:00
|
|
|
pinMode(Y_ENABLE_PIN, OUTPUT);
|
2014-07-13 11:26:29 -06:00
|
|
|
pinMode(Y_MIN_PIN , INPUT );
|
|
|
|
pinMode(Y_MAX_PIN , INPUT );
|
2014-05-15 15:46:47 -06:00
|
|
|
|
2014-07-13 11:26:29 -06:00
|
|
|
pinMode(Z_STEP_PIN , OUTPUT);
|
|
|
|
pinMode(Z_DIR_PIN , OUTPUT);
|
2014-05-15 15:46:47 -06:00
|
|
|
pinMode(Z_ENABLE_PIN, OUTPUT);
|
2014-07-13 11:26:29 -06:00
|
|
|
pinMode(Z_MIN_PIN , INPUT );
|
|
|
|
pinMode(Z_MAX_PIN , INPUT );
|
2014-05-15 15:46:47 -06:00
|
|
|
|
2014-09-10 09:21:17 -06:00
|
|
|
pinMode(HEATER_0_PIN, OUTPUT);
|
|
|
|
pinMode(HEATER_1_PIN, OUTPUT);
|
|
|
|
pinMode(FAN_PIN , OUTPUT);
|
|
|
|
pinMode(LED_PIN , OUTPUT);
|
2014-07-15 14:23:01 -06:00
|
|
|
|
2014-11-04 15:14:35 -07:00
|
|
|
//pinMode(SERVO_0_PIN , OUTPUT);
|
|
|
|
//pinMode(SERVO_1_PIN , OUTPUT);
|
|
|
|
|
2014-07-15 14:23:01 -06:00
|
|
|
digitalWrite(X_ENABLE_PIN, HIGH);
|
|
|
|
digitalWrite(Y_ENABLE_PIN, HIGH);
|
|
|
|
digitalWrite(Z_ENABLE_PIN, HIGH);
|
|
|
|
|
2014-05-15 15:46:47 -06:00
|
|
|
Serial.begin(115200);
|
2014-11-04 15:14:35 -07:00
|
|
|
|
|
|
|
ServoControl::getInstance()->attach();
|
|
|
|
|
2014-05-05 12:50:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// The loop function is called in an endless loop
|
|
|
|
void loop() {
|
2014-05-05 16:15:58 -06:00
|
|
|
if (Serial.available()) {
|
|
|
|
String commandString = Serial.readStringUntil(commandEndChar);
|
|
|
|
if (commandString && commandString.length() > 0) {
|
|
|
|
Command* command = new Command(commandString);
|
2014-05-16 14:27:16 -06:00
|
|
|
if(LOGGING) {
|
|
|
|
command->print();
|
|
|
|
}
|
2014-05-15 11:44:28 -06:00
|
|
|
gCodeProcessor->execute(command);
|
2014-07-29 16:12:19 -06:00
|
|
|
free(command);
|
2014-05-05 16:15:58 -06:00
|
|
|
}
|
2014-05-05 12:50:13 -06:00
|
|
|
}
|
|
|
|
delay(100);
|
2014-11-04 15:14:35 -07:00
|
|
|
|
|
|
|
//ServoControl::getInstance()->SetAngle(90);
|
|
|
|
|
2014-05-05 12:50:13 -06:00
|
|
|
}
|