Serial Commands can now be disabled
After setting up positions, cmdArduino can be disabled to save small amout of memory.
This commit is contained in:
@@ -47,3 +47,4 @@ const int stepPerRev = 4096;
|
||||
|
||||
//Extra Stuff
|
||||
#define rtcBlynk false
|
||||
#define cmds true //After setting up positions, cmdArduino can be disabled
|
||||
|
||||
@@ -133,25 +133,27 @@ void moveNow() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Function used to control the motor position via Serial
|
||||
void manualMove(int arg_cnt, char **args) {
|
||||
stepper.moveTo(cmdStr2Num(args[1], 10));
|
||||
Serial.print(F("Manual Move: ")); Serial.println(cmdStr2Num(args[1], 10));
|
||||
}
|
||||
|
||||
//Set home position via Serial
|
||||
void homePos(int arg_cnt, char **args) {
|
||||
stepper.setCurrentPosition(0);
|
||||
}
|
||||
|
||||
//Move to position via Serial
|
||||
void pos(int arg_cnt, char **args) {
|
||||
if (cmdStr2Num(args[1],10) > 0 && cmdStr2Num(args[1],10) < 5) {
|
||||
motorPos = cmdStr2Num(args[1],10);
|
||||
Serial.print("Target Position: "); Serial.println(cmdStr2Num(args[1],10));
|
||||
|
||||
} else {
|
||||
Serial.println("Invalid Input. (1-4 are valid.)");
|
||||
//Commands for controlling over Serial Monitor
|
||||
#if cmds
|
||||
//Function used to control the motor position via Serial
|
||||
void manualMove(int arg_cnt, char **args) {
|
||||
stepper.moveTo(cmdStr2Num(args[1], 10));
|
||||
Serial.print(F("Manual Move: ")); Serial.println(cmdStr2Num(args[1], 10));
|
||||
}
|
||||
}
|
||||
|
||||
//Set home position via Serial
|
||||
void homePos(int arg_cnt, char **args) {
|
||||
stepper.setCurrentPosition(0);
|
||||
}
|
||||
|
||||
//Move to position via Serial
|
||||
void pos(int arg_cnt, char **args) {
|
||||
if (cmdStr2Num(args[1],10) > 0 && cmdStr2Num(args[1],10) < 5) {
|
||||
motorPos = cmdStr2Num(args[1],10);
|
||||
Serial.print("Target Position: "); Serial.println(cmdStr2Num(args[1],10));
|
||||
|
||||
} else {
|
||||
Serial.println("Invalid Input. (1-4 are valid.)");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,9 +23,12 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <BlynkSimpleEsp8266.h>
|
||||
#include <Ethernet.h>
|
||||
#include <Cmd.h>
|
||||
#include "config.h"
|
||||
|
||||
#if cmds
|
||||
#include <Cmd.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
byte lastPosition = 2;
|
||||
@@ -129,11 +132,13 @@ void setup() {
|
||||
buttons.add(down);
|
||||
buttons.add(rst);
|
||||
#endif
|
||||
|
||||
cmdInit(&Serial);
|
||||
cmdAdd("move",manualMove);
|
||||
cmdAdd("rst",homePos);
|
||||
cmdAdd("pos",pos);
|
||||
|
||||
#if cmds
|
||||
cmdInit(&Serial);
|
||||
cmdAdd("move",manualMove);
|
||||
cmdAdd("rst",homePos);
|
||||
cmdAdd("pos",pos);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -173,8 +178,10 @@ void loop() {
|
||||
if (ledOn == true) {
|
||||
ledFeedback();
|
||||
}
|
||||
|
||||
cmdPoll();
|
||||
|
||||
#if cmds
|
||||
cmdPoll();
|
||||
#endif
|
||||
|
||||
#if buttonEnable
|
||||
buttons.check(); //Check for button presses
|
||||
|
||||
Reference in New Issue
Block a user