more "Q"
parent
20660d9c3b
commit
f69c820190
|
@ -57,6 +57,7 @@ public:
|
|||
long getM();
|
||||
long getQ();
|
||||
|
||||
void printQAndNewLine();
|
||||
private:
|
||||
CommandCodeEnum getGCodeEnum(char* code);
|
||||
void getParameter(char* charPointer);
|
||||
|
|
|
@ -13,6 +13,7 @@ long y = 0;
|
|||
long z = 0;
|
||||
unsigned int speed = 0;
|
||||
bool endStopState[3][2];
|
||||
long Q = 0;
|
||||
|
||||
CurrentState * CurrentState::getInstance() {
|
||||
if (!instance) {
|
||||
|
@ -26,6 +27,7 @@ CurrentState::CurrentState() {
|
|||
y = 0;
|
||||
z = 0;
|
||||
speed = 0;
|
||||
Q = 0;
|
||||
}
|
||||
|
||||
long CurrentState::getX() {
|
||||
|
@ -78,7 +80,8 @@ void CurrentState::printPosition() {
|
|||
Serial.print(y);
|
||||
Serial.print(" Z");
|
||||
Serial.print(z);
|
||||
Serial.print("\r\n");
|
||||
// Serial.print("\r\n");
|
||||
printQAndNewLine();
|
||||
}
|
||||
|
||||
void CurrentState::printBool(bool value)
|
||||
|
@ -86,8 +89,8 @@ void CurrentState::printBool(bool value)
|
|||
if (value)
|
||||
{
|
||||
Serial.print("1");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print("0");
|
||||
}
|
||||
|
@ -107,7 +110,8 @@ void CurrentState::printEndStops() {
|
|||
printBool(endStopState[2][0]);
|
||||
Serial.print(" ZB");
|
||||
printBool(endStopState[2][1]);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
printQAndNewLine();
|
||||
}
|
||||
|
||||
void CurrentState::print() {
|
||||
|
@ -115,4 +119,16 @@ void CurrentState::print() {
|
|||
printEndStops();
|
||||
}
|
||||
|
||||
void CurrentState::setQ(int q) {
|
||||
Q = q;
|
||||
}
|
||||
|
||||
void CurrentState::resetQ() {
|
||||
Q = 0;
|
||||
}
|
||||
|
||||
void CurrentState::printQAndNewLine() {
|
||||
Serial.print(" Q");
|
||||
Serial.print(Q);
|
||||
Serial.print("\r\n");
|
||||
}
|
||||
|
|
|
@ -26,10 +26,16 @@ public:
|
|||
void printEndStops();
|
||||
void print();
|
||||
void printBool(bool);
|
||||
|
||||
void setQ(int q);
|
||||
void resetQ();
|
||||
void printQAndNewLine();
|
||||
|
||||
private:
|
||||
CurrentState();
|
||||
CurrentState(CurrentState const&);
|
||||
void operator=(CurrentState const&);
|
||||
|
||||
};
|
||||
|
||||
#endif /* CURRENTSTATE_H_ */
|
||||
|
|
|
@ -29,6 +29,7 @@ int F11Handler::execute(Command* command) {
|
|||
}
|
||||
|
||||
StepperControl::getInstance()->moveToCoords(0,0,0, 0,0,0, true, false, false);
|
||||
|
||||
if (LOGGING) {
|
||||
CurrentState::getInstance()->print();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ int F12Handler::execute(Command* command) {
|
|||
}
|
||||
|
||||
StepperControl::getInstance()->moveToCoords(0,0,0, 0,0,0, false, true, false);
|
||||
|
||||
if (LOGGING) {
|
||||
CurrentState::getInstance()->print();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ int F13Handler::execute(Command* command) {
|
|||
}
|
||||
|
||||
StepperControl::getInstance()->moveToCoords(0,0,0, 0,0,0, false, false, true);
|
||||
|
||||
if (LOGGING) {
|
||||
CurrentState::getInstance()->print();
|
||||
}
|
||||
|
|
|
@ -36,5 +36,3 @@ int F15Handler::execute(Command* command) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ int F83Handler::execute(Command* command) {
|
|||
|
||||
Serial.print("R83 ");
|
||||
Serial.print(SOFTWARE_VERSION);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,12 @@ int G00Handler::execute(Command* command) {
|
|||
// Serial.print("\r\n");
|
||||
|
||||
|
||||
StepperControl::getInstance()->moveToCoords(
|
||||
StepperControl::getInstance()->moveToCoords
|
||||
(
|
||||
command->getX(), command->getY(), command->getZ(),
|
||||
command->getA(), command->getB(), command->getC(),
|
||||
false, false, false);
|
||||
false, false, false
|
||||
);
|
||||
|
||||
if (LOGGING) {
|
||||
CurrentState::getInstance()->print();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
#include "GCodeProcessor.h"
|
||||
#include "CurrentState.h"
|
||||
|
||||
GCodeProcessor::GCodeProcessor() {
|
||||
|
||||
|
@ -24,6 +25,8 @@ void GCodeProcessor::printCommandLog(Command* command) {
|
|||
|
||||
int GCodeProcessor::execute(Command* command) {
|
||||
long Q = command->getQ();
|
||||
//Q = 99;
|
||||
CurrentState::getInstance()->setQ(Q);
|
||||
|
||||
if(command == NULL || command->getCodeEnum() == CODE_UNDEFINED) {
|
||||
if(LOGGING) {
|
||||
|
@ -33,27 +36,31 @@ int GCodeProcessor::execute(Command* command) {
|
|||
}
|
||||
GCodeHandler* handler = getGCodeHandler(command->getCodeEnum());
|
||||
if(handler == NULL) {
|
||||
Serial.println("This is false: handler == NULL");
|
||||
Serial.println("R99 This is false: handler == NULL");
|
||||
return -1;
|
||||
}
|
||||
Serial.println(COMM_REPORT_CMD_START);
|
||||
Serial.print(" Q");
|
||||
Serial.print(Q);
|
||||
Serial.print("\n\r");
|
||||
Serial.print(COMM_REPORT_CMD_START);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
//Serial.print(" Q");
|
||||
//Serial.print(Q);
|
||||
//Serial.print("\n\r");
|
||||
|
||||
int execution = handler->execute(command);
|
||||
if(execution == 0) {
|
||||
Serial.println(COMM_REPORT_CMD_DONE);
|
||||
Serial.print(" Q");
|
||||
Serial.print(Q);
|
||||
Serial.print("\n\r");
|
||||
Serial.print(COMM_REPORT_CMD_DONE);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
//Serial.print(" Q");
|
||||
//Serial.print(Q);
|
||||
//Serial.print("\n\r");
|
||||
} else {
|
||||
Serial.println(COMM_REPORT_CMD_ERROR);
|
||||
Serial.print(" Q");
|
||||
Serial.print(Q);
|
||||
Serial.print("\n\r");
|
||||
|
||||
Serial.print(COMM_REPORT_CMD_ERROR);
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
//Serial.print(" Q");
|
||||
//Serial.print(Q);
|
||||
//Serial.print("\n\r");
|
||||
}
|
||||
|
||||
CurrentState::getInstance()->resetQ();
|
||||
return execution;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ ParameterList::ParameterList() {
|
|||
}
|
||||
}
|
||||
|
||||
// ===== Interfce functions for the raspberry pi =====
|
||||
// ===== Interface functions for the raspberry pi =====
|
||||
|
||||
int ParameterList::readValue(int id) {
|
||||
|
||||
|
@ -40,7 +40,9 @@ int ParameterList::readValue(int id) {
|
|||
Serial.print(" ");
|
||||
Serial.print("V");
|
||||
Serial.print(value);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
} else {
|
||||
Serial.print("R99 Error: invalid parameter id\r\n");
|
||||
}
|
||||
|
@ -71,7 +73,8 @@ int ParameterList::writeValue(int id, int value) {
|
|||
Serial.print("V");
|
||||
Serial.print(" ");
|
||||
Serial.print(value);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
// If any value is written,
|
||||
// trigger the loading of the new configuration in all other modules
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Arduino.h"
|
||||
#include "Config.h"
|
||||
#include "PinGuard.h"
|
||||
|
||||
#include "CurrentState.h"
|
||||
|
||||
//#define NULL 0
|
||||
const int PARAM_NR_OF_PARAMS = 300;
|
||||
|
|
|
@ -53,7 +53,8 @@ int PinControl::readValue(int pinNr, int mode) {
|
|||
Serial.print(" ");
|
||||
Serial.print("V");
|
||||
Serial.print(value);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "CurrentState.h"
|
||||
|
||||
class PinControl {
|
||||
public:
|
||||
|
|
|
@ -34,7 +34,8 @@ int StatusList::readValue(int id) {
|
|||
Serial.print(" ");
|
||||
Serial.print("V");
|
||||
Serial.print(value);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "Arduino.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "CurrentState.h"
|
||||
|
||||
//#define NULL 0
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ void StepperControl::reportStatus(StepperControlAxis* axis, int axisStatus) {
|
|||
Serial.print(" ");
|
||||
Serial.print(axis->label);
|
||||
Serial.print(axisStatus);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
|
||||
void StepperControl::reportCalib(StepperControlAxis* axis, int calibStatus) {
|
||||
|
@ -23,7 +24,8 @@ void StepperControl::reportCalib(StepperControlAxis* axis, int calibStatus) {
|
|||
Serial.print(" ");
|
||||
Serial.print(axis->label);
|
||||
Serial.print(calibStatus);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
|
||||
void StepperControl::checkAxisSubStatus(StepperControlAxis* axis, int* axisSubStatus) {
|
||||
|
@ -62,6 +64,7 @@ void StepperControl::checkAxisSubStatus(StepperControlAxis* axis, int* axisSubSt
|
|||
StepperControl::StepperControl() {
|
||||
|
||||
// Initialize some variables for testing
|
||||
|
||||
//motorConsMissedStepsMax[0] = 50;
|
||||
//motorConsMissedStepsMax[1] = 50;
|
||||
//motorConsMissedStepsMax[2] = 50;
|
||||
|
@ -126,7 +129,8 @@ void StepperControl::test2() {
|
|||
*/
|
||||
int StepperControl::moveToCoords( long xDest, long yDest, long zDest,
|
||||
unsigned int xMaxSpd, unsigned int yMaxSpd, unsigned int zMaxSpd,
|
||||
bool xHome, bool yHome, bool zHome) {
|
||||
bool xHome, bool yHome, bool zHome
|
||||
) {
|
||||
|
||||
unsigned long currentMillis = 0;
|
||||
unsigned long timeStart = millis();
|
||||
|
@ -363,7 +367,8 @@ int StepperControl::moveToCoords( long xDest, long yDest, long zDest,
|
|||
//if (1 == 1)
|
||||
{
|
||||
Serial.print(COMM_REPORT_CMD_BUSY);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
reportPosition();
|
||||
/*
|
||||
Serial.print("R99");
|
||||
|
@ -593,7 +598,8 @@ int StepperControl::calibrateAxis(int axis) {
|
|||
{
|
||||
// Periodically send message still active
|
||||
Serial.print(COMM_REPORT_CMD_BUSY);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
|
||||
if (stepsCount % (speedMin[axis] / 6) == 0 /*|| *missedSteps > 3*/)
|
||||
|
@ -712,7 +718,8 @@ int StepperControl::calibrateAxis(int axis) {
|
|||
{
|
||||
// Periodically send message still active
|
||||
Serial.print(COMM_REPORT_CMD_BUSY);
|
||||
Serial.print("\r\n");
|
||||
//Serial.print("\r\n");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
}
|
||||
/*
|
||||
if (stepsCount % (speedMin[axis] / 6) == 0)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "Config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Command.h"
|
||||
|
||||
class StepperControl {
|
||||
public:
|
||||
|
@ -30,7 +31,8 @@ public:
|
|||
// unsigned int maxAccelerationStepsPerSecond);
|
||||
int moveToCoords( long xDest, long yDest, long zDest,
|
||||
unsigned int xMaxSpd, unsigned int yMaxSpd, unsigned int zMaxSpd,
|
||||
bool homeX, bool homeY, bool homeZ);
|
||||
bool homeX, bool homeY, bool homeZ
|
||||
);
|
||||
|
||||
void handleMovementInterrupt();
|
||||
int calibrateAxis(int axis);
|
||||
|
|
|
@ -135,7 +135,9 @@ void loop() {
|
|||
|
||||
if ((currentTime - lastAction) > 5000) {
|
||||
// After an idle time, send the idle message
|
||||
Serial.print("R00\r\r\n");
|
||||
Serial.print("R00");
|
||||
CurrentState::getInstance()->printQAndNewLine();
|
||||
|
||||
CurrentState::getInstance()->printPosition();
|
||||
CurrentState::getInstance()->printEndStops();
|
||||
lastAction = millis();
|
||||
|
|
Loading…
Reference in New Issue