diff --git a/App/src/GcodeParser.tsx b/App/src/GcodeParser.tsx index 0e44122..7db3a49 100644 --- a/App/src/GcodeParser.tsx +++ b/App/src/GcodeParser.tsx @@ -51,6 +51,5 @@ export function parseCommand(cmd: string): Command { (command as any)[arg] = parseFloat(val); }); - console.log(command); return command; } diff --git a/App/src/GcodeVisualiser.tsx b/App/src/GcodeVisualiser.tsx index 64abcf5..de05299 100644 --- a/App/src/GcodeVisualiser.tsx +++ b/App/src/GcodeVisualiser.tsx @@ -1,11 +1,16 @@ import * as React from "react"; -import { Layer, Rect, Stage, Group } from "react-konva"; +import { Layer, Rect, Stage, Group, Line } from "react-konva"; +import { parseCommand, CommandType } from "~GcodeParser"; interface IGcodeVisualiserProps { gcodeLinesSent: string[]; gcodeLinesQueue: string[]; } +const mult = 3; +const width = 500; +const height = 500; + export default class GcodeVisualiser extends React.PureComponent< IGcodeVisualiserProps, {} @@ -14,18 +19,103 @@ export default class GcodeVisualiser extends React.PureComponent< super(props); } render() { - return ( - - - { + const command = parseCommand(sl); + if ( + command.type === CommandType.G00 || + command.type === CommandType.G01 + ) { + const line = ( + - + ); + if (command.X) { + lastPos.x = command.X; + } + if (command.Y) { + lastPos.y = command.Y; + } + if (command.Z) { + if (command.Z >= 0) { + lastPos.eng = false; + } else { + lastPos.eng = true; + } + } + return line; + } + }); + + const pendLines = gcodeLinesQueue.map(sl => { + const command = parseCommand(sl); + if ( + command.type === CommandType.G00 || + command.type === CommandType.G01 + ) { + const line = ( + + ); + if (command.X) { + lastPos.x = command.X; + } + if (command.Y) { + lastPos.y = command.Y; + } + if (command.Z) { + if (command.Z >= 0) { + lastPos.eng = false; + } else { + lastPos.eng = true; + } + } + return line; + } + }); + + return ( + + {[...sentLines, ...pendLines]} ); } diff --git a/Firmware/MotorControl/src/Globals.cpp b/Firmware/MotorControl/src/Globals.cpp index 0b99aa9..938001c 100644 --- a/Firmware/MotorControl/src/Globals.cpp +++ b/Firmware/MotorControl/src/Globals.cpp @@ -1,6 +1,6 @@ #include "Globals.h" -Stepper eggStepper(6, 5, STEPS_PER_REVOLUTION, 0, defYDegPerMM); +Stepper eggStepper(6, 5, -STEPS_PER_REVOLUTION, 0, defYDegPerMM); Stepper servoStepper(4, 3, STEPS_PER_REVOLUTION, xLimit, defXDegPerMM); unsigned int eggStepperDelay;