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:
mrcory
2019-05-17 12:55:05 -04:00
parent 182da42f96
commit b0b63950c3
3 changed files with 39 additions and 29 deletions
+1
View File
@@ -47,3 +47,4 @@ const int stepPerRev = 4096;
//Extra Stuff
#define rtcBlynk false
#define cmds true //After setting up positions, cmdArduino can be disabled
+23 -21
View File
@@ -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
+15 -8
View File
@@ -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