farmbot-arduino-firmware/src/farmbot_arduino_controller.cpp

67 lines
1.6 KiB
C++
Raw Normal View History

// Do not remove the include below
#include "farmbot_arduino_controller.h"
#include "pins.h"
#include "Config.h"
2014-11-04 15:14:35 -07:00
#include "ServoControl.h"
static char commandEndChar = 0x0A;
static GCodeProcessor* gCodeProcessor = new GCodeProcessor();
//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);
pinMode(X_ENABLE_PIN, OUTPUT);
2014-07-13 11:26:29 -06:00
pinMode(X_MIN_PIN , INPUT );
pinMode(X_MAX_PIN , INPUT );
2014-07-13 11:26:29 -06:00
pinMode(Y_STEP_PIN , OUTPUT);
pinMode(Y_DIR_PIN , OUTPUT);
pinMode(Y_ENABLE_PIN, OUTPUT);
2014-07-13 11:26:29 -06:00
pinMode(Y_MIN_PIN , INPUT );
pinMode(Y_MAX_PIN , INPUT );
2014-07-13 11:26:29 -06:00
pinMode(Z_STEP_PIN , OUTPUT);
pinMode(Z_DIR_PIN , OUTPUT);
pinMode(Z_ENABLE_PIN, OUTPUT);
2014-07-13 11:26:29 -06:00
pinMode(Z_MIN_PIN , INPUT );
pinMode(Z_MAX_PIN , INPUT );
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);
Serial.begin(115200);
2014-11-04 15:14:35 -07:00
ServoControl::getInstance()->attach();
}
// 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);
if(LOGGING) {
command->print();
}
gCodeProcessor->execute(command);
2014-07-29 16:12:19 -06:00
free(command);
2014-05-05 16:15:58 -06:00
}
}
delay(100);
2014-11-04 15:14:35 -07:00
//ServoControl::getInstance()->SetAngle(90);
}