Repetier: Added Repetier Firmware for 3D printer

This commit is contained in:
Nis Wechselberg 2015-10-16 11:04:50 +02:00
parent bc665c6431
commit 2e65b16628
70 changed files with 55640 additions and 0 deletions

2353
Repetier/Commands.cpp Normal file

File diff suppressed because it is too large Load diff

54
Repetier/Commands.h Normal file
View file

@ -0,0 +1,54 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
Functions in this file are used to communicate using ascii or repetier protocol.
*/
#ifndef COMMANDS_H_INCLUDED
#define COMMANDS_H_INCLUDED
class Commands
{
public:
static void commandLoop();
static void checkForPeriodicalActions(bool allowNewMoves);
static void processArc(GCode *com);
static void processGCode(GCode *com);
static void processMCode(GCode *com);
static void executeGCode(GCode *com);
static void waitUntilEndOfAllMoves();
static void waitUntilEndOfAllBuffers();
static void printCurrentPosition(FSTRINGPARAM(s));
static void printTemperatures(bool showRaw = false);
static void setFanSpeed(int speed,bool wait); /// Set fan speed 0..255
static void changeFeedrateMultiply(int factorInPercent);
static void changeFlowrateMultiply(int factorInPercent);
static void reportPrinterUsage();
static void emergencyStop();
static void checkFreeMemory();
static void writeLowestFreeRAM();
private:
static int lowestRAMValue;
static int lowestRAMValueSend;
};
#endif // COMMANDS_H_INCLUDED

593
Repetier/Communication.cpp Normal file
View file

@ -0,0 +1,593 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
*/
#include "Repetier.h"
#if DRIVE_SYSTEM == DELTA
FSTRINGVALUE(Com::tFirmware,"FIRMWARE_NAME:Repetier_" REPETIER_VERSION " FIRMWARE_URL:https://github.com/repetier/Repetier-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Delta EXTRUDER_COUNT:" XSTR(NUM_EXTRUDER) " REPETIER_PROTOCOL:3")
#else
#if DRIVE_SYSTEM == CARTESIAN
FSTRINGVALUE(Com::tFirmware,"FIRMWARE_NAME:Repetier_" REPETIER_VERSION " FIRMWARE_URL:https://github.com/repetier/Repetier-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:" XSTR(NUM_EXTRUDER) " REPETIER_PROTOCOL:3")
#else
FSTRINGVALUE(Com::tFirmware,"FIRMWARE_NAME:Repetier_" REPETIER_VERSION " FIRMWARE_URL:https://github.com/repetier/Repetier-Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Core_XY EXTRUDER_COUNT:" XSTR(NUM_EXTRUDER) " REPETIER_PROTOCOL:3")
#endif
#endif
FSTRINGVALUE(Com::tDebug,"Debug:")
FSTRINGVALUE(Com::tOk,"ok")
FSTRINGVALUE(Com::tNewline,"\r\n")
FSTRINGVALUE(Com::tNAN,"NAN")
FSTRINGVALUE(Com::tINF,"INF")
FSTRINGVALUE(Com::tError,"Error:")
FSTRINGVALUE(Com::tInfo,"Info:")
FSTRINGVALUE(Com::tWarning,"Warning:")
FSTRINGVALUE(Com::tResend,"Resend:")
FSTRINGVALUE(Com::tEcho,"Echo:")
FSTRINGVALUE(Com::tOkSpace,"ok ")
FSTRINGVALUE(Com::tWrongChecksum,"Wrong checksum")
FSTRINGVALUE(Com::tMissingChecksum,"Missing checksum")
FSTRINGVALUE(Com::tFormatError,"Format error")
FSTRINGVALUE(Com::tDonePrinting,"Done printing file")
FSTRINGVALUE(Com::tX," X")
FSTRINGVALUE(Com::tY," Y")
FSTRINGVALUE(Com::tZ," Z")
FSTRINGVALUE(Com::tE," E")
FSTRINGVALUE(Com::tF," F")
FSTRINGVALUE(Com::tS," S")
FSTRINGVALUE(Com::tP," P")
FSTRINGVALUE(Com::tI," I")
FSTRINGVALUE(Com::tJ," J")
FSTRINGVALUE(Com::tR," R")
FSTRINGVALUE(Com::tSDReadError,"SD read error")
FSTRINGVALUE(Com::tExpectedLine,"Error:expected line ")
FSTRINGVALUE(Com::tGot," got ")
FSTRINGVALUE(Com::tSkip,"skip ")
FSTRINGVALUE(Com::tBLK,"BLK ")
FSTRINGVALUE(Com::tStart,"start")
FSTRINGVALUE(Com::tPowerUp,"PowerUp")
FSTRINGVALUE(Com::tExternalReset,"External Reset")
FSTRINGVALUE(Com::tBrownOut,"Brown out Reset")
FSTRINGVALUE(Com::tWatchdog,"Watchdog Reset")
FSTRINGVALUE(Com::tSoftwareReset,"Software Reset")
FSTRINGVALUE(Com::tUnknownCommand,"Unknown command:")
FSTRINGVALUE(Com::tFreeRAM,"Free RAM:")
FSTRINGVALUE(Com::tXColon,"X:")
FSTRINGVALUE(Com::tSpaceXColon," X:")
FSTRINGVALUE(Com::tSpaceYColon," Y:")
FSTRINGVALUE(Com::tSpaceZColon," Z:")
FSTRINGVALUE(Com::tSpaceEColon," E:")
FSTRINGVALUE(Com::tTColon,"T:")
FSTRINGVALUE(Com::tSpaceBColon," B:")
FSTRINGVALUE(Com::tSpaceAtColon," @:")
FSTRINGVALUE(Com::tSpaceT," T")
FSTRINGVALUE(Com::tSpaceAt," @")
FSTRINGVALUE(Com::tSpaceBAtColon," B@:")
FSTRINGVALUE(Com::tSpaceRaw," RAW")
FSTRINGVALUE(Com::tColon,":")
FSTRINGVALUE(Com::tSlash,"/")
FSTRINGVALUE(Com::tSpaceSlash," /")
FSTRINGVALUE(Com::tSpeedMultiply,"SpeedMultiply:")
FSTRINGVALUE(Com::tFlowMultiply,"FlowMultiply:")
FSTRINGVALUE(Com::tFanspeed,"Fanspeed:")
FSTRINGVALUE(Com::tPrintedFilament,"Printed filament:")
FSTRINGVALUE(Com::tPrintingTime,"Printing time:")
FSTRINGVALUE(Com::tSpacem,"m ")
FSTRINGVALUE(Com::tSpaceDaysSpace," days ")
FSTRINGVALUE(Com::tSpaceHoursSpace," hours ")
FSTRINGVALUE(Com::tSpaceMin," min")
FSTRINGVALUE(Com::tInvalidArc,"Invalid arc")
FSTRINGVALUE(Com::tComma,",")
FSTRINGVALUE(Com::tSpace," ")
FSTRINGVALUE(Com::tYColon,"Y:")
FSTRINGVALUE(Com::tZColon,"Z:")
FSTRINGVALUE(Com::tE0Colon,"E0:")
FSTRINGVALUE(Com::tE1Colon,"E1:")
FSTRINGVALUE(Com::tMS1MS2Pins,"MS1,MS2 Pins")
FSTRINGVALUE(Com::tSetOutputSpace,"Set output: ")
FSTRINGVALUE(Com::tGetInputSpace,"Get Input: ")
FSTRINGVALUE(Com::tSpaceToSpace," to ")
FSTRINGVALUE(Com::tSpaceIsSpace," is ")
FSTRINGVALUE(Com::tHSpace,"H ")
FSTRINGVALUE(Com::tLSpace,"L ")
FSTRINGVALUE(Com::tXMinColon,"x_min:")
FSTRINGVALUE(Com::tXMaxColon,"x_max:")
FSTRINGVALUE(Com::tYMinColon,"y_min:")
FSTRINGVALUE(Com::tYMaxColon,"y_max:")
FSTRINGVALUE(Com::tZMinColon,"z_min:")
FSTRINGVALUE(Com::tZMaxColon,"z_max:")
FSTRINGVALUE(Com::tZ2MinMaxColon,"z2_minmax:")
FSTRINGVALUE(Com::tJerkColon,"Jerk:")
FSTRINGVALUE(Com::tZJerkColon," ZJerk:")
FSTRINGVALUE(Com::tLinearStepsColon," linear steps:")
FSTRINGVALUE(Com::tQuadraticStepsColon," quadratic steps:")
FSTRINGVALUE(Com::tCommaSpeedEqual,", speed=")
FSTRINGVALUE(Com::tEEPROMUpdated,"EEPROM updated")
FSTRINGVALUE(Com::tLinearLColon,"linear L:")
FSTRINGVALUE(Com::tQuadraticKColon," quadratic K:")
FSTRINGVALUE(Com::tExtruderJam, UI_TEXT_EXTRUDER_JAM)
FSTRINGVALUE(Com::tFilamentSlipping,"Filament slipping")
FSTRINGVALUE(Com::tPauseCommunication,"// action:pause")
FSTRINGVALUE(Com::tContinueCommunication,"// action:resume")
#if DRIVE_SYSTEM == DELTA
FSTRINGVALUE(Com::tMeasurementReset,"Measurement reset.")
FSTRINGVALUE(Com::tMeasureDeltaSteps,"Measure/delta (Steps) =")
FSTRINGVALUE(Com::tMeasureDelta,"Measure/delta =")
FSTRINGVALUE(Com::tMeasureOriginReset,"Measured origin set. Measurement reset.")
FSTRINGVALUE(Com::tMeasurementAbortedOrigin,"Origin measurement cannot be set. Use only Z-Cartesian (straight up and down) movements and try again.")
FSTRINGVALUE(Com::tInvalidDeltaCoordinate,"Invalid delta coordinate - move ignored")
FSTRINGVALUE(Com::tLevelingCalc,"Leveling calc:")
FSTRINGVALUE(Com::tTower1,"Tower 1:")
FSTRINGVALUE(Com::tTower2,"Tower 2:")
FSTRINGVALUE(Com::tTower3,"Tower 3:")
FSTRINGVALUE(Com::tDeltaAlphaA,"Alpha A(210):")
FSTRINGVALUE(Com::tDeltaAlphaB,"Alpha B(330):")
FSTRINGVALUE(Com::tDeltaAlphaC,"Alpha C(90):")
FSTRINGVALUE(Com::tDeltaRadiusCorrectionA,"Delta Radius A(0):")
FSTRINGVALUE(Com::tDeltaRadiusCorrectionB,"Delta Radius B(0):")
FSTRINGVALUE(Com::tDeltaRadiusCorrectionC,"Delta Radius C(0):")
FSTRINGVALUE(Com::tDBGDeltaNoMoveinDSegment,"No move in delta segment with > 1 segment. This should never happen and may cause a problem!")
#endif // DRIVE_SYSTEM
#if DRIVE_SYSTEM==TUGA
FSTRINGVALUE(Com::tInvalidDeltaCoordinate,"Invalid coordinate - move ignored")
FSTRINGVALUE(Com::tDBGDeltaNoMoveinDSegment,"No move in delta segment with > 1 segment. This should never happen and may cause a problem!")
FSTRINGVALUE(Com::tEPRDiagonalRodLength,"Long arm length [mm]")
#endif // DRIVE_SYSTEM
#ifdef DEBUG_GENERIC
FSTRINGVALUE(Com::tGenTemp,"GenTemp:")
#endif // DEBUG_GENERICFSTRINGVALUE(Com::,"")
FSTRINGVALUE(Com::tTargetExtr,"TargetExtr")
FSTRINGVALUE(Com::tTargetBedColon,"TargetBed:")
FSTRINGVALUE(Com::tPIDAutotuneStart,"PID Autotune start")
FSTRINGVALUE(Com::tAPIDBias," bias: ")
FSTRINGVALUE(Com::tAPIDD," d: ")
FSTRINGVALUE(Com::tAPIDMin," min: ")
FSTRINGVALUE(Com::tAPIDMax," max: ")
FSTRINGVALUE(Com::tAPIDKu," Ku: ")
FSTRINGVALUE(Com::tAPIDTu," Tu: ")
FSTRINGVALUE(Com::tAPIDClassic," Classic PID")
FSTRINGVALUE(Com::tAPIDKp," Kp: ")
FSTRINGVALUE(Com::tAPIDKi," Ki: ")
FSTRINGVALUE(Com::tAPIDKd," Kd: ")
FSTRINGVALUE(Com::tAPIDFailedHigh,"PID Autotune failed! Temperature to high")
FSTRINGVALUE(Com::tAPIDFailedTimeout,"PID Autotune failed! timeout")
FSTRINGVALUE(Com::tAPIDFinished,"PID Autotune finished ! Place the Kp, Ki and Kd constants in the Configuration.h or EEPROM")
FSTRINGVALUE(Com::tMTEMPColon,"MTEMP:")
FSTRINGVALUE(Com::tHeatedBed,"heated bed")
FSTRINGVALUE(Com::tExtruderSpace,"extruder ")
FSTRINGVALUE(Com::tTempSensorDefect,": temp sensor defect")
FSTRINGVALUE(Com::tTempSensorWorking,": working")
FSTRINGVALUE(Com::tDryModeUntilRestart,"Printer set into dry run mode until restart!")
#ifdef DEBUG_QUEUE_MOVE
FSTRINGVALUE(Com::tDBGId,"ID:")
FSTRINGVALUE(Com::tDBGVStartEnd,"vStart/End:")
FSTRINGVALUE(Com::tDBAccelSteps,"accel/decel steps:")
FSTRINGVALUE(Com::tDBGStartEndSpeed,"st./end speed:")
FSTRINGVALUE(Com::tDBGFlags,"Flags:")
FSTRINGVALUE(Com::tDBGJoinFlags,"joinFlags:")
FSTRINGVALUE(Com::tDBGDelta,"Delta")
FSTRINGVALUE(Com::tDBGDir,"Dir:")
FSTRINGVALUE(Com::tDBGFullSpeed,"fullSpeed:")
FSTRINGVALUE(Com::tDBGVMax,"vMax:")
FSTRINGVALUE(Com::tDBGAcceleration,"Acceleration:")
FSTRINGVALUE(Com::tDBGAccelerationPrim,"Acceleration Prim:")
FSTRINGVALUE(Com::tDBGRemainingSteps,"Remaining steps:")
FSTRINGVALUE(Com::tDBGAdvanceFull,"advanceFull:")
FSTRINGVALUE(Com::tDBGAdvanceRate,"advanceRate:")
FSTRINGVALUE(Com::tDBGLimitInterval,"LimitInterval:")
FSTRINGVALUE(Com::tDBGMoveDistance,"Move distance on the XYZ space:")
FSTRINGVALUE(Com::tDBGCommandedFeedrate,"Commanded feedrate:")
FSTRINGVALUE(Com::tDBGConstFullSpeedMoveTime,"Constant full speed move time:")
#endif // DEBUG_QUEUE_MOVEFSTRINGVALUE(Com::,"")
#ifdef DEBUG_DELTA_OVERFLOW
FSTRINGVALUE(Com::tDBGDeltaOverflow,"Delta overflow:")
#endif // DEBUG_DELTA_OVERFLOW
#ifdef DEBUG_SPLIT
FSTRINGVALUE(Com::tDBGDeltaSeconds,"Seconds:")
FSTRINGVALUE(Com::tDBGDeltaZDelta,"Z delta:")
FSTRINGVALUE(Com::tDBGDeltaSegments,"Segments:")
FSTRINGVALUE(Com::tDBGDeltaNumLines,"Num lines:")
FSTRINGVALUE(Com::tDBGDeltaSegmentsPerLine,"segments_per_line:")
FSTRINGVALUE(Com::tDBGDeltaMaxDS,"Max DS:")
FSTRINGVALUE(Com::tDBGDeltaStepsPerSegment,"Steps Per Segment:")
FSTRINGVALUE(Com::tDBGDeltaVirtualAxisSteps,"Virtual axis steps:")
#endif
#ifdef DEBUG_STEPCOUNT
FSTRINGVALUE(Com::tDBGMissedSteps,"Missed steps:")
#endif // DEBUG_STEPCOUNT
#if FEATURE_Z_PROBE
FSTRINGVALUE(Com::tZProbe,"Z-probe:")
FSTRINGVALUE(Com::tZProbeAverage,"Z-probe average height:")
FSTRINGVALUE(Com::tZProbeZReset,"Reset Z height")
FSTRINGVALUE(Com::tZProbeState,"Z-probe state:")
FSTRINGVALUE(Com::tZProbeStartScript,Z_PROBE_START_SCRIPT)
FSTRINGVALUE(Com::tZProbeEndScript,Z_PROBE_FINISHED_SCRIPT)
FSTRINGVALUE(Com::tHitZProbe,"Hit z-probe")
#endif
FSTRINGVALUE(Com::tAutolevelReset,"Autolevel matrix reset")
FSTRINGVALUE(Com::tAutolevelEnabled,"Autoleveling enabled")
FSTRINGVALUE(Com::tAutolevelDisabled,"Autoleveling disabled")
FSTRINGVALUE(Com::tTransformationMatrix,"Transformation matrix:")
FSTRINGVALUE(Com::tZProbeFailed,"Z-probe failed")
FSTRINGVALUE(Com::tZProbeMax,"Z-probe max:")
FSTRINGVALUE(Com::tZProbePrinterHeight,"Printer height:")
//FSTRINGVALUE(Com::,"")
#ifdef WAITING_IDENTIFIER
FSTRINGVALUE(Com::tWait,WAITING_IDENTIFIER)
#endif // WAITING_IDENTIFIER
#if EEPROM_MODE == 0
FSTRINGVALUE(Com::tNoEEPROMSupport,"No EEPROM support compiled.\r\n")
#else
#if FEATURE_Z_PROBE
FSTRINGVALUE(Com::tZProbeHeight,"Z-probe height [mm]")
FSTRINGVALUE(Com::tZProbeBedDitance,"Max. z-probe - bed dist. [mm]")
FSTRINGVALUE(Com::tZProbeOffsetX,"Z-probe offset x [mm]")
FSTRINGVALUE(Com::tZProbeOffsetY,"Z-probe offset y [mm]")
FSTRINGVALUE(Com::tZProbeSpeed,"Z-probe speed [mm/s]")
FSTRINGVALUE(Com::tZProbeSpeedXY,"Z-probe x-y-speed [mm/s]")
FSTRINGVALUE(Com::tZProbeX1,"Z-probe X1")
FSTRINGVALUE(Com::tZProbeY1,"Z-probe Y1")
FSTRINGVALUE(Com::tZProbeX2,"Z-probe X2")
FSTRINGVALUE(Com::tZProbeY2,"Z-probe Y2")
FSTRINGVALUE(Com::tZProbeX3,"Z-probe X3")
FSTRINGVALUE(Com::tZProbeY3,"Z-probe Y3")
#endif
#if FEATURE_AXISCOMP
FSTRINGVALUE(Com::tAxisCompTanXY,"tanXY Axis Compensation")
FSTRINGVALUE(Com::tAxisCompTanYZ,"tanYZ Axis Compensation")
FSTRINGVALUE(Com::tAxisCompTanXZ,"tanXZ Axis Compensation")
#endif
#if FEATURE_AUTOLEVEL
FSTRINGVALUE(Com::tAutolevelActive,"Autolevel active (1/0)")
#endif
FSTRINGVALUE(Com::tConfigStoredEEPROM,"Configuration stored to EEPROM.")
FSTRINGVALUE(Com::tConfigLoadedEEPROM,"Configuration loaded from EEPROM.")
FSTRINGVALUE(Com::tEPRConfigResetDefaults,"Configuration reset to defaults.")
FSTRINGVALUE(Com::tEPRProtocolChanged,"Protocol version changed, upgrading")
FSTRINGVALUE(Com::tEPR0,"EPR:0 ")
FSTRINGVALUE(Com::tEPR1,"EPR:1 ")
FSTRINGVALUE(Com::tEPR2,"EPR:2 ")
FSTRINGVALUE(Com::tEPR3,"EPR:3 ")
FSTRINGVALUE(Com::tEPRBaudrate,"Baudrate")
FSTRINGVALUE(Com::tEPRFilamentPrinted,"Filament printed [m]")
FSTRINGVALUE(Com::tEPRPrinterActive,"Printer active [s]")
FSTRINGVALUE(Com::tEPRMaxInactiveTime,"Max. inactive time [ms,0=off]")
FSTRINGVALUE(Com::tEPRStopAfterInactivty,"Stop stepper after inactivity [ms,0=off]")
FSTRINGVALUE(Com::tEPRXHomePos,"X min pos [mm]")
FSTRINGVALUE(Com::tEPRYHomePos,"Y min pos [mm]")
FSTRINGVALUE(Com::tEPRZHomePos,"Z min pos [mm]")
FSTRINGVALUE(Com::tEPRXMaxLength,"X max length [mm]")
FSTRINGVALUE(Com::tEPRYMaxLength,"Y max length [mm]")
FSTRINGVALUE(Com::tEPRZMaxLength,"Z max length [mm]")
FSTRINGVALUE(Com::tEPRXBacklash,"X backlash [mm]")
FSTRINGVALUE(Com::tEPRYBacklash,"Y backlash [mm]")
FSTRINGVALUE(Com::tEPRZBacklash,"Z backlash [mm]")
FSTRINGVALUE(Com::tEPRMaxJerk,"Max. jerk [mm/s]")
#if DRIVE_SYSTEM==DELTA
FSTRINGVALUE(Com::tEPRZAcceleration,"Acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRZTravelAcceleration,"Travel acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRZStepsPerMM,"Steps per mm")
FSTRINGVALUE(Com::tEPRZMaxFeedrate,"Max. feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRZHomingFeedrate,"Homing feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRDiagonalRodLength,"Diagonal rod length [mm]")
FSTRINGVALUE(Com::tEPRHorizontalRadius,"Horizontal rod radius at 0,0 [mm]")
FSTRINGVALUE(Com::tEPRSegmentsPerSecondPrint,"Segments/s for printing")
FSTRINGVALUE(Com::tEPRSegmentsPerSecondTravel,"Segments/s for travel")
FSTRINGVALUE(Com::tEPRTowerXOffset,"Tower X endstop offset [steps]")
FSTRINGVALUE(Com::tEPRTowerYOffset,"Tower Y endstop offset [steps]")
FSTRINGVALUE(Com::tEPRTowerZOffset,"Tower Z endstop offset [steps]")
FSTRINGVALUE(Com::tEPRDeltaMaxRadius,"Max printable radius [mm]")
FSTRINGVALUE(Com::tDeltaDiagonalCorrectionA,"Corr. diagonal A [mm]")
FSTRINGVALUE(Com::tDeltaDiagonalCorrectionB,"Corr. diagonal B [mm]")
FSTRINGVALUE(Com::tDeltaDiagonalCorrectionC,"Corr. diagonal C [mm]")
#else
FSTRINGVALUE(Com::tEPRMaxZJerk,"Max. Z-jerk [mm/s]")
FSTRINGVALUE(Com::tEPRXStepsPerMM,"X-axis steps per mm")
FSTRINGVALUE(Com::tEPRYStepsPerMM,"Y-axis steps per mm")
FSTRINGVALUE(Com::tEPRZStepsPerMM,"Z-axis steps per mm")
FSTRINGVALUE(Com::tEPRXMaxFeedrate,"X-axis max. feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRYMaxFeedrate,"Y-axis max. feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRZMaxFeedrate,"Z-axis max. feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRXHomingFeedrate,"X-axis homing feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRYHomingFeedrate,"Y-axis homing feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRZHomingFeedrate,"Z-axis homing feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRXAcceleration,"X-axis acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRYAcceleration,"Y-axis acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRZAcceleration,"Z-axis acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRXTravelAcceleration,"X-axis travel acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRYTravelAcceleration,"Y-axis travel acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRZTravelAcceleration,"Z-axis travel acceleration [mm/s^2]")
#endif
FSTRINGVALUE(Com::tEPROPSMode,"OPS operation mode [0=Off,1=Classic,2=Fast]")
FSTRINGVALUE(Com::tEPROPSMoveAfter,"OPS move after x% retract [%]")
FSTRINGVALUE(Com::tEPROPSMinDistance,"OPS min. distance for fil. retraction [mm]")
FSTRINGVALUE(Com::tEPROPSRetractionLength,"OPS retraction length [mm]")
FSTRINGVALUE(Com::tEPROPSRetractionBacklash,"OPS retraction backlash [mm]")
FSTRINGVALUE(Com::tEPRBedHeatManager,"Bed Heat Manager [0-3]")
FSTRINGVALUE(Com::tEPRBedPIDDriveMax,"Bed PID drive max")
FSTRINGVALUE(Com::tEPRBedPIDDriveMin,"Bed PID drive min")
FSTRINGVALUE(Com::tEPRBedPGain,"Bed PID P-gain")
FSTRINGVALUE(Com::tEPRBedIGain,"Bed PID I-gain")
FSTRINGVALUE(Com::tEPRBedDGain,"Bed PID D-gain")
FSTRINGVALUE(Com::tEPRBedPISMaxValue,"Bed PID max value [0-255]")
FSTRINGVALUE(Com::tEPRStepsPerMM,"steps per mm")
FSTRINGVALUE(Com::tEPRMaxFeedrate,"max. feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRStartFeedrate,"start feedrate [mm/s]")
FSTRINGVALUE(Com::tEPRAcceleration,"acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRHeatManager,"heat manager [0-3]")
FSTRINGVALUE(Com::tEPRDriveMax,"PID drive max")
FSTRINGVALUE(Com::tEPRDriveMin,"PID drive min")
FSTRINGVALUE(Com::tEPRPGain,"PID P-gain/dead-time")
FSTRINGVALUE(Com::tEPRDead,"Heater dead-time")
FSTRINGVALUE(Com::tEPRUnused,"na for dead time ctrl")
FSTRINGVALUE(Com::tEPRIGain,"PID I-gain")
FSTRINGVALUE(Com::tEPRDGain,"PID D-gain")
FSTRINGVALUE(Com::tEPRPIDMaxValue,"PID max value [0-255]")
FSTRINGVALUE(Com::tEPRXOffset,"X-offset [steps]")
FSTRINGVALUE(Com::tEPRYOffset,"Y-offset [steps]")
FSTRINGVALUE(Com::tEPRZOffset,"Z-offset [steps]")
FSTRINGVALUE(Com::tEPRStabilizeTime,"temp. stabilize time [s]")
FSTRINGVALUE(Com::tEPRRetractionWhenHeating,"temp. for retraction when heating [C]")
FSTRINGVALUE(Com::tEPRDistanceRetractHeating,"distance to retract when heating [mm]")
FSTRINGVALUE(Com::tEPRExtruderCoolerSpeed,"extruder cooler speed [0-255]")
FSTRINGVALUE(Com::tEPRAdvanceK,"advance K [0=off]")
FSTRINGVALUE(Com::tEPRAdvanceL,"advance L [0=off]")
#endif
#if SDSUPPORT
FSTRINGVALUE(Com::tSDRemoved,UI_TEXT_SD_REMOVED)
FSTRINGVALUE(Com::tSDInserted,UI_TEXT_SD_INSERTED)
FSTRINGVALUE(Com::tSDInitFail,"SD init fail")
FSTRINGVALUE(Com::tErrorWritingToFile,"error writing to file")
FSTRINGVALUE(Com::tBeginFileList,"Begin file list")
FSTRINGVALUE(Com::tEndFileList,"End file list")
FSTRINGVALUE(Com::tFileOpened,"File opened:")
FSTRINGVALUE(Com::tSpaceSizeColon," Size:")
FSTRINGVALUE(Com::tFileSelected,"File selected")
FSTRINGVALUE(Com::tFileOpenFailed,"file.open failed")
FSTRINGVALUE(Com::tSDPrintingByte,"SD printing byte ")
FSTRINGVALUE(Com::tNotSDPrinting,"Not SD printing")
FSTRINGVALUE(Com::tOpenFailedFile,"open failed, File: ")
FSTRINGVALUE(Com::tWritingToFile,"Writing to file: ")
FSTRINGVALUE(Com::tDoneSavingFile,"Done saving file.")
FSTRINGVALUE(Com::tFileDeleted,"File deleted")
FSTRINGVALUE(Com::tDeletionFailed,"Deletion failed")
FSTRINGVALUE(Com::tDirectoryCreated,"Directory created")
FSTRINGVALUE(Com::tCreationFailed,"Creation failed")
FSTRINGVALUE(Com::tSDErrorCode,"SD errorCode:")
#endif // SDSUPPORT
FSTRINGVALUE(Com::tHeaterDecoupled,"Heater decoupled")
FSTRINGVALUE(Com::tHeaterDecoupledWarning,"One heater seems decoupled from thermistor - disabling all for safety!")
#if DISTORTION_CORRECTION
FSTRINGVALUE(Com::tZCorrectionEnabled,"Z correction enabled")
FSTRINGVALUE(Com::tZCorrectionDisabled,"Z correction disabled")
#endif
#if FEATURE_RETRACTION
FSTRINGVALUE(Com::tEPRAutoretractEnabled,"Enable retraction conversion [0/1]")
FSTRINGVALUE(Com::tEPRRetractionLength,"Retraction length [mm]")
FSTRINGVALUE(Com::tEPRRetractionLongLength,"Retraction length extruder switch [mm]")
FSTRINGVALUE(Com::tEPRRetractionSpeed,"Retraction speed [mm/s]")
FSTRINGVALUE(Com::tEPRRetractionZLift,"Retraction z-lift [mm]")
FSTRINGVALUE(Com::tEPRRetractionUndoExtraLength,"Extra extrusion on undo retract [mm]")
FSTRINGVALUE(Com::tEPRRetractionUndoExtraLongLength,"Extra extrusion on undo switch retract [mm]")
FSTRINGVALUE(Com::tEPRRetractionUndoSpeed,"Retraction undo speed")
#endif
FSTRINGVALUE(Com::tConfig,"Config:")
FSTRINGVALUE(Com::tExtrDot,"Extr.")
#if STEPPER_CURRENT_CONTROL == CURRENT_CONTROL_MCP4728
FSTRINGVALUE(Com::tMCPEpromSettings, "MCP4728 DAC EEPROM Settings:")
FSTRINGVALUE(Com::tMCPCurrentSettings,"MCP4728 DAC Current Settings:")
#endif
void Com::config(FSTRINGPARAM(text)) {
printF(tConfig);
printFLN(text);
}
void Com::config(FSTRINGPARAM(text),int value) {
printF(tConfig);
printFLN(text,value);
}
void Com::config(FSTRINGPARAM(text),const char *msg) {
printF(tConfig);
printF(text);
print(msg);
println();
}
void Com::config(FSTRINGPARAM(text),int32_t value){
printF(tConfig);
printFLN(text,value);
}
void Com::config(FSTRINGPARAM(text),uint32_t value){
printF(tConfig);
printFLN(text,value);
}
void Com::config(FSTRINGPARAM(text),float value,uint8_t digits){
printF(tConfig);
printFLN(text,value,digits);
}
void Com::printWarningF(FSTRINGPARAM(text)) {
printF(tWarning);
printF(text);
}
void Com::printWarningFLN(FSTRINGPARAM(text)) {
printF(tWarning);
printFLN(text);
}
void Com::printInfoF(FSTRINGPARAM(text)) {
printF(tInfo);
printF(text);
}
void Com::printInfoFLN(FSTRINGPARAM(text)) {
printF(tInfo);
printFLN(text);
}
void Com::printErrorF(FSTRINGPARAM(text)) {
printF(tError);
printF(text);
}
void Com::printErrorFLN(FSTRINGPARAM(text)) {
printF(tError);
printFLN(text);
}
void Com::printFLN(FSTRINGPARAM(text)) {
printF(text);
println();
}
void Com::printFLN(FSTRINGPARAM(text),const char *msg) {
printF(text);
print(msg);
println();
}
void Com::printF(FSTRINGPARAM(ptr)) {
char c;
while ((c = HAL::readFlashByte(ptr++)) != 0)
HAL::serialWriteByte(c);
}
void Com::printF(FSTRINGPARAM(text),const char *msg) {
printF(text);
print(msg);
}
void Com::printF(FSTRINGPARAM(text),int value) {
printF(text);
print(value);
}
void Com::printF(FSTRINGPARAM(text),int32_t value) {
printF(text);
print(value);
}
void Com::printF(FSTRINGPARAM(text),uint32_t value) {
printF(text);
printNumber(value);
}
void Com::printFLN(FSTRINGPARAM(text),int value) {
printF(text);
print(value);
println();
}
void Com::printFLN(FSTRINGPARAM(text),int32_t value) {
printF(text);
print(value);
println();
}
void Com::printFLN(FSTRINGPARAM(text),uint32_t value) {
printF(text);
printNumber(value);
println();
}
void Com::printFLN(FSTRINGPARAM(text),float value,uint8_t digits) {
printF(text);
printFloat(value,digits);
println();
}
void Com::printF(FSTRINGPARAM(text),float value,uint8_t digits) {
printF(text);
printFloat(value,digits);
}
void Com::print(const char *text) {
while(*text) {
HAL::serialWriteByte(*text++);
}
}
void Com::print(long value) {
if(value<0) {
HAL::serialWriteByte('-');
value = -value;
}
printNumber(value);
}
void Com::printNumber(uint32_t n) {
char buf[11]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[10];
*str = '\0';
do {
unsigned long m = n;
n /= 10;
*--str = '0'+(m - 10 * n);
} while(n);
print(str);
}
void Com::printArrayFLN(FSTRINGPARAM(text),float *arr,uint8_t n,uint8_t digits) {
printF(text);
for(uint8_t i=0; i<n; i++)
printF(Com::tSpace,arr[i],digits);
println();
}
void Com::printArrayFLN(FSTRINGPARAM(text),int32_t *arr,uint8_t n) {
printF(text);
for(uint8_t i=0; i<n; i++)
printF(Com::tSpace,arr[i]);
println();
}
void Com::printFloat(float number, uint8_t digits)
{
if (isnan(number)) {
printF(tNAN);
return;
}
if (isinf(number)) {
printF(tINF);
return;
}
// Handle negative numbers
if (number < 0.0)
{
print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
float rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
float remainder = number - (float)int_part;
printNumber(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0)
print('.');
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
int toPrint = int(remainder);
print(toPrint);
remainder -= toPrint;
}
}

448
Repetier/Communication.h Normal file
View file

@ -0,0 +1,448 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
*/
#ifndef COMMUNICATION_H
#define COMMUNICATION_H
class Com
{
public:
FSTRINGVAR(tDebug)
FSTRINGVAR(tFirmware)
FSTRINGVAR(tOk)
FSTRINGVAR(tNewline)
FSTRINGVAR(tNAN)
FSTRINGVAR(tINF)
FSTRINGVAR(tError)
FSTRINGVAR(tInfo)
FSTRINGVAR(tWarning)
FSTRINGVAR(tResend)
FSTRINGVAR(tEcho)
FSTRINGVAR(tOkSpace)
FSTRINGVAR(tWrongChecksum)
FSTRINGVAR(tMissingChecksum)
FSTRINGVAR(tFormatError)
FSTRINGVAR(tDonePrinting)
FSTRINGVAR(tX)
FSTRINGVAR(tY)
FSTRINGVAR(tZ)
FSTRINGVAR(tE)
FSTRINGVAR(tF)
FSTRINGVAR(tS)
FSTRINGVAR(tP)
FSTRINGVAR(tI)
FSTRINGVAR(tJ)
FSTRINGVAR(tR)
FSTRINGVAR(tSDReadError)
FSTRINGVAR(tExpectedLine)
FSTRINGVAR(tGot)
FSTRINGVAR(tSkip)
FSTRINGVAR(tBLK)
FSTRINGVAR(tStart)
FSTRINGVAR(tPowerUp)
FSTRINGVAR(tExternalReset)
FSTRINGVAR(tBrownOut)
FSTRINGVAR(tWatchdog)
FSTRINGVAR(tSoftwareReset)
FSTRINGVAR(tUnknownCommand)
FSTRINGVAR(tFreeRAM)
FSTRINGVAR(tXColon)
FSTRINGVAR(tSlash)
FSTRINGVAR(tSpaceSlash)
FSTRINGVAR(tSpaceXColon)
FSTRINGVAR(tSpaceYColon)
FSTRINGVAR(tSpaceZColon)
FSTRINGVAR(tSpaceEColon)
FSTRINGVAR(tTColon)
FSTRINGVAR(tSpaceBColon)
FSTRINGVAR(tSpaceAtColon)
FSTRINGVAR(tSpaceT)
FSTRINGVAR(tSpaceRaw)
FSTRINGVAR(tSpaceAt)
FSTRINGVAR(tSpaceBAtColon)
FSTRINGVAR(tColon)
FSTRINGVAR(tSpeedMultiply)
FSTRINGVAR(tFlowMultiply)
FSTRINGVAR(tFanspeed)
FSTRINGVAR(tPrintedFilament)
FSTRINGVAR(tPrintingTime)
FSTRINGVAR(tSpacem)
FSTRINGVAR(tSpaceDaysSpace)
FSTRINGVAR(tSpaceHoursSpace)
FSTRINGVAR(tSpaceMin)
FSTRINGVAR(tInvalidArc)
FSTRINGVAR(tComma)
FSTRINGVAR(tSpace)
FSTRINGVAR(tYColon)
FSTRINGVAR(tZColon)
FSTRINGVAR(tE0Colon)
FSTRINGVAR(tE1Colon)
FSTRINGVAR(tMS1MS2Pins)
FSTRINGVAR(tSetOutputSpace)
FSTRINGVAR(tGetInputSpace)
FSTRINGVAR(tSpaceToSpace)
FSTRINGVAR(tSpaceIsSpace)
FSTRINGVAR(tHSpace)
FSTRINGVAR(tLSpace)
FSTRINGVAR(tXMinColon)
FSTRINGVAR(tXMaxColon)
FSTRINGVAR(tYMinColon)
FSTRINGVAR(tYMaxColon)
FSTRINGVAR(tZMinColon)
FSTRINGVAR(tZ2MinMaxColon)
FSTRINGVAR(tZMaxColon)
FSTRINGVAR(tJerkColon)
FSTRINGVAR(tZJerkColon)
FSTRINGVAR(tLinearStepsColon)
FSTRINGVAR(tQuadraticStepsColon)
FSTRINGVAR(tCommaSpeedEqual)
FSTRINGVAR(tLinearLColon)
FSTRINGVAR(tQuadraticKColon)
FSTRINGVAR(tEEPROMUpdated)
FSTRINGVAR(tExtruderJam)
FSTRINGVAR(tFilamentSlipping)
FSTRINGVAR(tPauseCommunication)
FSTRINGVAR(tContinueCommunication)
#if DRIVE_SYSTEM == DELTA
FSTRINGVAR(tMeasurementReset)
FSTRINGVAR(tMeasureDeltaSteps)
FSTRINGVAR(tMeasureDelta)
FSTRINGVAR(tMeasureOriginReset)
FSTRINGVAR(tMeasurementAbortedOrigin)
FSTRINGVAR(tInvalidDeltaCoordinate)
FSTRINGVAR(tLevelingCalc)
FSTRINGVAR(tTower1)
FSTRINGVAR(tTower2)
FSTRINGVAR(tTower3)
FSTRINGVAR(tDeltaAlphaA)
FSTRINGVAR(tDeltaAlphaB)
FSTRINGVAR(tDeltaAlphaC)
FSTRINGVAR(tDeltaRadiusCorrectionA)
FSTRINGVAR(tDeltaRadiusCorrectionB)
FSTRINGVAR(tDeltaRadiusCorrectionC)
FSTRINGVAR(tDeltaDiagonalCorrectionA)
FSTRINGVAR(tDeltaDiagonalCorrectionB)
FSTRINGVAR(tDeltaDiagonalCorrectionC)
FSTRINGVAR(tDBGDeltaNoMoveinDSegment)
FSTRINGVAR(tEPRDeltaMaxRadius)
#endif // DRIVE_SYSTEM
#if DRIVE_SYSTEM==TUGA
FSTRINGVAR(tInvalidDeltaCoordinate)
FSTRINGVAR(tDBGDeltaNoMoveinDSegment)
FSTRINGVAR(tEPRDiagonalRodLength)
#endif
#ifdef DEBUG_GENERIC
FSTRINGVAR(tGenTemp)
#endif // DEBUG_GENERICFSTRINGVALUE(Com::,"")
FSTRINGVAR(tTargetExtr)
FSTRINGVAR(tTargetBedColon)
FSTRINGVAR(tPIDAutotuneStart)
FSTRINGVAR(tAPIDBias)
FSTRINGVAR(tAPIDD)
FSTRINGVAR(tAPIDMin)
FSTRINGVAR(tAPIDMax)
FSTRINGVAR(tAPIDKu)
FSTRINGVAR(tAPIDTu)
FSTRINGVAR(tAPIDClassic)
FSTRINGVAR(tAPIDKp)
FSTRINGVAR(tAPIDKi)
FSTRINGVAR(tAPIDKd)
FSTRINGVAR(tAPIDFailedHigh)
FSTRINGVAR(tAPIDFailedTimeout)
FSTRINGVAR(tAPIDFinished)
FSTRINGVAR(tMTEMPColon)
FSTRINGVAR(tHeatedBed)
FSTRINGVAR(tExtruderSpace)
FSTRINGVAR(tTempSensorDefect)
FSTRINGVAR(tTempSensorWorking)
FSTRINGVAR(tDryModeUntilRestart)
#ifdef DEBUG_QUEUE_MOVE
FSTRINGVAR(tDBGId)
FSTRINGVAR(tDBGVStartEnd)
FSTRINGVAR(tDBAccelSteps)
FSTRINGVAR(tDBGStartEndSpeed)
FSTRINGVAR(tDBGFlags)
FSTRINGVAR(tDBGJoinFlags)
FSTRINGVAR(tDBGDelta)
FSTRINGVAR(tDBGDir)
FSTRINGVAR(tDBGFullSpeed)
FSTRINGVAR(tDBGVMax)
FSTRINGVAR(tDBGAcceleration)
FSTRINGVAR(tDBGAccelerationPrim)
FSTRINGVAR(tDBGRemainingSteps)
FSTRINGVAR(tDBGAdvanceFull)
FSTRINGVAR(tDBGAdvanceRate)
FSTRINGVAR(tDBGLimitInterval)
FSTRINGVAR(tDBGMoveDistance)
FSTRINGVAR(tDBGCommandedFeedrate)
FSTRINGVAR(tDBGConstFullSpeedMoveTime)
#endif // DEBUG_QUEUE_MOVEFSTRINGVALUE(Com::,"")
#ifdef DEBUG_DELTA_OVERFLOW
FSTRINGVAR(tDBGDeltaOverflow)
#endif // DEBUG_DELTA_OVERFLOW
#ifdef DEBUG_SPLIT
FSTRINGVAR(tDBGDeltaSeconds)
FSTRINGVAR(tDBGDeltaZDelta)
FSTRINGVAR(tDBGDeltaSegments)
FSTRINGVAR(tDBGDeltaNumLines)
FSTRINGVAR(tDBGDeltaSegmentsPerLine)
FSTRINGVAR(tDBGDeltaMaxDS)
FSTRINGVAR(tDBGDeltaStepsPerSegment)
FSTRINGVAR(tDBGDeltaVirtualAxisSteps)
#endif
#ifdef DEBUG_STEPCOUNT
FSTRINGVAR(tDBGMissedSteps)
#endif
#if FEATURE_Z_PROBE
FSTRINGVAR(tZProbe)
FSTRINGVAR(tZProbeState)
FSTRINGVAR(tZProbeStartScript)
FSTRINGVAR(tZProbeEndScript)
FSTRINGVAR(tHitZProbe)
FSTRINGVAR(tZProbeAverage)
FSTRINGVAR(tZProbeZReset)
FSTRINGVAR(tZProbeBedDitance)
#endif
FSTRINGVAR(tAutolevelReset)
FSTRINGVAR(tAutolevelEnabled)
FSTRINGVAR(tAutolevelDisabled)
FSTRINGVAR(tTransformationMatrix)
FSTRINGVAR(tZProbeFailed)
FSTRINGVAR(tZProbeMax)
FSTRINGVAR(tZProbePrinterHeight)
#ifdef WAITING_IDENTIFIER
FSTRINGVAR(tWait)
#endif // WAITING_IDENTIFIER
#if EEPROM_MODE==0
FSTRINGVAR(tNoEEPROMSupport)
#else
#if FEATURE_Z_PROBE
FSTRINGVAR(tZProbeHeight)
FSTRINGVAR(tZProbeOffsetX)
FSTRINGVAR(tZProbeOffsetY)
FSTRINGVAR(tZProbeSpeed)
FSTRINGVAR(tZProbeSpeedXY)
FSTRINGVAR(tZProbeX1)
FSTRINGVAR(tZProbeY1)
FSTRINGVAR(tZProbeX2)
FSTRINGVAR(tZProbeY2)
FSTRINGVAR(tZProbeX3)
FSTRINGVAR(tZProbeY3)
#endif
#if FEATURE_AUTOLEVEL
FSTRINGVAR(tAutolevelActive)
#endif
#if FEATURE_AXISCOMP
FSTRINGVAR(tAxisCompTanXY)
FSTRINGVAR(tAxisCompTanYZ)
FSTRINGVAR(tAxisCompTanXZ)
#endif
FSTRINGVAR(tConfigStoredEEPROM)
FSTRINGVAR(tConfigLoadedEEPROM)
FSTRINGVAR(tEPRConfigResetDefaults)
FSTRINGVAR(tEPRProtocolChanged)
FSTRINGVAR(tEPR0)
FSTRINGVAR(tEPR1)
FSTRINGVAR(tEPR2)
FSTRINGVAR(tEPR3)
FSTRINGVAR(tEPRBaudrate)
FSTRINGVAR(tEPRFilamentPrinted)
FSTRINGVAR(tEPRPrinterActive)
FSTRINGVAR(tEPRMaxInactiveTime)
FSTRINGVAR(tEPRStopAfterInactivty)
FSTRINGVAR(tEPRMaxJerk)
FSTRINGVAR(tEPRXHomePos)
FSTRINGVAR(tEPRYHomePos)
FSTRINGVAR(tEPRZHomePos)
FSTRINGVAR(tEPRXMaxLength)
FSTRINGVAR(tEPRYMaxLength)
FSTRINGVAR(tEPRZMaxLength)
FSTRINGVAR(tEPRXBacklash)
FSTRINGVAR(tEPRYBacklash)
FSTRINGVAR(tEPRZBacklash)
FSTRINGVAR(tEPRZAcceleration)
FSTRINGVAR(tEPRZTravelAcceleration)
FSTRINGVAR(tEPRZStepsPerMM)
FSTRINGVAR(tEPRZMaxFeedrate)
FSTRINGVAR(tEPRZHomingFeedrate)
#if DRIVE_SYSTEM!=DELTA
FSTRINGVAR(tEPRMaxZJerk)
FSTRINGVAR(tEPRXStepsPerMM)
FSTRINGVAR(tEPRYStepsPerMM)
FSTRINGVAR(tEPRXMaxFeedrate)
FSTRINGVAR(tEPRYMaxFeedrate)
FSTRINGVAR(tEPRXHomingFeedrate)
FSTRINGVAR(tEPRYHomingFeedrate)
FSTRINGVAR(tEPRXAcceleration)
FSTRINGVAR(tEPRYAcceleration)
FSTRINGVAR(tEPRXTravelAcceleration)
FSTRINGVAR(tEPRYTravelAcceleration)
#else
FSTRINGVAR(tEPRDiagonalRodLength)
FSTRINGVAR(tEPRHorizontalRadius)
FSTRINGVAR(tEPRSegmentsPerSecondPrint)
FSTRINGVAR(tEPRSegmentsPerSecondTravel)
FSTRINGVAR(tEPRTowerXOffset)
FSTRINGVAR(tEPRTowerYOffset)
FSTRINGVAR(tEPRTowerZOffset)
#endif
FSTRINGVAR(tEPROPSMode)
FSTRINGVAR(tEPROPSMoveAfter)
FSTRINGVAR(tEPROPSMinDistance)
FSTRINGVAR(tEPROPSRetractionLength)
FSTRINGVAR(tEPROPSRetractionBacklash)
FSTRINGVAR(tEPRBedHeatManager)
FSTRINGVAR(tEPRBedPIDDriveMax)
FSTRINGVAR(tEPRBedPIDDriveMin)
FSTRINGVAR(tEPRBedPGain)
FSTRINGVAR(tEPRBedIGain)
FSTRINGVAR(tEPRBedDGain)
FSTRINGVAR(tEPRBedPISMaxValue)
FSTRINGVAR(tEPRStepsPerMM)
FSTRINGVAR(tEPRMaxFeedrate)
FSTRINGVAR(tEPRStartFeedrate)
FSTRINGVAR(tEPRAcceleration)
FSTRINGVAR(tEPRHeatManager)
FSTRINGVAR(tEPRDriveMax)
FSTRINGVAR(tEPRDriveMin)
FSTRINGVAR(tEPRPGain)
FSTRINGVAR(tEPRDead)
FSTRINGVAR(tEPRUnused)
FSTRINGVAR(tEPRIGain)
FSTRINGVAR(tEPRDGain)
FSTRINGVAR(tEPRPIDMaxValue)
FSTRINGVAR(tEPRXOffset)
FSTRINGVAR(tEPRYOffset)
FSTRINGVAR(tEPRZOffset)
FSTRINGVAR(tEPRStabilizeTime)
FSTRINGVAR(tEPRRetractionWhenHeating)
FSTRINGVAR(tEPRDistanceRetractHeating)
FSTRINGVAR(tEPRExtruderCoolerSpeed)
FSTRINGVAR(tEPRAdvanceK)
FSTRINGVAR(tEPRAdvanceL)
#endif
#if SDSUPPORT
FSTRINGVAR(tSDRemoved)
FSTRINGVAR(tSDInserted)
FSTRINGVAR(tSDInitFail)
FSTRINGVAR(tErrorWritingToFile)
FSTRINGVAR(tBeginFileList)
FSTRINGVAR(tEndFileList)
FSTRINGVAR(tFileOpened)
FSTRINGVAR(tSpaceSizeColon)
FSTRINGVAR(tFileSelected)
FSTRINGVAR(tFileOpenFailed)
FSTRINGVAR(tSDPrintingByte)
FSTRINGVAR(tNotSDPrinting)
FSTRINGVAR(tOpenFailedFile)
FSTRINGVAR(tWritingToFile)
FSTRINGVAR(tDoneSavingFile)
FSTRINGVAR(tFileDeleted)
FSTRINGVAR(tDeletionFailed)
FSTRINGVAR(tDirectoryCreated)
FSTRINGVAR(tCreationFailed)
FSTRINGVAR(tSDErrorCode)
#endif // SDSUPPORT
FSTRINGVAR(tHeaterDecoupled)
FSTRINGVAR(tHeaterDecoupledWarning)
#if DISTORTION_CORRECTION
FSTRINGVAR(tZCorrectionEnabled)
FSTRINGVAR(tZCorrectionDisabled)
#endif
#if FEATURE_RETRACTION
FSTRINGVAR(tEPRAutoretractEnabled)
FSTRINGVAR(tEPRRetractionLength)
FSTRINGVAR(tEPRRetractionLongLength)
FSTRINGVAR(tEPRRetractionSpeed)
FSTRINGVAR(tEPRRetractionZLift)
FSTRINGVAR(tEPRRetractionUndoExtraLength)
FSTRINGVAR(tEPRRetractionUndoExtraLongLength)
FSTRINGVAR(tEPRRetractionUndoSpeed)
#endif
FSTRINGVAR(tConfig)
FSTRINGVAR(tExtrDot)
#if STEPPER_CURRENT_CONTROL == CURRENT_CONTROL_MCP4728
FSTRINGVAR(tMCPEpromSettings)
FSTRINGVAR(tMCPCurrentSettings)
#endif
static void config(FSTRINGPARAM(text));
static void config(FSTRINGPARAM(text),int value);
static void config(FSTRINGPARAM(text),const char *msg);
static void config(FSTRINGPARAM(text),int32_t value);
static void config(FSTRINGPARAM(text),uint32_t value);
static void config(FSTRINGPARAM(text),float value,uint8_t digits=2);
static void printNumber(uint32_t n);
static void printWarningF(FSTRINGPARAM(text));
static void printInfoF(FSTRINGPARAM(text));
static void printErrorF(FSTRINGPARAM(text));
static void printWarningFLN(FSTRINGPARAM(text));
static void printInfoFLN(FSTRINGPARAM(text));
static void printErrorFLN(FSTRINGPARAM(text));
static void printFLN(FSTRINGPARAM(text));
static void printF(FSTRINGPARAM(text));
static void printF(FSTRINGPARAM(text),int value);
static void printF(FSTRINGPARAM(text),const char *msg);
static void printF(FSTRINGPARAM(text),int32_t value);
static void printF(FSTRINGPARAM(text),uint32_t value);
static void printF(FSTRINGPARAM(text),float value,uint8_t digits=2);
static void printFLN(FSTRINGPARAM(text),int value);
static void printFLN(FSTRINGPARAM(text),int32_t value);
static void printFLN(FSTRINGPARAM(text),uint32_t value);
static void printFLN(FSTRINGPARAM(text),const char *msg);
static void printFLN(FSTRINGPARAM(text),float value,uint8_t digits=2);
static void printArrayFLN(FSTRINGPARAM(text),float *arr,uint8_t n=4,uint8_t digits=2);
static void printArrayFLN(FSTRINGPARAM(text),long *arr,uint8_t n=4);
static void print(long value);
static inline void print(uint32_t value) {printNumber(value);}
static inline void print(int value) {print((int32_t)value);}
static void print(const char *text);
static inline void print(char c) {HAL::serialWriteByte(c);}
static void printFloat(float number, uint8_t digits);
static inline void print(float number) {printFloat(number, 6);}
static inline void println() {HAL::serialWriteByte('\r');HAL::serialWriteByte('\n');}
protected:
private:
};
#ifdef DEBUG
#define SHOW(x) {Com::printF(PSTR(" " #x "=")); Com::print(x); Com::println();}
#define SHOWS(x) {Com::printF(PSTR(" " #x "=")); Com::print(x); Com::print(" steps "); Com::print(x/80); Com::printFLN(PSTR(" mm"));}
#define SHOWM(x) {Com::printF(PSTR(" " #x "=")); Com::print((long)x*80); Com::print(" steps "); Com::print(x); Com::printFLN(PSTR(" mm"));}
#define SHOT(x) Com::printF(PSTR(x " "))
#define SHOWA(t,a,n) {SHOT(t); for (int i=0;i<n;i++) SHOWS(a[i]);}
#define SHOWAM(t,a,n) {SHOT(t); for (int i=0;i<n;i++) SHOWM(a[i]);}
#else
#define SHOW(x)
#define SHOT(x)
#define SHOWS(x)
#define SHOWM(x)
#define SHOWA(t,a,n)
#define SHOWAM(t,a,n)
#endif
#endif // COMMUNICATION_H

983
Repetier/Configuration.h Normal file
View file

@ -0,0 +1,983 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
/**************** READ FIRST ************************
This configuration file was created with the configuration tool. For that
reason, it does not contain the same informations as the original Configuration.h file.
It misses the comments and unused parts. Open this file file in the config tool
to see and change the data. You can also upload it to newer/older versions. The system
will silently add new options, so compilation continues to work.
This file is optimized for version 0.92
generator: http://www.repetier.com/firmware/v092/
If you are in doubt which named functions use which pins on your board, please check the
pins.h for the used name->pin assignments and your board documentation to verify it is
as you expect.
*/
#define NUM_EXTRUDER 2
#define MOTHERBOARD 33
#include "pins.h"
// ################## EDIT THESE SETTINGS MANUALLY ################
// ################ END MANUAL SETTINGS ##########################
#define FAN_PIN -1
#define FAN_BOARD_PIN -1
//#define EXTERNALSERIAL use Arduino serial library instead of build in. Requires more ram, has only 63 byte input buffer.
// Uncomment the following line if you are using arduino compatible firmware made for Arduino version earlier then 1.0
// If it is incompatible you will get compiler errors about write functions not beeing compatible!
//#define COMPAT_PRE1
#define BLUETOOTH_SERIAL -1
#define BLUETOOTH_BAUD 115200
#define MIXING_EXTRUDER 0
#define DRIVE_SYSTEM 0
#define XAXIS_STEPS_PER_MM 200
#define YAXIS_STEPS_PER_MM 200
#define ZAXIS_STEPS_PER_MM 200
#define EXTRUDER_FAN_COOL_TEMP 50
#define PDM_FOR_EXTRUDER 0
#define PDM_FOR_COOLER 0
#define DECOUPLING_TEST_MAX_HOLD_VARIANCE 20
#define DECOUPLING_TEST_MIN_TEMP_RISE 1
#define KILL_IF_SENSOR_DEFECT 0
#define RETRACT_ON_PAUSE 2
#define PAUSE_START_COMMANDS ""
#define PAUSE_END_COMMANDS ""
#define EXT0_X_OFFSET 0
#define EXT0_Y_OFFSET 2800
#define EXT0_Z_OFFSET 0
#define EXT0_STEPS_PER_MM 1000
#define EXT0_TEMPSENSOR_TYPE 8
#define EXT0_TEMPSENSOR_PIN TEMP_0_PIN
#define EXT0_HEATER_PIN HEATER_0_PIN
#define EXT0_STEP_PIN ORIG_E0_STEP_PIN
#define EXT0_DIR_PIN ORIG_E0_DIR_PIN
#define EXT0_INVERSE 0
#define EXT0_ENABLE_PIN E0_ENABLE_PIN
#define EXT0_ENABLE_ON 0
#define EXT0_MAX_FEEDRATE 50
#define EXT0_MAX_START_FEEDRATE 20
#define EXT0_MAX_ACCELERATION 5000
#define EXT0_HEAT_MANAGER 1
#define EXT0_WATCHPERIOD 1
#define EXT0_PID_INTEGRAL_DRIVE_MAX 230
#define EXT0_PID_INTEGRAL_DRIVE_MIN 40
#define EXT0_PID_PGAIN_OR_DEAD_TIME 46.74
#define EXT0_PID_I 9.51
#define EXT0_PID_D 57.44
#define EXT0_PID_MAX 255
#define EXT0_ADVANCE_K 0
#define EXT0_ADVANCE_L 0
#define EXT0_ADVANCE_BACKLASH_STEPS 0
#define EXT0_WAIT_RETRACT_TEMP 150
#define EXT0_WAIT_RETRACT_UNITS 0
#define EXT0_SELECT_COMMANDS ""
#define EXT0_DESELECT_COMMANDS ""
#define EXT0_EXTRUDER_COOLER_PIN -1
#define EXT0_EXTRUDER_COOLER_SPEED 255
#define EXT0_DECOUPLE_TEST_PERIOD 12000
#define EXT0_JAM_PIN -1
#define EXT0_JAM_PULLUP 0
#define EXT1_X_OFFSET 0
#define EXT1_Y_OFFSET -2800
#define EXT1_Z_OFFSET 0
#define EXT1_STEPS_PER_MM 1000
#define EXT1_TEMPSENSOR_TYPE 8
#define EXT1_TEMPSENSOR_PIN TEMP_2_PIN
#define EXT1_HEATER_PIN HEATER_2_PIN
#define EXT1_STEP_PIN ORIG_E1_STEP_PIN
#define EXT1_DIR_PIN ORIG_E1_DIR_PIN
#define EXT1_INVERSE 0
#define EXT1_ENABLE_PIN E1_ENABLE_PIN
#define EXT1_ENABLE_ON 0
#define EXT1_MAX_FEEDRATE 50
#define EXT1_MAX_START_FEEDRATE 20
#define EXT1_MAX_ACCELERATION 5000
#define EXT1_HEAT_MANAGER 1
#define EXT1_WATCHPERIOD 1
#define EXT1_PID_INTEGRAL_DRIVE_MAX 230
#define EXT1_PID_INTEGRAL_DRIVE_MIN 40
#define EXT1_PID_PGAIN_OR_DEAD_TIME 25.74
#define EXT1_PID_I 2.97
#define EXT1_PID_D 55.74
#define EXT1_PID_MAX 255
#define EXT1_ADVANCE_K 0
#define EXT1_ADVANCE_L 0
#define EXT1_ADVANCE_BACKLASH_STEPS 0
#define EXT1_WAIT_RETRACT_TEMP 150
#define EXT1_WAIT_RETRACT_UNITS 0
#define EXT1_SELECT_COMMANDS ""
#define EXT1_DESELECT_COMMANDS ""
#define EXT1_EXTRUDER_COOLER_PIN -1
#define EXT1_EXTRUDER_COOLER_SPEED 255
#define EXT1_DECOUPLE_TEST_PERIOD 12000
#define EXT1_JAM_PIN -1
#define EXT1_JAM_PULLUP 0
#define FEATURE_RETRACTION 0
#define AUTORETRACT_ENABLED 0
#define RETRACTION_LENGTH 3
#define RETRACTION_LONG_LENGTH 13
#define RETRACTION_SPEED 40
#define RETRACTION_Z_LIFT 0
#define RETRACTION_UNDO_EXTRA_LENGTH 0
#define RETRACTION_UNDO_EXTRA_LONG_LENGTH 0
#define RETRACTION_UNDO_SPEED 20
#define FILAMENTCHANGE_X_POS 0
#define FILAMENTCHANGE_Y_POS 0
#define FILAMENTCHANGE_Z_ADD 2
#define FILAMENTCHANGE_REHOME 1
#define FILAMENTCHANGE_SHORTRETRACT 5
#define FILAMENTCHANGE_LONGRETRACT 50
#define JAM_STEPS 220
#define JAM_SLOWDOWN_STEPS 320
#define JAM_SLOWDOWN_TO 70
#define JAM_ERROR_STEPS 500
#define JAM_MIN_STEPS 10
#define JAM_ACTION 0
#define RETRACT_DURING_HEATUP true
#define PID_CONTROL_RANGE 20
#define SKIP_M109_IF_WITHIN 2
#define SCALE_PID_TO_MAX 0
#define TEMP_HYSTERESIS 0
#define EXTRUDE_MAXLENGTH 500
#define NUM_TEMPS_USERTHERMISTOR0 0
#define USER_THERMISTORTABLE0 {}
#define NUM_TEMPS_USERTHERMISTOR1 0
#define USER_THERMISTORTABLE1 {}
#define NUM_TEMPS_USERTHERMISTOR2 0
#define USER_THERMISTORTABLE2 {}
#define GENERIC_THERM_VREF 5
#define GENERIC_THERM_NUM_ENTRIES 33
#define HEATER_PWM_SPEED 0
// ############# Heated bed configuration ########################
#define HAVE_HEATED_BED 1
#define HEATED_BED_MAX_TEMP 80
#define SKIP_M190_IF_WITHIN 3
#define HEATED_BED_SENSOR_TYPE 1
#define HEATED_BED_SENSOR_PIN TEMP_1_PIN
#define HEATED_BED_HEATER_PIN HEATER_1_PIN
#define HEATED_BED_SET_INTERVAL 5000
#define HEATED_BED_HEAT_MANAGER 0
#define HEATED_BED_PID_INTEGRAL_DRIVE_MAX 255
#define HEATED_BED_PID_INTEGRAL_DRIVE_MIN 80
#define HEATED_BED_PID_PGAIN_OR_DEAD_TIME 196
#define HEATED_BED_PID_IGAIN 33
#define HEATED_BED_PID_DGAIN 290
#define HEATED_BED_PID_MAX 255
#define HEATED_BED_DECOUPLE_TEST_PERIOD 300000
#define MIN_EXTRUDER_TEMP 150
#define MAXTEMP 285
#define MIN_DEFECT_TEMPERATURE -10
#define MAX_DEFECT_TEMPERATURE 290
// ################ Endstop configuration #####################
#define ENDSTOP_PULLUP_X_MIN true
#define ENDSTOP_X_MIN_INVERTING true
#define MIN_HARDWARE_ENDSTOP_X true
#define ENDSTOP_PULLUP_Y_MIN true
#define ENDSTOP_Y_MIN_INVERTING true
#define MIN_HARDWARE_ENDSTOP_Y true
#define ENDSTOP_PULLUP_Z_MIN true
#define ENDSTOP_Z_MIN_INVERTING false
#define MIN_HARDWARE_ENDSTOP_Z false
#define ENDSTOP_PULLUP_X_MAX true
#define ENDSTOP_X_MAX_INVERTING false
#define MAX_HARDWARE_ENDSTOP_X false
#define ENDSTOP_PULLUP_Y_MAX true
#define ENDSTOP_Y_MAX_INVERTING false
#define MAX_HARDWARE_ENDSTOP_Y false
#define ENDSTOP_PULLUP_Z_MAX true
#define ENDSTOP_Z_MAX_INVERTING true
#define MAX_HARDWARE_ENDSTOP_Z true
#define max_software_endstop_r true
#define min_software_endstop_x false
#define min_software_endstop_y false
#define min_software_endstop_z true
#define max_software_endstop_x true
#define max_software_endstop_y true
#define max_software_endstop_z false
#define ENDSTOP_X_BACK_MOVE 5
#define ENDSTOP_Y_BACK_MOVE 5
#define ENDSTOP_Z_BACK_MOVE 2
#define ENDSTOP_X_RETEST_REDUCTION_FACTOR 3
#define ENDSTOP_Y_RETEST_REDUCTION_FACTOR 3
#define ENDSTOP_Z_RETEST_REDUCTION_FACTOR 3
#define ENDSTOP_X_BACK_ON_HOME 1
#define ENDSTOP_Y_BACK_ON_HOME 1
#define ENDSTOP_Z_BACK_ON_HOME 0
#define ALWAYS_CHECK_ENDSTOPS 0
// ################# XYZ movements ###################
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define DISABLE_X 0
#define DISABLE_Y 0
#define DISABLE_Z 0
#define DISABLE_E 0
#define INVERT_X_DIR 0
#define INVERT_Y_DIR 0
#define INVERT_Z_DIR 0
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR 1
#define X_MAX_LENGTH 200
#define Y_MAX_LENGTH 180
#define Z_MAX_LENGTH 135
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define DISTORTION_CORRECTION 0
#define DISTORTION_CORRECTION_POINTS 5
#define DISTORTION_CORRECTION_R 100
#define DISTORTION_PERMANENT 1
#define DISTORTION_UPDATE_FREQUENCY 15
#define DISTORTION_START_DEGRADE 0.5
#define DISTORTION_END_HEIGHT 1
#define DISTORTION_EXTRAPOLATE_CORNERS 0
// ##########################################################################################
// ## Movement settings ##
// ##########################################################################################
#define FEATURE_BABYSTEPPING 1
#define BABYSTEP_MULTIPLICATOR 1
#define DELTA_SEGMENTS_PER_SECOND_PRINT 180 // Move accurate setting for print moves
#define DELTA_SEGMENTS_PER_SECOND_MOVE 70 // Less accurate setting for other moves
#define EXACT_DELTA_MOVES 1
// Delta settings
#define DELTA_HOME_ON_POWER 0
#define DELTASEGMENTS_PER_PRINTLINE 24
#define STEPPER_INACTIVE_TIME 60L
#define MAX_INACTIVE_TIME 0L
#define MAX_FEEDRATE_X 200
#define MAX_FEEDRATE_Y 200
#define MAX_FEEDRATE_Z 100
#define HOMING_FEEDRATE_X 100
#define HOMING_FEEDRATE_Y 100
#define HOMING_FEEDRATE_Z 50
#define HOMING_ORDER HOME_ORDER_ZXY
#define ZHOME_MIN_TEMPERATURE 0
#define ZHOME_HEAT_ALL 1
#define ZHOME_HEAT_HEIGHT 20
#define ZHOME_X_POS 999999
#define ZHOME_Y_POS 999999
#define ENABLE_BACKLASH_COMPENSATION 0
#define X_BACKLASH 0
#define Y_BACKLASH 0
#define Z_BACKLASH 0
#define RAMP_ACCELERATION 1
#define STEPPER_HIGH_DELAY 0
#define DIRECTION_DELAY 0
#define STEP_DOUBLER_FREQUENCY 12000
#define ALLOW_QUADSTEPPING 1
#define DOUBLE_STEP_DELAY 0 // time in microseconds
#define MAX_ACCELERATION_UNITS_PER_SQ_SECOND_X 1000
#define MAX_ACCELERATION_UNITS_PER_SQ_SECOND_Y 1000
#define MAX_ACCELERATION_UNITS_PER_SQ_SECOND_Z 500
#define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_X 1000
#define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_Y 1000
#define MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_Z 500
#define MAX_JERK 20
#define MAX_ZJERK 0.3
#define PRINTLINE_CACHE_SIZE 16
#define MOVE_CACHE_LOW 10
#define LOW_TICKS_PER_MOVE 250000
#define FEATURE_TWO_XSTEPPER 0
#define X2_STEP_PIN ORIG_E1_STEP_PIN
#define X2_DIR_PIN ORIG_E1_DIR_PIN
#define X2_ENABLE_PIN E1_ENABLE_PIN
#define FEATURE_TWO_YSTEPPER 0
#define Y2_STEP_PIN ORIG_E1_STEP_PIN
#define Y2_DIR_PIN ORIG_E1_DIR_PIN
#define Y2_ENABLE_PIN E1_ENABLE_PIN
#define FEATURE_TWO_ZSTEPPER 0
#define Z2_STEP_PIN ORIG_E1_STEP_PIN
#define Z2_DIR_PIN ORIG_E1_DIR_PIN
#define Z2_ENABLE_PIN E1_ENABLE_PIN
#define FEATURE_DITTO_PRINTING 0
#define USE_ADVANCE 0
#define ENABLE_QUADRATIC_ADVANCE 0
// ################# Misc. settings ##################
#define BAUDRATE 115200
#define ENABLE_POWER_ON_STARTUP 1
#define POWER_INVERTING 0
#define KILL_METHOD 1
#define ACK_WITH_LINENUMBER 1
#define WAITING_IDENTIFIER "wait"
#define ECHO_ON_EXECUTE 1
#define EEPROM_MODE 0
#define PS_ON_PIN ORIG_PS_ON_PIN
/* ======== Servos =======
Control the servos with
M340 P<servoId> S<pulseInUS> / ServoID = 0..3 pulseInUs = 500..2500
Servos are controlled by a pulse width normally between 500 and 2500 with 1500ms in center position. 0 turns servo off.
WARNING: Servos can draw a considerable amount of current. Make sure your system can handle this or you may risk your hardware!
*/
#define FEATURE_SERVO 0
#define SERVO0_PIN 11
#define SERVO1_PIN -1
#define SERVO2_PIN -1
#define SERVO3_PIN -1
#define SERVO0_NEUTRAL_POS -1
#define SERVO1_NEUTRAL_POS -1
#define SERVO2_NEUTRAL_POS -1
#define SERVO3_NEUTRAL_POS -1
#define UI_SERVO_CONTROL 0
#define FAN_KICKSTART_TIME 200
#define FEATURE_WATCHDOG 1
// #################### Z-Probing #####################
#define Z_PROBE_Z_OFFSET 0
#define Z_PROBE_Z_OFFSET_MODE 0
#define UI_BED_COATING 1
#define FEATURE_Z_PROBE 1
#define Z_PROBE_BED_DISTANCE 10
#define Z_PROBE_PIN ORIG_Z_MIN_PIN
#define Z_PROBE_PULLUP 1
#define Z_PROBE_ON_HIGH 1
#define Z_PROBE_X_OFFSET 6.4
#define Z_PROBE_Y_OFFSET 0
#define Z_PROBE_WAIT_BEFORE_TEST 0
#define Z_PROBE_SPEED 8
#define Z_PROBE_XY_SPEED 150
#define Z_PROBE_SWITCHING_DISTANCE 1
#define Z_PROBE_REPETITIONS 1
#define Z_PROBE_HEIGHT 7.4
#define Z_PROBE_START_SCRIPT ""
#define Z_PROBE_FINISHED_SCRIPT ""
#define FEATURE_AUTOLEVEL 1
#define Z_PROBE_X1 20
#define Z_PROBE_Y1 20
#define Z_PROBE_X2 160
#define Z_PROBE_Y2 20
#define Z_PROBE_X3 100
#define Z_PROBE_Y3 160
#define FEATURE_AXISCOMP 0
#define AXISCOMP_TANXY 0
#define AXISCOMP_TANYZ 0
#define AXISCOMP_TANXZ 0
#ifndef SDSUPPORT // Some boards have sd support on board. These define the values already in pins.h
#define SDSUPPORT 0
#define SDCARDDETECT -1
#define SDCARDDETECTINVERTED 0
#endif
#define SD_EXTENDED_DIR 1 /** Show extended directory including file length. Don't use this with Pronterface! */
#define SD_RUN_ON_STOP ""
#define SD_STOP_HEATER_AND_MOTORS_ON_STOP 1
#define ARC_SUPPORT 1
#define FEATURE_MEMORY_POSITION 0
#define FEATURE_CHECKSUM_FORCED 0
#define FEATURE_FAN_CONTROL 0
#define FEATURE_CONTROLLER 0
#define UI_LANGUAGE 0
#define UI_PRINTER_NAME "RepRap"
#define UI_PRINTER_COMPANY "Home made"
#define UI_PAGES_DURATION 4000
#define UI_ANIMATION 0
#define UI_SPEEDDEPENDENT_POSITIONING 0
#define UI_DISABLE_AUTO_PAGESWITCH 1
#define UI_AUTORETURN_TO_MENU_AFTER 30000
#define FEATURE_UI_KEYS 0
#define UI_ENCODER_SPEED 1
#define UI_REVERSE_ENCODER 0
#define UI_KEY_BOUNCETIME 10
#define UI_KEY_FIRST_REPEAT 500
#define UI_KEY_REDUCE_REPEAT 50
#define UI_KEY_MIN_REPEAT 50
#define FEATURE_BEEPER 0
#define CASE_LIGHTS_PIN -1
#define CASE_LIGHT_DEFAULT_ON 1
#define UI_START_SCREEN_DELAY 1000
#define UI_DYNAMIC_ENCODER_SPEED 1
/**
Beeper sound definitions for short beeps during key actions
and longer beeps for important actions.
Parameter is delay in microseconds and the secons is the number of repetitions.
Values must be in range 1..255
*/
#define BEEPER_SHORT_SEQUENCE 2,2
#define BEEPER_LONG_SEQUENCE 8,8
#define UI_SET_PRESET_HEATED_BED_TEMP_PLA 60
#define UI_SET_PRESET_EXTRUDER_TEMP_PLA 190
#define UI_SET_PRESET_HEATED_BED_TEMP_ABS 110
#define UI_SET_PRESET_EXTRUDER_TEMP_ABS 240
#define UI_SET_MIN_HEATED_BED_TEMP 30
#define UI_SET_MAX_HEATED_BED_TEMP 120
#define UI_SET_MIN_EXTRUDER_TEMP 170
#define UI_SET_MAX_EXTRUDER_TEMP 260
#define UI_SET_EXTRUDER_FEEDRATE 2
#define UI_SET_EXTRUDER_RETRACT_DISTANCE 3
#define NUM_MOTOR_DRIVERS 0
#endif
/* Below you will find the configuration string, that created this Configuration.h
========== Start configuration string ==========
{
"editMode": 2,
"processor": 0,
"baudrate": 115200,
"bluetoothSerial": -1,
"bluetoothBaudrate": 115200,
"xStepsPerMM": 200,
"yStepsPerMM": 200,
"zStepsPerMM": 200,
"xInvert": 0,
"xInvertEnable": 0,
"eepromMode": 0,
"yInvert": 0,
"yInvertEnable": 0,
"zInvert": 0,
"zInvertEnable": 0,
"extruder": [
{
"id": 0,
"heatManager": 1,
"pidDriveMin": 40,
"pidDriveMax": 230,
"pidMax": 255,
"sensorType": 8,
"sensorPin": "TEMP_0_PIN",
"heaterPin": "HEATER_0_PIN",
"maxFeedrate": 50,
"startFeedrate": 20,
"invert": "0",
"invertEnable": "0",
"acceleration": 5000,
"watchPeriod": 1,
"pidP": 46.74,
"pidI": 9.51,
"pidD": 57.44,
"advanceK": 0,
"advanceL": 0,
"waitRetractTemp": 150,
"waitRetractUnits": 0,
"waitRetract": 0,
"stepsPerMM": 1000,
"coolerPin": -1,
"coolerSpeed": 255,
"selectCommands": "",
"deselectCommands": "",
"xOffset": 0,
"yOffset": 14,
"zOffset": 0,
"xOffsetSteps": 0,
"yOffsetSteps": 2800,
"zOffsetSteps": 0,
"stepper": {
"name": "Extruder 0",
"step": "ORIG_E0_STEP_PIN",
"dir": "ORIG_E0_DIR_PIN",
"enable": "E0_ENABLE_PIN"
},
"advanceBacklashSteps": 0,
"decoupleTestPeriod": 12,
"jamPin": -1,
"jamPullup": "0"
},
{
"id": 1,
"heatManager": 1,
"pidDriveMin": 40,
"pidDriveMax": 230,
"pidMax": 255,
"sensorType": 8,
"sensorPin": "TEMP_2_PIN",
"heaterPin": "HEATER_2_PIN",
"maxFeedrate": 50,
"startFeedrate": 20,
"invert": "0",
"invertEnable": "0",
"acceleration": 5000,
"watchPeriod": 1,
"pidP": 25.74,
"pidI": 2.97,
"pidD": 55.74,
"advanceK": 0,
"advanceL": 0,
"waitRetractTemp": 150,
"waitRetractUnits": 0,
"waitRetract": 0,
"stepsPerMM": 1000,
"coolerPin": -1,
"coolerSpeed": 255,
"selectCommands": "",
"deselectCommands": "",
"xOffset": 0,
"yOffset": -14,
"zOffset": 0,
"xOffsetSteps": 0,
"yOffsetSteps": -2800,
"zOffsetSteps": 0,
"stepper": {
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
},
"advanceBacklashSteps": 0,
"decoupleTestPeriod": 12,
"jamPin": -1,
"jamPullup": "0"
}
],
"uiLanguage": 0,
"uiController": 0,
"xMinEndstop": 1,
"yMinEndstop": 1,
"zMinEndstop": 0,
"xMaxEndstop": 0,
"yMaxEndstop": 0,
"zMaxEndstop": 1,
"motherboard": 33,
"driveSystem": 0,
"xMaxSpeed": 200,
"xHomingSpeed": 100,
"xTravelAcceleration": 1000,
"xPrintAcceleration": 1000,
"yMaxSpeed": 200,
"yHomingSpeed": 100,
"yTravelAcceleration": 1000,
"yPrintAcceleration": 1000,
"zMaxSpeed": 100,
"zHomingSpeed": 50,
"zTravelAcceleration": 500,
"zPrintAcceleration": 500,
"xMotor": {
"name": "X motor",
"step": "ORIG_X_STEP_PIN",
"dir": "ORIG_X_DIR_PIN",
"enable": "ORIG_X_ENABLE_PIN"
},
"yMotor": {
"name": "Y motor",
"step": "ORIG_Y_STEP_PIN",
"dir": "ORIG_Y_DIR_PIN",
"enable": "ORIG_Y_ENABLE_PIN"
},
"zMotor": {
"name": "Z motor",
"step": "ORIG_Z_STEP_PIN",
"dir": "ORIG_Z_DIR_PIN",
"enable": "ORIG_Z_ENABLE_PIN"
},
"enableBacklash": "0",
"backlashX": 0,
"backlashY": 0,
"backlashZ": 0,
"stepperInactiveTime": 60,
"maxInactiveTime": 0,
"xMinPos": 0,
"yMinPos": 0,
"zMinPos": 0,
"xLength": 200,
"yLength": 180,
"zLength": 135,
"alwaysCheckEndstops": "0",
"disableX": "0",
"disableY": "0",
"disableZ": "0",
"disableE": "0",
"xHomeDir": "-1",
"yHomeDir": "-1",
"zHomeDir": "1",
"xEndstopBack": 1,
"yEndstopBack": 1,
"zEndstopBack": 0,
"deltaSegmentsPerSecondPrint": 180,
"deltaSegmentsPerSecondTravel": 70,
"deltaDiagonalRod": 445,
"deltaHorizontalRadius": 209.25,
"deltaAlphaA": 210,
"deltaAlphaB": 330,
"deltaAlphaC": 90,
"deltaDiagonalCorrA": 0,
"deltaDiagonalCorrB": 0,
"deltaDiagonalCorrC": 0,
"deltaMaxRadius": 150,
"deltaFloorSafetyMarginMM": 15,
"deltaRadiusCorrA": 0,
"deltaRadiusCorrB": 0,
"deltaRadiusCorrC": 0,
"deltaXOffsetSteps": 0,
"deltaYOffsetSteps": 0,
"deltaZOffsetSteps": 0,
"deltaSegmentsPerLine": 24,
"stepperHighDelay": 0,
"directionDelay": 0,
"stepDoublerFrequency": 12000,
"allowQuadstepping": "1",
"doubleStepDelay": 0,
"maxJerk": 20,
"maxZJerk": 0.3,
"moveCacheSize": 16,
"moveCacheLow": 10,
"lowTicksPerMove": 250000,
"enablePowerOnStartup": "1",
"echoOnExecute": "1",
"sendWaits": "1",
"ackWithLineNumber": "1",
"killMethod": 1,
"useAdvance": "0",
"useQuadraticAdvance": "0",
"powerInverting": 0,
"mirrorX": 0,
"mirrorXMotor": {
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
},
"mirrorY": 0,
"mirrorYMotor": {
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
},
"mirrorZ": 0,
"mirrorZMotor": {
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
},
"dittoPrinting": "0",
"featureServos": "0",
"servo0Pin": 11,
"servo1Pin": -1,
"servo2Pin": -1,
"servo3Pin": -1,
"featureWatchdog": "1",
"hasHeatedBed": "1",
"enableZProbing": "1",
"extrudeMaxLength": 500,
"homeOrder": "HOME_ORDER_ZXY",
"featureController": 0,
"uiPrinterName": "RepRap",
"uiPrinterCompany": "Home made",
"uiPagesDuration": 4000,
"uiAnimation": "0",
"uiDisablePageswitch": "1",
"uiAutoReturnAfter": 30000,
"featureKeys": "0",
"uiEncoderSpeed": 1,
"uiReverseEncoder": "0",
"uiKeyBouncetime": 10,
"uiKeyFirstRepeat": 500,
"uiKeyReduceRepeat": 50,
"uiKeyMinRepeat": 50,
"featureBeeper": "0",
"uiPresetBedTempPLA": 60,
"uiPresetBedABS": 110,
"uiPresetExtruderPLA": 190,
"uiPresetExtruderABS": 240,
"uiMinHeatedBed": 30,
"uiMaxHeatedBed": 120,
"uiMinEtxruderTemp": 170,
"uiMaxExtruderTemp": 260,
"uiExtruderFeedrate": 2,
"uiExtruderRetractDistance": 3,
"uiSpeeddependentPositioning": "0",
"maxBedTemperature": 80,
"bedSensorType": 1,
"bedSensorPin": "TEMP_1_PIN",
"bedHeaterPin": "HEATER_1_PIN",
"bedHeatManager": 0,
"bedUpdateInterval": 5000,
"bedPidDriveMin": 80,
"bedPidDriveMax": 255,
"bedPidP": 196,
"bedPidI": 33,
"bedPidD": 290,
"bedPidMax": 255,
"bedDecoupleTestPeriod": 300,
"caseLightPin": -1,
"caseLightDefaultOn": "1",
"bedSkipIfWithin": 3,
"gen1T0": 25,
"gen1R0": 100000,
"gen1Beta": 4036,
"gen1MinTemp": -20,
"gen1MaxTemp": 300,
"gen1R1": 0,
"gen1R2": 4700,
"gen2T0": 25,
"gen2R0": 100000,
"gen2Beta": 4036,
"gen2MinTemp": -20,
"gen2MaxTemp": 300,
"gen2R1": 0,
"gen2R2": 4700,
"gen3T0": 25,
"gen3R0": 100000,
"gen3Beta": 4036,
"gen3MinTemp": -20,
"gen3MaxTemp": 300,
"gen3R1": 0,
"gen3R2": 4700,
"userTable0": {
"r1": 0,
"r2": 4700,
"temps": []
},
"userTable1": {
"r1": 0,
"r2": 4700,
"temps": []
},
"userTable2": {
"r1": 0,
"r2": 4700,
"temps": []
},
"tempHysteresis": 0,
"pidControlRange": 20,
"skipM109Within": 2,
"extruderFanCoolTemp": 50,
"minTemp": 150,
"maxTemp": 285,
"minDefectTemp": -10,
"maxDefectTemp": 290,
"arcSupport": "1",
"featureMemoryPositionWatchdog": "0",
"forceChecksum": "0",
"sdExtendedDir": "1",
"featureFanControl": "0",
"fanPin": -1,
"scalePidToMax": 0,
"zProbePin": "ORIG_Z_MIN_PIN",
"zProbeBedDistance": 10,
"zProbePullup": "1",
"zProbeOnHigh": "1",
"zProbeXOffset": 6.4,
"zProbeYOffset": 0,
"zProbeWaitBeforeTest": "0",
"zProbeSpeed": 8,
"zProbeXYSpeed": 150,
"zProbeHeight": 7.4,
"zProbeStartScript": "",
"zProbeFinishedScript": "",
"featureAutolevel": "1",
"zProbeX1": 20,
"zProbeY1": 20,
"zProbeX2": 160,
"zProbeY2": 20,
"zProbeX3": 100,
"zProbeY3": 160,
"zProbeSwitchingDistance": 1,
"zProbeRepetitions": 1,
"sdSupport": "0",
"sdCardDetectPin": -1,
"sdCardDetectInverted": "0",
"uiStartScreenDelay": 1000,
"xEndstopBackMove": 5,
"yEndstopBackMove": 5,
"zEndstopBackMove": 2,
"xEndstopRetestFactor": 3,
"yEndstopRetestFactor": 3,
"zEndstopRetestFactor": 3,
"xMinPin": "ORIG_X_MIN_PIN",
"yMinPin": "ORIG_Y_MIN_PIN",
"zMinPin": "ORIG_Z_MIN_PIN",
"xMaxPin": "ORIG_X_MAX_PIN",
"yMaxPin": "ORIG_Y_MAX_PIN",
"zMaxPin": "ORIG_Z_MAX_PIN",
"deltaHomeOnPower": "0",
"fanBoardPin": -1,
"heaterPWMSpeed": 0,
"featureBabystepping": "1",
"babystepMultiplicator": 1,
"pdmForHeater": "0",
"pdmForCooler": "0",
"psOn": "ORIG_PS_ON_PIN",
"mixingExtruder": "0",
"decouplingTestMaxHoldVariance": 20,
"decouplingTestMinTempRise": 1,
"featureAxisComp": "0",
"axisCompTanXY": 0,
"axisCompTanXZ": 0,
"axisCompTanYZ": 0,
"retractOnPause": 2,
"pauseStartCommands": "",
"pauseEndCommands": "",
"distortionCorrection": "0",
"distortionCorrectionPoints": 5,
"distortionCorrectionR": 100,
"distortionPermanent": "1",
"distortionUpdateFrequency": 15,
"distortionStartDegrade": 0.5,
"distortionEndDegrade": 1,
"distortionExtrapolateCorners": "0",
"sdRunOnStop": "",
"sdStopHeaterMotorsOnStop": "1",
"featureRetraction": "0",
"autoretractEnabled": "0",
"retractionLength": 3,
"retractionLongLength": 13,
"retractionSpeed": 40,
"retractionZLift": 0,
"retractionUndoExtraLength": 0,
"retractionUndoExtraLongLength": 0,
"retractionUndoSpeed": 20,
"filamentChangeXPos": 0,
"filamentChangeYPos": 0,
"filamentChangeZAdd": 2,
"filamentChangeRehome": 1,
"filamentChangeShortRetract": 5,
"filamentChangeLongRetract": 50,
"fanKickstart": 200,
"servo0StartPos": -1,
"servo1StartPos": -1,
"servo2StartPos": -1,
"servo3StartPos": -1,
"uiDynamicEncoderSpeed": "1",
"uiServoControl": 0,
"killIfSensorDefect": "0",
"jamSteps": 220,
"jamSlowdownSteps": 320,
"jamSlowdownTo": 70,
"jamErrorSteps": 500,
"jamMinSteps": 10,
"jamAction": 0,
"primaryPort": 0,
"numMotorDrivers": 0,
"motorDrivers": [
{
"t": "None",
"s": "",
"invertEnable": "0",
"invertDirection": "0",
"stepsPerMM": 100,
"speed": 10,
"dirPin": -1,
"stepPin": -1,
"enablePin": -1
},
{
"t": "None",
"s": "",
"invertEnable": "0",
"invertDirection": "0",
"stepsPerMM": 100,
"speed": 10,
"dirPin": -1,
"stepPin": -1,
"enablePin": -1
},
{
"t": "None",
"s": "",
"invertEnable": "0",
"invertDirection": "0",
"stepsPerMM": 100,
"speed": 10,
"dirPin": -1,
"stepPin": -1,
"enablePin": -1
},
{
"t": "None",
"s": "",
"invertEnable": "0",
"invertDirection": "0",
"stepsPerMM": 100,
"speed": 10,
"dirPin": -1,
"stepPin": -1,
"enablePin": -1
},
{
"t": "None",
"s": "",
"invertEnable": "0",
"invertDirection": "0",
"stepsPerMM": 100,
"speed": 10,
"dirPin": -1,
"stepPin": -1,
"enablePin": -1
},
{
"t": "None",
"s": "",
"invertEnable": "0",
"invertDirection": "0",
"stepsPerMM": 100,
"speed": 10,
"dirPin": -1,
"stepPin": -1,
"enablePin": -1
}
],
"manualConfig": "",
"zHomeMinTemperature": 0,
"zHomeXPos": 999999,
"zHomeYPos": 999999,
"zHomeHeatHeight": 20,
"zHomeHeatAll": "1",
"zProbeZOffsetMode": 0,
"zProbeZOffset": 0,
"uiBedCoating": "1",
"hasMAX6675": false,
"hasMAX31855": false,
"hasGeneric1": false,
"hasGeneric2": false,
"hasGeneric3": false,
"hasUser0": false,
"hasUser1": false,
"hasUser2": false,
"numExtruder": 2,
"version": 92.4,
"primaryPortName": ""
}
========== End configuration string ==========
*/

102
Repetier/Drivers.cpp Normal file
View file

@ -0,0 +1,102 @@
#include "Repetier.h"
#if defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS > 0
MOTOR_DRIVER_1(motorDriver1);
#if NUM_MOTOR_DRIVERS > 1
MOTOR_DRIVER_2(motorDriver2);
#endif
#if NUM_MOTOR_DRIVERS > 2
MOTOR_DRIVER_3(motorDriver3);
#endif
#if NUM_MOTOR_DRIVERS > 3
MOTOR_DRIVER_4(motorDriver4);
#endif
#if NUM_MOTOR_DRIVERS > 4
MOTOR_DRIVER_5(motorDriver5);
#endif
#if NUM_MOTOR_DRIVERS > 5
MOTOR_DRIVER_6(motorDriver6);
#endif
MotorDriverInterface *motorDrivers[NUM_MOTOR_DRIVERS] = {
&motorDriver1
#if NUM_MOTOR_DRIVERS > 1
, &motorDriver2
#endif
#if NUM_MOTOR_DRIVERS > 2
, &motorDriver3
#endif
#if NUM_MOTOR_DRIVERS > 3
, &motorDriver4
#endif
#if NUM_MOTOR_DRIVERS > 4
, &motorDriver5
#endif
#if NUM_MOTOR_DRIVERS > 5
, &motorDriver6
#endif
};
MotorDriverInterface *getMotorDriver(int idx) {
return motorDrivers[idx];
}
/**
Run motor P until it is at position X
*/
void commandG201(GCode &code) {
int id = 0;
if(code.hasP())
id = code.P;
if(id < 0) id = 0;
if(id >= NUM_MOTOR_DRIVERS) id = 0;
if(!code.hasX()) return;
motorDrivers[id]->gotoPosition(code.X);
}
//G202 P<motorId> X<setpos> - Mark current position as X
void commandG202(GCode &code) {
int id = 0;
if(code.hasP())
id = code.P;
if(id < 0) id = 0;
if(id >= NUM_MOTOR_DRIVERS) id = 0;
if(!code.hasX()) return;
motorDrivers[id]->setCurrentAs(code.X);
}
//G203 P<motorId> - Report current motor position
void commandG203(GCode &code) {
int id = 0;
if(code.hasP())
id = code.P;
if(id < 0) id = 0;
if(id >= NUM_MOTOR_DRIVERS) id = 0;
Com::printF(PSTR("Motor"),id);
Com::printFLN(PSTR("Pos:"),motorDrivers[id]->getPosition());
}
//G204 P<motorId> S<0/1> - Enable/disable motor
void commandG204(GCode &code) {
int id = 0;
if(code.hasP())
id = code.P;
if(id < 0) id = 0;
if(id >= NUM_MOTOR_DRIVERS) id = 0;
if(!code.hasS()) return;
if(code.S)
motorDrivers[id]->enable();
else
motorDrivers[id]->disable();
}
void disableAllMotorDrivers() {
for(int i = 0; i < NUM_MOTOR_DRIVERS; i++)
motorDrivers[i]->disable();
}
void initializeAllMotorDrivers() {
for(int i = 0; i < NUM_MOTOR_DRIVERS; i++)
motorDrivers[i]->initialize();
}
#endif // NUM_MOTOR_DRIVERS

106
Repetier/Drivers.h Normal file
View file

@ -0,0 +1,106 @@
#ifndef DRIVERS_H_INCLUDED
#define DRIVERS_H_INCLUDED
/**
For some special printers you need to control extra motors. Possible reasons are
- Extruder switches
- Clearing surface
- Leveling
Repetier-Firmware supports up to 4 extra motors that can be controlled by
G201 P<motorId> X<pos> - Go to position X with motor X
G202 P<motorId> X<setpos> - Mark current position as X
G203 P<motorId> - Report current motor position
G204 P<motorId> S<0/1> - Enable/disable motor
These motors are already special and there might be different types, so we can not assume
one class fits all needs. So to keep it simple, the firmware defines this general
interface whcih a motor must implement. That way we can handle any type without changing
the main code.
*/
class MotorDriverInterface
{
public:
virtual void initialize() = 0;
virtual float getPosition() = 0;
virtual void setCurrentAs(float newPos) = 0;
virtual void gotoPosition(float newPos) = 0;
virtual void enable() = 0;
virtual void disable() = 0;
};
/**
Simple class to drive a stepper motor with fixed speed.
*/
template<int stepPin, int dirPin, int enablePin,bool invertDir, bool invertEnable>
class StepperDriver : public MotorDriverInterface
{
int32_t position;
int32_t delayUS;
float stepsPerMM;
public:
StepperDriver(float _stepsPerMM,float speed)
{
stepsPerMM = _stepsPerMM;
delayUS = 500000 / (speed * stepsPerMM);
}
void initialize() {
HAL::pinMode(enablePin, OUTPUT);
HAL::pinMode(stepPin, OUTPUT);
HAL::pinMode(dirPin, OUTPUT);
HAL::digitalWrite(enablePin, !invertEnable);
}
float getPosition()
{
return position / stepsPerMM;
}
void setCurrentAs(float newPos)
{
position = floor(newPos * stepsPerMM + 0.5f);
}
void gotoPosition(float newPos)
{
enable();
int32_t target = floor(newPos * stepsPerMM + 0.5f) - position;
position += target;
if(target > 0) {
HAL::digitalWrite(dirPin, !invertDir);
} else {
target = -target;
HAL::digitalWrite(dirPin, invertDir);
}
while(target) {
HAL::digitalWrite(stepPin, HIGH);
HAL::delayMicroseconds(delayUS);
HAL::digitalWrite(stepPin, LOW);
HAL::delayMicroseconds(delayUS);
target--;
HAL::pingWatchdog();
if((target & 127) == 0)
Commands::checkForPeriodicalActions(false);
}
}
void enable()
{
HAL::digitalWrite(enablePin, invertEnable);
}
void disable()
{
HAL::digitalWrite(enablePin, !invertEnable);
}
};
#if defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS > 0
class GCode;
extern void commandG201(GCode &code);
extern void commandG202(GCode &code);
extern void commandG203(GCode &code);
extern void commandG204(GCode &code);
extern void disableAllMotorDrivers();
extern MotorDriverInterface *getMotorDriver(int idx);
extern void initializeAllMotorDrivers();
#endif
#endif // DRIVERS_H_INCLUDED

1096
Repetier/Eeprom.cpp Normal file

File diff suppressed because it is too large Load diff

522
Repetier/Eeprom.h Normal file
View file

@ -0,0 +1,522 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _EEPROM_H
#define _EEPROM_H
// Id to distinguish version changes
#define EEPROM_PROTOCOL_VERSION 13
/** Where to start with our datablock in memory. Can be moved if you
have problems with other modules using the eeprom */
#define EPR_MAGIC_BYTE 0
#define EPR_ACCELERATION_TYPE 1
#define EPR_XAXIS_STEPS_PER_MM 3
#define EPR_YAXIS_STEPS_PER_MM 7
#define EPR_ZAXIS_STEPS_PER_MM 11
#define EPR_X_MAX_FEEDRATE 15
#define EPR_Y_MAX_FEEDRATE 19
#define EPR_Z_MAX_FEEDRATE 23
#define EPR_X_HOMING_FEEDRATE 27
#define EPR_Y_HOMING_FEEDRATE 31
#define EPR_Z_HOMING_FEEDRATE 35
#define EPR_MAX_JERK 39
//#define EPR_OPS_MIN_DISTANCE 43
#define EPR_MAX_ZJERK 47
#define EPR_X_MAX_ACCEL 51
#define EPR_Y_MAX_ACCEL 55
#define EPR_Z_MAX_ACCEL 59
#define EPR_X_MAX_TRAVEL_ACCEL 63
#define EPR_Y_MAX_TRAVEL_ACCEL 67
#define EPR_Z_MAX_TRAVEL_ACCEL 71
#define EPR_BAUDRATE 75
#define EPR_MAX_INACTIVE_TIME 79
#define EPR_STEPPER_INACTIVE_TIME 83
//#define EPR_OPS_RETRACT_DISTANCE 87
//#define EPR_OPS_RETRACT_BACKLASH 91
#define EPR_EXTRUDER_SPEED 95
//#define EPR_OPS_MOVE_AFTER 99
//#define EPR_OPS_MODE 103
#define EPR_INTEGRITY_BYTE 104 // Here the xored sum over eeprom is stored
#define EPR_VERSION 105 // Version id for updates in EEPROM storage
#define EPR_BED_HEAT_MANAGER 106
#define EPR_BED_DRIVE_MAX 107
#define EPR_BED_PID_PGAIN 108
#define EPR_BED_PID_IGAIN 112
#define EPR_BED_PID_DGAIN 116
#define EPR_BED_PID_MAX 120
#define EPR_BED_DRIVE_MIN 124
#define EPR_PRINTING_TIME 125 // Time in seconds printing
#define EPR_PRINTING_DISTANCE 129 // Filament length printed
#define EPR_X_HOME_OFFSET 133
#define EPR_Y_HOME_OFFSET 137
#define EPR_Z_HOME_OFFSET 141
#define EPR_X_LENGTH 145
#define EPR_Y_LENGTH 149
#define EPR_Z_LENGTH 153
#define EPR_BACKLASH_X 157
#define EPR_BACKLASH_Y 161
#define EPR_BACKLASH_Z 165
#define EPR_Z_PROBE_X_OFFSET 800
#define EPR_Z_PROBE_Y_OFFSET 804
#define EPR_Z_PROBE_HEIGHT 808
#define EPR_Z_PROBE_SPEED 812
#define EPR_Z_PROBE_X1 816
#define EPR_Z_PROBE_Y1 820
#define EPR_Z_PROBE_X2 824
#define EPR_Z_PROBE_Y2 828
#define EPR_Z_PROBE_X3 832
#define EPR_Z_PROBE_Y3 836
#define EPR_Z_PROBE_XY_SPEED 840
#define EPR_AUTOLEVEL_MATRIX 844
#define EPR_AUTOLEVEL_ACTIVE 880
#define EPR_DELTA_DIAGONAL_ROD_LENGTH 881
#define EPR_DELTA_HORIZONTAL_RADIUS 885
#define EPR_DELTA_SEGMENTS_PER_SECOND_PRINT 889
#define EPR_DELTA_SEGMENTS_PER_SECOND_MOVE 891
#define EPR_DELTA_TOWERX_OFFSET_STEPS 893
#define EPR_DELTA_TOWERY_OFFSET_STEPS 895
#define EPR_DELTA_TOWERZ_OFFSET_STEPS 897
#define EPR_DELTA_ALPHA_A 901
#define EPR_DELTA_ALPHA_B 905
#define EPR_DELTA_ALPHA_C 909
#define EPR_DELTA_RADIUS_CORR_A 913
#define EPR_DELTA_RADIUS_CORR_B 917
#define EPR_DELTA_RADIUS_CORR_C 921
#define EPR_DELTA_MAX_RADIUS 925
#define EPR_Z_PROBE_BED_DISTANCE 929
#define EPR_DELTA_DIAGONAL_CORRECTION_A 933
#define EPR_DELTA_DIAGONAL_CORRECTION_B 937
#define EPR_DELTA_DIAGONAL_CORRECTION_C 941
#define EPR_TOUCHSCREEN 946 // - 975 = 30 byte for touchscreen calibration data
// Axis compensation
#define EPR_AXISCOMP_TANXY 976
#define EPR_AXISCOMP_TANYZ 980
#define EPR_AXISCOMP_TANXZ 984
#define EPR_DISTORTION_CORRECTION_ENABLED 988
#define EPR_RETRACTION_LENGTH 992
#define EPR_RETRACTION_LONG_LENGTH 996
#define EPR_RETRACTION_SPEED 1000
#define EPR_RETRACTION_Z_LIFT 1004
#define EPR_RETRACTION_UNDO_EXTRA_LENGTH 1008
#define EPR_RETRACTION_UNDO_EXTRA_LONG_LENGTH 1012
#define EPR_RETRACTION_UNDO_SPEED 1016
#define EPR_AUTORETRACT_ENABLED 1020
#if EEPROM_MODE != 0
#define EEPROM_FLOAT(x) HAL::eprGetFloat(EPR_##x)
#define EEPROM_INT32(x) HAL::eprGetInt32(EPR_##x)
#define EEPROM_BYTE(x) HAL::eprGetByte(EPR_##x)
#define EEPROM_SET_BYTE(x,val) HAL::eprSetByte(EPR_##x,val)
#else
#define EEPROM_FLOAT(x) (x)
#define EEPROM_INT32(x) (x)
#define EEPROM_BYTE(x) (x)
#define EEPROM_SET_BYTE(x,val)
#endif
#define EEPROM_EXTRUDER_OFFSET 200
// bytes per extruder needed, leave some space for future development
#define EEPROM_EXTRUDER_LENGTH 100
// Extruder positions relative to extruder start
#define EPR_EXTRUDER_STEPS_PER_MM 0
#define EPR_EXTRUDER_MAX_FEEDRATE 4
// Feedrate from halted extruder in mm/s
#define EPR_EXTRUDER_MAX_START_FEEDRATE 8
// Acceleration in mm/s^2
#define EPR_EXTRUDER_MAX_ACCELERATION 12
#define EPR_EXTRUDER_HEAT_MANAGER 16
#define EPR_EXTRUDER_DRIVE_MAX 17
#define EPR_EXTRUDER_PID_PGAIN 18
#define EPR_EXTRUDER_PID_IGAIN 22
#define EPR_EXTRUDER_PID_DGAIN 26
#define EPR_EXTRUDER_DEADTIME EPR_EXTRUDER_PID_PGAIN
#define EPR_EXTRUDER_PID_MAX 30
#define EPR_EXTRUDER_X_OFFSET 31
#define EPR_EXTRUDER_Y_OFFSET 35
#define EPR_EXTRUDER_WATCH_PERIOD 39
#define EPR_EXTRUDER_ADVANCE_K 41
#define EPR_EXTRUDER_DRIVE_MIN 45
#define EPR_EXTRUDER_ADVANCE_L 46
#define EPR_EXTRUDER_WAIT_RETRACT_TEMP 50
#define EPR_EXTRUDER_WAIT_RETRACT_UNITS 52
#define EPR_EXTRUDER_COOLER_SPEED 54
// 55-57 free for byte sized parameter
#define EPR_EXTRUDER_MIXING_RATIOS 58 // 16*2 byte ratios = 32 byte -> end = 89
#define EPR_EXTRUDER_Z_OFFSET 90
#ifndef Z_PROBE_BED_DISTANCE
#define Z_PROBE_BED_DISTANCE 5.0
#endif
class EEPROM
{
#if EEPROM_MODE != 0
static void writeExtruderPrefix(uint pos);
static void writeFloat(uint pos,PGM_P text,uint8_t digits = 3);
static void writeLong(uint pos,PGM_P text);
static void writeInt(uint pos,PGM_P text);
static void writeByte(uint pos,PGM_P text);
public:
static uint8_t computeChecksum();
static void updateChecksum();
#endif
public:
static void init();
static void initBaudrate();
static void storeDataIntoEEPROM(uint8_t corrupted = 0);
static void readDataFromEEPROM(bool includeExtruder);
static void restoreEEPROMSettingsFromConfiguration();
static void writeSettings();
static void update(GCode *com);
static void updatePrinterUsage();
static inline float zProbeSpeed() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_SPEED);
#else
return Z_PROBE_SPEED;
#endif
}
static inline float zProbeXYSpeed() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_XY_SPEED);
#else
return Z_PROBE_XY_SPEED;
#endif
}
static inline float zProbeXOffset() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_X_OFFSET);
#else
return Z_PROBE_X_OFFSET;
#endif
}
static inline float zProbeYOffset() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_Y_OFFSET);
#else
return Z_PROBE_Y_OFFSET;
#endif
}
static inline float zProbeHeight() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_HEIGHT);
#else
return Z_PROBE_HEIGHT;
#endif
}
static inline float zProbeX1() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_X1);
#else
return Z_PROBE_X1;
#endif
}
static inline float zProbeY1() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_Y1);
#else
return Z_PROBE_Y1;
#endif
}
static inline float zProbeX2() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_X2);
#else
return Z_PROBE_X2;
#endif
}
static inline float zProbeY2() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_Y2);
#else
return Z_PROBE_Y2;
#endif
}
static inline float zProbeX3() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_X3);
#else
return Z_PROBE_X3;
#endif
}
static inline float zProbeY3() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_Y3);
#else
return Z_PROBE_Y3;
#endif
}
static inline float zProbeBedDistance() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_BED_DISTANCE);
#else
return Z_PROBE_BED_DISTANCE;
#endif
}
static inline float axisCompTanXY() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_AXISCOMP_TANXY);
#else
return AXISCOMP_TANXY;
#endif
}
static inline float axisCompTanYZ() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_AXISCOMP_TANYZ);
#else
return AXISCOMP_TANYZ;
#endif
}
static inline float axisCompTanXZ() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_AXISCOMP_TANXZ);
#else
return AXISCOMP_TANXZ;
#endif
}
#if NONLINEAR_SYSTEM
static inline int16_t deltaSegmentsPerSecondMove() {
#if EEPROM_MODE != 0
return HAL::eprGetInt16(EPR_DELTA_SEGMENTS_PER_SECOND_MOVE);
#else
return DELTA_SEGMENTS_PER_SECOND_MOVE;
#endif
}
static inline float deltaDiagonalRodLength() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_DIAGONAL_ROD_LENGTH);
#else
return DELTA_DIAGONAL_ROD;
#endif
}
static inline int16_t deltaSegmentsPerSecondPrint() {
#if EEPROM_MODE != 0
return HAL::eprGetInt16(EPR_DELTA_SEGMENTS_PER_SECOND_PRINT);
#else
return DELTA_SEGMENTS_PER_SECOND_PRINT;
#endif
}
#endif
#if DRIVE_SYSTEM == DELTA
static inline float deltaHorizontalRadius() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_HORIZONTAL_RADIUS);
#else
return ROD_RADIUS;
#endif
}
static inline int16_t deltaTowerXOffsetSteps() {
#if EEPROM_MODE != 0
return HAL::eprGetInt16(EPR_DELTA_TOWERX_OFFSET_STEPS);
#else
return DELTA_X_ENDSTOP_OFFSET_STEPS;
#endif
}
static inline int16_t deltaTowerYOffsetSteps() {
#if EEPROM_MODE != 0
return HAL::eprGetInt16(EPR_DELTA_TOWERY_OFFSET_STEPS);
#else
return DELTA_Y_ENDSTOP_OFFSET_STEPS;
#endif
}
static inline int16_t deltaTowerZOffsetSteps() {
#if EEPROM_MODE != 0
return HAL::eprGetInt16(EPR_DELTA_TOWERZ_OFFSET_STEPS);
#else
return DELTA_Z_ENDSTOP_OFFSET_STEPS;
#endif
}
static inline void setRodRadius(float mm) {
#if DRIVE_SYSTEM == DELTA
Printer::radius0=mm;
Printer::updateDerivedParameter();
#if EEPROM_MODE != 0
//This is an odd situation, the radius can only be changed if eeprom is on.
// The radius is not saved to printer variablke now, it is all derived parameters of
// fetching the radius, which if EEProm is off returns the Configuration constant.
HAL::eprSetFloat(EPR_DELTA_HORIZONTAL_RADIUS, mm);
Com::printFLN(PSTR("Rod Radius set to: "),mm,3);
uint8_t newcheck = computeChecksum();
if(newcheck!=HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
#endif
}
static inline void incrementRodRadius(float mm) {
setRodRadius(mm + deltaHorizontalRadius());
}
static inline void setTowerXFloor(float newZ) {
#if DRIVE_SYSTEM == DELTA
Printer::xMin = newZ;
Printer::updateDerivedParameter();
Com::printFLN(PSTR("X (A) tower floor set to: "),Printer::xMin,3);
#if EEPROM_MODE != 0
HAL::eprSetFloat(EPR_X_HOME_OFFSET,Printer::xMin);
uint8_t newcheck = computeChecksum();
if(newcheck!=HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
#endif
}
static inline void setTowerYFloor(float newZ) {
#if DRIVE_SYSTEM == DELTA
Printer::yMin = newZ;
Printer::updateDerivedParameter();
Com::printFLN(PSTR("Y (B) tower floor set to: "), Printer::yMin, 3);
#if EEPROM_MODE != 0
HAL::eprSetFloat(EPR_Y_HOME_OFFSET,Printer::yMin);
uint8_t newcheck = computeChecksum();
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
#endif
}
static inline void setTowerZFloor(float newZ) {
#if DRIVE_SYSTEM == DELTA
Printer::zMin = newZ;
Printer::updateDerivedParameter();
Com::printFLN(PSTR("Z (C) tower floor set to: "), Printer::zMin, 3);
#if EEPROM_MODE != 0
HAL::eprSetFloat(EPR_Z_HOME_OFFSET,Printer::zMin);
uint8_t newcheck = computeChecksum();
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
#endif
}
static inline void setDeltaTowerXOffsetSteps(int16_t steps) {
#if EEPROM_MODE != 0
HAL::eprSetInt16(EPR_DELTA_TOWERX_OFFSET_STEPS,steps);
uint8_t newcheck = computeChecksum();
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
}
static inline void setDeltaTowerYOffsetSteps(int16_t steps) {
#if EEPROM_MODE != 0
HAL::eprSetInt16(EPR_DELTA_TOWERY_OFFSET_STEPS,steps);
uint8_t newcheck = computeChecksum();
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
}
static inline void setDeltaTowerZOffsetSteps(int16_t steps) {
#if EEPROM_MODE != 0
HAL::eprSetInt16(EPR_DELTA_TOWERZ_OFFSET_STEPS,steps);
uint8_t newcheck = computeChecksum();
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
#endif
}
static inline float deltaAlphaA() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_ALPHA_A);
#else
return DELTA_ALPHA_A;
#endif
}
static inline float deltaAlphaB() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_ALPHA_B);
#else
return DELTA_ALPHA_B;
#endif
}
static inline float deltaAlphaC() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_ALPHA_C);
#else
return DELTA_ALPHA_C;
#endif
}
static inline float deltaRadiusCorrectionA() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_RADIUS_CORR_A);
#else
return DELTA_RADIUS_CORRECTION_A;
#endif
}
static inline float deltaRadiusCorrectionB() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_RADIUS_CORR_B);
#else
return DELTA_RADIUS_CORRECTION_B;
#endif
}
static inline float deltaRadiusCorrectionC() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_DELTA_RADIUS_CORR_C);
#else
return DELTA_RADIUS_CORRECTION_C;
#endif
}
static inline float deltaDiagonalCorrectionA() {
return EEPROM_FLOAT(DELTA_DIAGONAL_CORRECTION_A);
}
static inline float deltaDiagonalCorrectionB() {
return EEPROM_FLOAT(DELTA_DIAGONAL_CORRECTION_B);
}
static inline float deltaDiagonalCorrectionC() {
return EEPROM_FLOAT(DELTA_DIAGONAL_CORRECTION_C);
}
static inline float deltaMaxRadius() {
return EEPROM_FLOAT(DELTA_MAX_RADIUS);
}
#endif
static void initalizeUncached();
#if MIXING_EXTRUDER
static void storeMixingRatios(bool updateChecksums = true);
static void readMixingRatios();
static void restoreMixingRatios();
#endif
static void setZCorrection(int32_t c,int index);
static inline int32_t getZCorrection(int index) {
return HAL::eprGetInt32(2048 + (index << 2));
}
static inline void setZCorrectionEnabled(int8_t on) {
#if EEPROM_MODE != 0
if(isZCorrectionEnabled() == on) return;
HAL::eprSetInt16(EPR_DISTORTION_CORRECTION_ENABLED, on);
uint8_t newcheck = computeChecksum();
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE, newcheck);
#endif
}
static inline int8_t isZCorrectionEnabled() {
#if EEPROM_MODE != 0
return HAL::eprGetByte(EPR_DISTORTION_CORRECTION_ENABLED);
#else
return 0;
#endif
}
};
#endif

71
Repetier/Events.h Normal file
View file

@ -0,0 +1,71 @@
#ifndef EVENTS_H_INCLUDED
#define EVENTS_H_INCLUDED
/*
Event system in a nutshell:
All printers are different and my need additions in th eone or other place.
It is not very convenient to add these code parts across the firmware. For this
reason repetier-firmware uses a simple event system that comes at no cost if
a event is not used.
- simple: Only one subscriber is possible
- cost effective: Macros work as event caller. By default all macros are empty
How to use the system:
1. In Configuration.h add
#define CUSTOM_EVENTS
2. Add a file "CustomEvents.h" which overrides all event macros you need.
It shoudl also include the function declarations used.
3. Add a file "CustomEventsImpl.h" which includes all function definitions.
Also it is named .h it will be included inside a cpp file only once.
This is to compile only when selected and still keep ArduinoIDE happy.
Each of the following events describe the parameter and when it is called.
*/
// Catch heating events. id is extruder id or -1 for heated bed.
#define EVENT_WAITING_HEATER(id) {}
#define EVENT_HEATING_FINISHED(id) {}
// This gets called every 0.1 second
#define EVENT_TIMER_100MS {}
// This gets called every 0.5 second
#define EVENT_TIMER_500MS {}
// Gets called on a regular basis as time allows
#define EVENT_PERIODICAL {}
// Gets called when kill gets called. only_steppes = true -> we only want to disable steppers, not everything.
#define EVENT_KILL(only_steppers) {}
// Gets called when a jam was detected.
#define EVENT_JAM_DETECTED {}
// Gets called everytime the jam detection signal switches. Steps are the extruder steps since last change.
#define EVENT_JAM_SIGNAL_CHANGED(extruderId,steps) {}
// Gets called if a heater decoupling is detected.
#define EVENT_HEATER_DECOUPLED(id) {}
// Gets called if a missing/shorted thermistor is detected.
#define EVENT_HEATER_DEFECT(id) {}
// Gets called if a action in ui.cpp okAction gets executed.
#define EVENT_START_UI_ACTION(shortAction) {}
// Gets called if a nextPrevius actions gets executed.
#define EVENT_START_NEXTPREVIOUS(action,increment) {}
// Allow adding new G and M codes. To implement it create a function
// bool eventUnhandledGCode(GCode *com)
// that returns true if it handled the code, otherwise false.
// Event define would then be
// #define EVENT_UNHANDLED_G_CODE(c) eventUnhandledGCode(c)
#define EVENT_UNHANDLED_G_CODE(c) false
#define EVENT_UNHANDLED_M_CODE(c) false
// This gets called every time the user has saved a value to eeprom
// or any other reason why dependent values may need recomputation.
#define EVENT_UPDATE_DERIVED {}
// This gets called after the basic firmware functions have initialized.
// Use this to initalize your hardware etc.
#define EVENT_INITIALIZE {}
#endif // EVENTS_H_INCLUDED

2209
Repetier/Extruder.cpp Normal file

File diff suppressed because it is too large Load diff

292
Repetier/Extruder.h Normal file
View file

@ -0,0 +1,292 @@
#ifndef EXTRUDER_H_INCLUDED
#define EXTRUDER_H_INCLUDED
#define CELSIUS_EXTRA_BITS 3
#define VIRTUAL_EXTRUDER 16 // don't change this to more then 16 without modifying the eeprom positions
//#if TEMP_PID
//extern uint8_t current_extruder_out;
//#endif
// Updates the temperature of all extruders and heated bed if it's time.
// Toggels the heater power if necessary.
extern bool reportTempsensorError(); ///< Report defect sensors
extern uint8_t manageMonitor;
#define HTR_OFF 0
#define HTR_PID 1
#define HTR_SLOWBANG 2
#define HTR_DEADTIME 3
#define TEMPERATURE_CONTROLLER_FLAG_ALARM 1
#define TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_FULL 2 //< Full heating enabled
#define TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_HOLD 4 //< Holding target temperature
#define TEMPERATURE_CONTROLLER_FLAG_SENSDEFECT 8 //< Indicating sensor defect
#define TEMPERATURE_CONTROLLER_FLAG_SENSDECOUPLED 16 //< Indicating sensor decoupling
#define TEMPERATURE_CONTROLLER_FLAG_JAM 32 //< Indicates a jammed filament
#define TEMPERATURE_CONTROLLER_FLAG_SLOWDOWN 64 //< Indicates a slowed down extruder
/** TemperatureController manages one heater-temperature sensore loop. You can have up to
4 loops allowing pid/bang bang for up to 3 extruder and the heated bed.
*/
class TemperatureController
{
public:
uint8_t pwmIndex; ///< pwm index for output control. 0-2 = Extruder, 3 = Fan, 4 = Heated Bed
uint8_t sensorType; ///< Type of temperature sensor.
uint8_t sensorPin; ///< Pin to read extruder temperature.
int16_t currentTemperature; ///< Currenttemperature value read from sensor.
int16_t targetTemperature; ///< Target temperature value in units of sensor.
float currentTemperatureC; ///< Current temperature in degC.
float targetTemperatureC; ///< Target temperature in degC.
uint32_t lastTemperatureUpdate; ///< Time in millis of the last temperature update.
int8_t heatManager; ///< How is temperature controled. 0 = on/off, 1 = PID-Control, 3 = deat time control
#if TEMP_PID
float tempIState; ///< Temp. var. for PID computation.
uint8_t pidDriveMax; ///< Used for windup in PID calculation.
uint8_t pidDriveMin; ///< Used for windup in PID calculation.
#define deadTime pidPGain
// deadTime is logically different value but physically overlays pidPGain for saving space
float pidPGain; ///< Pgain (proportional gain) for PID temperature control [0,01 Units].
float pidIGain; ///< Igain (integral) for PID temperature control [0,01 Units].
float pidDGain; ///< Dgain (damping) for PID temperature control [0,01 Units].
uint8_t pidMax; ///< Maximum PWM value, the heater should be set.
float tempIStateLimitMax;
float tempIStateLimitMin;
uint8_t tempPointer;
float tempArray[4];
#endif
uint8_t flags;
millis_t lastDecoupleTest; ///< Last time of decoupling sensor-heater test
float lastDecoupleTemp; ///< Temperature on last test
millis_t decoupleTestPeriod; ///< Time between setting and testing decoupling.
void setTargetTemperature(float target);
void updateCurrentTemperature();
void updateTempControlVars();
inline bool isAlarm()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_ALARM;
}
inline void setAlarm(bool on)
{
if(on) flags |= TEMPERATURE_CONTROLLER_FLAG_ALARM;
else flags &= ~TEMPERATURE_CONTROLLER_FLAG_ALARM;
}
inline bool isDecoupleFull()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_FULL;
}
inline bool isDecoupleFullOrHold()
{
return flags & (TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_FULL | TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_HOLD);
}
inline void setDecoupleFull(bool on)
{
flags &= ~(TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_FULL | TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_HOLD);
if(on) flags |= TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_FULL;
}
inline bool isDecoupleHold()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_HOLD;
}
inline void setDecoupleHold(bool on)
{
flags &= ~(TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_FULL | TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_HOLD);
if(on) flags |= TEMPERATURE_CONTROLLER_FLAG_DECOUPLE_HOLD;
}
inline void startFullDecouple(millis_t &t)
{
if(isDecoupleFull()) return;
lastDecoupleTest = t;
lastDecoupleTemp = currentTemperatureC;
setDecoupleFull(true);
}
inline void startHoldDecouple(millis_t &t)
{
if(isDecoupleHold()) return;
if(fabs(currentTemperatureC - targetTemperatureC) + 1 > DECOUPLING_TEST_MAX_HOLD_VARIANCE) return;
lastDecoupleTest = t;
lastDecoupleTemp = targetTemperatureC;
setDecoupleHold(true);
}
inline void stopDecouple()
{
setDecoupleFull(false);
}
inline bool isSensorDefect()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_SENSDEFECT;
}
inline bool isSensorDecoupled()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_SENSDECOUPLED;
}
#if EXTRUDER_JAM_CONTROL
inline bool isJammed()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_JAM;
}
void setJammed(bool on);
inline bool isSlowedDown()
{
return flags & TEMPERATURE_CONTROLLER_FLAG_SLOWDOWN;
}
inline void setSlowedDown(bool on)
{
flags &= ~TEMPERATURE_CONTROLLER_FLAG_SLOWDOWN;
if(on) flags |= TEMPERATURE_CONTROLLER_FLAG_SLOWDOWN;
}
#endif
void waitForTargetTemperature();
#if TEMP_PID
void autotunePID(float temp,uint8_t controllerId,int maxCycles,bool storeResult);
#endif
};
class Extruder;
extern Extruder extruder[];
#if EXTRUDER_JAM_CONTROL
#define _TEST_EXTRUDER_JAM(x,pin) {\
uint8_t sig = READ(pin);extruder[x].jamStepsSinceLastSignal += extruder[x].jamLastDir;\
if(extruder[x].jamLastSignal != sig && abs(extruder[x].jamStepsSinceLastSignal - extruder[x].jamLastChangeAt) > JAM_MIN_STEPS) {\
if(sig) {extruder[x].resetJamSteps();} \
extruder[x].jamLastSignal = sig;extruder[x].jamLastChangeAt = extruder[x].jamStepsSinceLastSignal;\
} else if(abs(extruder[x].jamStepsSinceLastSignal) > JAM_ERROR_STEPS && !Printer::isDebugJamOrDisabled() && !extruder[x].tempControl.isJammed()) \
extruder[x].tempControl.setJammed(true);\
}
#define ___TEST_EXTRUDER_JAM(x,y) _TEST_EXTRUDER_JAM(x,y)
#define __TEST_EXTRUDER_JAM(x) ___TEST_EXTRUDER_JAM(x,EXT ## x ## _JAM_PIN)
#define TEST_EXTRUDER_JAM(x) __TEST_EXTRUDER_JAM(x)
#define RESET_EXTRUDER_JAM(x,dir) extruder[x].jamLastDir = dir ? 1 : -1;
#else
#define TEST_EXTRUDER_JAM(x)
#define RESET_EXTRUDER_JAM(x,dir)
#endif
#define EXTRUDER_FLAG_RETRACTED 1
#define EXTRUDER_FLAG_WAIT_JAM_STARTCOUNT 2 ///< Waiting for the first signal to start counting
/** \brief Data to drive one extruder.
This structure contains all definitions for an extruder and all
current state variables, like current temperature, feeder position etc.
*/
class Extruder // Size: 12*1 Byte+12*4 Byte+4*2Byte = 68 Byte
{
public:
static Extruder *current;
#if FEATURE_DITTO_PRINTING
static uint8_t dittoMode;
#endif
#if MIXING_EXTRUDER > 0
static int mixingS; ///< Sum of all weights
static uint8_t mixingDir; ///< Direction flag
static uint8_t activeMixingExtruder;
#endif
uint8_t id;
int32_t xOffset;
int32_t yOffset;
int32_t zOffset;
float stepsPerMM; ///< Steps per mm.
int8_t enablePin; ///< Pin to enable extruder stepper motor.
// uint8_t directionPin; ///< Pin number to assign the direction.
// uint8_t stepPin; ///< Pin number for a step.
uint8_t enableOn;
// uint8_t invertDir; ///< 1 if the direction of the extruder should be inverted.
float maxFeedrate; ///< Maximum feedrate in mm/s.
float maxAcceleration; ///< Maximum acceleration in mm/s^2.
float maxStartFeedrate; ///< Maximum start feedrate in mm/s.
int32_t extrudePosition; ///< Current extruder position in steps.
int16_t watchPeriod; ///< Time in seconds, a M109 command will wait to stabalize temperature
int16_t waitRetractTemperature; ///< Temperature to retract the filament when waiting for heatup
int16_t waitRetractUnits; ///< Units to retract the filament when waiting for heatup
#if USE_ADVANCE
#if ENABLE_QUADRATIC_ADVANCE
float advanceK; ///< Koefficient for advance algorithm. 0 = off
#endif
float advanceL;
int16_t advanceBacklash;
#endif // USE_ADVANCE
#if MIXING_EXTRUDER > 0
int mixingW; ///< Weight for this extruder when mixing steps
int mixingE; ///< Cumulated error for this step.
int virtualWeights[VIRTUAL_EXTRUDER]; // Virtual extruder weights
#endif // MIXING_EXTRUDER > 0
TemperatureController tempControl;
const char * PROGMEM selectCommands;
const char * PROGMEM deselectCommands;
uint8_t coolerSpeed; ///< Speed to use when enabled
uint8_t coolerPWM; ///< current PWM setting
float diameter;
uint8_t flags;
#if EXTRUDER_JAM_CONTROL
int16_t jamStepsSinceLastSignal; // when was the last signal
uint8_t jamLastSignal; // what was the last signal
int8_t jamLastDir;
int16_t jamStepsOnSignal;
int16_t jamLastChangeAt;
#endif
// Methods here
#if EXTRUDER_JAM_CONTROL
inline bool isWaitJamStartcount()
{
return flags & EXTRUDER_FLAG_WAIT_JAM_STARTCOUNT;
}
inline void setWaitJamStartcount(bool on)
{
if(on) flags |= EXTRUDER_FLAG_WAIT_JAM_STARTCOUNT;
else flags &= ~(EXTRUDER_FLAG_WAIT_JAM_STARTCOUNT);
}
static void markAllUnjammed();
void resetJamSteps();
#endif
#if MIXING_EXTRUDER > 0
static void setMixingWeight(uint8_t extr,int weight);
#endif
static void step();
static void unstep();
static void setDirection(uint8_t dir);
static void enable();
#if FEATURE_RETRACTION
inline bool isRetracted() {return (flags & EXTRUDER_FLAG_RETRACTED) != 0;}
inline void setRetracted(bool on) {
flags = (flags & (255 - EXTRUDER_FLAG_RETRACTED)) | (on ? EXTRUDER_FLAG_RETRACTED : 0);
}
void retract(bool isRetract,bool isLong);
void retractDistance(float dist);
#endif
static void manageTemperatures();
static void disableCurrentExtruderMotor();
static void disableAllExtruderMotors();
static void selectExtruderById(uint8_t extruderId);
static void disableAllHeater();
static void initExtruder();
static void initHeatedBed();
static void setHeatedBedTemperature(float temp_celsius,bool beep = false);
static float getHeatedBedTemperature();
static void setTemperatureForExtruder(float temp_celsius,uint8_t extr,bool beep = false,bool wait = false);
static void pauseExtruders();
static void unpauseExtruders();
};
#if HAVE_HEATED_BED
#define NUM_TEMPERATURE_LOOPS NUM_EXTRUDER+1
extern TemperatureController heatedBedController;
#else
#define NUM_TEMPERATURE_LOOPS NUM_EXTRUDER
#endif
#define TEMP_INT_TO_FLOAT(temp) ((float)(temp)/(float)(1<<CELSIUS_EXTRA_BITS))
#define TEMP_FLOAT_TO_INT(temp) ((int)((temp)*(1<<CELSIUS_EXTRA_BITS)))
//extern Extruder *Extruder::current;
extern TemperatureController *tempController[NUM_TEMPERATURE_LOOPS];
extern uint8_t autotuneIndex;
#endif // EXTRUDER_H_INCLUDED

420
Repetier/FatStructs.h Normal file
View file

@ -0,0 +1,420 @@
/* Arduino SdFat Library
* Copyright (C) 2009 by William Greiman
*
* This file is part of the Arduino SdFat Library
*
* This Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Arduino SdFat Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef FatStructs_h
#define FatStructs_h
/**
* \file
* FAT file structures
*/
/*
* mostly from Microsoft document fatgen103.doc
* http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx
*/
//------------------------------------------------------------------------------
/** Value for byte 510 of boot block or MBR */
uint8_t const BOOTSIG0 = 0X55;
/** Value for byte 511 of boot block or MBR */
uint8_t const BOOTSIG1 = 0XAA;
//------------------------------------------------------------------------------
/**
* \struct partitionTable
* \brief MBR partition table entry
*
* A partition table entry for a MBR formatted storage device.
* The MBR partition table has four entries.
*/
struct partitionTable {
/**
* Boot Indicator . Indicates whether the volume is the active
* partition. Legal values include: 0X00. Do not use for booting.
* 0X80 Active partition.
*/
uint8_t boot;
/**
* Head part of Cylinder-head-sector address of the first block in
* the partition. Legal values are 0-255. Only used in old PC BIOS.
*/
uint8_t beginHead;
/**
* Sector part of Cylinder-head-sector address of the first block in
* the partition. Legal values are 1-63. Only used in old PC BIOS.
*/
unsigned beginSector : 6;
/** High bits cylinder for first block in partition. */
unsigned beginCylinderHigh : 2;
/**
* Combine beginCylinderLow with beginCylinderHigh. Legal values
* are 0-1023. Only used in old PC BIOS.
*/
uint8_t beginCylinderLow;
/**
* Partition type. See defines that begin with PART_TYPE_ for
* some Microsoft partition types.
*/
uint8_t type;
/**
* head part of cylinder-head-sector address of the last sector in the
* partition. Legal values are 0-255. Only used in old PC BIOS.
*/
uint8_t endHead;
/**
* Sector part of cylinder-head-sector address of the last sector in
* the partition. Legal values are 1-63. Only used in old PC BIOS.
*/
unsigned endSector : 6;
/** High bits of end cylinder */
unsigned endCylinderHigh : 2;
/**
* Combine endCylinderLow with endCylinderHigh. Legal values
* are 0-1023. Only used in old PC BIOS.
*/
uint8_t endCylinderLow;
/** Logical block address of the first block in the partition. */
uint32_t firstSector;
/** Length of the partition, in blocks. */
uint32_t totalSectors;
};
/** Type name for partitionTable */
typedef struct partitionTable part_t;
//------------------------------------------------------------------------------
/**
* \struct masterBootRecord
*
* \brief Master Boot Record
*
* The first block of a storage device that is formatted with a MBR.
*/
struct masterBootRecord {
/** Code Area for master boot program. */
uint8_t codeArea[440];
/** Optional WindowsNT disk signature. May contain more boot code. */
uint32_t diskSignature;
/** Usually zero but may be more boot code. */
uint16_t usuallyZero;
/** Partition tables. */
part_t part[4];
/** First MBR signature byte. Must be 0X55 */
uint8_t mbrSig0;
/** Second MBR signature byte. Must be 0XAA */
uint8_t mbrSig1;
};
/** Type name for masterBootRecord */
typedef struct masterBootRecord mbr_t;
//------------------------------------------------------------------------------
/**
* \struct biosParmBlock
*
* \brief BIOS parameter block
*
* The BIOS parameter block describes the physical layout of a FAT volume.
*/
struct biosParmBlock {
/**
* Count of bytes per sector. This value may take on only the
* following values: 512, 1024, 2048 or 4096
*/
uint16_t bytesPerSector;
/**
* Number of sectors per allocation unit. This value must be a
* power of 2 that is greater than 0. The legal values are
* 1, 2, 4, 8, 16, 32, 64, and 128.
*/
uint8_t sectorsPerCluster;
/**
* Number of sectors before the first FAT.
* This value must not be zero.
*/
uint16_t reservedSectorCount;
/** The count of FAT data structures on the volume. This field should
* always contain the value 2 for any FAT volume of any type.
*/
uint8_t fatCount;
/**
* For FAT12 and FAT16 volumes, this field contains the count of
* 32-byte directory entries in the root directory. For FAT32 volumes,
* this field must be set to 0. For FAT12 and FAT16 volumes, this
* value should always specify a count that when multiplied by 32
* results in a multiple of bytesPerSector. FAT16 volumes should
* use the value 512.
*/
uint16_t rootDirEntryCount;
/**
* This field is the old 16-bit total count of sectors on the volume.
* This count includes the count of all sectors in all four regions
* of the volume. This field can be 0; if it is 0, then totalSectors32
* must be non-zero. For FAT32 volumes, this field must be 0. For
* FAT12 and FAT16 volumes, this field contains the sector count, and
* totalSectors32 is 0 if the total sector count fits
* (is less than 0x10000).
*/
uint16_t totalSectors16;
/**
* This dates back to the old MS-DOS 1.x media determination and is
* no longer usually used for anything. 0xF8 is the standard value
* for fixed (non-removable) media. For removable media, 0xF0 is
* frequently used. Legal values are 0xF0 or 0xF8-0xFF.
*/
uint8_t mediaType;
/**
* Count of sectors occupied by one FAT on FAT12/FAT16 volumes.
* On FAT32 volumes this field must be 0, and sectorsPerFat32
* contains the FAT size count.
*/
uint16_t sectorsPerFat16;
/** Sectors per track for interrupt 0x13. Not used otherwise. */
uint16_t sectorsPerTrtack;
/** Number of heads for interrupt 0x13. Not used otherwise. */
uint16_t headCount;
/**
* Count of hidden sectors preceding the partition that contains this
* FAT volume. This field is generally only relevant for media
* visible on interrupt 0x13.
*/
uint32_t hidddenSectors;
/**
* This field is the new 32-bit total count of sectors on the volume.
* This count includes the count of all sectors in all four regions
* of the volume. This field can be 0; if it is 0, then
* totalSectors16 must be non-zero.
*/
uint32_t totalSectors32;
/**
* Count of sectors occupied by one FAT on FAT32 volumes.
*/
uint32_t sectorsPerFat32;
/**
* This field is only defined for FAT32 media and does not exist on
* FAT12 and FAT16 media.
* Bits 0-3 -- Zero-based number of active FAT.
* Only valid if mirroring is disabled.
* Bits 4-6 -- Reserved.
* Bit 7 -- 0 means the FAT is mirrored at runtime into all FATs.
* -- 1 means only one FAT is active; it is the one referenced in bits 0-3.
* Bits 8-15 -- Reserved.
*/
uint16_t fat32Flags;
/**
* FAT32 version. High byte is major revision number.
* Low byte is minor revision number. Only 0.0 define.
*/
uint16_t fat32Version;
/**
* Cluster number of the first cluster of the root directory for FAT32.
* This usually 2 but not required to be 2.
*/
uint32_t fat32RootCluster;
/**
* Sector number of FSINFO structure in the reserved area of the
* FAT32 volume. Usually 1.
*/
uint16_t fat32FSInfo;
/**
* If non-zero, indicates the sector number in the reserved area
* of the volume of a copy of the boot record. Usually 6.
* No value other than 6 is recommended.
*/
uint16_t fat32BackBootBlock;
/**
* Reserved for future expansion. Code that formats FAT32 volumes
* should always set all of the bytes of this field to 0.
*/
uint8_t fat32Reserved[12];
};
/** Type name for biosParmBlock */
typedef struct biosParmBlock bpb_t;
//------------------------------------------------------------------------------
/**
* \struct fat32BootSector
*
* \brief Boot sector for a FAT16 or FAT32 volume.
*
*/
struct fat32BootSector {
/** X86 jmp to boot program */
uint8_t jmpToBootCode[3];
/** informational only - don't depend on it */
char oemName[8];
/** BIOS Parameter Block */
bpb_t bpb;
/** for int0x13 use value 0X80 for hard drive */
uint8_t driveNumber;
/** used by Windows NT - should be zero for FAT */
uint8_t reserved1;
/** 0X29 if next three fields are valid */
uint8_t bootSignature;
/** usually generated by combining date and time */
uint32_t volumeSerialNumber;
/** should match volume label in root dir */
char volumeLabel[11];
/** informational only - don't depend on it */
char fileSystemType[8];
/** X86 boot code */
uint8_t bootCode[420];
/** must be 0X55 */
uint8_t bootSectorSig0;
/** must be 0XAA */
uint8_t bootSectorSig1;
};
//------------------------------------------------------------------------------
// End Of Chain values for FAT entries
/** FAT16 end of chain value used by Microsoft. */
uint16_t const FAT16EOC = 0XFFFF;
/** Minimum value for FAT16 EOC. Use to test for EOC. */
uint16_t const FAT16EOC_MIN = 0XFFF8;
/** FAT32 end of chain value used by Microsoft. */
uint32_t const FAT32EOC = 0X0FFFFFFF;
/** Minimum value for FAT32 EOC. Use to test for EOC. */
uint32_t const FAT32EOC_MIN = 0X0FFFFFF8;
/** Mask a for FAT32 entry. Entries are 28 bits. */
uint32_t const FAT32MASK = 0X0FFFFFFF;
/** Type name for fat32BootSector */
typedef struct fat32BootSector fbs_t;
//------------------------------------------------------------------------------
/**
* \struct directoryEntry
* \brief FAT short directory entry
*
* Short means short 8.3 name, not the entry size.
*
* Date Format. A FAT directory entry date stamp is a 16-bit field that is
* basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the
* format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the
* 16-bit word):
*
* Bits 9-15: Count of years from 1980, valid value range 0-127
* inclusive (1980-2107).
*
* Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive.
*
* Bits 0-4: Day of month, valid value range 1-31 inclusive.
*
* Time Format. A FAT directory entry time stamp is a 16-bit field that has
* a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the
* 16-bit word, bit 15 is the MSB of the 16-bit word).
*
* Bits 11-15: Hours, valid value range 0-23 inclusive.
*
* Bits 5-10: Minutes, valid value range 0-59 inclusive.
*
* Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds).
*
* The valid time range is from Midnight 00:00:00 to 23:59:58.
*/
struct directoryEntry {
/**
* Short 8.3 name.
* The first eight bytes contain the file name with blank fill.
* The last three bytes contain the file extension with blank fill.
*/
uint8_t name[11];
/** Entry attributes.
*
* The upper two bits of the attribute byte are reserved and should
* always be set to 0 when a file is created and never modified or
* looked at after that. See defines that begin with DIR_ATT_.
*/
uint8_t attributes;
/**
* Reserved for use by Windows NT. Set value to 0 when a file is
* created and never modify or look at it after that.
*/
uint8_t reservedNT;
/**
* The granularity of the seconds part of creationTime is 2 seconds
* so this field is a count of tenths of a second and its valid
* value range is 0-199 inclusive. (WHG note - seems to be hundredths)
*/
uint8_t creationTimeTenths;
/** Time file was created. */
uint16_t creationTime;
/** Date file was created. */
uint16_t creationDate;
/**
* Last access date. Note that there is no last access time, only
* a date. This is the date of last read or write. In the case of
* a write, this should be set to the same date as lastWriteDate.
*/
uint16_t lastAccessDate;
/**
* High word of this entry's first cluster number (always 0 for a
* FAT12 or FAT16 volume).
*/
uint16_t firstClusterHigh;
/** Time of last write. File creation is considered a write. */
uint16_t lastWriteTime;
/** Date of last write. File creation is considered a write. */
uint16_t lastWriteDate;
/** Low word of this entry's first cluster number. */
uint16_t firstClusterLow;
/** 32-bit unsigned holding this file's size in bytes. */
uint32_t fileSize;
};
//------------------------------------------------------------------------------
// Definitions for directory entries
//
/** Type name for directoryEntry */
typedef struct directoryEntry dir_t;
/** escape for name[0] = 0XE5 */
uint8_t const DIR_NAME_0XE5 = 0X05;
/** name[0] value for entry that is free after being "deleted" */
uint8_t const DIR_NAME_DELETED = 0XE5;
/** name[0] value for entry that is free and no allocated entries follow */
uint8_t const DIR_NAME_FREE = 0X00;
/** file is read-only */
uint8_t const DIR_ATT_READ_ONLY = 0X01;
/** File should hidden in directory listings */
uint8_t const DIR_ATT_HIDDEN = 0X02;
/** Entry is for a system file */
uint8_t const DIR_ATT_SYSTEM = 0X04;
/** Directory entry contains the volume label */
uint8_t const DIR_ATT_VOLUME_ID = 0X08;
/** Entry is for a directory */
uint8_t const DIR_ATT_DIRECTORY = 0X10;
/** Old DOS archive bit for backup support */
uint8_t const DIR_ATT_ARCHIVE = 0X20;
/** Test value for long name entry. Test is
(d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME. */
uint8_t const DIR_ATT_LONG_NAME = 0X0F;
/** Test mask for long name entry */
uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F;
/** defined attribute bits */
uint8_t const DIR_ATT_DEFINED_BITS = 0X3F;
/** Directory entry is part of a long name */
static inline uint8_t DIR_IS_LONG_NAME(const dir_t* dir) {
return (dir->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME;
}
/** Mask for file/subdirectory tests */
uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY);
/** Directory entry is for a file */
static inline uint8_t DIR_IS_FILE(const dir_t* dir) {
return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == 0;
}
/** Directory entry is for a subdirectory */
static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == DIR_ATT_DIRECTORY;
}
/** Directory entry is for a file or subdirectory */
static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
}
#endif // FatStructs_h

1437
Repetier/HAL.cpp Normal file

File diff suppressed because it is too large Load diff

760
Repetier/HAL.h Normal file
View file

@ -0,0 +1,760 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
Functions in this file are used to communicate using ascii or repetier protocol.
*/
#ifndef HAL_H
#define HAL_H
/**
This is the main Hardware Abstraction Layer (HAL).
To make the firmware work with different processors and toolchains,
all hardware related code should be packed into the hal files.
*/
#include <avr/pgmspace.h>
#include <avr/io.h>
#define INLINE __attribute__((always_inline))
#if CPU_ARCH == ARCH_AVR
#include <avr/io.h>
#else
#define PROGMEM
#define PGM_P const char *
#define PSTR(s) s
#define pgm_read_byte_near(x) (*(uint8_t*)x)
#define pgm_read_byte(x) (*(uint8_t*)x)
#endif
#define PACK
#define FSTRINGVALUE(var,value) const char var[] PROGMEM = value;
#define FSTRINGVAR(var) static const char var[] PROGMEM;
#define FSTRINGPARAM(var) PGM_P var
#include <avr/eeprom.h>
#include <avr/wdt.h>
/** \brief Prescale factor, timer0 runs at.
All known arduino boards use 64. This value is needed for the extruder timing. */
#define TIMER0_PRESCALE 64
#define ANALOG_PRESCALER _BV(ADPS0)|_BV(ADPS1)|_BV(ADPS2)
#if MOTHERBOARD==8 || MOTHERBOARD==88 || MOTHERBOARD==9 || MOTHERBOARD==92 || CPU_ARCH!=ARCH_AVR
#define EXTERNALSERIAL
#endif
//#define EXTERNALSERIAL // Force using arduino serial
#ifndef EXTERNALSERIAL
#define HardwareSerial_h // Don't use standard serial console
#endif
#include <inttypes.h>
#include "Print.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#define COMPAT_PRE1
#endif
#if CPU_ARCH==ARCH_AVR
#include "fastio.h"
#else
#define READ(IO) digitalRead(IO)
#define WRITE(IO, v) digitalWrite(IO, v)
#define SET_INPUT(IO) pinMode(IO, INPUT)
#define SET_OUTPUT(IO) pinMode(IO, OUTPUT)
#endif
class InterruptProtectedBlock
{
uint8_t sreg;
public:
inline void protect()
{
cli();
}
inline void unprotect()
{
SREG = sreg;
}
inline InterruptProtectedBlock(bool later = false)
{
sreg = SREG;
if(!later)
cli();
}
inline ~InterruptProtectedBlock()
{
SREG = sreg;
}
};
#define EEPROM_OFFSET 0
#define SECONDS_TO_TICKS(s) (unsigned long)(s*(float)F_CPU)
#define ANALOG_INPUT_SAMPLE 5
// Bits of the ADC converter
#define ANALOG_INPUT_BITS 10
#define ANALOG_REDUCE_BITS 0
#define ANALOG_REDUCE_FACTOR 1
#define MAX_RAM 32767
#define bit_clear(x,y) x&= ~(1<<y) //cbi(x,y)
#define bit_set(x,y) x|= (1<<y)//sbi(x,y)
/** defines the data direction (reading from I2C device) in i2cStart(),i2cRepStart() */
#define I2C_READ 1
/** defines the data direction (writing to I2C device) in i2cStart(),i2cRepStart() */
#define I2C_WRITE 0
#if NONLINEAR_SYSTEM
// Maximum speed with 100% inerrupt utilization is 27000 hz at 16MHz cpu
// leave some margin for all the extra transformations. So we keep inside clean timings.
#define LIMIT_INTERVAL ((F_CPU/30000)+1)
#else
#define LIMIT_INTERVAL ((F_CPU/40000)+1)
#endif
typedef uint16_t speed_t;
typedef uint32_t ticks_t;
typedef uint32_t millis_t;
typedef uint8_t flag8_t;
typedef int8_t fast8_t;
typedef uint8_t ufast8_t;
#define FAST_INTEGER_SQRT
#ifndef EXTERNALSERIAL
// Implement serial communication for one stream only!
/*
HardwareSerial.h - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 28 September 2010 by Mark Sproul
Modified to use only 1 queue with fixed length by Repetier
*/
#define SERIAL_BUFFER_SIZE 128
#define SERIAL_BUFFER_MASK 127
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_MASK 63
struct ring_buffer
{
uint8_t buffer[SERIAL_BUFFER_SIZE];
volatile uint8_t head;
volatile uint8_t tail;
};
struct ring_buffer_tx
{
uint8_t buffer[SERIAL_TX_BUFFER_SIZE];
volatile uint8_t head;
volatile uint8_t tail;
};
class RFHardwareSerial : public Print
{
public:
ring_buffer *_rx_buffer;
ring_buffer_tx *_tx_buffer;
volatile uint8_t *_ubrrh;
volatile uint8_t *_ubrrl;
volatile uint8_t *_ucsra;
volatile uint8_t *_ucsrb;
volatile uint8_t *_udr;
uint8_t _rxen;
uint8_t _txen;
uint8_t _rxcie;
uint8_t _udrie;
uint8_t _u2x;
public:
RFHardwareSerial(ring_buffer *rx_buffer, ring_buffer_tx *tx_buffer,
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *udr,
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x);
void begin(unsigned long);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
#ifdef COMPAT_PRE1
virtual void write(uint8_t);
#else
virtual size_t write(uint8_t);
#endif
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
int outputUnused(void); // Used for output in interrupts
};
extern RFHardwareSerial RFSerial;
#define RFSERIAL RFSerial
//extern ring_buffer tx_buffer;
#define WAIT_OUT_EMPTY while(tx_buffer.head != tx_buffer.tail) {}
#else
#define RFSERIAL Serial
#endif
#define OUT_P_I(p,i) Com::printF(PSTR(p),(int)(i))
#define OUT_P_I_LN(p,i) Com::printFLN(PSTR(p),(int)(i))
#define OUT_P_L(p,i) Com::printF(PSTR(p),(long)(i))
#define OUT_P_L_LN(p,i) Com::printFLN(PSTR(p),(long)(i))
#define OUT_P_F(p,i) Com::printF(PSTR(p),(float)(i))
#define OUT_P_F_LN(p,i) Com::printFLN(PSTR(p),(float)(i))
#define OUT_P_FX(p,i,x) Com::printF(PSTR(p),(float)(i),x)
#define OUT_P_FX_LN(p,i,x) Com::printFLN(PSTR(p),(float)(i),x)
#define OUT_P(p) Com::printF(PSTR(p))
#define OUT_P_LN(p) Com::printFLN(PSTR(p))
#define OUT_ERROR_P(p) Com::printErrorF(PSTR(p))
#define OUT_ERROR_P_LN(p) {Com::printErrorF(PSTR(p));Com::println();}
#define OUT(v) Com::print(v)
#define OUT_LN Com::println()
class HAL
{
public:
HAL();
virtual ~HAL();
static inline void hwSetup(void)
{}
// return val'val
static uint16_t integerSqrt(uint32_t a);
/** \brief Optimized division
Normally the C compiler will compute a long/long division, which takes ~670 Ticks.
This version is optimized for a 16 bit dividend and recognises the special cases
of a 24 bit and 16 bit dividend, which offen, but not always occur in updating the
interval.
*/
static inline int32_t Div4U2U(uint32_t a,uint16_t b)
{
#if CPU_ARCH==ARCH_AVR
// r14/r15 remainder
// r16 counter
__asm__ __volatile__ (
"clr r14 \n\t"
"sub r15,r15 \n\t"
"tst %D0 \n\t"
"brne do32%= \n\t"
"tst %C0 \n\t"
"breq donot24%= \n\t"
"rjmp do24%= \n\t"
"donot24%=:" "ldi r16,17 \n\t" // 16 Bit divide
"d16u_1%=:" "rol %A0 \n\t"
"rol %B0 \n\t"
"dec r16 \n\t"
"brne d16u_2%= \n\t"
"rjmp end%= \n\t"
"d16u_2%=:" "rol r14 \n\t"
"rol r15 \n\t"
"sub r14,%A2 \n\t"
"sbc r15,%B2 \n\t"
"brcc d16u_3%= \n\t"
"add r14,%A2 \n\t"
"adc r15,%B2 \n\t"
"clc \n\t"
"rjmp d16u_1%= \n\t"
"d16u_3%=:" "sec \n\t"
"rjmp d16u_1%= \n\t"
"do32%=:" // divide full 32 bit
"rjmp do32B%= \n\t"
"do24%=:" // divide 24 bit
"ldi r16,25 \n\t" // 24 Bit divide
"d24u_1%=:" "rol %A0 \n\t"
"rol %B0 \n\t"
"rol %C0 \n\t"
"dec r16 \n\t"
"brne d24u_2%= \n\t"
"rjmp end%= \n\t"
"d24u_2%=:" "rol r14 \n\t"
"rol r15 \n\t"
"sub r14,%A2 \n\t"
"sbc r15,%B2 \n\t"
"brcc d24u_3%= \n\t"
"add r14,%A2 \n\t"
"adc r15,%B2 \n\t"
"clc \n\t"
"rjmp d24u_1%= \n\t"
"d24u_3%=:" "sec \n\t"
"rjmp d24u_1%= \n\t"
"do32B%=:" // divide full 32 bit
"ldi r16,33 \n\t" // 32 Bit divide
"d32u_1%=:" "rol %A0 \n\t"
"rol %B0 \n\t"
"rol %C0 \n\t"
"rol %D0 \n\t"
"dec r16 \n\t"
"brne d32u_2%= \n\t"
"rjmp end%= \n\t"
"d32u_2%=:" "rol r14 \n\t"
"rol r15 \n\t"
"sub r14,%A2 \n\t"
"sbc r15,%B2 \n\t"
"brcc d32u_3%= \n\t"
"add r14,%A2 \n\t"
"adc r15,%B2 \n\t"
"clc \n\t"
"rjmp d32u_1%= \n\t"
"d32u_3%=:" "sec \n\t"
"rjmp d32u_1%= \n\t"
"end%=:" // end
:"=&r"(a)
:"0"(a),"r"(b)
:"r14","r15","r16"
);
return a;
#else
return a/b;
#endif
}
static inline unsigned long U16SquaredToU32(unsigned int val)
{
long res;
__asm__ __volatile__ ( // 15 Ticks
"mul %A1,%A1 \n\t"
"movw %A0,r0 \n\t"
"mul %B1,%B1 \n\t"
"movw %C0,r0 \n\t"
"mul %A1,%B1 \n\t"
"clr %A1 \n\t"
"add %B0,r0 \n\t"
"adc %C0,r1 \n\t"
"adc %D0,%A1 \n\t"
"add %B0,r0 \n\t"
"adc %C0,r1 \n\t"
"adc %D0,%A1 \n\t"
"clr r1 \n\t"
: "=&r"(res),"=r"(val)
: "1"(val)
);
return res;
}
static inline unsigned int ComputeV(long timer,long accel)
{
#if CPU_ARCH==ARCH_AVR
unsigned int res;
// 38 Ticks
__asm__ __volatile__ ( // 0 = res, 1 = timer, 2 = accel %D2=0 ,%A1 are unused is free
// Result LSB first: %A0, %B0, %A1
"mul %B1,%A2 \n\t"
"mov %A0,r1 \n\t"
"mul %B1,%C2 \n\t"
"mov %B0,r0 \n\t"
"mov %A1,r1 \n\t"
"mul %B1,%B2 \n\t"
"add %A0,r0 \n\t"
"adc %B0,r1 \n\t"
"adc %A1,%D2 \n\t"
"mul %C1,%A2 \n\t"
"add %A0,r0 \n\t"
"adc %B0,r1 \n\t"
"adc %A1,%D2 \n\t"
"mul %C1,%B2 \n\t"
"add %B0,r0 \n\t"
"adc %A1,r1 \n\t"
"mul %D1,%A2 \n\t"
"add %B0,r0 \n\t"
"adc %A1,r1 \n\t"
"mul %C1,%C2 \n\t"
"add %A1,r0 \n\t"
"mul %D1,%B2 \n\t"
"add %A1,r0 \n\t"
"lsr %A1 \n\t"
"ror %B0 \n\t"
"ror %A0 \n\t"
"lsr %A1 \n\t"
"ror %B0 \n\t"
"ror %A0 \n\t"
"clr r1 \n\t"
:"=&r"(res),"=r"(timer),"=r"(accel)
:"1"(timer),"2"(accel)
: );
// unsigned int v = ((timer>>8)*cur->accel)>>10;
return res;
#else
return ((timer >> 8) * accel) >> 10;
#endif
}
// Multiply two 16 bit values and return 32 bit result
static inline uint32_t mulu16xu16to32(unsigned int a,unsigned int b)
{
uint32_t res;
// 18 Ticks = 1.125 us
__asm__ __volatile__ ( // 0 = res, 1 = timer, 2 = accel %D2=0 ,%A1 are unused is free
// Result LSB first: %A0, %B0, %A1
"clr r18 \n\t"
"mul %B2,%B1 \n\t" // mul hig bytes
"movw %C0,r0 \n\t"
"mul %A1,%A2 \n\t" // mul low bytes
"movw %A0,r0 \n\t"
"mul %A1,%B2 \n\t"
"add %B0,r0 \n\t"
"adc %C0,r1 \n\t"
"adc %D0,r18 \n\t"
"mul %B1,%A2 \n\t"
"add %B0,r0 \n\t"
"adc %C0,r1 \n\t"
"adc %D0,r18 \n\t"
"clr r1 \n\t"
:"=&r"(res),"=r"(a),"=r"(b)
:"1"(a),"2"(b)
:"r18" );
// return (long)a*b;
return res;
}
// Multiply two 16 bit values and return 32 bit result
static inline unsigned int mulu6xu16shift16(unsigned int a,unsigned int b)
{
#if CPU_ARCH == ARCH_AVR
unsigned int res;
// 18 Ticks = 1.125 us
__asm__ __volatile__ ( // 0 = res, 1 = timer, 2 = accel %D2=0 ,%A1 are unused is free
// Result LSB first: %A0, %B0, %A1
"clr r18 \n\t"
"mul %B2,%B1 \n\t" // mul hig bytes
"movw %A0,r0 \n\t"
"mul %A1,%A2 \n\t" // mul low bytes
"mov r19,r1 \n\t"
"mul %A1,%B2 \n\t"
"add r19,r0 \n\t"
"adc %A0,r1 \n\t"
"adc %B0,r18 \n\t"
"mul %B1,%A2 \n\t"
"add r19,r0 \n\t"
"adc %A0,r1 \n\t"
"adc %B0,r18 \n\t"
"clr r1 \n\t"
:"=&r"(res),"=r"(a),"=r"(b)
:"1"(a),"2"(b)
:"r18","r19" );
return res;
#else
return ((int32_t)a * b) >> 16;
#endif
}
static inline void digitalWrite(uint8_t pin,uint8_t value)
{
::digitalWrite(pin,value);
}
static inline uint8_t digitalRead(uint8_t pin)
{
return ::digitalRead(pin);
}
static inline void pinMode(uint8_t pin,uint8_t mode)
{
::pinMode(pin,mode);
}
static int32_t CPUDivU2(unsigned int divisor);
static inline void delayMicroseconds(unsigned int delayUs)
{
::delayMicroseconds(delayUs);
}
static inline void delayMilliseconds(unsigned int delayMs)
{
::delay(delayMs);
}
static inline void tone(uint8_t pin,int duration)
{
::tone(pin,duration);
}
static inline void noTone(uint8_t pin)
{
::noTone(pin);
}
static inline void eprSetByte(unsigned int pos,uint8_t value)
{
eeprom_write_byte((unsigned char *)(EEPROM_OFFSET + pos), value);
}
static inline void eprSetInt16(unsigned int pos,int16_t value)
{
eeprom_write_word((unsigned int*)(EEPROM_OFFSET + pos),value);
}
static inline void eprSetInt32(unsigned int pos,int32_t value)
{
eeprom_write_dword((uint32_t*)(EEPROM_OFFSET + pos),value);
}
static inline void eprSetFloat(unsigned int pos,float value)
{
eeprom_write_block(&value,(void*)(EEPROM_OFFSET + pos), 4);
}
static inline uint8_t eprGetByte(unsigned int pos)
{
return eeprom_read_byte ((unsigned char *)(EEPROM_OFFSET + pos));
}
static inline int16_t eprGetInt16(unsigned int pos)
{
return eeprom_read_word((uint16_t *)(EEPROM_OFFSET + pos));
}
static inline int32_t eprGetInt32(unsigned int pos)
{
return eeprom_read_dword((uint32_t*)(EEPROM_OFFSET + pos));
}
static inline float eprGetFloat(unsigned int pos)
{
float v;
eeprom_read_block(&v,(void *)(EEPROM_OFFSET + pos),4); // newer gcc have eeprom_read_block but not arduino 22
return v;
}
// Faster version of InterruptProtectedBlock.
// For safety it ma yonly be called from within an
// interrupt handler.
static inline void allowInterrupts()
{
sei();
}
// Faster version of InterruptProtectedBlock.
// For safety it ma yonly be called from within an
// interrupt handler.
static inline void forbidInterrupts()
{
cli();
}
static inline unsigned long timeInMilliseconds()
{
return millis();
}
static inline char readFlashByte(PGM_P ptr)
{
return pgm_read_byte(ptr);
}
static inline void serialSetBaudrate(long baud)
{
RFSERIAL.begin(baud);
}
static inline bool serialByteAvailable()
{
return RFSERIAL.available() > 0;
}
static inline uint8_t serialReadByte()
{
return RFSERIAL.read();
}
static inline void serialWriteByte(char b)
{
RFSERIAL.write(b);
}
static inline void serialFlush()
{
RFSERIAL.flush();
}
static void setupTimer();
static void showStartReason();
static int getFreeRam();
static void resetHardware();
// SPI related functions
static void spiBegin()
{
#if SDSS >= 0
SET_INPUT(MISO_PIN);
SET_OUTPUT(MOSI_PIN);
SET_OUTPUT(SCK_PIN);
// SS must be in output mode even it is not chip select
SET_OUTPUT(SDSS);
#if SDSSORIG >- 1
SET_OUTPUT(SDSSORIG);
#endif
// set SS high - may be chip select for another SPI device
#if SET_SPI_SS_HIGH
WRITE(SDSS, HIGH);
#endif // SET_SPI_SS_HIGH
#endif
}
static inline void spiInit(uint8_t spiRate)
{
uint8_t r = 0;
for (uint8_t b = 2; spiRate > b && r < 6; b <<= 1, r++);
SET_OUTPUT(SS);
WRITE(SS,HIGH);
SET_OUTPUT(SCK);
SET_OUTPUT(MOSI_PIN);
SET_INPUT(MISO_PIN);
#ifdef PRR
PRR &= ~(1<<PRSPI);
#elif defined PRR0
PRR0 &= ~(1<<PRSPI);
#endif
// See avr processor documentation
SPCR = (1 << SPE) | (1 << MSTR) | (r >> 1);
SPSR = (r & 1 || r == 6 ? 0 : 1) << SPI2X;
}
static inline uint8_t spiReceive(uint8_t send=0xff)
{
SPDR = send;
while (!(SPSR & (1 << SPIF))) {}
return SPDR;
}
static inline void spiReadBlock(uint8_t*buf,size_t nbyte)
{
if (nbyte-- == 0) return;
SPDR = 0XFF;
for (size_t i = 0; i < nbyte; i++)
{
while (!(SPSR & (1 << SPIF))) {}
buf[i] = SPDR;
SPDR = 0XFF;
}
while (!(SPSR & (1 << SPIF))) {}
buf[nbyte] = SPDR;
}
static inline void spiSend(uint8_t b)
{
SPDR = b;
while (!(SPSR & (1 << SPIF))) {}
}
static inline void spiSend(const uint8_t* buf , size_t n)
{
if (n == 0) return;
SPDR = buf[0];
if (n > 1)
{
uint8_t b = buf[1];
size_t i = 2;
while (1)
{
while (!(SPSR & (1 << SPIF))) {}
SPDR = b;
if (i == n) break;
b = buf[i++];
}
}
while (!(SPSR & (1 << SPIF))) {}
}
static inline __attribute__((always_inline))
void spiSendBlock(uint8_t token, const uint8_t* buf)
{
SPDR = token;
for (uint16_t i = 0; i < 512; i += 2)
{
while (!(SPSR & (1 << SPIF))) {}
SPDR = buf[i];
while (!(SPSR & (1 << SPIF))) {}
SPDR = buf[i + 1];
}
while (!(SPSR & (1 << SPIF))) {}
}
// I2C Support
static void i2cInit(uint32_t clockSpeedHz);
static unsigned char i2cStart(uint8_t address);
static void i2cStartWait(uint8_t address);
static void i2cStop(void);
static uint8_t i2cWrite( uint8_t data );
static uint8_t i2cReadAck(void);
static uint8_t i2cReadNak(void);
// Watchdog support
inline static void startWatchdog()
{
#if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
WDTCSR = (1<<WDCE) | (1<<WDE); // wdt FIX for arduino mega boards
WDTCSR = (1<<WDIE) | (1<<WDP3);
#else
wdt_enable(WDTO_1S);
#endif
};
inline static void stopWatchdog()
{
wdt_disable();
}
inline static void pingWatchdog()
{
#if FEATURE_WATCHDOG
wdt_reset();
#endif
};
inline static float maxExtruderTimerFrequency()
{
return (float)F_CPU/TIMER0_PRESCALE;
}
#if FEATURE_SERVO
static unsigned int servoTimings[4];
static void servoMicroseconds(uint8_t servo,int ms, uint16_t autoOff);
#endif
static void analogStart();
#if USE_ADVANCE
static void resetExtruderDirection();
#endif
protected:
private:
};
/*#if MOTHERBOARD==6 || MOTHERBOARD==62 || MOTHERBOARD==7
#if MOTHERBOARD!=7
#define SIMULATE_PWM
#endif
#define EXTRUDER_TIMER_VECTOR TIMER2_COMPA_vect
#define EXTRUDER_OCR OCR2A
#define EXTRUDER_TCCR TCCR2A
#define EXTRUDER_TIMSK TIMSK2
#define EXTRUDER_OCIE OCIE2A
#define PWM_TIMER_VECTOR TIMER2_COMPB_vect
#define PWM_OCR OCR2B
#define PWM_TCCR TCCR2B
#define PWM_TIMSK TIMSK2
#define PWM_OCIE OCIE2B
#else*/
#define EXTRUDER_TIMER_VECTOR TIMER0_COMPA_vect
#define EXTRUDER_OCR OCR0A
#define EXTRUDER_TCCR TCCR0A
#define EXTRUDER_TIMSK TIMSK0
#define EXTRUDER_OCIE OCIE0A
#define PWM_TIMER_VECTOR TIMER0_COMPB_vect
#define PWM_OCR OCR0B
#define PWM_TCCR TCCR0A
#define PWM_TIMSK TIMSK0
#define PWM_OCIE OCIE0B
//#endif
#endif // HAL_H

2198
Repetier/Printer.cpp Normal file

File diff suppressed because it is too large Load diff

1022
Repetier/Printer.h Normal file

File diff suppressed because it is too large Load diff

875
Repetier/Repetier.cbp Normal file
View file

@ -0,0 +1,875 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Repetier" />
<Option pch_mode="2" />
<Option compiler="avrgcc" />
<Option virtualFolders="libraries\;" />
<Build>
<Target title="Simulator - Debug">
<Option output="bin/Release/Repetier_sim.exe" prefix_auto="1" extension_auto="0" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="GCC" />
<Compiler>
<Add option="-g" />
<Add option="-DF_CPU=16000000L" />
<Add option="-DARDUSIM" />
<Add option="-D__AVR_ATmega2560__" />
<Add option="-x c++" />
<Add directory="$(ARDUINO_DIR)/arduino/cores" />
<Add directory="$(ARDUINO_DIR)/arduino/variants/standard" />
<Add directory="$(ARDUINO_DIR)/include" />
</Compiler>
<Environment>
<Variable name="ARDUINO_DIR" value="$(APP_PATH)\ardusim" />
</Environment>
</Target>
<Target title="Simulator - Release">
<Option output="bin/Release/Repetier_sim.exe" prefix_auto="1" extension_auto="0" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="GCC" />
<Compiler>
<Add option="-Os" />
<Add option="-DF_CPU=16000000L" />
<Add option="-DARDUSIM" />
<Add option="-D__AVR_ATmega2560__" />
<Add option="-x c++" />
<Add directory="$(ARDUINO_DIR)/arduino/cores" />
<Add directory="$(ARDUINO_DIR)/arduino/variants/standard" />
<Add directory="$(ARDUINO_DIR)/include" />
</Compiler>
<Environment>
<Variable name="ARDUINO_DIR" value="$(APP_PATH)\ardusim" />
</Environment>
</Target>
<Target title="Arduino Uno">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Uno" />
<Variable name="BOARD_ID" value="uno" />
<Variable name="MCU" value="atmega328p" />
<Variable name="UPLOAD_BAUDRATE" value="115200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Leonardo">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega32U4__" />
<Add option="-DUSB_VID=0x2341" />
<Add option="-DUSB_PID=0x8036" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/leonardo" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Leonardo" />
<Variable name="BOARD_ID" value="leonardo" />
<Variable name="MCU" value="atmega32u4" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Esplora">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega32U4__" />
<Add option="-DUSB_VID=0x2341" />
<Add option="-DUSB_PID=0x8037" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/leonardo" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Esplora" />
<Variable name="BOARD_ID" value="esplora" />
<Variable name="MCU" value="atmega32u4" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Micro">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega32U4__" />
<Add option="-DUSB_VID=0x2341" />
<Add option="-DUSB_PID=0x803C" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/micro" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Micro" />
<Variable name="BOARD_ID" value="micro" />
<Variable name="MCU" value="atmega32u4" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Duemilanove (328)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Duemilanove (328)" />
<Variable name="BOARD_ID" value="duemilanove328" />
<Variable name="MCU" value="atmega328p" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Duemilanove (168)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega168__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Duemilanove (168)" />
<Variable name="BOARD_ID" value="duemilanove168" />
<Variable name="MCU" value="atmega168" />
<Variable name="UPLOAD_BAUDRATE" value="19200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Nano (328)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Nano (328)" />
<Variable name="BOARD_ID" value="nano328" />
<Variable name="MCU" value="atmega328p" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Nano (168)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega168__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Nano (168)" />
<Variable name="BOARD_ID" value="nano168" />
<Variable name="MCU" value="atmega168" />
<Variable name="UPLOAD_BAUDRATE" value="19200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Mini (328)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Mini (328)" />
<Variable name="BOARD_ID" value="mini328" />
<Variable name="MCU" value="atmega328p" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Mini (168)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega168__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/eightanaloginputs" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Mini (168)" />
<Variable name="BOARD_ID" value="mini168" />
<Variable name="MCU" value="atmega168" />
<Variable name="UPLOAD_BAUDRATE" value="19200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Pro Mini (328)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Pro Mini (328)" />
<Variable name="BOARD_ID" value="promini328" />
<Variable name="MCU" value="atmega328p" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Pro Mini (168)">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega168__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Pro Mini (168)" />
<Variable name="BOARD_ID" value="promini168" />
<Variable name="MCU" value="atmega168" />
<Variable name="UPLOAD_BAUDRATE" value="19200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Mega 2560/ADK">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-Os" />
<Add option="-W" />
<Add option="-Wall" />
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega2560__" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/mega" />
<Add directory="$(ARDUINO_DIR)/libraries/U8glib" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Mega 2560\ADK" />
<Variable name="BOARD_ID" value="mega2560" />
<Variable name="MCU" value="atmega2560" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Mega 1280">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega1280__" />
<Add option="-O2" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/mega" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Mega 1280" />
<Variable name="BOARD_ID" value="mega1280" />
<Variable name="MCU" value="atmega1280" />
<Variable name="UPLOAD_BAUDRATE" value="57600" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Arduino Mega 8">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/standard" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Arduino Mega 8" />
<Variable name="BOARD_ID" value="mega8" />
<Variable name="MCU" value="atmega8" />
<Variable name="UPLOAD_BAUDRATE" value="19200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
<Target title="Microduino Core+">
<Option output="bin/Release/Repetier_${BOARD_ID}_${UPLOAD_PORT}.elf" prefix_auto="1" extension_auto="0" />
<Option type="1" />
<Option compiler="avrgcc" />
<Compiler>
<Add option="-mmcu=$(MCU)" />
<Add option="-DF_CPU=16000000L" />
<Add option="-D__AVR_ATmega328P__" />
<Add option="-Os" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/cores/arduino" />
<Add directory="$(ARDUINO_DIR)/libraries" />
<Add directory="$(ARDUINO_DIR)/hardware/arduino/variants/plus" />
</Compiler>
<Linker>
<Add option="-mmcu=$(MCU)" />
<Add option="-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref" />
</Linker>
<ExtraCommands>
<Add after="avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex" />
<Add after="avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex" />
<Add after="avr-size --mcu=$(MCU) --format=avr $(TARGET_OUTPUT_FILE)" />
<Add after='cmd /c &quot;avr-objdump -h -S $(TARGET_OUTPUT_FILE) &gt; $(TARGET_OUTPUT_FILE).lss&quot;' />
</ExtraCommands>
<Environment>
<Variable name="BOARD" value="Microduino Core+" />
<Variable name="BOARD_ID" value="uduino644p" />
<Variable name="MCU" value="atmega644p" />
<Variable name="UPLOAD_BAUDRATE" value="115200" />
<Variable name="UPLOAD_PORT" value="" />
</Environment>
</Target>
</Build>
<Compiler>
<Add option="-w" />
<Add directory="." />
</Compiler>
<Unit filename="Commands.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="Commands.h" />
<Unit filename="Communication.cpp" />
<Unit filename="Communication.h" />
<Unit filename="Configuration.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="Eeprom.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="Eeprom.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="Extruder.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="Extruder.h" />
<Unit filename="FatStructs.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="HAL.cpp" />
<Unit filename="HAL.h" />
<Unit filename="Printer.cpp" />
<Unit filename="Printer.h" />
<Unit filename="Repetier.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="Repetier.ino">
<Option compile="1" />
<Option link="1" />
<Option compiler="avrgcc" use="1" buildCommand="$compiler $options -x c++ $includes -c $file -o $object" />
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="SDCard.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="SdFat.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="SdFat.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="cores/CDC.cpp" />
<Unit filename="cores/IPAddress.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="cores/Print.cpp" />
<Unit filename="cores/Stream.cpp" />
<Unit filename="cores/Tone.cpp" />
<Unit filename="cores/USBCore.cpp" />
<Unit filename="cores/WInterrupts.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cores/WMath.cpp" />
<Unit filename="cores/WString.cpp" />
<Unit filename="cores/main.cpp" />
<Unit filename="cores/new.cpp" />
<Unit filename="cores/wiring.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cores/wiring_analog.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cores/wiring_digital.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cores/wiring_pulse.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="cores/wiring_shift.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="fastio.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="gcode.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="gcode.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="libraries/EEPROM.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/Ethernet.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/Firmata.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/LiquidCrystal.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/MultiLCD.cpp">
<Option compile="0" />
<Option link="0" />
<Option target="Arduino Uno" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Micro" />
<Option target="Arduino Duemilanove (328)" />
<Option target="Arduino Duemilanove (168)" />
<Option target="Arduino Nano (328)" />
<Option target="Arduino Nano (168)" />
<Option target="Arduino Mini (328)" />
<Option target="Arduino Mini (168)" />
<Option target="Arduino Pro Mini (328)" />
<Option target="Arduino Pro Mini (168)" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
<Option target="Microduino Core+" />
</Unit>
<Unit filename="libraries/OBD.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/SD.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/SPI.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/Servo.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/Stepper.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/TinyGPS.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/U8gui.h">
<Option virtualFolder="libraries/" />
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="libraries/WiFi.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/Wire.cpp">
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="libraries/twi.c">
<Option compilerVar="CC" />
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="motion.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="motion.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="pins.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="u8glib_ex.h" />
<Unit filename="ui.cpp">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="ui.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="uiconfig.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="uilang.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Unit filename="uimenu.h">
<Option target="Simulator - Debug" />
<Option target="Simulator - Release" />
<Option target="Arduino Leonardo" />
<Option target="Arduino Esplora" />
<Option target="Arduino Mega 2560/ADK" />
<Option target="Arduino Mega 1280" />
<Option target="Arduino Mega 8" />
</Unit>
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

1696
Repetier/Repetier.depend Normal file

File diff suppressed because it is too large Load diff

656
Repetier/Repetier.h Normal file
View file

@ -0,0 +1,656 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
*/
#ifndef _REPETIER_H
#define _REPETIER_H
#include <math.h>
#define REPETIER_VERSION "0.92.3"
// ##########################################################################################
// ## Debug configuration ##
// ##########################################################################################
// These are run time sqitchable debug flags
enum debugFlags {DEB_ECHO = 0x1, DEB_INFO = 0x2, DEB_ERROR = 0x4,DEB_DRYRUN = 0x8,
DEB_COMMUNICATION = 0x10, DEB_NOMOVES = 0x20, DEB_DEBUG = 0x40};
/** Uncomment, to see detailed data for every move. Only for debugging purposes! */
//#define DEBUG_QUEUE_MOVE
/** Allows M111 to set bit 5 (16) which disables all commands except M111. This can be used
to test your data througput or search for communication problems. */
#define INCLUDE_DEBUG_COMMUNICATION 1
/** Allows M111 so set bit 6 (32) which disables moves, at the first tried step. In combination
with a dry run, you can test the speed of path computations, which are still performed. */
#define INCLUDE_DEBUG_NO_MOVE 1
/** Writes the free RAM to output, if it is less then at the last test. Should always return
values >500 for safety, since it doesn't catch every function call. Nice to tweak cache
usage or for seraching for memory induced errors. Switch it off for production, it costs execution time. */
//#define DEBUG_FREE_MEMORY
//#define DEBUG_ADVANCE
/** If enabled, writes the created generic table to serial port at startup. */
//#define DEBUG_GENERIC
/** If enabled, steps to move and moved steps are compared. */
//#define DEBUG_STEPCOUNT
/** This enables code to make M666 drop an ok, so you get problems with communication. It is to test host robustness. */
//#define DEBUG_COM_ERRORS
/** Adds a menu point in quick settings to write debg informations to the host in case of hangs where the ui still works. */
//#define DEBUG_PRINT
//#define DEBUG_DELTA_OVERFLOW
//#define DEBUG_DELTA_REALPOS
//#define DEBUG_SPLIT
//#define DEBUG_JAM
// Find the longest segment length during a print
//#define DEBUG_SEGMENT_LENGTH
// Find the maximum real jerk during a print
//#define DEBUG_REAL_JERK
// Uncomment the following line to enable debugging. You can better control debugging below the following line
//#define DEBUG
#define CARTESIAN 0
#define XY_GANTRY 1
#define YX_GANTRY 2
#define DELTA 3
#define TUGA 4
#define BIPOD 5
#define XZ_GANTRY 8
#define ZX_GANTRY 9
#define WIZARD_STACK_SIZE 8
#define IGNORE_COORDINATE 999999
// Uncomment if no analyzer is connected
//#define ANALYZER
// Channel->pin assignments
#define ANALYZER_CH0 63 // New move
#define ANALYZER_CH1 40 // Step loop
#define ANALYZER_CH2 53 // X Step
#define ANALYZER_CH3 65 // Y Step
#define ANALYZER_CH4 59 // X Direction
#define ANALYZER_CH5 64 // Y Direction
#define ANALYZER_CH6 58 // xsig
#define ANALYZER_CH7 57 // ysig
#ifdef ANALYZER
#define ANALYZER_ON(a) {WRITE(a,HIGH);}
#define ANALYZER_OFF(a) {WRITE(a,LOW);}
#else
#define ANALYZER_ON(a)
#define ANALYZER_OFF(a)
#endif
#define X_AXIS 0
#define Y_AXIS 1
#define Z_AXIS 2
#define E_AXIS 3
#define VIRTUAL_AXIS 4
// How big an array to hold X_AXIS..<MAX_AXIS>
#define Z_AXIS_ARRAY 3
#define E_AXIS_ARRAY 4
#define VIRTUAL_AXIS_ARRAY 5
#define A_TOWER 0
#define B_TOWER 1
#define C_TOWER 2
#define TOWER_ARRAY 3
#define E_TOWER_ARRAY 4
#define ANALOG_REF_AREF 0
#define ANALOG_REF_AVCC _BV(REFS0)
#define ANALOG_REF_INT_1_1 _BV(REFS1)
#define ANALOG_REF_INT_2_56 _BV(REFS0) | _BV(REFS1)
#define ANALOG_REF ANALOG_REF_AVCC
#define HOME_ORDER_XYZ 1
#define HOME_ORDER_XZY 2
#define HOME_ORDER_YXZ 3
#define HOME_ORDER_YZX 4
#define HOME_ORDER_ZXY 5
#define HOME_ORDER_ZYX 6
#define HOME_ORDER_ZXYTZ 7 // Needs hot hotend for correct homing
#define NO_CONTROLLER 0
#define UICONFIG_CONTROLLER 1
#define CONTROLLER_SMARTRAMPS 2
#define CONTROLLER_ADAFRUIT 3
#define CONTROLLER_FOLTYN 4
#define CONTROLLER_VIKI 5
#define CONTROLLER_MEGATRONIC 6
#define CONTROLLER_RADDS 7
#define CONTROLLER_PIBOT20X4 8
#define CONTROLLER_PIBOT16X2 9
#define CONTROLLER_GADGETS3D_SHIELD 10
#define CONTROLLER_REPRAPDISCOUNT_GLCD 11
#define CONTROLLER_FELIX 12
#define CONTROLLER_RAMBO 13
#define CONTROLLER_OPENHARDWARE_LCD2004 14
#define CONTROLLER_SANGUINOLOLU_PANELOLU2 15
#define CONTROLLER_GAMEDUINO2 16
#define CONTROLLER_MIREGLI 17
#define CONTROLLER_GATE_3NOVATICA 18
#define CONTROLLER_SPARKLCD 19
#define CONTROLLER_BAM_DICE_DUE 20
#define CONTROLLER_VIKI2 21
#define CONTROLLER_FELIX_DUE 405
//direction flags
#define X_DIRPOS 1
#define Y_DIRPOS 2
#define Z_DIRPOS 4
#define E_DIRPOS 8
#define XYZ_DIRPOS 7
//step flags
#define XSTEP 16
#define YSTEP 32
#define ZSTEP 64
#define ESTEP 128
//combo's
#define XYZ_STEP 112
#define XY_STEP 48
#define XYZE_STEP 240
#define E_STEP_DIRPOS 136
#define Y_STEP_DIRPOS 34
#define X_STEP_DIRPOS 17
#define Z_STEP_DIRPOS 68
// add pid control
#define TEMP_PID 1
#include "Configuration.h"
#if FEATURE_Z_PROBE && Z_PROBE_PIN < 0
#error You need to define Z_PROBE_PIN to use z probe!
#endif
#if DISTORTION_CORRECTION
#if !FEATURE_Z_PROBE
#error Distortion correction requires the z probe feature to be enabled and configured!
#endif
#endif
#ifndef MAX_ROOM_TEMPERATURE
#define MAX_ROOM_TEMPERATURE 40
#endif
#ifndef ZHOME_X_POS
#define ZHOME_X_POS IGNORE_COORDINATE
#endif
#ifndef ZHOME_Y_POS
#define ZHOME_Y_POS IGNORE_COORDINATE
#endif
// MS1 MS2 Stepper Driver Microstepping mode table
#define MICROSTEP1 LOW,LOW
#define MICROSTEP2 HIGH,LOW
#define MICROSTEP4 LOW,HIGH
#define MICROSTEP8 HIGH,HIGH
#if (MOTHERBOARD == 501)
#define MICROSTEP16 LOW,LOW
#else
#define MICROSTEP16 HIGH,HIGH
#endif
#define MICROSTEP32 HIGH,HIGH
#define GCODE_BUFFER_SIZE 1
#ifndef FEATURE_BABYSTEPPING
#define FEATURE_BABYSTEPPING 0
#define BABYSTEP_MULTIPLICATOR 1
#endif
#if !defined(Z_PROBE_REPETITIONS) || Z_PROBE_REPETITIONS < 1
#define Z_PROBE_SWITCHING_DISTANCE 0.5 // Distance to safely untrigger probe
#define Z_PROBE_REPETITIONS 1
#endif
#ifndef MINMAX_HARDWARE_ENDSTOP_Z2
#define MINMAX_HARDWARE_ENDSTOP_Z2 0
#define Z2_MINMAX_PIN -1
#endif
#define SPEED_MIN_MILLIS 400
#define SPEED_MAX_MILLIS 60
#define SPEED_MAGNIFICATION 100.0f
#define SOFTWARE_LEVELING (FEATURE_SOFTWARE_LEVELING && (DRIVE_SYSTEM==DELTA))
/** \brief Horizontal distance bridged by the diagonal push rod when the end effector is in the center. It is pretty close to 50% of the push rod length (250 mm).
*/
#define ROD_RADIUS (PRINTER_RADIUS-END_EFFECTOR_HORIZONTAL_OFFSET-CARRIAGE_HORIZONTAL_OFFSET)
#ifndef UI_SPEEDDEPENDENT_POSITIONING
#define UI_SPEEDDEPENDENT_POSITIONING true
#endif
#if DRIVE_SYSTEM==DELTA || DRIVE_SYSTEM==TUGA || DRIVE_SYSTEM==BIPOD
#define NONLINEAR_SYSTEM 1
#else
#define NONLINEAR_SYSTEM 0
#endif
#ifdef FEATURE_Z_PROBE
#define MANUAL_CONTROL 1
#endif
#define GANTRY ( DRIVE_SYSTEM==XY_GANTRY || DRIVE_SYSTEM==YX_GANTRY || DRIVE_SYSTEM==XZ_GANTRY || DRIVE_SYSTEM==ZX_GANTRY)
//Step to split a cirrcle in small Lines
#ifndef MM_PER_ARC_SEGMENT
#define MM_PER_ARC_SEGMENT 1
#define MM_PER_ARC_SEGMENT_BIG 3
#else
#define MM_PER_ARC_SEGMENT_BIG MM_PER_ARC_SEGMENT
#endif
//After this count of steps a new SIN / COS caluclation is startet to correct the circle interpolation
#define N_ARC_CORRECTION 25
// Test for shared cooler
#if NUM_EXTRUDER == 6 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT3_EXTRUDER_COOLER_PIN && EXT4_EXTRUDER_COOLER_PIN == EXT5_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT2_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT4_EXTRUDER_COOLER_PIN
#define SHARED_COOLER 1
#elif NUM_EXTRUDER == 5 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT3_EXTRUDER_COOLER_PIN && EXT3_EXTRUDER_COOLER_PIN == EXT5_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT2_EXTRUDER_COOLER_PIN
#define SHARED_COOLER 1
#elif NUM_EXTRUDER == 4 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT3_EXTRUDER_COOLER_PIN && EXT0_EXTRUDER_COOLER_PIN == EXT2_EXTRUDER_COOLER_PIN
#define SHARED_COOLER 1
#elif NUM_EXTRUDER == 3 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN && EXT2_EXTRUDER_COOLER_PIN == EXT0_EXTRUDER_COOLER_PIN
#define SHARED_COOLER 1
#elif NUM_EXTRUDER == 2 && EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == EXT1_EXTRUDER_COOLER_PIN
#define SHARED_COOLER 1
#else
#define SHARED_COOLER 0
#endif
// Test for shared coolers between extruders and mainboard
#if EXT0_EXTRUDER_COOLER_PIN > -1 && EXT0_EXTRUDER_COOLER_PIN == FAN_BOARD_PIN
#define SHARED_COOLER_BOARD_EXT 1
#else
#define SHARED_COOLER_BOARD_EXT 0
#endif
#if defined(UI_SERVO_CONTROL) && UI_SERVO_CONTROL > FEATURE_SERVO
#undef UI_SERVO_CONTROL
#define UI_SERVO_CONTROL FEATURE_SERVO
#endif
#if (defined(EXT0_JAM_PIN) && EXT0_JAM_PIN > -1) || (defined(EXT1_JAM_PIN) && EXT1_JAM_PIN > -1) || (defined(EXT2_JAM_PIN) && EXT2_JAM_PIN > -1) || (defined(EXT3_JAM_PIN) && EXT3_JAM_PIN > -1) || (defined(EXT4_JAM_PIN) && EXT4_JAM_PIN > -1) || (defined(EXT5_JAM_PIN) && EXT5_JAM_PIN > -1)
#define EXTRUDER_JAM_CONTROL 1
#else
#define EXTRUDER_JAM_CONTROL 0
#endif
#if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE < 101
#define EXT0_ANALOG_INPUTS 1
#define EXT0_SENSOR_INDEX 0
#define EXT0_ANALOG_CHANNEL EXT0_TEMPSENSOR_PIN
#define ACCOMMA0 ,
#else
#define ACCOMMA0
#define EXT0_ANALOG_INPUTS 0
#define EXT0_SENSOR_INDEX EXT0_TEMPSENSOR_PIN
#define EXT0_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER>1 && EXT1_TEMPSENSOR_TYPE<101
#define EXT1_ANALOG_INPUTS 1
#define EXT1_SENSOR_INDEX EXT0_ANALOG_INPUTS
#define EXT1_ANALOG_CHANNEL ACCOMMA0 EXT1_TEMPSENSOR_PIN
#define ACCOMMA1 ,
#else
#define ACCOMMA1 ACCOMMA0
#define EXT1_ANALOG_INPUTS 0
#define EXT1_SENSOR_INDEX EXT1_TEMPSENSOR_PIN
#define EXT1_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER>2 && EXT2_TEMPSENSOR_TYPE<101
#define EXT2_ANALOG_INPUTS 1
#define EXT2_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS
#define EXT2_ANALOG_CHANNEL ACCOMMA1 EXT2_TEMPSENSOR_PIN
#define ACCOMMA2 ,
#else
#define ACCOMMA2 ACCOMMA1
#define EXT2_ANALOG_INPUTS 0
#define EXT2_SENSOR_INDEX EXT2_TEMPSENSOR_PIN
#define EXT2_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER > 3 && EXT3_TEMPSENSOR_TYPE < 101
#define EXT3_ANALOG_INPUTS 1
#define EXT3_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS
#define EXT3_ANALOG_CHANNEL ACCOMMA2 EXT3_TEMPSENSOR_PIN
#define ACCOMMA3 ,
#else
#define ACCOMMA3 ACCOMMA2
#define EXT3_ANALOG_INPUTS 0
#define EXT3_SENSOR_INDEX EXT3_TEMPSENSOR_PIN
#define EXT3_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER > 4 && EXT4_TEMPSENSOR_TYPE < 101
#define EXT4_ANALOG_INPUTS 1
#define EXT4_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS
#define EXT4_ANALOG_CHANNEL ACCOMMA3 EXT4_TEMPSENSOR_PIN
#define ACCOMMA4 ,
#else
#define ACCOMMA4 ACCOMMA3
#define EXT4_ANALOG_INPUTS 0
#define EXT4_SENSOR_INDEX EXT4_TEMPSENSOR_PIN
#define EXT4_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER>5 && EXT5_TEMPSENSOR_TYPE<101
#define EXT5_ANALOG_INPUTS 1
#define EXT5_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS
#define EXT5_ANALOG_CHANNEL ACCOMMA4 EXT5_TEMPSENSOR_PIN
#define ACCOMMA5 ,
#else
#define ACCOMMA5 ACCOMMA4
#define EXT5_ANALOG_INPUTS 0
#define EXT5_SENSOR_INDEX EXT5_TEMPSENSOR_PIN
#define EXT5_ANALOG_CHANNEL
#endif
#if HAVE_HEATED_BED && HEATED_BED_SENSOR_TYPE<101
#define BED_ANALOG_INPUTS 1
#define BED_SENSOR_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS
#define BED_ANALOG_CHANNEL ACCOMMA5 HEATED_BED_SENSOR_PIN
#undef KOMMA
#define KOMMA ,
#else
#define BED_ANALOG_INPUTS 0
#define BED_SENSOR_INDEX HEATED_BED_SENSOR_PIN
#define BED_ANALOG_CHANNEL
#endif
#ifndef DEBUG_FREE_MEMORY
#define DEBUG_MEMORY
#else
#define DEBUG_MEMORY Commands::checkFreeMemory();
#endif
/** \brief number of analog input signals. Normally 1 for each temperature sensor */
#define ANALOG_INPUTS (EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS)
#if ANALOG_INPUTS>0
/** Channels are the MUX-part of ADMUX register */
#define ANALOG_INPUT_CHANNELS {EXT0_ANALOG_CHANNEL EXT1_ANALOG_CHANNEL EXT2_ANALOG_CHANNEL EXT3_ANALOG_CHANNEL EXT4_ANALOG_CHANNEL EXT5_ANALOG_CHANNEL BED_ANALOG_CHANNEL}
#endif
#define MENU_MODE_SD_MOUNTED 1
#define MENU_MODE_SD_PRINTING 2
#define MENU_MODE_SD_PAUSED 4
#define MENU_MODE_FAN_RUNNING 8
#define MENU_MODE_PRINTING 16
#define MENU_MODE_FULL_PID 32
#define MENU_MODE_DEADTIME 64
#include "HAL.h"
#include "gcode.h"
#define MAX_VFAT_ENTRIES (2)
/** Total size of the buffer used to store the long filenames */
#define LONG_FILENAME_LENGTH (13*MAX_VFAT_ENTRIES+1)
#define SD_MAX_FOLDER_DEPTH 2
#include "ui.h"
#include "Communication.h"
#if UI_DISPLAY_TYPE != DISPLAY_U8G
#if (defined(USER_KEY1_PIN) && (USER_KEY1_PIN==UI_DISPLAY_D5_PIN || USER_KEY1_PIN==UI_DISPLAY_D6_PIN || USER_KEY1_PIN==UI_DISPLAY_D7_PIN)) || (defined(USER_KEY2_PIN) && (USER_KEY2_PIN==UI_DISPLAY_D5_PIN || USER_KEY2_PIN==UI_DISPLAY_D6_PIN || USER_KEY2_PIN==UI_DISPLAY_D7_PIN)) || (defined(USER_KEY3_PIN) && (USER_KEY3_PIN==UI_DISPLAY_D5_PIN || USER_KEY3_PIN==UI_DISPLAY_D6_PIN || USER_KEY3_PIN==UI_DISPLAY_D7_PIN)) || (defined(USER_KEY4_PIN) && (USER_KEY4_PIN==UI_DISPLAY_D5_PIN || USER_KEY4_PIN==UI_DISPLAY_D6_PIN || USER_KEY4_PIN==UI_DISPLAY_D7_PIN))
#error "You cannot use DISPLAY_D5_PIN, DISPLAY_D6_PIN or DISPLAY_D7_PIN for "User Keys" with character LCD display"
#endif
#endif
#ifndef SDCARDDETECT
#define SDCARDDETECT -1
#endif
#ifndef SDSUPPORT
#define SDSUPPORT 0
#endif
#if SDSUPPORT
#include "SdFat.h"
#endif
#if ENABLE_BACKLASH_COMPENSATION && DRIVE_SYSTEM != CARTESIAN
#undef ENABLE_BACKLASH_COMPENSATION
#define ENABLE_BACKLASH_COMPENSATION false
#endif
#define uint uint16_t
#define uint8 uint8_t
#define int8 int8_t
#define uint32 uint32_t
#define int32 int32_t
#undef min
#undef max
class RMath {
public:
static inline float min(float a,float b) {
if(a<b) return a;
return b;
}
static inline float max(float a,float b) {
if(a<b) return b;
return a;
}
static inline int32_t min(int32_t a,int32_t b) {
if(a<b) return a;
return b;
}
static inline int32_t min(int32_t a,int32_t b, int32_t c) {
if(a<b) return a<c ? a : c;
return b<c ? b : c;
}
static inline float min(float a,float b, float c) {
if(a<b) return a<c ? a : c;
return b<c ? b : c;
}
static inline int32_t max(int32_t a,int32_t b) {
if(a<b) return b;
return a;
}
static inline int min(int a,int b) {
if(a<b) return a;
return b;
}
static inline uint16_t min(uint16_t a,uint16_t b) {
if(a<b) return a;
return b;
}
static inline int16_t max(int16_t a,int16_t b) {
if(a<b) return b;
return a;
}
static inline uint16_t max(uint16_t a,uint16_t b) {
if(a<b) return b;
return a;
}
static inline unsigned long absLong(long a) {return a >= 0 ? a : -a;}
static inline int32_t sqr(int32_t a) {return a*a;}
static inline uint32_t sqr(uint32_t a) {return a*a;}
#ifdef SUPPORT_64_BIT_MATH
static inline int64_t sqr(int64_t a) {return a*a;}
static inline uint64_t sqr(uint64_t a) {return a*a;}
#endif
static inline float sqr(float a) {return a*a;}
};
extern const uint8 osAnalogInputChannels[] PROGMEM;
//extern uint8 osAnalogInputCounter[ANALOG_INPUTS];
//extern uint osAnalogInputBuildup[ANALOG_INPUTS];
//extern uint8 osAnalogInputPos; // Current sampling position
extern volatile uint osAnalogInputValues[ANALOG_INPUTS];
extern uint8_t pwm_pos[NUM_EXTRUDER+3]; // 0-NUM_EXTRUDER = Heater 0-NUM_EXTRUDER of extruder, NUM_EXTRUDER = Heated bed, NUM_EXTRUDER+1 Board fan, NUM_EXTRUDER+2 = Fan
#if USE_ADVANCE
#if ENABLE_QUADRATIC_ADVANCE
extern int maxadv;
#endif
extern int maxadv2;
extern float maxadvspeed;
#endif
#include "Extruder.h"
void manage_inactivity(uint8_t debug);
extern void finishNextSegment();
#if NONLINEAR_SYSTEM
extern uint8_t transformCartesianStepsToDeltaSteps(long cartesianPosSteps[], long deltaPosSteps[]);
#if SOFTWARE_LEVELING
extern void calculatePlane(long factors[], long p1[], long p2[], long p3[]);
extern float calcZOffset(long factors[], long pointX, long pointY);
#endif
#endif
extern void linear_move(long steps_remaining[]);
#ifndef FEATURE_DITTO_PRINTING
#define FEATURE_DITTO_PRINTING false
#endif
#if FEATURE_DITTO_PRINTING && (NUM_EXTRUDER > 4 || NUM_EXTRUDER < 2)
#error Ditto printing requires 2 - 4 extruder.
#endif
extern millis_t previousMillisCmd;
extern millis_t maxInactiveTime;
extern millis_t stepperInactiveTime;
extern void setupTimerInterrupt();
extern void motorCurrentControlInit();
extern void microstepInit();
#include "Printer.h"
#include "motion.h"
extern long baudrate;
#if OS_ANALOG_INPUTS>0
// Get last result for pin x
extern volatile uint osAnalogInputValues[OS_ANALOG_INPUTS];
#endif
#include "HAL.h"
extern unsigned int counterPeriodical;
extern volatile uint8_t executePeriodical;
extern uint8_t counter250ms;
extern void writeMonitor();
extern uint8_t fanKickstart;
#if SDSUPPORT
extern char tempLongFilename[LONG_FILENAME_LENGTH+1];
extern char fullName[LONG_FILENAME_LENGTH*SD_MAX_FOLDER_DEPTH+SD_MAX_FOLDER_DEPTH+1];
#define SHORT_FILENAME_LENGTH 14
#include "SdFat.h"
enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
class SDCard {
public:
SdFat fat;
//Sd2Card card; // ~14 Byte
//SdVolume volume;
//SdFile root;
//SdFile dir[SD_MAX_FOLDER_DEPTH+1];
SdFile file;
uint32_t filesize;
uint32_t sdpos;
//char fullName[13*SD_MAX_FOLDER_DEPTH+13]; // Fill name
char *shortname; // Pointer to start of filename itself
char *pathend; // File to char where pathname in fullname ends
uint8_t sdmode; // true if we are printing from sd card, 2 = stop accepting new commands
bool sdactive;
//int16_t n;
bool savetosd;
SdBaseFile parentFound;
SDCard();
void initsd();
void writeCommand(GCode *code);
bool selectFile(const char *filename,bool silent=false);
void mount();
void unmount();
void startPrint();
void pausePrint(bool intern = false);
void continuePrint(bool intern = false);
void stopPrint();
inline void setIndex(uint32_t newpos) { if(!sdactive) return; sdpos = newpos;file.seekSet(sdpos);}
void printStatus();
void ls();
void startWrite(char *filename);
void deleteFile(char *filename);
void finishWrite();
char *createFilename(char *buffer,const dir_t &p);
void makeDirectory(char *filename);
bool showFilename(const uint8_t *name);
void automount();
#ifdef GLENN_DEBUG
void writeToFile();
#endif
private:
uint8_t lsRecursive(SdBaseFile *parent,uint8_t level,char *findFilename);
// SdFile *getDirectory(char* name);
};
extern SDCard sd;
#endif
extern volatile int waitRelax; // Delay filament relax at the end of print, could be a simple timeout
extern void updateStepsParameter(PrintLine *p/*,uint8_t caller*/);
#ifdef DEBUG_PRINT
extern int debugWaitLoop;
#endif
#if NONLINEAR_SYSTEM
#define NUM_AXIS 4
#endif
#define STR(s) #s
#define XSTR(s) STR(s)
#include "Commands.h"
#include "Eeprom.h"
#if CPU_ARCH == ARCH_AVR
#define DELAY1MICROSECOND __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
#define DELAY2MICROSECOND __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\tnop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
#else
#define DELAY1MICROSECOND HAL::delayMicroseconds(1);
#define DELAY2MICROSECOND HAL::delayMicroseconds(2);
#endif
#ifdef FAST_INTEGER_SQRT
#define SQRT(x) ( HAL::integerSqrt(x) )
#else
#define SQRT(x) sqrt(x)
#endif
#include "Drivers.h"
#include "Events.h"
#if defined(CUSTOM_EVENTS)
#include "CustomEvents.h"
#endif
#endif

167
Repetier/Repetier.ino Normal file
View file

@ -0,0 +1,167 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
Main author: repetier
*/
/**
\mainpage Repetier-Firmware for Arduino based RepRaps
<CENTER>Copyright &copy; 2011-2013 by repetier
</CENTER>
\section Intro Introduction
\section GCodes Implemented GCodes
look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
and http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
Implemented Codes
- G0 -> G1
- G1 - Coordinated Movement X Y Z E, S1 disables boundary check, S0 enables it
- G4 - Dwell S<seconds> or P<milliseconds>
- G10 S<1 = long retract, 0 = short retract = default> retracts filament accoridng to stored setting
- G11 S<1 = long retract, 0 = short retract = default> = Undo retraction according to stored setting
- G20 - Units for G0/G1 are inches.
- G21 - Units for G0/G1 are mm.
- G28 - Home all axis or named axis.
- G29 S<0..2> - Z-Probe at the 3 defined probe points. S = 1 measure avg. zHeight, S = 2 store avg zHeight
- G30 P<0..3> - Single z-probe at current position P = 1 first measurement, P = 2 Last measurement P = 0 or 3 first and last measurement
- G31 - Write signal of probe sensor
- G32 S<0..2> P<0..1> - Autolevel print bed. S = 1 measure zLength, S = 2 Measue and store new zLength
- G90 - Use absolute coordinates
- G91 - Use relative coordinates
- G92 - Set current position to cordinates given
- G131 - set extruder offset position to 0 - needed for calibration with G132
- G132 - calibrate endstop positions. Call this, after calling G131 and after centering the extruder holder.
RepRap M Codes
- M104 - Set extruder target temp
- M105 - Read current temp
- M106 - Fan on
- M107 - Fan off
- M109 - Wait for extruder current temp to reach target temp.
- M114 - Display current position
Custom M Codes
- M20 - List SD card
- M21 - Init SD card
- M22 - Release SD card
- M23 - Select SD file (M23 filename.g)
- M24 - Start/resume SD print
- M25 - Pause SD print
- M26 - Set SD position in bytes (M26 S12345)
- M27 - Report SD print status
- M28 - Start SD write (M28 filename.g)
- M29 - Stop SD write
- M30 <filename> - Delete file on sd card
- M32 <dirname> create subdirectory
- M42 P<pin number> S<value 0..255> - Change output of pin P to S. Does not work on most important pins.
- M80 - Turn on power supply
- M81 - Turn off power supply
- M82 - Set E codes absolute (default)
- M83 - Set E codes relative while in Absolute Coordinates (G90) mode
- M84 - Disable steppers until next move,
or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
- M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
- M92 - Set axisStepsPerMM - same syntax as G92
- M99 S<delayInSec> X0 Y0 Z0 - Disable motors for S seconds (default 10) for given axis.
- M104 S<temp> T<extruder> P1 F1 - Set temperature without wait. P1 = wait for moves to finish, F1 = beep when temp. reached first time
- M105 X0 - Get temperatures. If X0 is added, the raw analog values are also written.
- M112 - Emergency kill
- M115- Capabilities string
- M116 - Wait for all temperatures in a +/- 1 degree range
- M117 <message> - Write message in status row on lcd
- M119 - Report endstop status
- M140 S<temp> F1 - Set bed target temp, F1 makes a beep when temperature is reached the first time
- M163 S<extruderNum> P<weight> - Set weight for this mixing extruder drive
- M164 S<virtNum> P<0 = dont store eeprom,1 = store to eeprom> - Store weights as virtual extruder S
- M190 - Wait for bed current temp to reach target temp.
- M200 T<extruder> D<diameter> - Use volumetric extrusion. Set D0 or omit D to disable volumetric extr. Omit T for current extruder.
- M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
- M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000)
- M203 - Set temperture monitor to Sx
- M204 - Set PID parameter X => Kp Y => Ki Z => Kd S<extruder> Default is current extruder. NUM_EXTRUDER=Heated bed
- M205 - Output EEPROM settings
- M206 - Set EEPROM value
- M207 X<XY jerk> Z<Z Jerk> E<ExtruderJerk> - Changes current jerk values, but do not store them in eeprom.
- M209 S<0/1> - Enable/disable autoretraction
- M220 S<Feedrate multiplier in percent> - Increase/decrease given feedrate
- M221 S<Extrusion flow multiplier in percent> - Increase/decrease given flow rate
- M231 S<OPS_MODE> X<Min_Distance> Y<Retract> Z<Backlash> F<ReatrctMove> - Set OPS parameter
- M232 - Read and reset max. advance values
- M233 X<AdvanceK> Y<AdvanceL> - Set temporary advance K-value to X and linear term advanceL to Y
- M251 Measure Z steps from homing stop (Delta printers). S0 - Reset, S1 - Print, S2 - Store to Z length (also EEPROM if enabled)
- M280 S<mode> - Set ditto printing mode. mode: 0 = off, 1 = 1 extra extruder, 2 = 2 extra extruder, 3 = 3 extra extruders
- M281 Test if watchdog is running and working.
- M300 S<Frequency> P<DurationMillis> play frequency
- M302 S<0 or 1> - allow cold extrusion. Without S parameter it will allow. S1 will disallow.
- M303 P<extruder/bed> S<printTemerature> X0 R<Repetitions>- Autodetect pid values. Use P<NUM_EXTRUDER> for heated bed. X0 saves result in EEPROM. R is number of cycles.
- M320 - Activate autolevel
- M321 - Deactivate autolevel
- M322 - Reset autolevel matrix
- M323 S0/S1 enable disable distortion correction P0 = not permanent, P1 = permanent = default
- M340 P<servoId> S<pulseInUS> R<autoOffIn ms>: servoID = 0..3, Servos are controlled by a pulse with normally between 500 and 2500 with 1500ms in center position. 0 turns servo off. R allows automatic disabling after a while.
- M350 S<mstepsAll> X<mstepsX> Y<mstepsY> Z<mstepsZ> E<mstepsE0> P<mstespE1> : Set microstepping on RAMBO board
- M355 S<0/1> - Turn case light on/off, no S = report status
- M360 - show configuration
- M400 - Wait until move buffers empty.
- M401 - Store x, y and z position.
- M402 - Go to stored position. If X, Y or Z is specified, only these coordinates are used. F changes feedrate fo rthat move.
- M500 Store settings to EEPROM
- M501 Load settings from EEPROM
- M502 Reset settings to the one in configuration.h. Does not store values in EEPROM!
- M513 - Clear all jam marker.
- M600 Change filament
- M601 S<1/0> - Pause extruders. Paused extrudes disable heaters and motor. Unpausing reheats extruder to old temp.
- M602 S<1/0> P<1/0>- Debug jam control (S) Disable jam control (P). If enabled it will log signal changes and will not trigger jam errors!
- M908 P<address> S<value> : Set stepper current for digipot (RAMBO board)
*/
#include "Repetier.h"
#include <SPI.h>
#if UI_DISPLAY_TYPE == DISPLAY_ARDUINO_LIB
//#include <LiquidCrystal.h> // Uncomment this if you are using liquid crystal library
#endif
void setup()
{
Printer::setup();
}
void loop()
{
Commands::commandLoop();
}

213
Repetier/Repetier.layout Normal file
View file

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Arduino Mega 2560/ADK" />
<File name="fastio.h" open="0" top="0" tabpos="25" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2263" topLine="59" />
</Cursor>
</File>
<File name="gcode.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="21260" topLine="603" />
</Cursor>
<Folding>
<Collapse line="231" />
<Collapse line="239" />
</Folding>
</File>
<File name="gcode.h" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1228" topLine="15" />
</Cursor>
</File>
<File name="libraries\EEPROM.cpp" open="0" top="0" tabpos="29" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="libraries\Ethernet.cpp" open="0" top="0" tabpos="28" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="Printer.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2659" topLine="26" />
</Cursor>
<Folding>
<Collapse line="179" />
<Collapse line="1059" />
</Folding>
</File>
<File name="Printer.h" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7168" topLine="126" />
</Cursor>
</File>
<File name="Repetier.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2489" topLine="27" />
</Cursor>
</File>
<File name="Repetier.ino" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1912" topLine="37" />
</Cursor>
</File>
<File name="libraries\OBD.cpp" open="0" top="0" tabpos="33" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="SDCard.cpp" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="2466" topLine="71" />
</Cursor>
</File>
<File name="SdFat.cpp" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="86777" topLine="3013" />
</Cursor>
</File>
<File name="libraries\SPI.cpp" open="0" top="0" tabpos="37" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20" topLine="0" />
</Cursor>
</File>
<File name="Communication.h" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="10270" topLine="346" />
</Cursor>
</File>
<File name="SdFat.h" open="0" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="29389" topLine="772" />
</Cursor>
</File>
<File name="libraries\Servo.cpp" open="0" top="0" tabpos="34" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="Configuration.h" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="7460" topLine="217" />
</Cursor>
</File>
<File name="motion.cpp" open="1" top="1" tabpos="12" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="26758" topLine="645" />
</Cursor>
<Folding>
<Collapse line="891" />
<Collapse line="912" />
<Collapse line="938" />
<Collapse line="1397" />
</Folding>
</File>
<File name="libraries\Stepper.cpp" open="0" top="0" tabpos="36" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="Eeprom.cpp" open="1" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="26476" topLine="616" />
</Cursor>
</File>
<File name="motion.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="18497" topLine="629" />
</Cursor>
</File>
<File name="Eeprom.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="pins.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="32601" topLine="1166" />
</Cursor>
</File>
<File name="cores\Print.cpp" open="0" top="0" tabpos="26" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="Extruder.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="838" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="34982" topLine="885" />
</Cursor>
</File>
<File name="u8glib_ex.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="11774" topLine="315" />
</Cursor>
</File>
<File name="cores\Stream.cpp" open="0" top="0" tabpos="27" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="Extruder.h" open="0" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1209" topLine="13" />
</Cursor>
</File>
<File name="ui.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="89117" topLine="2763" />
</Cursor>
</File>
<File name="FatStructs.h" open="0" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="952" topLine="0" />
</Cursor>
</File>
<File name="ui.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="24207" topLine="12" />
</Cursor>
</File>
<File name="HAL.cpp" open="1" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="12287" topLine="267" />
</Cursor>
</File>
<File name="uiconfig.h" open="0" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2235" topLine="48" />
</Cursor>
</File>
<File name="HAL.h" open="1" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="7282" topLine="212" />
</Cursor>
</File>
<File name="uilang.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="9398" topLine="202" />
</Cursor>
</File>
<File name="Commands.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor>
<Cursor1 position="56856" topLine="1491" />
</Cursor>
</File>
<File name="uimenu.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13785" topLine="361" />
</Cursor>
</File>
<File name="Commands.h" open="0" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1295" topLine="10" />
</Cursor>
</File>
<File name="Communication.cpp" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="19721" topLine="459" />
</Cursor>
</File>
</CodeBlocks_layout_file>

484
Repetier/SDCard.cpp Normal file
View file

@ -0,0 +1,484 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
*/
#include "Repetier.h"
#if SDSUPPORT
char tempLongFilename[LONG_FILENAME_LENGTH + 1];
char fullName[LONG_FILENAME_LENGTH * SD_MAX_FOLDER_DEPTH + SD_MAX_FOLDER_DEPTH + 1];
SDCard sd;
SDCard::SDCard()
{
sdmode = 0;
sdactive = false;
savetosd = false;
Printer::setAutomount(false);
}
void SDCard::automount()
{
#if SDCARDDETECT > -1
if(READ(SDCARDDETECT) != SDCARDDETECTINVERTED)
{
if(sdactive) // Card removed
{
Com::printFLN(PSTR("SD card removed"));
#if UI_DISPLAY_TYPE != NO_DISPLAY
uid.executeAction(UI_ACTION_TOP_MENU, true);
#endif
unmount();
UI_STATUS(UI_TEXT_SD_REMOVED);
}
}
else
{
if(!sdactive)
{
UI_STATUS(UI_TEXT_SD_INSERTED);
Com::printFLN(PSTR("SD card inserted")); // Not translateable or host will not understand signal
initsd();
#if UI_DISPLAY_TYPE != NO_DISPLAY
if(sdactive) {
Printer::setAutomount(true);
uid.executeAction(UI_ACTION_SD_PRINT + UI_ACTION_TOPMENU, true);
}
#endif
}
}
#endif
}
void SDCard::initsd()
{
sdactive = false;
#if SDSS > -1
#if SDCARDDETECT > -1
if(READ(SDCARDDETECT) != SDCARDDETECTINVERTED)
return;
#endif
/*if(dir[0].isOpen())
dir[0].close();*/
if(!fat.begin(SDSS, SPI_FULL_SPEED))
{
Com::printFLN(Com::tSDInitFail);
return;
}
sdactive = true;
Printer::setMenuMode(MENU_MODE_SD_MOUNTED, true);
fat.chdir();
if(selectFile("init.g", true))
{
startPrint();
}
#endif
}
void SDCard::mount()
{
sdmode = 0;
initsd();
}
void SDCard::unmount()
{
sdmode = 0;
sdactive = false;
savetosd = false;
Printer::setAutomount(false);
Printer::setMenuMode(MENU_MODE_SD_MOUNTED + MENU_MODE_SD_PAUSED + MENU_MODE_SD_PRINTING, false);
#if UI_DISPLAY_TYPE != NO_DISPLAY && SDSUPPORT
uid.cwd[0] = '/';
uid.cwd[1] = 0;
uid.folderLevel = 0;
#endif
}
void SDCard::startPrint()
{
if(!sdactive) return;
sdmode = 1;
Printer::setMenuMode(MENU_MODE_SD_PRINTING, true);
Printer::setMenuMode(MENU_MODE_SD_PAUSED, false);
}
void SDCard::pausePrint(bool intern)
{
if(!sd.sdactive) return;
sdmode = 2; // finish running line
Printer::setMenuMode(MENU_MODE_SD_PAUSED, true);
if(intern) {
Commands::waitUntilEndOfAllBuffers();
sdmode = 0;
Printer::MemoryPosition();
Printer::moveToReal(IGNORE_COORDINATE, IGNORE_COORDINATE, IGNORE_COORDINATE,
Printer::memoryE - RETRACT_ON_PAUSE,
Printer::maxFeedrate[E_AXIS] / 2);
#if DRIVE_SYSTEM == DELTA
Printer::moveToReal(0, 0.9 * EEPROM::deltaMaxRadius(), IGNORE_COORDINATE, IGNORE_COORDINATE, Printer::maxFeedrate[X_AXIS]);
#else
Printer::moveToReal(Printer::xMin, Printer::yMin + Printer::yLength, IGNORE_COORDINATE, IGNORE_COORDINATE, Printer::maxFeedrate[X_AXIS]);
#endif
Printer::lastCmdPos[X_AXIS] = Printer::currentPosition[X_AXIS];
Printer::lastCmdPos[Y_AXIS] = Printer::currentPosition[Y_AXIS];
Printer::lastCmdPos[Z_AXIS] = Printer::currentPosition[Z_AXIS];
GCode::executeFString(PSTR(PAUSE_START_COMMANDS));
}
}
void SDCard::continuePrint(bool intern)
{
if(!sd.sdactive) return;
if(intern) {
GCode::executeFString(PSTR(PAUSE_END_COMMANDS));
Printer::GoToMemoryPosition(true, true, false, false, Printer::maxFeedrate[X_AXIS]);
Printer::GoToMemoryPosition(false, false, true, false, Printer::maxFeedrate[Z_AXIS] / 2.0f);
Printer::GoToMemoryPosition(false, false, false, true, Printer::maxFeedrate[E_AXIS] / 2.0f);
}
Printer::setMenuMode(MENU_MODE_SD_PAUSED, false);
sdmode = 1;
}
void SDCard::stopPrint()
{
if(!sd.sdactive) return;
if(sdmode)
Com::printFLN(PSTR("SD print stopped by user."));
sdmode = 0;
Printer::setMenuMode(MENU_MODE_SD_PRINTING,false);
Printer::setMenuMode(MENU_MODE_SD_PAUSED,false);
GCode::executeFString(PSTR(SD_RUN_ON_STOP));
if(SD_STOP_HEATER_AND_MOTORS_ON_STOP) {
Commands::waitUntilEndOfAllMoves();
Printer::kill(true);
}
}
void SDCard::writeCommand(GCode *code)
{
unsigned int sum1=0,sum2=0; // for fletcher-16 checksum
uint8_t buf[100];
uint8_t p=2;
file.writeError = false;
int params = 128 | (code->params & ~1);
*(int*)buf = params;
if(code->isV2()) // Read G,M as 16 bit value
{
*(int*)&buf[p] = code->params2;
p+=2;
if(code->hasString())
buf[p++] = strlen(code->text);
if(code->hasM())
{
*(int*)&buf[p] = code->M;
p+=2;
}
if(code->hasG())
{
*(int*)&buf[p]= code->G;
p+=2;
}
}
else
{
if(code->hasM())
{
buf[p++] = (uint8_t)code->M;
}
if(code->hasG())
{
buf[p++] = (uint8_t)code->G;
}
}
if(code->hasX())
{
*(float*)&buf[p] = code->X;
p+=4;
}
if(code->hasY())
{
*(float*)&buf[p] = code->Y;
p+=4;
}
if(code->hasZ())
{
*(float*)&buf[p] = code->Z;
p+=4;
}
if(code->hasE())
{
*(float*)&buf[p] = code->E;
p+=4;
}
if(code->hasF())
{
*(float*)&buf[p] = code->F;
p+=4;
}
if(code->hasT())
{
buf[p++] = code->T;
}
if(code->hasS())
{
*(long int*)&buf[p] = code->S;
p+=4;
}
if(code->hasP())
{
*(long int*)&buf[p] = code->P;
p+=4;
}
if(code->hasI())
{
*(float*)&buf[p] = code->I;
p+=4;
}
if(code->hasJ())
{
*(float*)&buf[p] = code->J;
p+=4;
}
if(code->hasString()) // read 16 uint8_t into string
{
char *sp = code->text;
if(code->isV2())
{
uint8_t i = strlen(code->text);
for(; i; i--) buf[p++] = *sp++;
}
else
{
for(uint8_t i=0; i<16; ++i) buf[p++] = *sp++;
}
}
uint8_t *ptr = buf;
uint8_t len = p;
while (len)
{
uint8_t tlen = len > 21 ? 21 : len;
len -= tlen;
do
{
sum1 += *ptr++;
if(sum1>=255) sum1-=255;
sum2 += sum1;
if(sum2>=255) sum2-=255;
}
while (--tlen);
}
buf[p++] = sum1;
buf[p++] = sum2;
if(params == 128)
{
Com::printErrorFLN(Com::tAPIDFinished);
}
else
file.write(buf,p);
if (file.writeError)
{
Com::printFLN(Com::tErrorWritingToFile);
}
}
char *SDCard::createFilename(char *buffer,const dir_t &p)
{
char *pos = buffer,*src = (char*)p.name;
for (uint8_t i = 0; i < 11; i++,src++)
{
if (*src == ' ') continue;
if (i == 8)
*pos++ = '.';
*pos++ = *src;
}
*pos = 0;
return pos;
}
bool SDCard::showFilename(const uint8_t *name)
{
if (*name == DIR_NAME_DELETED || *name == '.') return false;
return true;
}
int8_t RFstricmp(const char* s1, const char* s2)
{
while(*s1 && (tolower(*s1) == tolower(*s2)))
s1++,s2++;
return (const uint8_t)tolower(*s1)-(const uint8_t)tolower(*s2);
}
int8_t RFstrnicmp(const char* s1, const char* s2, size_t n)
{
while(n--)
{
if(tolower(*s1)!=tolower(*s2))
return (uint8_t)tolower(*s1) - (uint8_t)tolower(*s2);
s1++;
s2++;
}
return 0;
}
void SDCard::ls()
{
SdBaseFile file;
Com::printFLN(Com::tBeginFileList);
fat.chdir();
file.openRoot(fat.vol());
file.ls(0, 0);
Com::printFLN(Com::tEndFileList);
}
bool SDCard::selectFile(const char *filename, bool silent)
{
SdBaseFile parent;
const char *oldP = filename;
boolean bFound;
if(!sdactive) return false;
sdmode = 0;
file.close();
parent = *fat.vwd();
if (file.open(&parent, filename, O_READ))
{
if ((oldP = strrchr(filename, '/')) != NULL)
oldP++;
else
oldP = filename;
if(!silent)
{
Com::printF(Com::tFileOpened, oldP);
Com::printFLN(Com::tSpaceSizeColon,file.fileSize());
}
sdpos = 0;
filesize = file.fileSize();
Com::printFLN(Com::tFileSelected);
return true;
}
else
{
if(!silent)
Com::printFLN(Com::tFileOpenFailed);
return false;
}
}
void SDCard::printStatus()
{
if(sdactive)
{
Com::printF(Com::tSDPrintingByte, sdpos);
Com::printFLN(Com::tSlash, filesize);
}
else
{
Com::printFLN(Com::tNotSDPrinting);
}
}
void SDCard::startWrite(char *filename)
{
if(!sdactive) return;
file.close();
sdmode = 0;
fat.chdir();
if(!file.open(filename, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
{
Com::printFLN(Com::tOpenFailedFile,filename);
}
else
{
UI_STATUS(UI_TEXT_UPLOADING);
savetosd = true;
Com::printFLN(Com::tWritingToFile,filename);
}
}
void SDCard::finishWrite()
{
if(!savetosd) return; // already closed or never opened
file.sync();
file.close();
savetosd = false;
Com::printFLN(Com::tDoneSavingFile);
UI_CLEAR_STATUS;
}
void SDCard::deleteFile(char *filename)
{
if(!sdactive) return;
sdmode = 0;
file.close();
if(fat.remove(filename))
{
Com::printFLN(Com::tFileDeleted);
}
else
{
if(fat.rmdir(filename))
Com::printFLN(Com::tFileDeleted);
else
Com::printFLN(Com::tDeletionFailed);
}
}
void SDCard::makeDirectory(char *filename)
{
if(!sdactive) return;
sdmode = 0;
file.close();
if(fat.mkdir(filename))
{
Com::printFLN(Com::tDirectoryCreated);
}
else
{
Com::printFLN(Com::tCreationFailed);
}
}
#ifdef GLENN_DEBUG
void SDCard::writeToFile()
{
size_t nbyte;
char szName[10];
strcpy(szName, "Testing\r\n");
nbyte = file.write(szName, strlen(szName));
Com::print("L=");
Com::print((long)nbyte);
Com::println();
}
#endif
#endif

4438
Repetier/SdFat.cpp Normal file

File diff suppressed because it is too large Load diff

2325
Repetier/SdFat.h Normal file

File diff suppressed because it is too large Load diff

3
Repetier/cores/CDC.cpp Normal file
View file

@ -0,0 +1,3 @@
/* Stub for CDC.cpp */
#include <CDC.cpp>

View file

@ -0,0 +1,3 @@
/* Stub for HardwareSerial.cpp */
#include <HardwareSerial.cpp>

View file

@ -0,0 +1,3 @@
/* Stub for IPAddress.cpp */
#include <IPAddress.cpp>

1
Repetier/cores/Print.cpp Normal file
View file

@ -0,0 +1 @@
#include <Print.cpp>

View file

@ -0,0 +1 @@
#include <Stream.cpp>

1
Repetier/cores/Tone.cpp Normal file
View file

@ -0,0 +1 @@
#include <Tone.cpp>

View file

@ -0,0 +1,2 @@
#include <HID.cpp>
#include <USBCore.cpp>

View file

@ -0,0 +1 @@
#include <WInterrupts.c>

1
Repetier/cores/WMath.cpp Normal file
View file

@ -0,0 +1 @@
#include <WMath.cpp>

View file

@ -0,0 +1 @@
#include <WString.cpp>

1
Repetier/cores/main.cpp Normal file
View file

@ -0,0 +1 @@
#include <main.cpp>

1
Repetier/cores/new.cpp Normal file
View file

@ -0,0 +1 @@
#include <new.cpp>

1
Repetier/cores/wiring.c Normal file
View file

@ -0,0 +1 @@
#include <wiring.c>

View file

@ -0,0 +1 @@
#include <wiring_analog.c>

View file

@ -0,0 +1 @@
#include <wiring_digital.c>

View file

@ -0,0 +1 @@
#include <wiring_pulse.c>

View file

@ -0,0 +1 @@
#include <wiring_shift.c>

3739
Repetier/fastio.h Normal file

File diff suppressed because it is too large Load diff

956
Repetier/gcode.cpp Normal file
View file

@ -0,0 +1,956 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
Functions in this file are used to communicate using ascii or repetier protocol.
*/
#include "Repetier.h"
#ifndef FEATURE_CHECKSUM_FORCED
#define FEATURE_CHECKSUM_FORCED false
#endif
GCode GCode::commandsBuffered[GCODE_BUFFER_SIZE]; ///< Buffer for received commands.
uint8_t GCode::bufferReadIndex = 0; ///< Read position in gcode_buffer.
uint8_t GCode::bufferWriteIndex = 0; ///< Write position in gcode_buffer.
uint8_t GCode::commandReceiving[MAX_CMD_SIZE]; ///< Current received command.
uint8_t GCode::commandsReceivingWritePosition = 0; ///< Writing position in gcode_transbuffer.
uint8_t GCode::sendAsBinary; ///< Flags the command as binary input.
uint8_t GCode::wasLastCommandReceivedAsBinary = 0; ///< Was the last successful command in binary mode?
uint8_t GCode::commentDetected = false; ///< Flags true if we are reading the comment part of a command.
uint8_t GCode::binaryCommandSize; ///< Expected size of the incoming binary command.
bool GCode::waitUntilAllCommandsAreParsed = false; ///< Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings.
uint32_t GCode::lastLineNumber = 0; ///< Last line number received.
uint32_t GCode::actLineNumber; ///< Line number of current command.
int8_t GCode::waitingForResend = -1; ///< Waiting for line to be resend. -1 = no wait.
volatile uint8_t GCode::bufferLength = 0; ///< Number of commands stored in gcode_buffer
millis_t GCode::timeOfLastDataPacket = 0; ///< Time, when we got the last data packet. Used to detect missing uint8_ts.
uint8_t GCode::formatErrors = 0;
/** \page Repetier-protocol
\section Introduction
The repetier-protocol was developed, to overcome some shortcommings in the standard
RepRap communication method, while remaining backward compatible. To use the improved
features of this protocal, you need a host which speaks it. On Windows the recommended
host software is Repetier-Host. It is developed in parallel to this firmware and supports
all implemented features.
\subsection Improvements
- With higher speeds, the serial connection is more likely to produce communication failures.
The standard method is to transfer a checksum at the end of the line. This checksum is the
XORd value of all characters send. The value is limited to a range between 0 and 127. It can
not detect two identical missing characters or a wrong order. Therefore the new protocol
uses Fletchers checksum, which overcomes these shortcommings.
- The new protocol send data in binary format. This reduces the data size to less then 50% and
it speeds up decoding the command. No slow conversion from string to floats are needed.
*/
/** \brief Computes size of binary data from bitfield.
In the repetier-protocol in binary mode, the first 2 uint8_ts define the
data. From this bitfield, this function computes the size of the command
including the 2 uint8_ts of the bitfield and the 2 uint8_ts for the checksum.
Gcode Letter to Bit and Datatype:
- N : Bit 0 : 16-Bit Integer
- M : Bit 1 : 8-Bit unsigned uint8_t
- G : Bit 2 : 8-Bit unsigned uint8_t
- X : Bit 3 : 32-Bit Float
- Y : Bit 4 : 32-Bit Float
- Z : Bit 5 : 32-Bit Float
- E : Bit 6 : 32-Bit Float
- : Bit 7 : always set to distinguish binary from ASCII line.
- F : Bit 8 : 32-Bit Float
- T : Bit 9 : 8 Bit Integer
- S : Bit 10 : 32 Bit Value
- P : Bit 11 : 32 Bit Integer
- V2 : Bit 12 : Version 2 command for additional commands/sizes
- Ext : Bit 13 : There are 2 more uint8_ts following with Bits, only for future versions
- Int :Bit 14 : Marks it as internal command,
- Text : Bit 15 : 16 Byte ASCII String terminated with 0
Second word if V2:
- I : Bit 0 : 32-Bit float
- J : Bit 1 : 32-Bit float
- R : Bit 2 : 32-Bit float
- D : Bit 3 : 32-Bit float
- C : Bit 4 : 32-Bit float
- H : Bit 5 : 32-Bit float
- A : Bit 6 : 32-Bit float
- B : Bit 7 : 32-Bit float
- K : Bit 8 : 32-Bit float
- L : Bit 9 : 32-Bit float
- O : Bit 0 : 32-Bit float
*/
uint8_t GCode::computeBinarySize(char *ptr) // unsigned int bitfield) {
{
uint8_t s = 4; // include checksum and bitfield
uint16_t bitfield = *(uint16_t*)ptr;
if(bitfield & 1) s += 2;
if(bitfield & 8) s += 4;
if(bitfield & 16) s += 4;
if(bitfield & 32) s += 4;
if(bitfield & 64) s += 4;
if(bitfield & 256) s += 4;
if(bitfield & 512) s += 1;
if(bitfield & 1024) s += 4;
if(bitfield & 2048) s += 4;
if(bitfield & 4096) // Version 2 or later
{
s += 2; // for bitfield 2
uint16_t bitfield2 = *(uint16_t*)(ptr + 2);
if(bitfield & 2) s += 2;
if(bitfield & 4) s += 2;
if(bitfield2 & 1) s += 4;
if(bitfield2 & 2) s += 4;
if(bitfield2 & 4) s += 4;
if(bitfield2 & 8) s += 4;
if(bitfield2 & 16) s += 4;
if(bitfield2 & 32) s += 4;
if(bitfield2 & 64) s += 4;
if(bitfield2 & 128) s += 4;
if(bitfield2 & 256) s += 4;
if(bitfield2 & 512) s += 4;
if(bitfield2 & 1024) s += 4;
if(bitfield2 & 2048) s += 4;
if(bitfield2 & 4096) s += 4;
if(bitfield2 & 8192) s += 4;
if(bitfield2 & 16384) s += 4;
if(bitfield2 & 32768) s += 4;
if(bitfield & 32768) s += RMath::min(80,(uint8_t)ptr[4] + 1);
}
else
{
if(bitfield & 2) s += 1;
if(bitfield & 4) s += 1;
if(bitfield & 32768) s += 16;
}
return s;
}
void GCode::requestResend()
{
HAL::serialFlush();
commandsReceivingWritePosition = 0;
if(sendAsBinary)
waitingForResend = 30;
else
waitingForResend = 14;
Com::println();
Com::printFLN(Com::tResend,lastLineNumber + 1);
Com::printFLN(Com::tOk);
}
/**
Check if result is plausible. If it is, an ok is send and the command is stored in queue.
If not, a resend and ok is send.
*/
void GCode::checkAndPushCommand()
{
if(hasM())
{
if(M == 110) // Reset line number
{
lastLineNumber = actLineNumber;
Com::printFLN(Com::tOk);
waitingForResend = -1;
return;
}
if(M == 112) // Emergency kill - freeze printer
{
Commands::emergencyStop();
}
#ifdef DEBUG_COM_ERRORS
if(M == 666) // force an communication error
{
lastLineNumber++;
return;
} else if(M == 668) {
lastLineNumber = 0; // simulate a reset so lines are out of resend buffer
}
#endif // DEBUG_COM_ERRORS
}
if(hasN())
{
if((((lastLineNumber + 1) & 0xffff) != (actLineNumber & 0xffff)))
{
if(static_cast<uint16_t>(lastLineNumber - actLineNumber) < 40)
{
// we have seen that line already. So we assume it is a repeated resend and we ignore it
commandsReceivingWritePosition = 0;
Com::printFLN(Com::tSkip,actLineNumber);
Com::printFLN(Com::tOk);
}
else if(waitingForResend < 0) // after a resend, we have to skip the garbage in buffers, no message for this
{
if(Printer::debugErrors())
{
Com::printF(Com::tExpectedLine, lastLineNumber + 1);
Com::printFLN(Com::tGot, actLineNumber);
}
requestResend(); // Line missing, force resend
}
else
{
--waitingForResend;
commandsReceivingWritePosition = 0;
Com::printFLN(Com::tSkip, actLineNumber);
Com::printFLN(Com::tOk);
}
return;
}
lastLineNumber = actLineNumber;
}
pushCommand();
#ifdef DEBUG_COM_ERRORS
if(M == 667)
return; // omit ok
#endif
#if ACK_WITH_LINENUMBER
Com::printFLN(Com::tOkSpace, actLineNumber);
#else
Com::printFLN(Com::tOk);
#endif
wasLastCommandReceivedAsBinary = sendAsBinary;
waitingForResend = -1; // everything is ok.
}
void GCode::pushCommand()
{
#if !ECHO_ON_EXECUTE
commandsBuffered[bufferWriteIndex].echoCommand();
#endif
if(++bufferWriteIndex >= GCODE_BUFFER_SIZE) bufferWriteIndex = 0;
bufferLength++;
}
/**
Get the next buffered command. Returns 0 if no more commands are buffered. For each
returned command, the gcode_command_finished() function must be called.
*/
GCode *GCode::peekCurrentCommand()
{
if(bufferLength == 0) return NULL; // No more data
return &commandsBuffered[bufferReadIndex];
}
/** \brief Removes the last returned command from cache. */
void GCode::popCurrentCommand()
{
if(!bufferLength) return; // Should not happen, but safety first
#if ECHO_ON_EXECUTE
echoCommand();
#endif
if(++bufferReadIndex == GCODE_BUFFER_SIZE) bufferReadIndex = 0;
bufferLength--;
}
void GCode::echoCommand()
{
if(Printer::debugEcho())
{
Com::printF(Com::tEcho);
printCommand();
}
}
void GCode::debugCommandBuffer()
{
Com::printF(PSTR("CommandBuffer"));
for(int i = 0; i < commandsReceivingWritePosition; i++)
Com::printF(Com::tColon,(int)commandReceiving[i]);
Com::println();
Com::printFLN(PSTR("Binary:"), (int)sendAsBinary);
if(!sendAsBinary)
{
Com::print((char*)commandReceiving);
Com::println();
}
}
/** \brief Execute commands in progmem stored string. Multiple commands are seperated by \n */
void GCode::executeFString(FSTRINGPARAM(cmd))
{
char buf[80];
uint8_t buflen;
char c;
GCode code;
do
{
// Wait for a free place in command buffer
// Scan next command from string
uint8_t comment = 0;
buflen = 0;
do
{
c = HAL::readFlashByte(cmd++);
if(c == 0 || c == '\n') break;
if(c == ';') comment = 1;
if(comment) continue;
buf[buflen++] = c;
}
while(buflen < 79);
if(buflen == 0) // empty line ignore
continue;
buf[buflen] = 0;
// Send command into command buffer
if(code.parseAscii((char *)buf,false) && (code.params & 518)) // Success
{
#ifdef DEBUG_PRINT
debugWaitLoop = 7;
#endif
Commands::executeGCode(&code);
Printer::defaultLoopActions();
}
}
while(c);
}
/** \brief Read from serial console or sdcard.
This function is the main function to read the commands from serial console or from sdcard.
It must be called frequently to empty the incoming buffer.
*/
void GCode::readFromSerial()
{
if(bufferLength >= GCODE_BUFFER_SIZE) return; // all buffers full
if(waitUntilAllCommandsAreParsed && bufferLength) return;
waitUntilAllCommandsAreParsed = false;
millis_t time = HAL::timeInMilliseconds();
if(!HAL::serialByteAvailable())
{
if((waitingForResend >= 0 || commandsReceivingWritePosition > 0) && time - timeOfLastDataPacket > 200)
{
// Com::printF(PSTR("WFR:"),waitingForResend);Com::printF(PSTR(" CRWP:"),commandsReceivingWritePosition);commandReceiving[commandsReceivingWritePosition] = 0;Com::printFLN(PSTR(" GOT:"),(char*)commandReceiving);
requestResend(); // Something is wrong, a started line was not continued in the last second
timeOfLastDataPacket = time;
}
#ifdef WAITING_IDENTIFIER
else if(bufferLength == 0 && time - timeOfLastDataPacket > 1000) // Don't do it if buffer is not empty. It may be a slow executing command.
{
Com::printFLN(Com::tWait); // Unblock communication in case the last ok was not received correct.
timeOfLastDataPacket = time;
}
#endif
}
while(HAL::serialByteAvailable() && commandsReceivingWritePosition < MAX_CMD_SIZE) // consume data until no data or buffer full
{
timeOfLastDataPacket = time; //HAL::timeInMilliseconds();
commandReceiving[commandsReceivingWritePosition++] = HAL::serialReadByte();
// first lets detect, if we got an old type ascii command
if(commandsReceivingWritePosition == 1)
{
if(waitingForResend >= 0 && wasLastCommandReceivedAsBinary)
{
if(!commandReceiving[0])
waitingForResend--; // Skip 30 zeros to get in sync
else
waitingForResend = 30;
commandsReceivingWritePosition = 0;
continue;
}
if(!commandReceiving[0]) // Ignore zeros
{
commandsReceivingWritePosition = 0;
continue;
}
sendAsBinary = (commandReceiving[0] & 128) != 0;
}
if(sendAsBinary)
{
if(commandsReceivingWritePosition < 2 ) continue;
if(commandsReceivingWritePosition == 5 || commandsReceivingWritePosition == 4)
binaryCommandSize = computeBinarySize((char*)commandReceiving);
if(commandsReceivingWritePosition == binaryCommandSize)
{
GCode *act = &commandsBuffered[bufferWriteIndex];
if(act->parseBinary(commandReceiving, true)) // Success
act->checkAndPushCommand();
else
requestResend();
commandsReceivingWritePosition = 0;
return;
}
}
else // Ascii command
{
char ch = commandReceiving[commandsReceivingWritePosition - 1];
if(ch == 0 || ch == '\n' || ch == '\r' || (!commentDetected && ch == ':')) // complete line read
{
commandReceiving[commandsReceivingWritePosition - 1] = 0;
//Com::printF(PSTR("Parse ascii:"));Com::print((char*)commandReceiving);Com::println();
commentDetected = false;
if(commandsReceivingWritePosition == 1) // empty line ignore
{
commandsReceivingWritePosition = 0;
continue;
}
GCode *act = &commandsBuffered[bufferWriteIndex];
if(act->parseAscii((char *)commandReceiving, true)) // Success
act->checkAndPushCommand();
else
requestResend();
commandsReceivingWritePosition = 0;
return;
}
else
{
if(ch == ';') commentDetected = true; // ignore new data until lineend
if(commentDetected) commandsReceivingWritePosition--;
}
}
if(commandsReceivingWritePosition == MAX_CMD_SIZE)
{
requestResend();
return;
}
}
#if SDSUPPORT
if(sd.sdmode == 0 || commandsReceivingWritePosition != 0) // not reading or incoming serial command
return;
while( sd.filesize > sd.sdpos && commandsReceivingWritePosition < MAX_CMD_SIZE) // consume data until no data or buffer full
{
timeOfLastDataPacket = HAL::timeInMilliseconds();
int n = sd.file.read();
if(n == -1)
{
Com::printFLN(Com::tSDReadError);
UI_ERROR("SD Read Error");
// Second try in case of recoverable errors
sd.file.seekSet(sd.sdpos);
n = sd.file.read();
if(n == -1)
{
Com::printErrorFLN(PSTR("SD error did not recover!"));
sd.sdmode = 0;
break;
}
UI_ERROR("SD error fixed");
}
sd.sdpos++; // = file.curPosition();
commandReceiving[commandsReceivingWritePosition++] = (uint8_t)n;
// first lets detect, if we got an old type ascii command
if(commandsReceivingWritePosition == 1)
{
sendAsBinary = (commandReceiving[0] & 128) != 0;
}
if(sendAsBinary)
{
if(commandsReceivingWritePosition < 2 ) continue;
if(commandsReceivingWritePosition == 4 || commandsReceivingWritePosition == 5)
binaryCommandSize = computeBinarySize((char*)commandReceiving);
if(commandsReceivingWritePosition == binaryCommandSize)
{
GCode *act = &commandsBuffered[bufferWriteIndex];
if(act->parseBinary(commandReceiving, false)) // Success, silently ignore illegal commands
pushCommand();
commandsReceivingWritePosition = 0;
if(sd.sdmode == 2)
sd.sdmode = 0;
return;
}
}
else
{
char ch = commandReceiving[commandsReceivingWritePosition-1];
bool returnChar = ch == '\n' || ch == '\r';
if(returnChar || sd.filesize == sd.sdpos || (!commentDetected && ch == ':') || commandsReceivingWritePosition >= (MAX_CMD_SIZE - 1) ) // complete line read
{
if(returnChar || ch == ':')
commandReceiving[commandsReceivingWritePosition - 1] = 0;
else
commandReceiving[commandsReceivingWritePosition] = 0;
commentDetected = false;
if(commandsReceivingWritePosition == 1) // empty line ignore
{
commandsReceivingWritePosition = 0;
continue;
}
GCode *act = &commandsBuffered[bufferWriteIndex];
if(act->parseAscii((char *)commandReceiving, false)) // Success
pushCommand();
commandsReceivingWritePosition = 0;
if(sd.sdmode == 2)
sd.sdmode = 0;
return;
}
else
{
if(ch == ';') commentDetected = true; // ignore new data until lineend
if(commentDetected) commandsReceivingWritePosition--;
}
}
}
sd.sdmode = 0;
Com::printFLN(Com::tDonePrinting);
commandsReceivingWritePosition = 0;
commentDetected = false;
Printer::setMenuMode(MENU_MODE_SD_PRINTING, false);
#endif
}
/**
Converts a binary uint8_tfield containing one GCode line into a GCode structure.
Returns true if checksum was correct.
*/
bool GCode::parseBinary(uint8_t *buffer,bool fromSerial)
{
internalCommand = !fromSerial;
unsigned int sum1 = 0,sum2 = 0; // for fletcher-16 checksum
// first do fletcher-16 checksum tests see
// http://en.wikipedia.org/wiki/Fletcher's_checksum
uint8_t *p = buffer;
uint8_t len = binaryCommandSize - 2;
while (len)
{
uint8_t tlen = len > 21 ? 21 : len;
len -= tlen;
do
{
sum1 += *p++;
if(sum1 >= 255) sum1 -= 255;
sum2 += sum1;
if(sum2 >= 255) sum2 -= 255;
}
while (--tlen);
}
sum1 -= *p++;
sum2 -= *p;
if(sum1 | sum2)
{
if(Printer::debugErrors())
{
Com::printErrorFLN(Com::tWrongChecksum);
}
return false;
}
p = buffer;
params = *(unsigned int *)p;
p += 2;
uint8_t textlen = 16;
if(isV2())
{
params2 = *(unsigned int *)p;
p+=2;
if(hasString())
textlen = *p++;
}
else params2 = 0;
if(params & 1)
{
actLineNumber = N = *(uint16_t *)p;
p+=2;
}
if(isV2()) // Read G,M as 16 bit value
{
if(params & 2)
{
M = *(uint16_t *)p;
p += 2;
}
if(params & 4)
{
G = *(uint16_t *)p;
p += 2;
}
}
else
{
if(params & 2)
{
M = *p++;
}
if(params & 4)
{
G = *p++;
}
}
//if(code->params & 8) {memcpy(&code->X,p,4);p+=4;}
if(params & 8)
{
X = *(float *)p;
p += 4;
}
if(params & 16)
{
Y = *(float *)p;
p += 4;
}
if(params & 32)
{
Z = *(float *)p;
p += 4;
}
if(params & 64)
{
E = *(float *)p;
p += 4;
}
if(params & 256)
{
F = *(float *)p;
p += 4;
}
if(params & 512)
{
T = *p++;
}
if(params & 1024)
{
S = *(int32_t*)p;
p += 4;
}
if(params & 2048)
{
P = *(int32_t*)p;
p += 4;
}
if(hasI())
{
I = *(float *)p;
p += 4;
}
if(hasJ())
{
J = *(float *)p;
p += 4;
}
if(hasR())
{
R = *(float *)p;
p += 4;
}
if(hasD())
{
D = *(float *)p;
p += 4;
}
if(hasC())
{
C = *(float *)p;
p += 4;
}
if(hasH())
{
H = *(float *)p;
p += 4;
}
if(hasA())
{
A = *(float *)p;
p += 4;
}
if(hasB())
{
B = *(float *)p;
p += 4;
}
if(hasK())
{
K = *(float *)p;
p += 4;
}
if(hasL())
{
L = *(float *)p;
p += 4;
}
if(hasO())
{
O = *(float *)p;
p += 4;
}
if(hasString()) // set text pointer to string
{
text = (char*)p;
text[textlen] = 0; // Terminate string overwriting checksum
waitUntilAllCommandsAreParsed=true; // Don't destroy string until executed
}
formatErrors = 0;
return true;
}
/**
Converts a ascii GCode line into a GCode structure.
*/
bool GCode::parseAscii(char *line,bool fromSerial)
{
char *pos = line;
params = 0;
params2 = 0;
internalCommand = !fromSerial;
char c;
while ( (c = *(pos++)) )
{
switch(c)
{
case 'N':
case 'n':
{
actLineNumber = parseLongValue(pos);
params |=1;
N = actLineNumber;
break;
}
case 'G':
case 'g':
{
G = parseLongValue(pos) & 0xffff;
params |= 4;
if(G > 255) params |= 4096;
break;
}
case 'M':
case 'm':
{
M = parseLongValue(pos) & 0xffff;
params |=2;
if(M > 255) params |= 4096;
// handle non standard text arguments that some M codes have
if (M == 23 || M == 28 || M == 29 || M == 30 || M == 32 || M == 117)
{
// after M command we got a filename or text
char digit;
while( (digit = *pos) )
{
if (digit < '0' || digit > '9') break;
pos++;
}
while( (digit = *pos) )
{
if (digit != ' ') break;
pos++;
// skip leading whitespaces (may be no white space)
}
text = pos;
while (*pos)
{
if((M != 117 && *pos==' ') || *pos=='*') break;
pos++; // find a space as file name end
}
*pos = 0; // truncate filename by erasing space with nul, also skips checksum
waitUntilAllCommandsAreParsed = true; // don't risk string be deleted
params |= 32768;
}
break;
}
case 'X':
case 'x':
{
X = parseFloatValue(pos);
params |= 8;
break;
}
case 'Y':
case 'y':
{
Y = parseFloatValue(pos);
params |= 16;
break;
}
case 'Z':
case 'z':
{
Z = parseFloatValue(pos);
params |= 32;
break;
}
case 'E':
case 'e':
{
E = parseFloatValue(pos);
params |= 64;
break;
}
case 'F':
case 'f':
{
F = parseFloatValue(pos);
params |= 256;
break;
}
case 'T':
case 't':
{
T = parseLongValue(pos) & 0xff;
params |= 512;
break;
}
case 'S':
case 's':
{
S = parseLongValue(pos);
params |= 1024;
break;
}
case 'P':
case 'p':
{
P = parseLongValue(pos);
params |= 2048;
break;
}
case 'I':
case 'i':
{
I = parseFloatValue(pos);
params2 |= 1;
params |= 4096; // Needs V2 for saving
break;
}
case 'J':
case 'j':
{
J = parseFloatValue(pos);
params2 |= 2;
params |= 4096; // Needs V2 for saving
break;
}
case 'R':
case 'r':
{
R = parseFloatValue(pos);
params2 |= 4;
params |= 4096; // Needs V2 for saving
break;
}
case 'D':
case 'd':
{
D = parseFloatValue(pos);
params2 |= 8;
params |= 4096; // Needs V2 for saving
break;
}
case '*' : //checksum
{
uint8_t checksum_given = parseLongValue(pos);
uint8_t checksum = 0;
while(line != (pos-1)) checksum ^= *line++;
#if FEATURE_CHECKSUM_FORCED
Printer::flag0 |= PRINTER_FLAG0_FORCE_CHECKSUM;
#endif
if(checksum != checksum_given)
{
if(Printer::debugErrors())
{
Com::printErrorFLN(Com::tWrongChecksum);
}
return false; // mismatch
}
break;
}
default:
break;
}// end switch
}// end while
if(hasFormatError() || (params & 518)==0) // Must contain G, M or T command and parameter need to have variables!
{
formatErrors++;
if(Printer::debugErrors())
Com::printErrorFLN(Com::tFormatError);
if(formatErrors<3) return false;
}
else formatErrors = 0;
return true;
}
/** \brief Print command on serial console */
void GCode::printCommand()
{
if(hasN()) {
Com::print('N');
Com::print((long)N);
Com::print(' ');
}
if(hasM())
{
Com::print('M');
Com::print((int)M);
Com::print(' ');
}
if(hasG())
{
Com::print('G');
Com::print((int)G);
Com::print(' ');
}
if(hasT())
{
Com::print('T');
Com::print((int)T);
Com::print(' ');
}
if(hasX())
{
Com::printF(Com::tX,X);
}
if(hasY())
{
Com::printF(Com::tY,Y);
}
if(hasZ())
{
Com::printF(Com::tZ,Z);
}
if(hasE())
{
Com::printF(Com::tE,E,4);
}
if(hasF())
{
Com::printF(Com::tF,F);
}
if(hasS())
{
Com::printF(Com::tS,S);
}
if(hasP())
{
Com::printF(Com::tP,P);
}
if(hasI())
{
Com::printF(Com::tI,I);
}
if(hasJ())
{
Com::printF(Com::tJ,J);
}
if(hasR())
{
Com::printF(Com::tR,R);
}
if(hasString())
{
Com::print(text);
}
Com::println();
}

228
Repetier/gcode.h Normal file
View file

@ -0,0 +1,228 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GCODE_H
#define _GCODE_H
#define MAX_CMD_SIZE 96
class SDCard;
class GCode // 52 uint8_ts per command needed
{
unsigned int params;
unsigned int params2;
public:
unsigned int N; // Line number
unsigned int M;
unsigned int G;
float X;
float Y;
float Z;
float E;
float F;
long S;
long P;
float I;
float J;
float R;
float D;
float C;
float H;
float A;
float B;
float K;
float L;
float O;
char *text; //text[17];
//moved the byte to the end and aligned ints on short boundary
// Old habit from PC, which require alignments for data types such as int and long to be on 2 or 4 byte boundary
// Otherwise, the compiler adds padding, wasted space.
uint8_t T; // This may not matter on any of these controllers, but it can't hurt
// True if origin did not come from serial console. That way we can send status messages to
// a host only if he would normally not know about the mode switch.
bool internalCommand;
inline bool hasM()
{
return ((params & 2)!=0);
}
inline bool hasN()
{
return ((params & 1)!=0);
}
inline bool hasG()
{
return ((params & 4)!=0);
}
inline bool hasX()
{
return ((params & 8)!=0);
}
inline bool hasY()
{
return ((params & 16)!=0);
}
inline bool hasZ()
{
return ((params & 32)!=0);
}
inline bool hasNoXYZ()
{
return ((params & 56)==0);
}
inline bool hasE()
{
return ((params & 64)!=0);
}
inline bool hasF()
{
return ((params & 256)!=0);
}
inline bool hasT()
{
return ((params & 512)!=0);
}
inline bool hasS()
{
return ((params & 1024)!=0);
}
inline bool hasP()
{
return ((params & 2048)!=0);
}
inline bool isV2()
{
return ((params & 4096)!=0);
}
inline bool hasString()
{
return ((params & 32768)!=0);
}
inline bool hasI()
{
return ((params2 & 1)!=0);
}
inline bool hasJ()
{
return ((params2 & 2)!=0);
}
inline bool hasR()
{
return ((params2 & 4)!=0);
}
inline bool hasD()
{
return ((params2 & 8)!=0);
}
inline bool hasC()
{
return ((params2 & 16)!=0);
}
inline bool hasH()
{
return ((params2 & 32)!=0);
}
inline bool hasA()
{
return ((params2 & 64)!=0);
}
inline bool hasB()
{
return ((params2 & 128)!=0);
}
inline bool hasK()
{
return ((params2 & 256)!=0);
}
inline bool hasL()
{
return ((params2 & 512)!=0);
}
inline bool hasO()
{
return ((params2 & 1024)!=0);
}
inline long getS(long def)
{
return (hasS() ? S : def);
}
inline long getP(long def)
{
return (hasP() ? P : def);
}
inline void setFormatError() {
params2 |= 32768;
}
inline bool hasFormatError() {
return ((params2 & 32768)!=0);
}
void printCommand();
bool parseBinary(uint8_t *buffer,bool fromSerial);
bool parseAscii(char *line,bool fromSerial);
void popCurrentCommand();
void echoCommand();
/** Get next command in command buffer. After the command is processed, call gcode_command_finished() */
static GCode *peekCurrentCommand();
/** Frees the cache used by the last command fetched. */
static void readFromSerial();
static void pushCommand();
static void executeFString(FSTRINGPARAM(cmd));
static uint8_t computeBinarySize(char *ptr);
friend class SDCard;
friend class UIDisplay;
private:
void debugCommandBuffer();
void checkAndPushCommand();
static void requestResend();
inline float parseFloatValue(char *s)
{
char *endPtr;
float f = (strtod(s, &endPtr));
if(s == endPtr) f=0.0; // treat empty string "x " as "x0"
return f;
}
inline long parseLongValue(char *s)
{
char *endPtr;
long l = (strtol(s, &endPtr, 10));
if(s == endPtr) l=0; // treat empty string argument "p " as "p0"
return l;
}
static GCode commandsBuffered[GCODE_BUFFER_SIZE]; ///< Buffer for received commands.
static uint8_t bufferReadIndex; ///< Read position in gcode_buffer.
static uint8_t bufferWriteIndex; ///< Write position in gcode_buffer.
static uint8_t commandReceiving[MAX_CMD_SIZE]; ///< Current received command.
static uint8_t commandsReceivingWritePosition; ///< Writing position in gcode_transbuffer.
static uint8_t sendAsBinary; ///< Flags the command as binary input.
static uint8_t wasLastCommandReceivedAsBinary; ///< Was the last successful command in binary mode?
static uint8_t commentDetected; ///< Flags true if we are reading the comment part of a command.
static uint8_t binaryCommandSize; ///< Expected size of the incoming binary command.
static bool waitUntilAllCommandsAreParsed; ///< Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings.
static uint32_t lastLineNumber; ///< Last line number received.
static uint32_t actLineNumber; ///< Line number of current command.
static int8_t waitingForResend; ///< Waiting for line to be resend. -1 = no wait.
static volatile uint8_t bufferLength; ///< Number of commands stored in gcode_buffer
static millis_t timeOfLastDataPacket; ///< Time, when we got the last data packet. Used to detect missing uint8_ts.
static uint8_t formatErrors; ///< Number of sequential format errors
};
#endif

View file

@ -0,0 +1 @@
#include <EEPROM.cpp>

View file

@ -0,0 +1,8 @@
#include <w5100.cpp>
#include <socket.cpp>
#include <Dns.cpp>
#include <Dhcp.cpp>
#include <Ethernet.cpp>
#include <EthernetClient.cpp>
#include <EthernetServer.cpp>
#include <EthernetUdp.cpp>

View file

@ -0,0 +1 @@
#include <Firmata.cpp>

View file

@ -0,0 +1 @@
#include <LiquidCrystal.cpp>

View file

@ -0,0 +1 @@
#include <OBD.cpp>

View file

@ -0,0 +1,5 @@
#include <SD.cpp>
#include <Sd2Card.cpp>
#include <SdFile.cpp>
#include <SdVolume.cpp>
#include <File.cpp>

View file

@ -0,0 +1 @@
#include <SPI.cpp>

View file

@ -0,0 +1 @@
#include <Servo.cpp>

View file

@ -0,0 +1 @@
#include <SoftwareSerial.cpp>

View file

@ -0,0 +1 @@
#include <Stepper.cpp>

View file

@ -0,0 +1 @@
#include <TinyGPS.cpp>

View file

@ -0,0 +1 @@
#include <U8glib.cpp>

View file

@ -0,0 +1,7 @@
#include <server_drv.cpp>
#include <socket.cpp>
#include <spi_drv.cpp>
#include <wifi_drv.cpp>
#include <WiFi.cpp>
#include <WiFiClient.cpp>
#include <WiFiServer.cpp>

View file

@ -0,0 +1,2 @@
#include <twi.c>
#include <Wire.cpp>

1
Repetier/libraries/twi.c Normal file
View file

@ -0,0 +1 @@
#include <twi.c>

79
Repetier/logo.h Normal file
View file

@ -0,0 +1,79 @@
//------------------------------------------------------------------------------
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------
#define LOGO_WIDTH 60
#define LOGO_HEIGHT 64
const unsigned char logo[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0xFF, 0xFE, 0x00,
0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xC3, 0xE1, 0xF0, 0x7F, 0x0F, 0xC0,
0x00, 0x07, 0x1F, 0x87, 0xC1, 0xFC, 0x3F, 0xC0, 0x00, 0x38, 0xFF, 0xFF, 0xFF, 0xF0, 0xFE, 0x40,
0x01, 0xC3, 0xFF, 0xFF, 0xFF, 0xC1, 0xFC, 0x40, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x40,
0x3F, 0xFF, 0xFF, 0x80, 0x00, 0x1F, 0xE0, 0x40, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x40,
0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x40, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x40,
0x30, 0x00, 0x00, 0x01, 0xFF, 0xFC, 0x04, 0x40, 0x30, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x40,
0x30, 0x00, 0x00, 0x00, 0x00, 0x38, 0x1C, 0x40, 0x30, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3E, 0x40,
0x30, 0x00, 0x00, 0x00, 0x00, 0x38, 0x7E, 0x40, 0x30, 0xFF, 0xFF, 0x80, 0x00, 0x38, 0xFE, 0x40,
0x30, 0xFF, 0xFF, 0xF8, 0x00, 0x38, 0xFE, 0x40, 0x30, 0xFF, 0xFF, 0xFE, 0x00, 0x38, 0xE6, 0x40,
0x30, 0xFF, 0xFF, 0xFF, 0x00, 0x38, 0xE6, 0x40, 0x30, 0xFF, 0xFF, 0xFF, 0x80, 0x38, 0xC6, 0x40,
0x30, 0xFF, 0xFF, 0xFF, 0x80, 0x38, 0xC6, 0x40, 0x30, 0xFF, 0xBF, 0xFF, 0x80, 0x38, 0xC4, 0x40,
0x30, 0xFF, 0x80, 0xFF, 0xC0, 0x38, 0xC4, 0x40, 0x30, 0xFF, 0x80, 0xFF, 0xC0, 0x38, 0xC4, 0x40,
0x30, 0xFF, 0x80, 0x7F, 0xC0, 0x38, 0xCC, 0x40, 0x30, 0xFF, 0x80, 0x7F, 0xC0, 0x38, 0xFC, 0x40,
0x30, 0xFF, 0x80, 0x7F, 0xC0, 0x38, 0xF8, 0x40, 0x30, 0xFF, 0x80, 0xFF, 0xC0, 0x38, 0xF8, 0x40,
0x30, 0xFF, 0xFF, 0xFF, 0xC0, 0x38, 0xF0, 0x40, 0x30, 0xFF, 0xFF, 0xFF, 0x80, 0x38, 0xE0, 0x40,
0x30, 0xFF, 0xFF, 0xFF, 0x80, 0x38, 0xE0, 0x40, 0x30, 0xFF, 0xFF, 0xFF, 0x00, 0x38, 0xC0, 0x40,
0x30, 0xFF, 0xFF, 0xFE, 0x00, 0x38, 0xC0, 0x40, 0x30, 0xFF, 0xFF, 0xF0, 0x00, 0x38, 0xC0, 0x40,
0x30, 0xFF, 0x9F, 0xF0, 0x00, 0x38, 0xC0, 0x40, 0x30, 0xFF, 0x8F, 0xFC, 0x00, 0x38, 0xC0, 0x40,
0x30, 0xFF, 0x87, 0xFC, 0x00, 0x38, 0xC0, 0x40, 0x30, 0xFF, 0x87, 0xFE, 0x00, 0x38, 0xC0, 0x40,
0x30, 0xFF, 0x83, 0xFF, 0x00, 0x38, 0xC0, 0x80, 0x30, 0xFF, 0x83, 0xFF, 0x00, 0x38, 0xC0, 0x80,
0x30, 0xFF, 0x81, 0xFF, 0x80, 0x38, 0xC1, 0x00, 0x30, 0xFF, 0x81, 0xFF, 0x80, 0x38, 0xC2, 0x00,
0x30, 0xFF, 0x80, 0xFF, 0xC0, 0x38, 0x82, 0x00, 0x30, 0xFF, 0x80, 0xFF, 0xC0, 0x38, 0x84, 0x00,
0x30, 0xFF, 0x80, 0x7F, 0xE0, 0x38, 0x08, 0x00, 0x30, 0x7F, 0x80, 0x7F, 0xE0, 0x38, 0x08, 0x00,
0x30, 0x0F, 0x80, 0x3F, 0xE0, 0x38, 0x10, 0x00, 0x30, 0x00, 0x00, 0x3F, 0xF0, 0x38, 0x10, 0x00,
0x38, 0x00, 0x00, 0x03, 0xF0, 0x38, 0x20, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x38, 0x40, 0x00,
0x3C, 0x00, 0x00, 0x00, 0x00, 0x38, 0x40, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x00, 0x39, 0x80, 0x00,
0x3F, 0xFF, 0xF8, 0x00, 0x00, 0x3D, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF8, 0x00, 0x7F, 0x00, 0x00,
0x00, 0x07, 0xFF, 0xFF, 0xF8, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFC, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xF8, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
/*
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F,
0xFF, 0xFF, 0xF7, 0x83, 0xC1, 0xF0, 0x1E, 0x0F, 0xFF, 0xFF, 0x7C, 0x0F, 0x07, 0xC0, 0x78, 0x0F,
0xFF, 0xFD, 0xE0, 0x00, 0x00, 0x01, 0xE0, 0x3F, 0xFF, 0xDF, 0x80, 0x00, 0x00, 0x07, 0xC0, 0x7F,
0xFE, 0x3F, 0xFF, 0xFF, 0xFF, 0xDF, 0x01, 0xFF, 0xF8, 0x00, 0x00, 0x0B, 0xFF, 0xFC, 0x03, 0xFF,
0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF,
0xF0, 0x50, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xF1, 0xFF, 0xFF, 0xFF, 0xD0, 0x00, 0x7F, 0x7F,
0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x7E, 0x7F, 0xF3, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xFC, 0x7F,
0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF8, 0x3F, 0xF1, 0xEF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0x3F,
0xF9, 0xE0, 0x00, 0x0F, 0xFF, 0xF0, 0xE0, 0x3F, 0xF1, 0xE0, 0x00, 0x00, 0xFF, 0xF8, 0xE0, 0x3F,
0xF9, 0xE0, 0x00, 0x00, 0x3F, 0xF0, 0xE3, 0x3F, 0xF1, 0xE0, 0x00, 0x00, 0x1F, 0xF8, 0xE3, 0x7F,
0xF9, 0xE0, 0x00, 0x00, 0x0F, 0xF0, 0xE7, 0x3F, 0xF1, 0xE0, 0x00, 0x00, 0x0F, 0xF8, 0xE7, 0x7F,
0xF9, 0xE0, 0x08, 0x00, 0x0F, 0xF0, 0xE7, 0x7F, 0xF1, 0xE0, 0x0F, 0xE0, 0x07, 0xF8, 0xE7, 0x7F,
0xF9, 0xE0, 0x0F, 0xE0, 0x07, 0xF0, 0xE7, 0x7F, 0xF1, 0xE0, 0x0F, 0xF0, 0x07, 0xF8, 0xE6, 0x7F,
0xF9, 0xE0, 0x0F, 0xF0, 0x07, 0xF0, 0xE0, 0x7F, 0xF9, 0xE0, 0x0F, 0xF0, 0x07, 0xF8, 0xE0, 0xFF,
0xF9, 0xE0, 0x0F, 0xE0, 0x07, 0xF0, 0xE0, 0xFF, 0xF9, 0xE0, 0x00, 0x00, 0x07, 0xF8, 0xE1, 0xFF,
0xF9, 0xE0, 0x00, 0x00, 0x0F, 0xF0, 0xE3, 0xFF, 0xF9, 0xE0, 0x00, 0x00, 0x0F, 0xF8, 0xE3, 0xFF,
0xF9, 0xE0, 0x00, 0x00, 0x1F, 0xF8, 0xE7, 0xFF, 0xF9, 0xE0, 0x00, 0x00, 0x3F, 0xF8, 0xE7, 0xFF,
0xF9, 0xE0, 0x00, 0x01, 0xFF, 0xF8, 0xE7, 0xFF, 0xF9, 0xE0, 0x0C, 0x01, 0xFF, 0xF8, 0xE7, 0xFF,
0xF9, 0xE0, 0x0E, 0x00, 0x7F, 0xF8, 0xE7, 0xFF, 0xF9, 0xE0, 0x0F, 0x00, 0x7F, 0xF8, 0xE7, 0xFF,
0xF9, 0xE0, 0x0F, 0x00, 0x3F, 0xF8, 0xE7, 0xFF, 0xF9, 0xE0, 0x0F, 0x80, 0x1F, 0xF8, 0xE7, 0xFF,
0xF9, 0xE0, 0x0F, 0x80, 0x1F, 0xF8, 0xE7, 0xFF, 0xF9, 0xE0, 0x0F, 0xC0, 0x0F, 0xF8, 0xE7, 0xFF,
0xF9, 0xE0, 0x0F, 0xC0, 0x0F, 0xF8, 0xE7, 0xFF, 0xF9, 0xE0, 0x0F, 0xE0, 0x07, 0xF8, 0xEF, 0xFF,
0xF9, 0xF0, 0x0F, 0xE0, 0x07, 0xF8, 0xEF, 0xFF, 0xF9, 0xE0, 0x0F, 0xF0, 0x03, 0xF8, 0xFF, 0xFF,
0xF9, 0xF0, 0x0F, 0xF0, 0x03, 0xF8, 0xFF, 0xFF, 0xF9, 0xFE, 0x0F, 0xF8, 0x03, 0xF8, 0xFF, 0xFF,
0xF9, 0xFF, 0xFF, 0xF8, 0x01, 0xF8, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0x81, 0xF8, 0xFF, 0xFF,
0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xF8, 0x7F, 0xFF, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF,
0xF8, 0x00, 0xFF, 0xFF, 0xFF, 0xF8, 0xDF, 0xFF, 0xF8, 0x00, 0x00, 0xFF, 0xFF, 0xF8, 0x7F, 0xFF,
0xFF, 0x40, 0x00, 0x00, 0xFF, 0xF0, 0x3F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xC0, 0x7F, 0xFF,
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x80, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0xAF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF
*/
};

2492
Repetier/motion.cpp Normal file

File diff suppressed because it is too large Load diff

710
Repetier/motion.h Normal file
View file

@ -0,0 +1,710 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
This firmware is a nearly complete rewrite of the sprinter firmware
by kliment (https://github.com/kliment/Sprinter)
which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
#
Functions in this file are used to communicate using ascii or repetier protocol.
*/
#ifndef MOTION_H_INCLUDED
#define MOTION_H_INCLUDED
/** Marks the first step of a new move */
#define FLAG_WARMUP 1
#define FLAG_NOMINAL 2
#define FLAG_DECELERATING 4
#define FLAG_ACCELERATION_ENABLED 8
#define FLAG_CHECK_ENDSTOPS 16
#define FLAG_SKIP_ACCELERATING 32
#define FLAG_SKIP_DEACCELERATING 64
#define FLAG_BLOCKED 128
/** Are the step parameter computed */
#define FLAG_JOIN_STEPPARAMS_COMPUTED 1
/** The right speed is fixed. Don't check this block or any block to the left. */
#define FLAG_JOIN_END_FIXED 2
/** The left speed is fixed. Don't check left block. */
#define FLAG_JOIN_START_FIXED 4
/** Start filament retraction at move start */
#define FLAG_JOIN_START_RETRACT 8
/** Wait for filament pushback, before ending move */
#define FLAG_JOIN_END_RETRACT 16
/** Disable retract for this line */
#define FLAG_JOIN_NO_RETRACT 32
/** Wait for the extruder to finish it's up movement */
#define FLAG_JOIN_WAIT_EXTRUDER_UP 64
/** Wait for the extruder to finish it's down movement */
#define FLAG_JOIN_WAIT_EXTRUDER_DOWN 128
// Printing related data
#if NONLINEAR_SYSTEM
// Allow the delta cache to store segments for every line in line cache. Beware this gets big ... fast.
// DELTASEGMENTS_PER_PRINTLINE *
#define DELTA_CACHE_SIZE (DELTASEGMENTS_PER_PRINTLINE * PRINTLINE_CACHE_SIZE)
class PrintLine;
typedef struct
{
flag8_t dir; ///< Direction of delta movement.
uint16_t deltaSteps[TOWER_ARRAY]; ///< Number of steps in move.
inline void checkEndstops(PrintLine *cur,bool checkall);
inline void setXMoveFinished()
{
dir &= ~XSTEP;
}
inline void setYMoveFinished()
{
dir &= ~YSTEP;
}
inline void setZMoveFinished()
{
dir &= ~ZSTEP;
}
inline void setXYMoveFinished()
{
dir &= ~XY_STEP;
}
inline bool isXPositiveMove()
{
return (dir & X_STEP_DIRPOS) == X_STEP_DIRPOS;
}
inline bool isXNegativeMove()
{
return (dir & X_STEP_DIRPOS) == XSTEP;
}
inline bool isYPositiveMove()
{
return (dir & Y_STEP_DIRPOS) == Y_STEP_DIRPOS;
}
inline bool isYNegativeMove()
{
return (dir & Y_STEP_DIRPOS) == YSTEP;
}
inline bool isZPositiveMove()
{
return (dir & Z_STEP_DIRPOS) == Z_STEP_DIRPOS;
}
inline bool isZNegativeMove()
{
return (dir & Z_STEP_DIRPOS) == ZSTEP;
}
inline bool isEPositiveMove()
{
return (dir & E_STEP_DIRPOS) == E_STEP_DIRPOS;
}
inline bool isENegativeMove()
{
return (dir & E_STEP_DIRPOS) == ESTEP;
}
inline bool isXMove()
{
return (dir & XSTEP);
}
inline bool isYMove()
{
return (dir & YSTEP);
}
inline bool isXOrYMove()
{
return dir & XY_STEP;
}
inline bool isZMove()
{
return (dir & ZSTEP);
}
inline bool isEMove()
{
return (dir & ESTEP);
}
inline bool isEOnlyMove()
{
return (dir & XYZE_STEP)==ESTEP;
}
inline bool isNoMove()
{
return (dir & XYZE_STEP) == 0;
}
inline bool isXYZMove()
{
return dir & XYZ_STEP;
}
inline bool isMoveOfAxis(uint8_t axis)
{
return (dir & (XSTEP<<axis));
}
inline void setMoveOfAxis(uint8_t axis)
{
dir |= XSTEP << axis;
}
inline void setPositiveMoveOfAxis(uint8_t axis)
{
dir |= X_STEP_DIRPOS << axis;
}
inline void setPositiveDirectionForAxis(uint8_t axis)
{
dir |= X_DIRPOS << axis;
}
} DeltaSegment;
extern uint8_t lastMoveID;
#endif
class UIDisplay;
class PrintLine // RAM usage: 24*4+15 = 113 Byte
{
friend class UIDisplay;
#if CPU_ARCH==ARCH_ARM
static volatile bool nlFlag;
#endif
public:
static ufast8_t linesPos; // Position for executing line movement
static PrintLine lines[];
static ufast8_t linesWritePos; // Position where we write the next cached line move
ufast8_t joinFlags;
volatile ufast8_t flags;
private:
fast8_t primaryAxis;
int32_t timeInTicks;
ufast8_t dir; ///< Direction of movement. 1 = X+, 2 = Y+, 4= Z+, values can be combined.
int32_t delta[E_AXIS_ARRAY]; ///< Steps we want to move.
int32_t error[E_AXIS_ARRAY]; ///< Error calculation for Bresenham algorithm
float speedX; ///< Speed in x direction at fullInterval in mm/s
float speedY; ///< Speed in y direction at fullInterval in mm/s
float speedZ; ///< Speed in z direction at fullInterval in mm/s
float speedE; ///< Speed in E direction at fullInterval in mm/s
float fullSpeed; ///< Desired speed mm/s
float invFullSpeed; ///< 1.0/fullSpeed for fatser computation
float accelerationDistance2; ///< Real 2.0*distanceÜacceleration mm²/s²
float maxJunctionSpeed; ///< Max. junction speed between this and next segment
float startSpeed; ///< Staring speed in mm/s
float endSpeed; ///< Exit speed in mm/s
float minSpeed;
float distance;
#if NONLINEAR_SYSTEM
uint8_t numDeltaSegments; ///< Number of delta segments left in line. Decremented by stepper timer.
uint8_t moveID; ///< ID used to identify moves which are all part of the same line
int32_t numPrimaryStepPerSegment; ///< Number of primary bresenham axis steps in each delta segment
DeltaSegment segments[DELTASEGMENTS_PER_PRINTLINE];
#endif
ticks_t fullInterval; ///< interval at full speed in ticks/step.
uint16_t accelSteps; ///< How much steps does it take, to reach the plateau.
uint16_t decelSteps; ///< How much steps does it take, to reach the end speed.
uint32_t accelerationPrim; ///< Acceleration along primary axis
uint32_t fAcceleration; ///< accelerationPrim*262144/F_CPU
speed_t vMax; ///< Maximum reached speed in steps/s.
speed_t vStart; ///< Starting speed in steps/s.
speed_t vEnd; ///< End speed in steps/s
#if USE_ADVANCE
#if ENABLE_QUADRATIC_ADVANCE
int32_t advanceRate; ///< Advance steps at full speed
int32_t advanceFull; ///< Maximum advance at fullInterval [steps*65536]
int32_t advanceStart;
int32_t advanceEnd;
#endif
uint16_t advanceL; ///< Recomputated L value
#endif
#ifdef DEBUG_STEPCOUNT
int32_t totalStepsRemaining;
#endif
public:
int32_t stepsRemaining; ///< Remaining steps, until move is finished
static PrintLine *cur;
static volatile ufast8_t linesCount; // Number of lines cached 0 = nothing to do
inline bool areParameterUpToDate()
{
return joinFlags & FLAG_JOIN_STEPPARAMS_COMPUTED;
}
inline void invalidateParameter()
{
joinFlags &= ~FLAG_JOIN_STEPPARAMS_COMPUTED;
}
inline void setParameterUpToDate()
{
joinFlags |= FLAG_JOIN_STEPPARAMS_COMPUTED;
}
inline bool isStartSpeedFixed()
{
return joinFlags & FLAG_JOIN_START_FIXED;
}
inline void setStartSpeedFixed(bool newState)
{
joinFlags = (newState ? joinFlags | FLAG_JOIN_START_FIXED : joinFlags & ~FLAG_JOIN_START_FIXED);
}
inline void fixStartAndEndSpeed()
{
joinFlags |= FLAG_JOIN_END_FIXED | FLAG_JOIN_START_FIXED;
}
inline bool isEndSpeedFixed()
{
return joinFlags & FLAG_JOIN_END_FIXED;
}
inline void setEndSpeedFixed(bool newState)
{
joinFlags = (newState ? joinFlags | FLAG_JOIN_END_FIXED : joinFlags & ~FLAG_JOIN_END_FIXED);
}
inline bool isWarmUp()
{
return flags & FLAG_WARMUP;
}
inline uint8_t getWaitForXLinesFilled()
{
return primaryAxis;
}
inline void setWaitForXLinesFilled(uint8_t b)
{
primaryAxis = b;
}
inline bool isExtruderForwardMove()
{
return (dir & E_STEP_DIRPOS)==E_STEP_DIRPOS;
}
inline void block()
{
flags |= FLAG_BLOCKED;
}
inline void unblock()
{
flags &= ~FLAG_BLOCKED;
}
inline bool isBlocked()
{
return flags & FLAG_BLOCKED;
}
inline bool isCheckEndstops()
{
return flags & FLAG_CHECK_ENDSTOPS;
}
inline bool isNominalMove()
{
return flags & FLAG_NOMINAL;
}
inline void setNominalMove()
{
flags |= FLAG_NOMINAL;
}
inline void checkEndstops()
{
if(isCheckEndstops())
{
if(isXNegativeMove() && Endstops::xMin())
setXMoveFinished();
else if(isXPositiveMove() && Endstops::xMax())
setXMoveFinished();
if(isYNegativeMove() && Endstops::yMin())
setYMoveFinished();
else if(isYPositiveMove() && Endstops::yMax())
setYMoveFinished();
#if FEATURE_Z_PROBE
if(Printer::isZProbingActive() && isZNegativeMove() && Endstops::zProbe())
{
setZMoveFinished();
Printer::stepsRemainingAtZHit = stepsRemaining;
}
else
#endif
if(isZNegativeMove() && Endstops::zMin())
{
setZMoveFinished();
}
else if(isZPositiveMove() && Endstops::zMax())
{
#if MAX_HARDWARE_ENDSTOP_Z
Printer::stepsRemainingAtZHit = stepsRemaining;
#endif
setZMoveFinished();
}
}
#if FEATURE_Z_PROBE
else if(Printer::isZProbingActive() && isZNegativeMove() && Endstops::zProbe())
{
setZMoveFinished();
Printer::stepsRemainingAtZHit = stepsRemaining;
}
#endif
}
inline void setXMoveFinished()
{
#if DRIVE_SYSTEM == CARTESIAN || NONLINEAR_SYSTEM
dir &= ~16;
#else
dir &= ~48;
#endif
}
inline void setYMoveFinished()
{
#if DRIVE_SYSTEM == CARTESIAN || NONLINEAR_SYSTEM
dir &= ~32;
#else
dir &= ~48;
#endif
}
inline void setZMoveFinished()
{
dir &= ~64;
}
inline void setXYMoveFinished()
{
dir &= ~48;
}
inline bool isXPositiveMove()
{
return (dir & X_STEP_DIRPOS) == X_STEP_DIRPOS;
}
inline bool isXNegativeMove()
{
return (dir & X_STEP_DIRPOS) == XSTEP;
}
inline bool isYPositiveMove()
{
return (dir & Y_STEP_DIRPOS) == Y_STEP_DIRPOS;
}
inline bool isYNegativeMove()
{
return (dir & Y_STEP_DIRPOS) == YSTEP;
}
inline bool isZPositiveMove()
{
return (dir & Z_STEP_DIRPOS) == Z_STEP_DIRPOS;
}
inline bool isZNegativeMove()
{
return (dir & Z_STEP_DIRPOS) == ZSTEP;
}
inline bool isEPositiveMove()
{
return (dir & E_STEP_DIRPOS) == E_STEP_DIRPOS;
}
inline bool isENegativeMove()
{
return (dir & E_STEP_DIRPOS) == ESTEP;
}
inline bool isXMove()
{
return (dir & XSTEP);
}
inline bool isYMove()
{
return (dir & YSTEP);
}
inline bool isXOrYMove()
{
return dir & XY_STEP;
}
inline bool isXOrZMove()
{
return dir & (XSTEP | YSTEP);
}
inline bool isZMove()
{
return (dir & ZSTEP);
}
inline bool isEMove()
{
return (dir & ESTEP);
}
inline bool isEOnlyMove()
{
return (dir & XYZE_STEP) == ESTEP;
}
inline bool isNoMove()
{
return (dir & XYZE_STEP) == 0;
}
inline bool isXYZMove()
{
return dir & XYZ_STEP;
}
inline bool isMoveOfAxis(uint8_t axis)
{
return (dir & (XSTEP << axis));
}
inline void setMoveOfAxis(uint8_t axis)
{
dir |= XSTEP << axis;
}
inline void setPositiveDirectionForAxis(uint8_t axis)
{
dir |= X_DIRPOS << axis;
}
inline static void resetPathPlanner()
{
linesCount = 0;
linesPos = linesWritePos;
Printer::setMenuMode(MENU_MODE_PRINTING, false);
}
// Only called from bresenham -> inside interrupt handle
inline void updateAdvanceSteps(speed_t v, uint8_t max_loops, bool accelerate)
{
#if USE_ADVANCE
if(!Printer::isAdvanceActivated()) return;
#if ENABLE_QUADRATIC_ADVANCE
long advanceTarget = Printer::advanceExecuted;
if(accelerate)
{
for(uint8_t loop = 0; loop < max_loops; loop++) advanceTarget += advanceRate;
if(advanceTarget > advanceFull)
advanceTarget = advanceFull;
}
else
{
for(uint8_t loop = 0; loop < max_loops; loop++) advanceTarget -= advanceRate;
if(advanceTarget < advanceEnd)
advanceTarget = advanceEnd;
}
long h = HAL::mulu16xu16to32(v, advanceL);
int tred = ((advanceTarget + h) >> 16);
HAL::forbidInterrupts();
Printer::extruderStepsNeeded += tred - Printer::advanceStepsSet;
if(tred > 0 && Printer::advanceStepsSet <= 0)
Printer::extruderStepsNeeded += Extruder::current->advanceBacklash;
else if(tred < 0 && Printer::advanceStepsSet >= 0)
Printer::extruderStepsNeeded -= Extruder::current->advanceBacklash;
Printer::advanceStepsSet = tred;
HAL::allowInterrupts();
Printer::advanceExecuted = advanceTarget;
#else
int tred = HAL::mulu6xu16shift16(v, advanceL);
HAL::forbidInterrupts();
Printer::extruderStepsNeeded += tred - Printer::advanceStepsSet;
if(tred > 0 && Printer::advanceStepsSet <= 0)
Printer::extruderStepsNeeded += (Extruder::current->advanceBacklash << 1);
else if(tred < 0 && Printer::advanceStepsSet >= 0)
Printer::extruderStepsNeeded -= (Extruder::current->advanceBacklash << 1);
Printer::advanceStepsSet = tred;
HAL::allowInterrupts();
#endif
#endif
}
inline bool moveDecelerating()
{
if(stepsRemaining <= decelSteps)
{
if (!(flags & FLAG_DECELERATING))
{
Printer::timer = 0;
flags |= FLAG_DECELERATING;
}
return true;
}
else return false;
}
inline bool moveAccelerating()
{
return Printer::stepNumber <= accelSteps;
}
inline void startXStep()
{
#if !(GANTRY)
WRITE(X_STEP_PIN,HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,HIGH);
#endif
#else
#if DRIVE_SYSTEM == XY_GANTRY || DRIVE_SYSTEM == XZ_GANTRY
if(isXPositiveMove())
{
Printer::motorX++;
Printer::motorYorZ++;
}
else
{
Printer::motorX--;
Printer::motorYorZ--;
}
#endif
#if DRIVE_SYSTEM == YX_GANTRY || DRIVE_SYSTEM == ZX_GANTRY
if(isXPositiveMove())
{
Printer::motorX++;
Printer::motorYorZ--;
}
else
{
Printer::motorX--;
Printer::motorYorZ++;
}
#endif
#endif
#ifdef DEBUG_STEPCOUNT
totalStepsRemaining--;
#endif
}
inline void startYStep()
{
#if !(GANTRY) || DRIVE_SYSTEM == ZX_GANTRY || DRIVE_SYSTEM == XZ_GANTRY
WRITE(Y_STEP_PIN,HIGH);
#if FEATURE_TWO_YSTEPPER
WRITE(Y2_STEP_PIN,HIGH);
#endif
#else
#if DRIVE_SYSTEM == XY_GANTRY
if(isYPositiveMove())
{
Printer::motorX++;
Printer::motorYorZ--;
}
else
{
Printer::motorX--;
Printer::motorYorZ++;
}
#endif
#if DRIVE_SYSTEM == YX_GANTRY
if(isYPositiveMove())
{
Printer::motorX++;
Printer::motorYorZ++;
}
else
{
Printer::motorX--;
Printer::motorYorZ--;
}
#endif
#endif // GANTRY
#ifdef DEBUG_STEPCOUNT
totalStepsRemaining--;
#endif
}
inline void startZStep()
{
#if !(GANTRY) || DRIVE_SYSTEM == YX_GANTRY || DRIVE_SYSTEM == XY_GANTRY
WRITE(Z_STEP_PIN,HIGH);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_STEP_PIN,HIGH);
#endif
#else
#if DRIVE_SYSTEM == XZ_GANTRY
if(isYPositiveMove())
{
Printer::motorX++;
Printer::motorYorZ--;
}
else
{
Printer::motorX--;
Printer::motorYorZ++;
}
#endif
#if DRIVE_SYSTEM == ZX_GANTRY
if(isYPositiveMove())
{
Printer::motorX++;
Printer::motorYorZ++;
}
else
{
Printer::motorX--;
Printer::motorYorZ--;
}
#endif
#endif
}
void updateStepsParameter();
inline float safeSpeed();
void calculateMove(float axis_diff[],uint8_t pathOptimize);
void logLine();
inline long getWaitTicks()
{
return timeInTicks;
}
inline void setWaitTicks(long wait)
{
timeInTicks = wait;
}
static inline bool hasLines()
{
return linesCount;
}
static inline void setCurrentLine()
{
cur = &lines[linesPos];
#if CPU_ARCH==ARCH_ARM
PrintLine::nlFlag = true;
#endif
}
// Only called from within interrupts
static inline void removeCurrentLineForbidInterrupt()
{
linesPos++;
if(linesPos >= PRINTLINE_CACHE_SIZE) linesPos = 0;
cur = NULL;
#if CPU_ARCH == ARCH_ARM
nlFlag = false;
#endif
HAL::forbidInterrupts();
--linesCount;
if(!linesCount)
Printer::setMenuMode(MENU_MODE_PRINTING, false);
}
static inline void pushLine()
{
linesWritePos++;
if(linesWritePos >= PRINTLINE_CACHE_SIZE) linesWritePos = 0;
Printer::setMenuMode(MENU_MODE_PRINTING, true);
InterruptProtectedBlock noInts;
linesCount++;
}
static uint8_t getLinesCount()
{
InterruptProtectedBlock noInts;
return linesCount;
}
static PrintLine *getNextWriteLine()
{
return &lines[linesWritePos];
}
static inline void computeMaxJunctionSpeed(PrintLine *previous,PrintLine *current);
static int32_t bresenhamStep();
static void waitForXFreeLines(uint8_t b=1, bool allowMoves = false);
static inline void forwardPlanner(ufast8_t p);
static inline void backwardPlanner(ufast8_t p,ufast8_t last);
static void updateTrapezoids();
static uint8_t insertWaitMovesIfNeeded(uint8_t pathOptimize, uint8_t waitExtraLines);
static void queueCartesianMove(uint8_t check_endstops,uint8_t pathOptimize);
static void moveRelativeDistanceInSteps(int32_t x,int32_t y,int32_t z,int32_t e,float feedrate,bool waitEnd,bool check_endstop);
static void moveRelativeDistanceInStepsReal(int32_t x,int32_t y,int32_t z,int32_t e,float feedrate,bool waitEnd);
#if ARC_SUPPORT
static void arc(float *position, float *target, float *offset, float radius, uint8_t isclockwise);
#endif
static inline void previousPlannerIndex(ufast8_t &p)
{
p = (p ? p - 1 : PRINTLINE_CACHE_SIZE - 1);
}
static inline void nextPlannerIndex(ufast8_t& p)
{
p = (p == PRINTLINE_CACHE_SIZE - 1 ? 0 : p + 1);
}
#if NONLINEAR_SYSTEM
static uint8_t queueDeltaMove(uint8_t check_endstops,uint8_t pathOptimize, uint8_t softEndstop);
static inline void queueEMove(int32_t e_diff,uint8_t check_endstops,uint8_t pathOptimize);
inline uint16_t calculateDeltaSubSegments(uint8_t softEndstop);
static inline void calculateDirectionAndDelta(int32_t difference[], ufast8_t *dir, int32_t delta[]);
static inline uint8_t calculateDistance(float axis_diff[], uint8_t dir, float *distance);
#if SOFTWARE_LEVELING && DRIVE_SYSTEM == DELTA
static void calculatePlane(int32_t factors[], int32_t p1[], int32_t p2[], int32_t p3[]);
static float calcZOffset(int32_t factors[], int32_t pointX, int32_t pointY);
#endif
#endif
};
#endif // MOTION_H_INCLUDED

2588
Repetier/pins.h Normal file

File diff suppressed because it is too large Load diff

10703
Repetier/u8glib_ex.h Normal file

File diff suppressed because it is too large Load diff

3635
Repetier/ui.cpp Normal file

File diff suppressed because it is too large Load diff

1733
Repetier/ui.h Normal file

File diff suppressed because it is too large Load diff

455
Repetier/uiconfig.h Normal file
View file

@ -0,0 +1,455 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
/* ===================== IMPORTANT ========================
The LCD and Key support is new. I tested everything as good as possible,
but some combinations may not work as supposed.
The I2C methods rely on a stable I2C connection. Noise may cause wrong signals
which can cause the firmware to freeze.
The ui adds quite some code, so AVRs with 64kB ram (Sanguino, Gen6) can not handle all features
of the firmware at the same time. You have to disable some features to gain the
ram needed. What should work:
- No sd card - the sd card code is quite large.
- No keys attached - The longest part is the menu handling.
- EEPROM_MODE 0 .
Currently supported hardware:
*** Displays ***
- direct connected lcd with 4 data lines
- connected via i2c
*** Keys ***
- rotary encoder
- push button
- key matrix up to 4x4
- rotary encoder via i2c (only slow turns are captured correct)
- push button via i2c
*** Buzzer ***
- directly connected, high = on
- connected via i2c, low = on
==============================================================*/
#ifndef _ui_config_h
#define _ui_config_h
/** While the ascii chars are all the same, the driver have different charsets
for special chars used in different countries. The charset allows to fix for
this problem. If characters look wrong, try a different charset. If nothing
works, use the ascii charset 0 as fallback. Not the nicest for everything but working!
0 = ASCII fallback
1 = Default works on most displays. This has some japanese chars in charset
2 = Alternative charset with more european chars
*/
#define UI_DISPLAY_CHARSET 2
/** Select type of beeper
0 = none
1 = Piezo connected to pin
2 = Piezo connected to a pin over I2C
*/
#ifndef BEEPER_TYPE
#define BEEPER_TYPE 1
#define BEEPER_TYPE_INVERTING false
#endif
#if BEEPER_TYPE==1 && !defined(BEEPER_PIN)
#define BEEPER_PIN 37
#endif
#if BEEPER_TYPE==2
#define BEEPER_ADDRESS 0x40 // I2C address of the chip with the beeper pin
#define BEEPER_PIN _BV(7) // Bit value for pin 8
#define COMPILE_I2C_DRIVER // We need the I2C driver as we are using i2c
#endif
/**
What display type do you use?
0 = No display - do not use here. Set FEATURE_CONTROLLER 0 instead
1 = LCD Display with 4 bit data bus
2 = LCD Display with 8 bit data bus (currently not implemented, fallback to 1)
3 = LCD Display with I2C connection, 4 bit mode
4 = Use the slower LiquiedCrystal library bundled with arduino.
IMPORTANT: You need to uncomment the LiquidCrystal include in Repetier.pde for it to work.
If you have Sanguino and want to use the library, you need to have Arduino 023 or older. (13.04.2012)
5 = U8G supported display
*/
#define UI_DISPLAY_TYPE 5
#if UI_DISPLAY_TYPE == DISPLAY_U8G // Special case for graphic displays
// You need to define which controller you use and set pins accodringly
// For software spi assign these definitions
// SCK Pin: UI_DISPLAY_D4_PIN
// Mosi Pin: UI_DISPLAY_ENABLE_PIN
// CD Pin: UI_DISPLAY_RS_PIN
// ST7920 with software SPI
#define U8GLIB_ST7920
// SSD1306 with software SPI
//#define U8GLIB_SSD1306_SW_SPI
// SSD1306 over I2C using hardware I2C pins
//#define U8GLIB_SSD1306_I2C
// For the 8 bit ks0108 display you need to set these pins
// UI_DISPLAY_D0_PIN,UI_DISPLAY_D1_PIN,UI_DISPLAY_D2_PIN,UI_DISPLAY_D3_PIN,UI_DISPLAY_D4_PIN,UI_DISPLAY_D5_PIN,UI_DISPLAY_D6_PIN,UI_DISPLAY_D7_PIN
// UI_DISPLAY_ENABLE_PIN,UI_DISPLAY_CS1,UI_DISPLAY_CS2,
// UI_DISPLAY_DI,UI_DISPLAY_RW_PIN,UI_DISPLAY_RESET_PIN
//#define U8GLIB_KS0108
//#define U8GLIB_KS0108_FAST
// UI_DISPLAY_RS_PIN = CS
// UI_DISPLAY_D5_PIN = A0
//#define U8GLIB_ST7565_NHD_C2832_HW_SPI
#define UI_LCD_WIDTH 128
#define UI_LCD_HEIGHT 64
//select font size
#define UI_FONT_6X10 //default font
#ifdef UI_FONT_6X10
#define UI_FONT_WIDTH 6
#define UI_FONT_HEIGHT 10
#define UI_FONT_SMALL_HEIGHT 7
#define UI_FONT_DEFAULT repetier_6x10
#define UI_FONT_SMALL repetier_5x7
#define UI_FONT_SMALL_WIDTH 5 //smaller font for status display
#define UI_ANIMATION false // Animations are too slow
#endif
//calculate rows and cols available with current font
#define UI_COLS (UI_LCD_WIDTH/UI_FONT_WIDTH)
#define UI_ROWS (UI_LCD_HEIGHT/UI_FONT_HEIGHT)
#define UI_DISPLAY_CHARSET 3
#else
/** Number of columns per row
Typical values are 16 and 20
*/
#define UI_COLS 20
/**
Rows of your display. 2 or 4
*/
#define UI_ROWS 4
#endif // UI_DISPLAY_TYPE
/* What type of chip is used for I2C communication
0 : PCF8574 or PCF8574A or compatible chips.
1 : MCP23017
*/
#define UI_DISPLAY_I2C_CHIPTYPE 0
// 0x40 till 0x4e for PCF8574, 0x40 for the adafruid RGB shield, 0x40 - 0x4e for MCP23017
// Official addresses have a value half as high!
#define UI_DISPLAY_I2C_ADDRESS 0x4e
// For MCP 23017 define which pins should be output
#define UI_DISPLAY_I2C_OUTPUT_PINS 65504
// Set the output mask that is or'd over the output data. This is needed to activate
// a backlight switched over the I2C.
// The adafruit RGB shields enables a light if the bit is not set. Bits 6-8 are used for backlight.
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
// For MCP which inputs are with pullup. 31 = pins 0-4 for adafruid rgb shield buttons
#define UI_DISPLAY_I2C_PULLUP 31
/* How fast should the I2C clock go. The PCF8574 work only with the lowest setting 100000.
A MCP23017 can run also with 400000 Hz */
#define UI_I2C_CLOCKSPEED 100000L
/**
Define the pin
*/
#if UI_DISPLAY_TYPE == DISPLAY_I2C // I2C Pin configuration
#define UI_DISPLAY_RS_PIN _BV(4)
#define UI_DISPLAY_RW_PIN _BV(5)
#define UI_DISPLAY_ENABLE_PIN _BV(6)
#define UI_DISPLAY_D0_PIN _BV(0)
#define UI_DISPLAY_D1_PIN _BV(1)
#define UI_DISPLAY_D2_PIN _BV(2)
#define UI_DISPLAY_D3_PIN _BV(3)
#define UI_DISPLAY_D4_PIN _BV(0)
#define UI_DISPLAY_D5_PIN _BV(1)
#define UI_DISPLAY_D6_PIN _BV(2)
#define UI_DISPLAY_D7_PIN _BV(3)
// uncomment if your using led to indicated the bed is hot
//#define UI_I2C_HEATBED_LED _BV(8)
// uncomment if your using led to indicated the extruder is hot
//#define UI_I2C_HOTEND_LED _BV(7)
// uncomment if your using led to indicated the FAN is on
//#define UI_I2C_FAN_LED _BV(6)
// Pins for adafruid RGB shield
/*#define UI_DISPLAY_RS_PIN _BV(15)
#define UI_DISPLAY_RW_PIN _BV(14)
#define UI_DISPLAY_ENABLE_PIN _BV(13)
#define UI_DISPLAY_D0_PIN _BV(12)
#define UI_DISPLAY_D1_PIN _BV(11)
#define UI_DISPLAY_D2_PIN _BV(10)
#define UI_DISPLAY_D3_PIN _BV(9)
#define UI_DISPLAY_D4_PIN _BV(12)
#define UI_DISPLAY_D5_PIN _BV(11)
#define UI_DISPLAY_D6_PIN _BV(10)
#define UI_DISPLAY_D7_PIN _BV(9)*/
#else // Direct display connections
#define UI_DISPLAY_RS_PIN 63 // PINK.1, 88, D_RS
#define UI_DISPLAY_RW_PIN -1
#define UI_DISPLAY_ENABLE_PIN 65 // PINK.3, 86, D_E
#define UI_DISPLAY_D0_PIN 59 // PINF.5, 92, D_D4
#define UI_DISPLAY_D1_PIN 64 // PINK.2, 87, D_D5
#define UI_DISPLAY_D2_PIN 44 // PINL.5, 40, D_D6
#define UI_DISPLAY_D3_PIN 66 // PINK.4, 85, D_D7
#define UI_DISPLAY_D4_PIN 59 // PINF.5, 92, D_D4
#define UI_DISPLAY_D5_PIN 64 // PINK.2, 87, D_D5
#define UI_DISPLAY_D6_PIN 44 // PINL.5, 40, D_D6
#define UI_DISPLAY_D7_PIN 66 // PINK.4, 85, D_D7
#define UI_DELAYPERCHAR 50
// Special pins for some u8g driven display
#define UI_DISPLAY_CS1 59
#define UI_DISPLAY_CS2 59
#define UI_DISPLAY_DI 59
#define UI_DISPLAY_RW_PIN 59
#define UI_DISPLAY_RESET_PIN 59
#endif
/** \brief Are some keys connected?
0 = No keys attached - disables also menu
1 = Some keys attached
*/
#define UI_HAS_KEYS 0
/** \brief Is a back key present.
If you have menus enabled, you need a method to leave it. If you have a back key, you can always go one level higher.
Without a back key, you need to navigate to the back entry in the menu. Setting this value to 1 removes the back entry.
*/
#define UI_HAS_BACK_KEY 1
/* Then you have the next/previous keys more like up/down keys, it may be more intuitive to change the direction you skip through the menus.
If you set it to true, next will go to previous menu instead of the next menu.
*/
#define UI_INVERT_MENU_DIRECTION 0
/** Uncomment this, if you have keys connected via i2c to a PCF8574 chip. */
//#define UI_HAS_I2C_KEYS
// Do you have a I2C connected encoder?
#define UI_HAS_I2C_ENCODER 0
// Under which address can the key status requested. This is the address of your PCF8574 where the keys are connected.
// If you use a MCP23017 the address from display is used also for keys.
#define UI_I2C_KEY_ADDRESS 0x40
#ifdef UI_MAIN
/* #######################################################################
Key definitions
The firmware is very flexible regarding your input methods. You can use one
or more of the predefined key macros, to define a mapper. If no matching mapper
is available, you can add you c-code for mapping directly into the keyboard
routines. The predefined macros do the same, just hiding the code behind it.
For each key, two seperate parts must be defined. The first is the initialization
which must be added inside uiInitKeys() and the second ist a testing routine.
These come into uiCheckKeys() or uiCheckSlowKeys() depending on the time needed
for testing. If you are in doubt, put it in uiCheckSlowKeys().
uiInitKeys() is called from an interrupt controlling the extruder, so only
fast tests should be put there.
The detect methods need an action identifier. A list of supported ids is found
at the beginning of ui.h It's best to use the symbol name, in case the value changes.
1. Simple push button connected to gnd if closed on a free arduino pin
init -> UI_KEYS_INIT_BUTTON_LOW(pinNumber);
detect -> UI_KEYS_BUTTON_LOW(pinNumber,action);
2. Simple push button connected to 5v if closed on a free arduino pin
init -> UI_KEYS_INIT_BUTTON_HIGH(pinNumber);
detect -> UI_KEYS_BUTTON_HIGH(pinNumber,action);
3. Click encoder, A/B connected to gnd if closed.
init -> UI_KEYS_INIT_CLICKENCODER_LOW(pinA,pinB);
detect -> UI_KEYS_CLICKENCODER_LOW(pinA,pinB);
or UI_KEYS_CLICKENCODER_LOW_REV(pinA,pinB); // reverse direction
If you can move the menu cursor without a click, just be adding some force in one direction,
toggle the _REV with non _REV and toggle pins.
If the direction is wrong, toggle _REV with non _REV version.
For the push button of the encoder use 1.
4. Click encoder, A/B connected to 5V if closed.
init -> UI_KEYS_INIT_CLICKENCODER_HIGH(pinA,pinB);
detect -> UI_KEYS_CLICKENCODER_HIGH(pinA,pinB);
or UI_KEYS_CLICKENCODER_HIGH_REV(pinA,pinB); // reverse direction
If you can move the menu cursor without a click, just be adding some force in one direction,
toggle the _REV with non _REV and toggle pins.
If the direction is wrong, toggle _REV with non _REV version.
For the push button of the encoder use 2.
5. Maxtrix keyboard with 1-4 rows and 1-4 columns.
init -> UI_KEYS_INIT_MATRIX(r1,r2,r3,r4,c1,c2,c3,c4);
detect -> UI_KEYS_MATRIX(r1,r2,r3,r4,c1,c2,c3,c4);
In addition you have to set UI_MATRIX_ACTIONS to match your desired actions.
------- Keys connected via I2C -------------
All keys and the buzzer if present must be on a connected to a single PCF8574 chip!
As all I2C request take time, they belong all in uiCheckSlowKeys.
Dont use the pin ids but instead _BV(pinNumber0_7) as pin id. 0 = First pin
6. Click encoder, A/B connected to gnd if closed.
init -> not needed, but make sure UI_HAS_I2C_KEY is not commented out.
detect -> UI_KEYS_I2C_CLICKENCODER_LOW(pinA,pinB);
or UI_KEYS_I2C_CLICKENCODER_LOW_REV(pinA,pinB); // reverse direction
If you can move the menu cursor without a click, just be adding some force in one direction,
toggle the _REV with non _REV and toggle pins.
If the direction is wrong, toggle _REV with non _REV version.
For the push button of the encoder use 7.
NOTICE: The polling frequency is limited, so only slow turns are captured correct!
7. Simple push button connected to gnd if closed via I2C on a PCF8574
init -> not needed, but make sure UI_HAS_I2C_KEY is not commented out.
detect -> UI_KEYS_I2C_BUTTON_LOW(pinNumber,action);
-------- Some notes on actions -------------
There are three kinds of actions.
Type 1: Immediate actions - these are execute and forget actions like home/pre-heat
Type 2: Parameter change action - these change the mode for next/previous keys. They are valid
until a new change action is initiated or the action is finished with ok button.
Type 3: Show menu action. These actions have a _MENU_ in their name. If they are executed, a new
menu is pushed on the menu stack and you see the menu. If you assign these actions directly
to a key, you might not want this pushing behaviour. In this case add UI_ACTION_TOPMENU to the
action, like UI_ACTION_TOPMENU+UI_ACTION_MENU_XPOSFAST. That will show the menu as top-menu
closing all othe submenus that were open.
####################################################################### */
// Use these codes for key detect. The main menu will show the pressed action in the lcd display.
// after that assign the desired codes.
//#define UI_MATRIX_ACTIONS {2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015}
// Define your matrix actions
#define UI_MATRIX_ACTIONS {UI_ACTION_HOME_ALL, UI_ACTION_TOP_MENU, UI_ACTION_SET_ORIGIN, UI_ACTION_NEXT,\
UI_ACTION_HOME_Z, UI_ACTION_MENU_ZPOS, UI_ACTION_COOLDOWN, UI_ACTION_OK,\
UI_ACTION_HOME_Y, UI_ACTION_MENU_YPOSFAST, UI_ACTION_PREHEAT_ABS, UI_ACTION_PREVIOUS,\
UI_ACTION_HOME_X, UI_ACTION_MENU_XPOSFAST, UI_ACTION_DISABLE_STEPPER, UI_ACTION_BACK}
#ifdef UI_MATRIX_ACTIONS
const int matrixActions[] PROGMEM = UI_MATRIX_ACTIONS;
#endif
void uiInitKeys() {
#if UI_HAS_KEYS!=0
//UI_KEYS_INIT_CLICKENCODER_LOW(33,31); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_INIT_BUTTON_LOW(4); // push button, connects gnd to pin
UI_KEYS_INIT_BUTTON_LOW(5);
UI_KEYS_INIT_BUTTON_LOW(6);
UI_KEYS_INIT_BUTTON_LOW(11);
UI_KEYS_INIT_BUTTON_LOW(42);
// UI_KEYS_INIT_CLICKENCODER_LOW(47,45); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
// UI_KEYS_INIT_BUTTON_LOW(43); // push button, connects gnd to pin
// UI_KEYS_INIT_MATRIX(32,47,45,43,41,39,37,35);
#endif
}
void uiCheckKeys(int &action) {
#if UI_HAS_KEYS!=0
//UI_KEYS_CLICKENCODER_LOW_REV(33,31); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
UI_KEYS_BUTTON_LOW(4,UI_ACTION_OK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(5,UI_ACTION_NEXT); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(6,UI_ACTION_PREVIOUS); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(11,UI_ACTION_BACK); // push button, connects gnd to pin
UI_KEYS_BUTTON_LOW(42,UI_ACTION_SD_PRINT ); // push button, connects gnd to pin
// UI_KEYS_CLICKENCODER_LOW_REV(47,45); // click encoder on pins 47 and 45. Phase is connected with gnd for signals.
// UI_KEYS_BUTTON_LOW(43,UI_ACTION_OK); // push button, connects gnd to pin
#endif
}
inline void uiCheckSlowEncoder() {
#if defined(UI_HAS_I2C_KEYS) && UI_HAS_KEYS!=0
#if UI_DISPLAY_I2C_CHIPTYPE==0
HAL::i2cStartWait(UI_I2C_KEY_ADDRESS+I2C_READ);
uint8_t keymask = HAL::i2cReadNak(); // Read current key mask
#endif
#if UI_DISPLAY_I2C_CHIPTYPE==1
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE);
HAL::i2cWrite(0x12); // GIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ);
unsigned int keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak()<<8);
#endif
HAL::i2cStop();
// Add I2C click encoder tests here, all other i2c tests and a copy of the encoder test belog in uiCheckSlowKeys
UI_KEYS_I2C_CLICKENCODER_LOW_REV(_BV(2),_BV(0)); // click encoder on pins 0 and 2. Phase is connected with gnd for signals.
#endif
}
void uiCheckSlowKeys(int &action) {
#if defined(UI_HAS_I2C_KEYS) && UI_HAS_KEYS!=0
#if UI_DISPLAY_I2C_CHIPTYPE==0
HAL::i2cStartWait(UI_I2C_KEY_ADDRESS+I2C_READ);
uint8_t keymask = HAL::i2cReadNak(); // Read current key mask
#endif
#if UI_DISPLAY_I2C_CHIPTYPE==1
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE);
HAL::i2cWrite(0x12); // GPIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ);
unsigned int keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak()<<8);
#endif
HAL::i2cStop();
// Add I2C key tests here
UI_KEYS_I2C_CLICKENCODER_LOW_REV(_BV(2),_BV(0)); // click encoder on pins 0 and 2. Phase is connected with gnd for signals.
UI_KEYS_I2C_BUTTON_LOW(_BV(1),UI_ACTION_OK); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(3),UI_ACTION_BACK); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(4),UI_ACTION_MENU_QUICKSETTINGS+UI_ACTION_TOPMENU); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(5),UI_ACTION_MENU_EXTRUDER+UI_ACTION_TOPMENU); // push button, connects gnd to pin
UI_KEYS_I2C_BUTTON_LOW(_BV(6),UI_ACTION_MENU_POSITIONS+UI_ACTION_TOPMENU); // push button, connects gnd to pin
/*
// Button handling for the Adafruit RGB shild
UI_KEYS_I2C_BUTTON_LOW(4,UI_ACTION_PREVIOUS); // Up button
UI_KEYS_I2C_BUTTON_LOW(8,UI_ACTION_NEXT); // down button
UI_KEYS_I2C_BUTTON_LOW(16,UI_ACTION_BACK); // left button
UI_KEYS_I2C_BUTTON_LOW(2,UI_ACTION_OK); // right button
UI_KEYS_I2C_BUTTON_LOW(1,UI_ACTION_MENU_QUICKSETTINGS); //Select button
// ----- End RGB shield ----------
*/
#endif
//UI_KEYS_MATRIX(32,47,45,43,41,39,37,35);
}
#endif
#endif

1953
Repetier/uilang.h Normal file

File diff suppressed because it is too large Load diff

792
Repetier/uimenu.h Normal file
View file

@ -0,0 +1,792 @@
/*
This file is part of Repetier-Firmware.
Repetier-Firmware is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Repetier-Firmware is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(_UI_MENU_H)
#define _UI_MENU_H
/*moved to uilang.h
#define cUP "\001"
#define cDEG "\002"
#define cSEL "\003"
#define cUNSEL "\004"
#define cTEMP "\005"
#define cFOLD "\006"
#define cARROW "\176"
*/
/*
The menu configuration uses dynamic strings. These dynamic strings can contain
a placeholder for special values. During print these placeholder are exchanged
by their current value. Everything else is printed exactly as written.
A placeholder always has 3 chars. It starts with a % followed by 2 characters
defining the value. You can use any placeholder in any position, also it doesn't
always make sense.
Special Characters
constant description
cUP Folder up arrow
cDEG Degree mark
cSEL Selected
cUNSEL Unselected
cTEMP Thermometer symbol
cFOLD Folder symbol
List of placeholder:
%%% : The % char
%% : The % char (also)
%?<c> : Conditional. Print c if current char is not c. Allows avoiding duplicate character, like space
acceleration
%ax : X acceleration during print moves
%ay : Y acceleration during print moves
%az : Z acceleration during print moves
%aX : X acceleration during travel moves
%aY : Y acceleration during travel moves
%aZ : Z acceleration during travel moves
%aj : Max. jerk
%aJ : Max. Z-jerk
debug
%do : Debug echo state.
%di : Debug info state.
%de : Debug error state.
%dd : Debug dry run state.
extruder
%ec : Current extruder temperature
%eIc : Current extruder temperature integer (shorter)
%eb : Current heated bed temperature
%e0..9 : Temp. of extruder 0..9
%er : Extruder relative mode
%Ec : Target temperature of current extruder
%Eb : Target temperature of heated bed
%E0-9 : Target temperature of extruder 0..9
feed rate
%fx : Max. feedrate x direction
%fy : Max. feedrate y direction
%fz : Max. feedrate z direction
%fe : Max. feedrate current extruder
%fX : Homing feedrate x direction
%fY : Homing feedrate y direction
%fZ : Homing feedrate z direction
%Fs : Fan speed
%Fi : ignore M106 commands state
inactivity
%is : Stepper inactive time in minutes
%ip : Max. inactive time in minutes
random stuff
%os : Status message
%oe : Error message
%oB : Buffer length
%om : Speed multiplier
%of : flow multiplier
%oc : Connection baudrate
%o0..9 : Output level extruder 0..9 is % including %sign.
%oC : Output level current extruder
%ob : Output level heated bed
%PN : Printer name
%on : current extruder number (1,2,3...)
%oS : servo position
%oY : babysteps counter
stops
%sx : State of x min endstop.
%sX : State of x max endstop.
%sy : State of y min endstop.
%sY : State of y max endstop.
%sz : State of z min endstop.
%sZ : State of z max endstop.
steps
%Sx : Steps per mm x direction
%Sy : Steps per mm y direction
%Sz : Steps per mm z direction
%Se : Steps per mm current extruder
totals
%Ut : Shows printing time
%Uf : Shows total filament usage
extruder position
%x0 : X position
%x1 : Y position
%x2 : Z position
%x3 : Current extruder position
%x4 : Printed since temperature on in meters (for filament usage)
extruder parameters
%X0..9 : Extruder selected marker
%Xi : PID I gain
%Xp : PID P gain
%Xd : PID D gain
%Xm : PID drive min
%XM : PID drive max
%XD : PID max
%Xw : Extruder watch period in seconds
%Xh : Extruder heat manager (BangBang/PID)
%Xa : Advance K value
%Xl : Advance L value
%Xx : x offset in steps
%Xy : y offset in steps
%Xf : Extruder max. start feedrate
%XF : Extruder max. feedrate
%XA : Extruder max. acceleration
delta stuff
%y0-3 : same as %y0-3 back calculated from delta position steps
%Y0-3 : raw delta position steps (no round off error to display it)
%yD : delta printer low tower distance
%YL : delta print envelope radius Limit
%yx : low towers x offset mm
%yy : low towers y offset mm
%Yx : low towers x offset steps
%Yy : low towers y offset steps
%yX : high (Z) tower x offset mm
%yY : high (Z) tower y offset mm
%YX : high (Z) tower x offset steps
%YY : high (Z) tower y offset steps
*/
#if UI_DISPLAY_TYPE != NO_DISPLAY
// Define precision for temperatures. With small displays only integer values fit.
#ifndef UI_TEMP_PRECISION
#if UI_COLS>16
#define UI_TEMP_PRECISION 1
#else
#define UI_TEMP_PRECISION 0
#endif
#endif
/* ============= PAGES DEFINITION =============
If you are not iside a menu, the firmware displays pages with information.
Especially if you have only a small display it is convenient to have
more then one information page.
*/
/* Define your pages using dynamic strings. To define a page use
UI_PAGE4(name,row1,row2,row3,row4);
for 4 row displays and
UI_PAGE2(name,row1,row2);
for 2 row displays. You can add additional pages or change the default pages like you want.
*/
#if UI_ROWS>=6 && UI_DISPLAY_TYPE == DISPLAY_U8G
//graphic main status
UI_PAGE6(ui_page1,"\xa %e0/%E0\xb0 X:%x0",
#if NUM_EXTRUDER > 1 && MIXING_EXTRUDER == 0
"\xa %e1/%E1\xb0 Y:%x1",
#elif HAVE_HEATED_BED
"\xe %eb/%Eb\xb0 Y:%x1",
#else
" Y:%x1",
#endif
#if HAVE_HEATED_BED && NUM_EXTRUDER > 1 && MIXING_EXTRUDER == 0
"\xe %eb/%Eb\xb0 Z:%x2",
#else
"Flow:\xfd %of%%% Z:%x2",
#endif
"Mul: %om%%% \xfd E: %x4m", "Buf: %oB", "%os")
#if EEPROM_MODE != 0
UI_PAGE4(ui_page2,UI_TEXT_PRINT_TIME,"%Ut",UI_TEXT_PRINT_FILAMENT,"%Uf m")
#define UI_PRINTTIME_PAGES ,&ui_page2
#define UI_PRINTTIME_COUNT 1
#else
#define UI_PRINTTIME_PAGES
#define UI_PRINTTIME_COUNT 0
#endif
/*
Merge pages together. Use the following pattern:
#define UI_PAGES {&name1,&name2,&name3}
*/
#define UI_PAGES {&ui_page1 UI_PRINTTIME_PAGES}
// How many pages do you want to have. Minimum is 1.
#define UI_NUM_PAGES 1+UI_PRINTTIME_COUNT
#elif UI_ROWS >= 4
#if HAVE_HEATED_BED
#if NUM_EXTRUDER > 0
// UI_PAGE4(ui_page1,cTEMP "%ec/%Ec" cDEG "B%eB/%Eb" cDEG,"Z:%x2 Buf : %oB","Mul: %om Flow: %of","%os")
UI_PAGE4(ui_page1,cTEMP "%ec/%Ec" cDEG "B%eB/%Eb" cDEG,"Z:%x2 Buf : %oB","Mul: %om E:%x4","%os")
#else
// UI_PAGE4(ui_page1,"B%eB/%Eb" cDEG,"Z:%x2 Buf : %oB","Mul: %om Flow: %of","%os")
UI_PAGE4(ui_page1,"B%eB/%Eb" cDEG,"Z:%x2 Buf : %oB","Mul: %om E:%x4","%os")
#endif
//UI_PAGE4(ui_page1,UI_TEXT_PAGE_EXTRUDER,UI_TEXT_PAGE_BED,UI_TEXT_PAGE_BUFFER,"%os");
#else
#if NUM_EXTRUDER > 0
UI_PAGE4(ui_page1,UI_TEXT_PAGE_EXTRUDER,"Z:%x2 mm",UI_TEXT_PAGE_BUFFER,"%os")
#else
UI_PAGE4(ui_page1,"","Z:%x2 mm",UI_TEXT_PAGE_BUFFER,"%os")
#endif
#endif
UI_PAGE4(ui_page2,"X:%x0 mm","Y:%x1 mm","Z:%x2 mm","%os")
//UI_PAGE4(ui_page2,"dX:%y0 mm %sX","dY:%y1 mm %sY","dZ:%y2 mm %sZ","%os");
#if NUM_EXTRUDER>0
UI_PAGE4(ui_page3,UI_TEXT_PAGE_EXTRUDER1
#else
UI_PAGE4(ui_page3
#endif
#if NUM_EXTRUDER>1 && MIXING_EXTRUDER == 0
,UI_TEXT_PAGE_EXTRUDER2
#endif
#if NUM_EXTRUDER>2 && MIXING_EXTRUDER == 0
,UI_TEXT_PAGE_EXTRUDER3
#endif
#if HAVE_HEATED_BED
,UI_TEXT_PAGE_BED
#endif
#if (NUM_EXTRUDER >= 3 && MIXING_EXTRUDER == 0 && !HAVE_HEATED_BED) || (NUM_EXTRUDER==2 && MIXING_EXTRUDER == 0 && HAVE_HEATED_BED==true)
,"%os"
#elif (NUM_EXTRUDER == 2 && MIXING_EXTRUDER == 0) || ((NUM_EXTRUDER == 1 || MIXING_EXTRUDER == 1) && HAVE_HEATED_BED)
,"","%os"
#elif (NUM_EXTRUDER == 1 || MIXING_EXTRUDER == 1) || (NUM_EXTRUDER == 0 && HAVE_HEATED_BED)
,"","","%os"
#elif NUM_EXTRUDER == 0
,"","","","%os"
#endif
)
#if EEPROM_MODE != 0
UI_PAGE4(ui_page4,UI_TEXT_PRINT_TIME,"%Ut",UI_TEXT_PRINT_FILAMENT,"%Uf m")
#define UI_PRINTTIME_PAGES ,&ui_page4
#define UI_PRINTTIME_COUNT 1
#else
#define UI_PRINTTIME_PAGES
#define UI_PRINTTIME_COUNT 0
#endif
/*
Merge pages together. Use the following pattern:
#define UI_PAGES {&name1,&name2,&name3}
*/
#define UI_PAGES {&ui_page1, &ui_page2, &ui_page3 UI_PRINTTIME_PAGES}
// How many pages do you want to have. Minimum is 1.
#define UI_NUM_PAGES 3+UI_PRINTTIME_COUNT
#else
#if HAVE_HEATED_BED
UI_PAGE2(ui_page1,UI_TEXT_PAGE_EXTRUDER,UI_TEXT_PAGE_BED)
#else
UI_PAGE2(ui_page1,UI_TEXT_PAGE_EXTRUDER,"%os")
#endif
UI_PAGE2(ui_page2,"X:%x0 Y:%x1","%os")
UI_PAGE2(ui_page3,"Z:%x2 mm","%os")
/*
Merge pages together. Use the following pattern:
#define UI_PAGES {&name1,&name2,&name3}
*/
#define UI_PAGES {&ui_page1,&ui_page2,&ui_page3}
// How many pages do you want to have. Minimum is 1.
#define UI_NUM_PAGES 3
#endif
/* ============ MENU definition ================
The menu works the same as pages. In addion you need to define what the lines do
or where to jump to. For that reason, the menu structure needs to be entered in
reverse order. Starting from the leaves, the menu structure is defined.
*/
/*
At first define all actions available in the menu. The actions define, what the
next/previous button will do. All menu actions work the same:
next/previous changes the value
ok sets the value if not already done and goes back to previous menu.
*/
// Error menu
UI_MENU_ACTION2(ui_menu_error,UI_ACTION_DUMMY,UI_TEXT_ERROR,"%oe")
// Filament change wizard
#if FEATURE_RETRACTION
#if UI_ROWS >= 4
UI_WIZARD4(ui_wiz_filamentchange, UI_ACTION_WIZARD_FILAMENTCHANGE, UI_TEXT_WIZ_CH_FILAMENT1, UI_TEXT_WIZ_CH_FILAMENT2, UI_TEXT_WIZ_CH_FILAMENT3, UI_TEXT_CLICK_DONE)
UI_WIZARD4(ui_wiz_jamwaitheat, UI_ACTION_WIZARD_JAM_WAITHEAT, UI_TEXT_WIZ_WAITTEMP1, UI_TEXT_WIZ_WAITTEMP2,"",cTEMP "%ec/%Ec" cDEG)
UI_WIZARD4(ui_wiz_jamreheat, UI_ACTION_WIZARD_JAM_REHEAT, UI_TEXT_WIZ_REHEAT1, UI_TEXT_WIZ_REHEAT2,"",cTEMP "%ec" cDEG)
#else
UI_WIZARD2(ui_wiz_filamentchange, UI_ACTION_WIZARD_FILAMENTCHANGE, UI_TEXT_WIZ_CH_FILAMENT1, UI_TEXT_CLICK_DONE)
UI_WIZARD2(ui_wiz_jamwaitheat, UI_ACTION_WIZARD_JAM_WAITHEAT, UI_TEXT_WIZ_WAITTEMP1, UI_TEXT_WIZ_WAITTEMP2)
UI_WIZARD2(ui_wiz_jamreheat, UI_ACTION_WIZARD_JAM_REHEAT, UI_TEXT_WIZ_REHEAT1, UI_TEXT_WIZ_REHEAT2)
#endif
#endif
// **** Positions submenus
#if UI_ROWS >= 4
UI_MENU_ACTION4C(ui_menu_xpos,UI_ACTION_XPOSITION,UI_TEXT_ACTION_XPOSITION4)
UI_MENU_ACTION4C(ui_menu_ypos,UI_ACTION_YPOSITION,UI_TEXT_ACTION_YPOSITION4)
UI_MENU_ACTION4C(ui_menu_zpos,UI_ACTION_ZPOSITION,UI_TEXT_ACTION_ZPOSITION4)
UI_MENU_ACTION4C(ui_menu_zpos_notest,UI_ACTION_ZPOSITION_NOTEST,UI_TEXT_ACTION_ZPOSITION4)
UI_MENU_ACTION4C(ui_menu_xpos_fast,UI_ACTION_XPOSITION_FAST,UI_TEXT_ACTION_XPOSITION_FAST4)
UI_MENU_ACTION4C(ui_menu_ypos_fast,UI_ACTION_YPOSITION_FAST,UI_TEXT_ACTION_YPOSITION_FAST4)
UI_MENU_ACTION4C(ui_menu_zpos_fast,UI_ACTION_ZPOSITION_FAST,UI_TEXT_ACTION_ZPOSITION_FAST4)
UI_MENU_ACTION4C(ui_menu_zpos_fast_notest,UI_ACTION_ZPOSITION_FAST_NOTEST,UI_TEXT_ACTION_ZPOSITION_FAST4)
#define EPOS_ROWS UI_TEXT_ACTION_EPOSITION_FAST2,UI_TEXT_PAGE_EXTRUDER,"%Uf m " UI_TEXT_PRINTED
UI_MENU_ACTION4C(ui_menu_epos,UI_ACTION_EPOSITION,EPOS_ROWS)
#else
UI_MENU_ACTION2C(ui_menu_xpos,UI_ACTION_XPOSITION,UI_TEXT_ACTION_XPOSITION2)
UI_MENU_ACTION2C(ui_menu_ypos,UI_ACTION_YPOSITION,UI_TEXT_ACTION_YPOSITION2)
UI_MENU_ACTION2C(ui_menu_zpos,UI_ACTION_ZPOSITION,UI_TEXT_ACTION_ZPOSITION2)
UI_MENU_ACTION2C(ui_menu_zpos_notest,UI_ACTION_ZPOSITION_NOTEST,UI_TEXT_ACTION_ZPOSITION2)
UI_MENU_ACTION2C(ui_menu_xpos_fast,UI_ACTION_XPOSITION_FAST,UI_TEXT_ACTION_XPOSITION_FAST2)
UI_MENU_ACTION2C(ui_menu_ypos_fast,UI_ACTION_YPOSITION_FAST,UI_TEXT_ACTION_YPOSITION_FAST2)
UI_MENU_ACTION2C(ui_menu_zpos_fast,UI_ACTION_ZPOSITION_FAST,UI_TEXT_ACTION_ZPOSITION_FAST2)
UI_MENU_ACTION2C(ui_menu_zpos_fast_notest,UI_ACTION_ZPOSITION_FAST_NOTEST,UI_TEXT_ACTION_ZPOSITION_FAST2)
UI_MENU_ACTION2C(ui_menu_epos,UI_ACTION_EPOSITION,UI_TEXT_ACTION_EPOSITION_FAST2)
#endif
/*
Next step is to define submenus leading to the action.
*/
// **** Positionening menu
UI_MENU_ACTIONCOMMAND(ui_menu_back,UI_TEXT_BACK,UI_ACTION_BACK)
#if UI_HAS_BACK_KEY==0
#define UI_MENU_ADDCONDBACK &ui_menu_back,
#define UI_MENU_BACKCNT 1
#else
#define UI_MENU_ADDCONDBACK
#define UI_MENU_BACKCNT 0
#endif
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_home_all,UI_TEXT_HOME_ALL,UI_ACTION_HOME_ALL,0,MENU_MODE_PRINTING)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_home_x,UI_TEXT_HOME_X,UI_ACTION_HOME_X,0,MENU_MODE_PRINTING)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_home_y,UI_TEXT_HOME_Y,UI_ACTION_HOME_Y,0,MENU_MODE_PRINTING)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_home_z,UI_TEXT_HOME_Z,UI_ACTION_HOME_Z,0,MENU_MODE_PRINTING)
UI_MENU_ACTIONSELECTOR(ui_menu_go_xpos,UI_TEXT_X_POSITION,ui_menu_xpos)
UI_MENU_ACTIONSELECTOR(ui_menu_go_ypos,UI_TEXT_Y_POSITION,ui_menu_ypos)
UI_MENU_ACTIONSELECTOR(ui_menu_go_zpos,UI_TEXT_Z_POSITION,ui_menu_zpos)
UI_MENU_ACTIONSELECTOR(ui_menu_go_zpos_notest,UI_TEXT_Z_POSITION,ui_menu_zpos_notest)
UI_MENU_ACTIONSELECTOR(ui_menu_go_epos,UI_TEXT_E_POSITION,ui_menu_epos)
#if !UI_SPEEDDEPENDENT_POSITIONING
UI_MENU_ACTIONSELECTOR(ui_menu_go_xfast,UI_TEXT_X_POS_FAST,ui_menu_xpos_fast)
UI_MENU_ACTIONSELECTOR(ui_menu_go_yfast,UI_TEXT_Y_POS_FAST,ui_menu_ypos_fast)
UI_MENU_ACTIONSELECTOR(ui_menu_go_zfast,UI_TEXT_Z_POS_FAST,ui_menu_zpos_fast)
UI_MENU_ACTIONSELECTOR(ui_menu_go_zfast_notest,UI_TEXT_Z_POS_FAST,ui_menu_zpos_fast_notest)
#define UI_SPEED 2
#define UI_SPEED_X ,&ui_menu_go_xfast,&ui_menu_go_xpos
#define UI_SPEED_Y ,&ui_menu_go_yfast,&ui_menu_go_ypos
#define UI_SPEED_Z ,&ui_menu_go_zfast,&ui_menu_go_zpos
#define UI_SPEED_Z_NOTEST ,&ui_menu_go_zfast_notest,&ui_menu_go_zpos_notest
#else
#define UI_SPEED 1
#define UI_SPEED_X ,&ui_menu_go_xpos
#define UI_SPEED_Y ,&ui_menu_go_ypos
#define UI_SPEED_Z ,&ui_menu_go_zpos
#define UI_SPEED_Z_NOTEST ,&ui_menu_go_zpos_notest
#endif
#if FEATURE_SERVO > 0 && UI_SERVO_CONTROL > 0
UI_MENU_CHANGEACTION(ui_menu_servopos, UI_TEXT_SERVOPOS, UI_ACTION_SERVOPOS)
#define SERVOPOS_COUNT 1
#define SERVOPOS_ENTRY ,&ui_menu_servopos
#else
#define SERVOPOS_COUNT 0
#define SERVOPOS_ENTRY
#endif
#if DRIVE_SYSTEM != DELTA //Positioning menu for non-delta
#define UI_MENU_POSITIONS {UI_MENU_ADDCONDBACK &ui_menu_home_all,&ui_menu_home_x,&ui_menu_home_y,&ui_menu_home_z UI_SPEED_X UI_SPEED_Y UI_SPEED_Z ,&ui_menu_go_epos SERVOPOS_ENTRY}
UI_MENU(ui_menu_positions,UI_MENU_POSITIONS,5 + 3 * UI_SPEED + UI_MENU_BACKCNT + SERVOPOS_COUNT)
#else //Positioning menu for delta (removes individual x,y,z homing)
#define UI_MENU_POSITIONS {UI_MENU_ADDCONDBACK &ui_menu_home_all UI_SPEED_X UI_SPEED_Y UI_SPEED_Z ,&ui_menu_go_epos SERVOPOS_ENTRY}
UI_MENU(ui_menu_positions,UI_MENU_POSITIONS,2 + 3 * UI_SPEED + UI_MENU_BACKCNT + SERVOPOS_COUNT)
#endif
// **** Delta calibration menu
#if Z_HOME_DIR > 0
UI_MENU_ACTIONCOMMAND(ui_menu_set_measured_origin,UI_TEXT_SET_MEASURED_ORIGIN,UI_ACTION_SET_MEASURED_ORIGIN)
#define UI_MENU_DELTA {UI_MENU_ADDCONDBACK &ui_menu_home_all UI_SPEED_Z_NOTEST,&ui_menu_set_measured_origin}
UI_MENU(ui_menu_delta,UI_MENU_DELTA,2 + UI_SPEED + UI_MENU_BACKCNT)
#endif
// **** Bed leveling menu
#ifdef SOFTWARE_LEVELING
UI_MENU_ACTIONCOMMAND(ui_menu_set_p1,UI_TEXT_SET_P1,UI_ACTION_SET_P1)
UI_MENU_ACTIONCOMMAND(ui_menu_set_p2,UI_TEXT_SET_P2,UI_ACTION_SET_P2)
UI_MENU_ACTIONCOMMAND(ui_menu_set_p3,UI_TEXT_SET_P3,UI_ACTION_SET_P3)
UI_MENU_ACTIONCOMMAND(ui_menu_calculate_leveling,UI_TEXT_CALCULATE_LEVELING,UI_ACTION_CALC_LEVEL)
#define UI_MENU_LEVEL {UI_MENU_ADDCONDBACK &ui_menu_set_p1,&ui_menu_set_p2,&ui_menu_set_p3,&ui_menu_calculate_leveling UI_SPEED_X UI_SPEED_Y UI_SPEED_Z}
UI_MENU(ui_menu_level,UI_MENU_LEVEL,4+3*UI_SPEED+UI_MENU_BACKCNT)
#endif
// **** Extruder menu
UI_MENU_CHANGEACTION(ui_menu_ext_temp0,UI_TEXT_EXTR0_TEMP,UI_ACTION_EXTRUDER0_TEMP)
UI_MENU_CHANGEACTION(ui_menu_ext_temp1,UI_TEXT_EXTR1_TEMP,UI_ACTION_EXTRUDER1_TEMP)
#if NUM_EXTRUDER>2 && MIXING_EXTRUDER == 0
UI_MENU_CHANGEACTION(ui_menu_ext_temp2,UI_TEXT_EXTR2_TEMP,UI_ACTION_EXTRUDER2_TEMP)
#endif
UI_MENU_CHANGEACTION(ui_menu_bed_temp, UI_TEXT_BED_TEMP,UI_ACTION_HEATED_BED_TEMP)
UI_MENU_ACTIONCOMMAND(ui_menu_ext_sel0,UI_TEXT_EXTR0_SELECT,UI_ACTION_SELECT_EXTRUDER0)
UI_MENU_ACTIONCOMMAND(ui_menu_ext_sel1,UI_TEXT_EXTR1_SELECT,UI_ACTION_SELECT_EXTRUDER1)
#if NUM_EXTRUDER>2 && MIXING_EXTRUDER == 0
UI_MENU_ACTIONCOMMAND(ui_menu_ext_sel2,UI_TEXT_EXTR2_SELECT,UI_ACTION_SELECT_EXTRUDER2)
#endif
UI_MENU_ACTIONCOMMAND(ui_menu_ext_off0,UI_TEXT_EXTR0_OFF,UI_ACTION_EXTRUDER0_OFF)
UI_MENU_ACTIONCOMMAND(ui_menu_ext_off1,UI_TEXT_EXTR1_OFF,UI_ACTION_EXTRUDER1_OFF)
#if NUM_EXTRUDER>2 && MIXING_EXTRUDER == 0
UI_MENU_ACTIONCOMMAND(ui_menu_ext_off2,UI_TEXT_EXTR2_OFF,UI_ACTION_EXTRUDER2_OFF)
#endif
UI_MENU_ACTIONCOMMAND(ui_menu_ext_origin,UI_TEXT_EXTR_ORIGIN,UI_ACTION_RESET_EXTRUDER)
#if NUM_EXTRUDER==2 && MIXING_EXTRUDER == 0
#define UI_MENU_EXTCOND &ui_menu_ext_temp0,&ui_menu_ext_temp1,&ui_menu_ext_off0,&ui_menu_ext_off1,&ui_menu_ext_sel0,&ui_menu_ext_sel1,
#define UI_MENU_EXTCNT 6
#elif NUM_EXTRUDER > 2 && MIXING_EXTRUDER == 0
#define UI_MENU_EXTCOND &ui_menu_ext_temp0,&ui_menu_ext_temp1,&ui_menu_ext_temp2,&ui_menu_ext_off0,&ui_menu_ext_off1,&ui_menu_ext_off2,&ui_menu_ext_sel0,&ui_menu_ext_sel1,&ui_menu_ext_sel2,
#define UI_MENU_EXTCNT 9
#else
#define UI_MENU_EXTCOND &ui_menu_ext_temp0,&ui_menu_ext_off0,
#define UI_MENU_EXTCNT 2
#endif
#if HAVE_HEATED_BED
#define UI_MENU_BEDCOND &ui_menu_bed_temp,
#define UI_MENU_BEDCNT 1
#else
#define UI_MENU_BEDCOND
#define UI_MENU_BEDCNT 0
#endif
#define UI_MENU_EXTRUDER {UI_MENU_ADDCONDBACK UI_MENU_BEDCOND UI_MENU_EXTCOND &ui_menu_go_epos,&ui_menu_ext_origin}
UI_MENU(ui_menu_extruder,UI_MENU_EXTRUDER,UI_MENU_BACKCNT+UI_MENU_BEDCNT+UI_MENU_EXTCNT+2)
// **** SD card menu
// **** Quick menu
#if PS_ON_PIN > -1
UI_MENU_ACTIONCOMMAND(ui_menu_quick_power,UI_TEXT_POWER,UI_ACTION_POWER)
#define MENU_PSON_COUNT 1
#define MENU_PSON_ENTRY ,&ui_menu_quick_power
#else
#define MENU_PSON_COUNT 0
#define MENU_PSON_ENTRY
#endif
#if CASE_LIGHTS_PIN >= 0
UI_MENU_ACTIONCOMMAND(ui_menu_toggle_light,UI_TEXT_LIGHTS_ONOFF,UI_ACTION_LIGHTS_ONOFF)
#define UI_TOOGLE_LIGHT_ENTRY ,&ui_menu_toggle_light
#define UI_TOGGLE_LIGHT_COUNT 1
#else
#define UI_TOOGLE_LIGHT_ENTRY
#define UI_TOGGLE_LIGHT_COUNT 0
#endif
UI_MENU_ACTIONCOMMAND(ui_menu_quick_preheat_pla,UI_TEXT_PREHEAT_PLA,UI_ACTION_PREHEAT_PLA)
UI_MENU_ACTIONCOMMAND(ui_menu_quick_preheat_abs,UI_TEXT_PREHEAT_ABS,UI_ACTION_PREHEAT_ABS)
UI_MENU_ACTIONCOMMAND(ui_menu_quick_cooldown,UI_TEXT_COOLDOWN,UI_ACTION_COOLDOWN)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_quick_origin,UI_TEXT_SET_TO_ORIGIN,UI_ACTION_SET_ORIGIN,0,MENU_MODE_PRINTING)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_quick_stopstepper,UI_TEXT_DISABLE_STEPPER,UI_ACTION_DISABLE_STEPPER,0,MENU_MODE_PRINTING)
#if FEATURE_BABYSTEPPING
UI_MENU_CHANGEACTION(ui_menu_quick_zbaby,UI_TEXT_Z_BABYSTEPPING,UI_ACTION_Z_BABYSTEPS)
#define BABY_CNT 1
#define BABY_ENTRY ,&ui_menu_quick_zbaby
#else
#define BABY_CNT 0
#define BABY_ENTRY
#endif
UI_MENU_CHANGEACTION(ui_menu_quick_speedmultiply,UI_TEXT_SPEED_MULTIPLY,UI_ACTION_FEEDRATE_MULTIPLY)
UI_MENU_CHANGEACTION(ui_menu_quick_flowmultiply,UI_TEXT_FLOW_MULTIPLY,UI_ACTION_FLOWRATE_MULTIPLY)
#ifdef DEBUG_PRINT
UI_MENU_ACTIONCOMMAND(ui_menu_quick_debug,"Write Debug",UI_ACTION_WRITE_DEBUG)
#define DEBUG_PRINT_COUNT 1
#define DEBUG_PRINT_EXTRA ,&ui_menu_quick_debug
#else
#define DEBUG_PRINT_COUNT 0
#define DEBUG_PRINT_EXTRA
#endif
#if FEATURE_RETRACTION
UI_MENU_ACTIONCOMMAND(ui_menu_quick_changefil,UI_TEXT_CHANGE_FILAMENT,UI_ACTION_WIZARD_FILAMENTCHANGE)
#define UI_CHANGE_FIL_CNT 1
#define UI_CHANGE_FIL_ENT ,&ui_menu_quick_changefil
#else
#define UI_CHANGE_FIL_CNT 0
#define UI_CHANGE_FIL_ENT
#endif
#define UI_MENU_QUICK {UI_MENU_ADDCONDBACK &ui_menu_home_all BABY_ENTRY ,&ui_menu_quick_speedmultiply,&ui_menu_quick_flowmultiply UI_TOOGLE_LIGHT_ENTRY UI_CHANGE_FIL_ENT,&ui_menu_quick_preheat_pla,&ui_menu_quick_preheat_abs,&ui_menu_quick_cooldown,&ui_menu_quick_origin,&ui_menu_quick_stopstepper MENU_PSON_ENTRY DEBUG_PRINT_EXTRA}
UI_MENU(ui_menu_quick,UI_MENU_QUICK,8+BABY_CNT+UI_MENU_BACKCNT+MENU_PSON_COUNT+DEBUG_PRINT_COUNT+UI_TOGGLE_LIGHT_COUNT+UI_CHANGE_FIL_CNT)
// **** Fan menu
#if FAN_PIN>-1 && FEATURE_FAN_CONTROL
UI_MENU_CHANGEACTION(ui_menu_fan_fanspeed, UI_TEXT_ACTION_FANSPEED,UI_ACTION_FANSPEED)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_fan_off,UI_TEXT_FAN_OFF,UI_ACTION_FAN_OFF,MENU_MODE_FAN_RUNNING,0)
UI_MENU_ACTIONCOMMAND(ui_menu_fan_25,UI_TEXT_FAN_25,UI_ACTION_FAN_25)
UI_MENU_ACTIONCOMMAND(ui_menu_fan_50,UI_TEXT_FAN_50,UI_ACTION_FAN_50)
UI_MENU_ACTIONCOMMAND(ui_menu_fan_75,UI_TEXT_FAN_75,UI_ACTION_FAN_75)
UI_MENU_ACTIONCOMMAND(ui_menu_fan_full,UI_TEXT_FAN_FULL,UI_ACTION_FAN_FULL)
UI_MENU_ACTIONCOMMAND(ui_menu_fan_ignoreM106,UI_TEXT_IGNORE_M106,UI_ACTION_IGNORE_M106)
#define UI_MENU_FAN {UI_MENU_ADDCONDBACK &ui_menu_fan_fanspeed,&ui_menu_fan_off,&ui_menu_fan_25,&ui_menu_fan_50,&ui_menu_fan_75,&ui_menu_fan_full,&ui_menu_fan_ignoreM106}
UI_MENU(ui_menu_fan,UI_MENU_FAN,7+UI_MENU_BACKCNT)
UI_MENU_SUBMENU(ui_menu_fan_sub,UI_TEXT_FANSPEED,ui_menu_fan)
#define UI_MENU_FAN_COND &ui_menu_fan_sub,
#define UI_MENU_FAN_CNT 1
#else
#define UI_MENU_FAN_COND
#define UI_MENU_FAN_CNT 0
#endif
// **** SD card menu
#if SDSUPPORT
UI_MENU_HEADLINE(ui_menu_sd_askstop_head,UI_TEXT_STOP_PRINT)
UI_MENU_ACTIONCOMMAND(ui_menu_sd_askstop_no,UI_TEXT_NO,UI_ACTION_BACK)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_askstop_yes, UI_TEXT_YES, UI_ACTION_SD_STOP | UI_ACTION_TOPMENU, MENU_MODE_SD_PRINTING, 0)
#define UI_MENU_SD_ASKSTOP {&ui_menu_sd_askstop_head,&ui_menu_sd_askstop_no,&ui_menu_sd_askstop_yes}
UI_MENU(ui_menu_sd_askstop,UI_MENU_SD_ASKSTOP,3)
#define UI_MENU_SD_FILESELECTOR {&ui_menu_back}
UI_MENU_FILESELECT(ui_menu_sd_fileselector,UI_MENU_SD_FILESELECTOR,1)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_printfile, UI_TEXT_PRINT_FILE, UI_ACTION_SD_PRINT, MENU_MODE_SD_MOUNTED, MENU_MODE_SD_PRINTING)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_pause, UI_TEXT_PAUSE_PRINT, UI_ACTION_SD_PAUSE, MENU_MODE_SD_PRINTING, MENU_MODE_SD_PAUSED)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_continue, UI_TEXT_CONTINUE_PRINT, UI_ACTION_SD_CONTINUE, MENU_MODE_SD_PAUSED, 0)
// two versions of stop. Second is with security question since pausing can trigger stop with bad luck!
//UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_stop, UI_TEXT_STOP_PRINT, UI_ACTION_SD_STOP, MENU_MODE_SD_PRINTING, 0)
UI_MENU_SUBMENU_FILTER(ui_menu_sd_stop, UI_TEXT_STOP_PRINT,ui_menu_sd_askstop, MENU_MODE_SD_PRINTING, 0 )
#define SD_PRINTFILE_ENTRY &ui_menu_sd_printfile,
#define SD_PRINTFILE_ENTRY_CNT 1
#if SDCARDDETECT > -1
#define UI_MOUNT_CNT 0
#define UI_MOUNT_CMD
#else
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_unmount,UI_TEXT_UNMOUNT_CARD,UI_ACTION_SD_UNMOUNT,MENU_MODE_SD_MOUNTED,0)
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_mount,UI_TEXT_MOUNT_CARD,UI_ACTION_SD_MOUNT,0,MENU_MODE_SD_MOUNTED)
#define UI_MOUNT_CNT 2
#define UI_MOUNT_CMD ,&ui_menu_sd_unmount,&ui_menu_sd_mount
#endif
UI_MENU_ACTIONCOMMAND_FILTER(ui_menu_sd_delete,UI_TEXT_DELETE_FILE,UI_ACTION_SD_DELETE,MENU_MODE_SD_MOUNTED,MENU_MODE_SD_PRINTING)
#define UI_MENU_SD {UI_MENU_ADDCONDBACK &ui_menu_sd_printfile,&ui_menu_sd_pause,&ui_menu_sd_continue,&ui_menu_sd_stop UI_MOUNT_CMD ,&ui_menu_sd_delete}
UI_MENU(ui_menu_sd, UI_MENU_SD, UI_MENU_BACKCNT + 5 + UI_MOUNT_CNT)
UI_MENU_SUBMENU(ui_menu_sd_sub, UI_TEXT_SD_CARD, ui_menu_sd)
#define UI_MENU_SD_COND &ui_menu_sd_sub,
#define UI_MENU_SD_CNT 1
#else
#define UI_MENU_SD_COND
#define UI_MENU_SD_CNT 0
#define SD_PRINTFILE_ENTRY
#define SD_PRINTFILE_ENTRY_CNT 0
#endif
// **** Debugging menu
UI_MENU_ACTIONCOMMAND(ui_menu_debug_echo, UI_TEXT_DBG_ECHO, UI_ACTION_DEBUG_ECHO)
UI_MENU_ACTIONCOMMAND(ui_menu_debug_info, UI_TEXT_DBG_INFO, UI_ACTION_DEBUG_INFO)
UI_MENU_ACTIONCOMMAND(ui_menu_debug_error, UI_TEXT_DBG_ERROR, UI_ACTION_DEBUG_ERROR)
UI_MENU_ACTIONCOMMAND(ui_menu_debug_dryrun, UI_TEXT_DBG_DRYRUN, UI_ACTION_DEBUG_DRYRUN)
#define UI_MENU_DEBUGGING {UI_MENU_ADDCONDBACK &ui_menu_debug_echo,&ui_menu_debug_info,&ui_menu_debug_error,&ui_menu_debug_dryrun}
UI_MENU(ui_menu_debugging,UI_MENU_DEBUGGING,4 + UI_MENU_BACKCNT)
// **** Acceleration settings
#if DRIVE_SYSTEM != DELTA
UI_MENU_CHANGEACTION(ui_menu_accel_printx, UI_TEXT_PRINT_X,UI_ACTION_PRINT_ACCEL_X)
UI_MENU_CHANGEACTION(ui_menu_accel_printy, UI_TEXT_PRINT_Y,UI_ACTION_PRINT_ACCEL_Y)
UI_MENU_CHANGEACTION(ui_menu_accel_printz, UI_TEXT_PRINT_Z,UI_ACTION_PRINT_ACCEL_Z)
UI_MENU_CHANGEACTION(ui_menu_accel_travelx, UI_TEXT_MOVE_X,UI_ACTION_MOVE_ACCEL_X)
UI_MENU_CHANGEACTION(ui_menu_accel_travely, UI_TEXT_MOVE_Y,UI_ACTION_MOVE_ACCEL_Y)
UI_MENU_CHANGEACTION(ui_menu_accel_travelz, UI_TEXT_MOVE_Z,UI_ACTION_MOVE_ACCEL_Z)
UI_MENU_CHANGEACTION(ui_menu_accel_jerk, UI_TEXT_JERK,UI_ACTION_MAX_JERK)
UI_MENU_CHANGEACTION(ui_menu_accel_zjerk, UI_TEXT_ZJERK,UI_ACTION_MAX_ZJERK)
#define UI_MENU_ACCEL {UI_MENU_ADDCONDBACK &ui_menu_accel_printx,&ui_menu_accel_printy,&ui_menu_accel_printz,&ui_menu_accel_travelx,&ui_menu_accel_travely,&ui_menu_accel_travelz,&ui_menu_accel_jerk,&ui_menu_accel_zjerk}
UI_MENU(ui_menu_accel,UI_MENU_ACCEL,8+UI_MENU_BACKCNT)
// **** Feedrates
UI_MENU_CHANGEACTION(ui_menu_feedrate_maxx, UI_TEXT_FEED_MAX_X, UI_ACTION_MAX_FEEDRATE_X)
UI_MENU_CHANGEACTION(ui_menu_feedrate_maxy, UI_TEXT_FEED_MAX_Y, UI_ACTION_MAX_FEEDRATE_Y)
UI_MENU_CHANGEACTION(ui_menu_feedrate_maxz, UI_TEXT_FEED_MAX_Z, UI_ACTION_MAX_FEEDRATE_Z)
UI_MENU_CHANGEACTION(ui_menu_feedrate_homex, UI_TEXT_FEED_HOME_X, UI_ACTION_HOMING_FEEDRATE_X)
UI_MENU_CHANGEACTION(ui_menu_feedrate_homey, UI_TEXT_FEED_HOME_Y, UI_ACTION_HOMING_FEEDRATE_Y)
UI_MENU_CHANGEACTION(ui_menu_feedrate_homez, UI_TEXT_FEED_HOME_Z, UI_ACTION_HOMING_FEEDRATE_Z)
#define UI_MENU_FEEDRATE {UI_MENU_ADDCONDBACK &ui_menu_feedrate_maxx,&ui_menu_feedrate_maxy,&ui_menu_feedrate_maxz,&ui_menu_feedrate_homex,&ui_menu_feedrate_homey,&ui_menu_feedrate_homez}
UI_MENU(ui_menu_feedrate,UI_MENU_FEEDRATE,6 + UI_MENU_BACKCNT)
#else
UI_MENU_CHANGEACTION(ui_menu_accel_printz,UI_TEXT_PRINT_Z_DELTA,UI_ACTION_PRINT_ACCEL_Z)
UI_MENU_CHANGEACTION(ui_menu_accel_travelz,UI_TEXT_MOVE_Z_DELTA,UI_ACTION_MOVE_ACCEL_Z)
UI_MENU_CHANGEACTION(ui_menu_accel_jerk,UI_TEXT_JERK,UI_ACTION_MAX_JERK)
#define UI_MENU_ACCEL {UI_MENU_ADDCONDBACK &ui_menu_accel_printz,&ui_menu_accel_travelz,&ui_menu_accel_jerk}
UI_MENU(ui_menu_accel,UI_MENU_ACCEL,3+UI_MENU_BACKCNT)
// **** Feedrates
UI_MENU_CHANGEACTION(ui_menu_feedrate_maxz,UI_TEXT_FEED_MAX_Z_DELTA,UI_ACTION_MAX_FEEDRATE_Z)
UI_MENU_CHANGEACTION(ui_menu_feedrate_homez,UI_TEXT_FEED_HOME_Z_DELTA,UI_ACTION_HOMING_FEEDRATE_Z)
#define UI_MENU_FEEDRATE {UI_MENU_ADDCONDBACK &ui_menu_feedrate_maxz,&ui_menu_feedrate_homez}
UI_MENU(ui_menu_feedrate,UI_MENU_FEEDRATE,2+UI_MENU_BACKCNT)
#endif
// **** General configuration settings
UI_MENU_ACTION2C(ui_menu_stepper2,UI_ACTION_STEPPER_INACTIVE,UI_TEXT_STEPPER_INACTIVE2)
UI_MENU_ACTION2C(ui_menu_maxinactive2,UI_ACTION_MAX_INACTIVE,UI_TEXT_POWER_INACTIVE2)
UI_MENU_CHANGEACTION(ui_menu_general_baud,UI_TEXT_BAUDRATE,UI_ACTION_BAUDRATE)
UI_MENU_ACTIONSELECTOR(ui_menu_general_stepper_inactive,UI_TEXT_STEPPER_INACTIVE,ui_menu_stepper2)
UI_MENU_ACTIONSELECTOR(ui_menu_general_max_inactive,UI_TEXT_POWER_INACTIVE,ui_menu_maxinactive2)
#if FEATURE_AUTOLEVEL
UI_MENU_ACTIONCOMMAND(ui_menu_toggle_autolevel,UI_TEXT_AUTOLEVEL_ONOFF,UI_ACTION_AUTOLEVEL_ONOFF)
#define UI_TOOGLE_AUTOLEVEL_ENTRY ,&ui_menu_toggle_autolevel
#define UI_TOGGLE_AUTOLEVEL_COUNT 1
#else
#define UI_TOOGLE_AUTOLEVEL_ENTRY
#define UI_TOGGLE_AUTOLEVEL_COUNT 0
#endif
#define UI_MENU_GENERAL {UI_MENU_ADDCONDBACK &ui_menu_general_baud,&ui_menu_general_stepper_inactive,&ui_menu_general_max_inactive UI_TOOGLE_AUTOLEVEL_ENTRY}
UI_MENU(ui_menu_general,UI_MENU_GENERAL,3+UI_MENU_BACKCNT+UI_TOGGLE_AUTOLEVEL_COUNT)
// **** Extruder configuration
UI_MENU_CHANGEACTION(ui_menu_cext_steps, UI_TEXT_EXTR_STEPS, UI_ACTION_EXTR_STEPS)
UI_MENU_CHANGEACTION(ui_menu_cext_start_feedrate, UI_TEXT_EXTR_START_FEED, UI_ACTION_EXTR_START_FEEDRATE)
UI_MENU_CHANGEACTION(ui_menu_cext_max_feedrate, UI_TEXT_EXTR_MAX_FEED, UI_ACTION_EXTR_MAX_FEEDRATE)
UI_MENU_CHANGEACTION(ui_menu_cext_acceleration, UI_TEXT_EXTR_ACCEL, UI_ACTION_EXTR_ACCELERATION)
UI_MENU_CHANGEACTION(ui_menu_cext_watch_period, UI_TEXT_EXTR_WATCH, UI_ACTION_EXTR_WATCH_PERIOD)
UI_MENU_CHANGEACTION(ui_menu_ext_wait_temp, UI_TEXT_EXTR_WAIT_RETRACT_TEMP, UI_ACTION_EXTR_WAIT_RETRACT_TEMP)
UI_MENU_CHANGEACTION(ui_menu_ext_wait_units, UI_TEXT_EXTR_WAIT_RETRACT_UNITS, UI_ACTION_EXTR_WAIT_RETRACT_UNITS)
#define UI_MENU_ADV_CNT 0
#define UI_MENU_ADVANCE
#if USE_ADVANCE
#define UI_MENU_ADV_CNT 1
#define UI_MENU_ADVANCE ,&ui_menu_cext_advancel
#if ENABLE_QUADRATIC_ADVANCE
#define UI_MENU_ADV_CNT 2
#define UI_MENU_ADVANCE ,&ui_menu_cext_advancel,&ui_menu_cext_advancek
UI_MENU_CHANGEACTION(ui_menu_cext_advancek,UI_TEXT_EXTR_ADVANCE_K,UI_ACTION_ADVANCE_K)
#endif
UI_MENU_CHANGEACTION(ui_menu_cext_advancel,UI_TEXT_EXTR_ADVANCE_L,UI_ACTION_ADVANCE_L)
#endif
UI_MENU_CHANGEACTION( ui_menu_cext_manager, UI_TEXT_EXTR_MANAGER, UI_ACTION_EXTR_HEATMANAGER)
UI_MENU_CHANGEACTION( ui_menu_cext_pmax, UI_TEXT_EXTR_PMAX, UI_ACTION_PID_MAX)
#if TEMP_PID
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_pgain, UI_TEXT_EXTR_PGAIN, UI_ACTION_PID_PGAIN, MENU_MODE_FULL_PID, 0)
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_igain, UI_TEXT_EXTR_IGAIN, UI_ACTION_PID_IGAIN, MENU_MODE_FULL_PID, 0)
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_dgain, UI_TEXT_EXTR_DGAIN, UI_ACTION_PID_DGAIN, MENU_MODE_FULL_PID, 0)
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_dmin, UI_TEXT_EXTR_DMIN, UI_ACTION_DRIVE_MIN, MENU_MODE_FULL_PID, 0)
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_dmax, UI_TEXT_EXTR_DMAX, UI_ACTION_DRIVE_MAX, MENU_MODE_FULL_PID, 0)
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_pgain_dt, UI_TEXT_EXTR_DEADTIME, UI_ACTION_PID_PGAIN, MENU_MODE_DEADTIME, 0)
UI_MENU_CHANGEACTION_FILTER(ui_menu_cext_dmax_dt, UI_TEXT_EXTR_DMAX_DT, UI_ACTION_DRIVE_MAX, MENU_MODE_DEADTIME, 0)
#define UI_MENU_PIDCOND ,&ui_menu_cext_manager,&ui_menu_cext_pgain,&ui_menu_cext_igain,&ui_menu_cext_dgain,&ui_menu_cext_dmin,&ui_menu_cext_dmax, &ui_menu_cext_pgain_dt,&ui_menu_cext_dmax_dt,&ui_menu_cext_pmax
#define UI_MENU_PIDCNT 9
#else
#define UI_MENU_PIDCOND ,&ui_menu_cext_manager, &ui_menu_cext_pmax
#define UI_MENU_PIDCNT 2
#endif
#if NUM_EXTRUDER>2 && MIXING_EXTRUDER == 0
UI_MENU_CHANGEACTION(ui_menu_cext_xoffset,UI_TEXT_EXTR_XOFF,UI_ACTION_X_OFFSET)
UI_MENU_CHANGEACTION(ui_menu_cext_yoffset,UI_TEXT_EXTR_YOFF,UI_ACTION_Y_OFFSET)
#define UI_MENU_CONFEXTCOND &ui_menu_ext_sel0,&ui_menu_ext_sel1,&ui_menu_ext_sel2,&ui_menu_cext_xoffset,&ui_menu_cext_yoffset,
#define UI_MENU_CONFEXTCNT 5
#elif NUM_EXTRUDER>1 && MIXING_EXTRUDER == 0
UI_MENU_CHANGEACTION(ui_menu_cext_xoffset,UI_TEXT_EXTR_XOFF,UI_ACTION_X_OFFSET)
UI_MENU_CHANGEACTION(ui_menu_cext_yoffset,UI_TEXT_EXTR_YOFF,UI_ACTION_Y_OFFSET)
#define UI_MENU_CONFEXTCOND &ui_menu_ext_sel0,&ui_menu_ext_sel1,&ui_menu_cext_xoffset,&ui_menu_cext_yoffset,
#define UI_MENU_CONFEXTCNT 4
#else
#define UI_MENU_CONFEXTCOND
#define UI_MENU_CONFEXTCNT 0
#endif
#define UI_MENU_CEXTR {UI_MENU_ADDCONDBACK UI_MENU_CONFEXTCOND &ui_menu_cext_steps,&ui_menu_cext_start_feedrate,&ui_menu_cext_max_feedrate,&ui_menu_cext_acceleration,&ui_menu_cext_watch_period,&ui_menu_ext_wait_units,&ui_menu_ext_wait_temp UI_MENU_ADVANCE UI_MENU_PIDCOND}
UI_MENU(ui_menu_cextr,UI_MENU_CEXTR,7+UI_MENU_BACKCNT+UI_MENU_PIDCNT+UI_MENU_CONFEXTCNT+UI_MENU_ADV_CNT)
// HeatBed Configuration - use menu actions from extruder configuration
#if HAVE_HEATED_BED
#if TEMP_PID
#define UI_MENU_BEDCONF {UI_MENU_ADDCONDBACK &ui_menu_cext_manager,&ui_menu_cext_pgain,&ui_menu_cext_igain,&ui_menu_cext_dgain,&ui_menu_cext_dmin,&ui_menu_cext_dmax,&ui_menu_cext_pmax}
UI_MENU(ui_menu_bedconf, UI_MENU_BEDCONF, 8)
#else
#define UI_MENU_BEDCONF {UI_MENU_ADDCONDBACK &ui_menu_cext_manager, &ui_menu_cext_pmax}
UI_MENU(ui_menu_bedconf, UI_MENU_BEDCONF, 3)
#endif
#endif
// **** Configuration menu
UI_MENU_SUBMENU(ui_menu_conf_general, UI_TEXT_GENERAL, ui_menu_general)
UI_MENU_SUBMENU(ui_menu_conf_accel, UI_TEXT_ACCELERATION, ui_menu_accel)
UI_MENU_SUBMENU(ui_menu_conf_feed, UI_TEXT_FEEDRATE, ui_menu_feedrate)
UI_MENU_SUBMENU(ui_menu_conf_extr, UI_TEXT_EXTRUDER, ui_menu_cextr)
#if HAVE_HEATED_BED
UI_MENU_SUBMENU(ui_menu_conf_bed, UI_TEXT_HEATING_BED, ui_menu_bedconf)
#define UI_MENU_BEDCONF_COND ,&ui_menu_conf_bed
#define UI_MENU_BEDCONF_CNT 1
#else
#define UI_MENU_BEDCONF_COND
#define UI_MENU_BEDCONF_CNT 0
#endif
#if EEPROM_MODE!=0
UI_MENU_ACTIONCOMMAND(ui_menu_conf_to_eeprom,UI_TEXT_STORE_TO_EEPROM,UI_ACTION_STORE_EEPROM)
UI_MENU_ACTIONCOMMAND(ui_menu_conf_from_eeprom,UI_TEXT_LOAD_EEPROM,UI_ACTION_LOAD_EEPROM)
#define UI_MENU_EEPROM_COND ,&ui_menu_conf_to_eeprom,&ui_menu_conf_from_eeprom
#define UI_MENU_EEPROM_CNT 2
UI_MENU_ACTION2C(ui_menu_eeprom_saved, UI_ACTION_DUMMY, UI_TEXT_EEPROM_STORED)
UI_MENU_ACTION2C(ui_menu_eeprom_loaded, UI_ACTION_DUMMY, UI_TEXT_EEPROM_LOADED)
#else
#define UI_MENU_EEPROM_COND
#define UI_MENU_EEPROM_CNT 0
#endif
#ifdef SOFTWARE_LEVELING
#define UI_MENU_SL_COND ,&ui_menu_conf_level
#define UI_MENU_SL_CNT 1
UI_MENU_SUBMENU(ui_menu_conf_level, UI_TEXT_LEVEL, ui_menu_level)
#else
#define UI_MENU_SL_COND
#define UI_MENU_SL_CNT 0
#endif
#if Z_HOME_DIR > 0
#define UI_MENU_DELTA_COND ,&ui_menu_conf_delta
#define UI_MENU_DELTA_CNT 1
UI_MENU_SUBMENU(ui_menu_conf_delta, UI_TEXT_ZCALIB, ui_menu_delta)
#else
#define UI_MENU_DELTA_COND
#define UI_MENU_DELTA_CNT 0
#endif
#define UI_MENU_CONFIGURATION {UI_MENU_ADDCONDBACK &ui_menu_conf_general,&ui_menu_conf_accel,&ui_menu_conf_feed,&ui_menu_conf_extr UI_MENU_BEDCONF_COND UI_MENU_EEPROM_COND UI_MENU_DELTA_COND UI_MENU_SL_COND}
UI_MENU(ui_menu_configuration,UI_MENU_CONFIGURATION,UI_MENU_BACKCNT+UI_MENU_EEPROM_CNT+UI_MENU_BEDCONF_CNT+UI_MENU_DELTA_CNT+UI_MENU_SL_CNT+4)
// Main menu
UI_MENU_SUBMENU(ui_menu_main1, UI_TEXT_QUICK_SETTINGS,ui_menu_quick)
UI_MENU_SUBMENU(ui_menu_main2, UI_TEXT_POSITION,ui_menu_positions)
UI_MENU_SUBMENU(ui_menu_main3, UI_TEXT_EXTRUDER,ui_menu_extruder)
UI_MENU_SUBMENU(ui_menu_main4, UI_TEXT_DEBUGGING,ui_menu_debugging)
UI_MENU_SUBMENU(ui_menu_main5, UI_TEXT_CONFIGURATION,ui_menu_configuration)
#define UI_MENU_MAIN {UI_MENU_ADDCONDBACK &ui_menu_main1,SD_PRINTFILE_ENTRY &ui_menu_main2,&ui_menu_main3,UI_MENU_FAN_COND UI_MENU_SD_COND &ui_menu_main4,&ui_menu_main5}
UI_MENU(ui_menu_main,UI_MENU_MAIN,5+UI_MENU_BACKCNT+UI_MENU_SD_CNT+UI_MENU_FAN_CNT+SD_PRINTFILE_ENTRY_CNT)
/* Define menus accessible by action commands
You can create up to 10 user menus which are accessible by the action commands UI_ACTION_SHOW_USERMENU1 until UI_ACTION_SHOW_USERMENU10
You this the same way as with the menus above or you use one of the above menus. Then add a define like
#define UI_USERMENU1 ui_menu_conf_feed
which assigns the menu stored in ui_menu_conf_feed to the action UI_ACTION_SHOW_USERMENU1. Make sure only to change the numbers and not the name of the define.
When do you need this? You might want a fast button to change the temperature. In the default menu you have no menu
to change the temperature and view it the same time. So you need to make an action menu for this like:
UI_MENU_ACTION4C(ui_menu_extrtemp,UI_ACTION_EXTRUDER0_TEMP,"Temp. 0 :%E0" cDEG,"","","");
Then you assign this menu to a usermenu:
#define UI_USERMENU2 ui_menu_extrtemp
Now you can assign the action UI_ACTION_SHOW_USERMENU2+UI_ACTION_TOPMENU to a key and that will now show the temperture screen and allows
the change of temperature with the next/previous buttons.
*/
#endif
#endif // __UI_MENU_H