Updated Repetier version

This commit is contained in:
Nis Wechselberg 2016-01-15 20:42:10 +01:00
parent d46229bf4b
commit a0bb6d8315
73 changed files with 23884 additions and 15089 deletions

View file

@ -63,6 +63,9 @@ WiFiServer server(port);
void setup() {
// Set wifi mode to client
WiFi.mode(WIFI_STA);
// Initialize Serial connection
Serial.begin(115200);
delay(10);
@ -73,8 +76,6 @@ void setup() {
pinMode(bluePin, OUTPUT);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

635
Repetier/BedLeveling.cpp Normal file
View file

@ -0,0 +1,635 @@
/*
More and more printers now have automatic bed leveling using an ever increasing variety of methods.
This makes the leveling routine one of the most complex parts of the firmware and there is not one
way to level but hundreds of combinations.
First you should decide on the correction method. Once we know how our bed is tilted we want to
remove that. This correction is defined by BED_CORRECTION_METHOD and allows the following values:
BED_CORRECTION_METHOD 0
Use a rotation matrix. This will make z axis go up/down while moving in x/y direction to compensate
the tilt. For multiple extruders make sure the height match the tilt of the bed or one will scratch.
BED_CORRECTION_METHOD 1
Motorized correction. This method needs a bed that is fixed on 3 points from which 2 have a motor
to change the height. The positions are defined by
BED_MOTOR_1_X, BED_MOTOR_1_Y, BED_MOTOR_2_X, BED_MOTOR_2_Y, BED_MOTOR_3_X, BED_MOTOR_3_Y
Motor 2 and 3 are the one driven by motor driver 0 and 1. These can be extra motors like Felix Pro 1
uses them or a system with 3 z axis where motors can be controlled individually like the Sparkcube
does.
Next we have to distinguish several methods of z probing sensors. Each have their own advantages and
disadvantages. First the z probe has a position when activated and that position is defined by
#define Z_PROBE_X_OFFSET 0
#define Z_PROBE_Y_OFFSET 0
This is needed since we need to know where we measure the height when the z probe triggers. When
probing is activated you will see a move to make probe go over current extruder position. The
position can be changed in eeprom later on.
Some probes need to be activated/deactivated so we can use them. This is defined in the scripts
#define Z_PROBE_START_SCRIPT ""
#define Z_PROBE_FINISHED_SCRIPT ""
Now when we probe we want to know the distance of the extruder to the bed. This is defined by
#define Z_PROBE_HEIGHT 4
The 4 means that when we trigger the distance of the nozzle tip is 4mm. If your switch tends
to return different points you might repeat a measured point and use the average height:
#define Z_PROBE_SWITCHING_DISTANCE 1
#define Z_PROBE_REPETITIONS 5
Switching distance is the z raise needed to turn back a signal reliably to off. Inductive sensors
need only a bit while mechanical switches may require a bit more.
Next thing to consider is the force for switching. Some beds use a cantilever design and pushing on
the outside easily bends the bed. If your sensor needs some force to trigger you add the error of
bending. For this reason you might add a bending correction. Currently you define
#define BENDING_CORRECTION_A 0
#define BENDING_CORRECTION_B 0
#define BENDING_CORRECTION_C 0
which are the deflections at the 3 z probe points. For all other possible measurements these values
get interpolated. You can modify the values later on in eeprom. For force less sensors set them to 0.
Next thing is endstop handling. Without bed leveling you normally home to minimum position for x,y and z.
With bed leveling this is not that easy any more. Since we do bed leveling we already assume the bed is
not leveled for x/y moves. So without correction we would hit the bed for different x/y positions at
different heights. As a result we have no real minimum position. That makes a z min endstop quite useless.
There is an exception to this. If your nozzle triggers z min or if a inductive sensor would trigger at a given
position we could use that signal. With nozzle triggers you need to be careful as a drop of filament
would change the height. The other problem is that while homing the auto leveling is not used. So
the only position would be if the z min sensor is directly over the 0,0 coordinate which is the rotation point
if we have matrix based correction. For motor based correction this will work everywhere correctly.
So the only useful position for a z endstop is z max position. Apart from not having the bed tilt problem it
also allows homing with a full bed so you can continue an aborted print with some gcode tweaking. With z max
homing we adjust the error by simply changing the max. z height. One thing you need to remember is setting
#define ENDSTOP_Z_BACK_ON_HOME 4
so we release the z max endstop. This is very important if we move xy at z max. Auto leveling might want to
increase z and the endstop might prevent it causing wrong position and a head crash if we later go down.
The value should be larger then the maximum expected tilt.
Now it is time to define how we measure the bed rotation. Here again we have several methods to choose.
All methods need at least 3 points to define the bed rotation correctly. The quality we get comes
from the selection of the right points and method.
BED_LEVELING_METHOD 0
This method measures at the 3 probe points and creates a plane through these points. If you have
a really planar bed this gives the optimum result. The 3 points must not be in one line and have
a long distance to increase numerical stability.
BED_LEVELING_METHOD 1
This measures a grid. Probe point 1 is the origin and points 2 and 3 span a grid. We measure
BED_LEVELING_GRID_SIZE points in each direction and compute a regression plane through all
points. This gives a good overall plane if you have small bumps measuring inaccuracies.
BED_LEVELING_METHOD 2
Bending correcting 4 point measurement. This is for cantilevered beds that have the rotation axis
not at the side but inside the bed. Here we can assume no bending on the axis and a symmetric
bending to both sides of the axis. So probe points 2 and 3 build the symmetric axis and
point 1 is mirrored to 1m across the axis. Using the symmetry we then remove the bending
from 1 and use that as plane.
By now the leveling process is finished. All errors that remain are measuring errors and bumps on
the bed it self. For deltas you can enable distortion correction to follow the bumps.
*/
#include "Repetier.h"
#ifndef BED_LEVELING_METHOD
#define BED_LEVELING_METHOD 0
#endif
#ifndef BED_CORRECTION_METHOD
#define BED_CORRECTION_METHOD 0
#endif
#ifndef BED_LEVELING_GRID_SIZE
#define BED_LEVELING_GRID_SIZE 5
#endif
#ifndef BED_LEVELING_REPETITIONS
#define BED_LEVELING_REPETITIONS 1
#endif
#if FEATURE_AUTOLEVEL && FEATURE_Z_PROBE
class Plane {
public:
// f(x, y) = ax + by + c
float a,b,c;
float z(float x,float y) {
return a * x + y * b + c;
}
};
class PlaneBuilder {
float sum_xx,sum_xy,sum_yy,sum_x,sum_y,sum_xz,sum_yz,sum_z,n;
public:
void reset() {
sum_xx = sum_xy = sum_yy = sum_x = sum_y = sum_xz = sum_yz = sum_z = n = 0;
}
void addPoint(float x,float y,float z) {
n++;
sum_xx += x * x;
sum_xy += x * y;
sum_yy += y * y;
sum_x += x;
sum_y += y;
sum_xz += x * z;
sum_yz += y * z;
sum_z += z;
}
void createPlane(Plane &plane) {
float det = (sum_x*(sum_xy*sum_y-sum_x*sum_yy)+sum_xx*(n*sum_yy-sum_y*sum_y)+sum_xy*(sum_x*sum_y-n*sum_xy));
plane.a = ((sum_xy*sum_y-sum_x*sum_yy)*sum_z+(sum_x*sum_y-n*sum_xy)*sum_yz+sum_xz*(n*sum_yy-sum_y*sum_y)) /det;
plane.b = ((sum_x*sum_xy-sum_xx*sum_y)*sum_z+(n*sum_xx-sum_x*sum_x)*sum_yz+sum_xz*(sum_x*sum_y-n*sum_xy)) /det;
plane.c = ((sum_xx*sum_yy-sum_xy*sum_xy)*sum_z+(sum_x*sum_xy-sum_xx*sum_y)*sum_yz+sum_xz*(sum_xy*sum_y-sum_x*sum_yy))/det;
Com::printF(PSTR("plane: a = "),plane.a,4);
Com::printF(PSTR(" b = "),plane.b,4);
Com::printFLN(PSTR(" c = "),plane.c,4);
}
};
bool measureAutolevelPlane(Plane &plane) {
PlaneBuilder builder;
builder.reset();
#if BED_LEVELING_METHOD == 0 // 3 point
float h;
Printer::moveTo(EEPROM::zProbeX1(),EEPROM::zProbeY1(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h = Printer::runZProbe(false,false);
if(h < -1)
return false;
builder.addPoint(EEPROM::zProbeX1(),EEPROM::zProbeY1(),h);
Printer::moveTo(EEPROM::zProbeX2(),EEPROM::zProbeY2(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h = Printer::runZProbe(false,false);
if(h < -1)
return false;
builder.addPoint(EEPROM::zProbeX2(),EEPROM::zProbeY2(),h);
Printer::moveTo(EEPROM::zProbeX3(),EEPROM::zProbeY3(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h = Printer::runZProbe(false,false);
if(h < -1)
return false;
builder.addPoint(EEPROM::zProbeX3(),EEPROM::zProbeY3(),h);
#elif BED_LEVELING_METHOD == 1 // linear regression
float delta = 1.0/(BED_LEVELING_GRID_SIZE - 1);
float ox = EEPROM::zProbeX1();
float oy = EEPROM::zProbeY1();
float ax = delta * (EEPROM::zProbeX2() - EEPROM::zProbeX1());
float ay = delta * (EEPROM::zProbeY2() - EEPROM::zProbeY1());
float bx = delta * (EEPROM::zProbeX3() - EEPROM::zProbeX1());
float by = delta * (EEPROM::zProbeY3() - EEPROM::zProbeY1());
for(int ix = 0; ix < BED_LEVELING_GRID_SIZE; ix++) {
for(int iy = 0; iy < BED_LEVELING_GRID_SIZE; iy++) {
float px = ox + static_cast<float>(ix) * ax + static_cast<float>(iy) * bx;
float py = oy + static_cast<float>(ix) * ay + static_cast<float>(iy) * by;
Printer::moveTo(px,py,IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
float h = Printer::runZProbe(false,false);
if(h < -1)
return false;
builder.addPoint(px,py,h);
}
}
#elif BED_LEVELING_METHOD == 2 // 4 point symmetric
float h1,h2,h3,h4;
float apx = EEPROM::zProbeX1() - EEPROM::zProbeX2();
float apy = EEPROM::zProbeY1() - EEPROM::zProbeY2();
float abx = EEPROM::zProbeX3() - EEPROM::zProbeX2();
float aby = EEPROM::zProbeY3() - EEPROM::zProbeY2();
float ab2 = abx * abx + aby * aby;
float abap = apx * abx + apy * aby;
float t = abap / ab2;
float xx = EEPROM::zProbeX2() + t * abx;
float xy = EEPROM::zProbeY2() + t * aby;
float x1Mirror = EEPROM::zProbeX1() + 2.0 * (xx - EEPROM::zProbeX1());
float y1Mirror = EEPROM::zProbeY1() + 2.0 * (xy - EEPROM::zProbeY1());
Printer::moveTo(EEPROM::zProbeX1(),EEPROM::zProbeY1(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h1 = Printer::runZProbe(false,false);
if(h1 < -1)
return false;
Printer::moveTo(EEPROM::zProbeX2(),EEPROM::zProbeY2(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h2 = Printer::runZProbe(false,false);
if(h2 < -1)
return false;
Printer::moveTo(EEPROM::zProbeX3(),EEPROM::zProbeY3(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h3 = Printer::runZProbe(false,false);
if(h3 < -1)
return false;
Printer::moveTo(x1Mirror,y1Mirror,IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h4 = Printer::runZProbe(false,false);
if(h4 < -1)
return false;
t = h2 + (h3-h2) * t; // theoretical height for crossing point for symmetric axis
h1 = t - (h4-h1) * 0.5; // remove bending part
builder.addPoint(EEPROM::zProbeX1(),EEPROM::zProbeY1(),h1);
builder.addPoint(EEPROM::zProbeX2(),EEPROM::zProbeY2(),h2);
builder.addPoint(EEPROM::zProbeX3(),EEPROM::zProbeY3(),h3);
#else
#error Unknown bed leveling method
#endif
builder.createPlane(plane);
return true;
}
void correctAutolevel(GCode *code,Plane &plane) {
#if BED_CORRECTION_METHOD == 0 // rotation matrix
Printer::buildTransformationMatrix(plane.z(EEPROM::zProbeX1(),EEPROM::zProbeY1()),plane.z(EEPROM::zProbeX2(),EEPROM::zProbeY2()),plane.z(EEPROM::zProbeX3(),EEPROM::zProbeY3()));
#elif BED_CORRECTION_METHOD == 1 // motorized correction
#if !defined(NUM_MOTOR_DRIVERS) || NUM_MOTOR_DRIVERS < 2
#error You need to define 2 motors for motorized bed correction
#endif
Commands::waitUntilEndOfAllMoves(); // move steppers might be leveling steppers as well !
float h1 = plane.z(BED_MOTOR_1_X,BED_MOTOR_1_Y);
float h2 = plane.z(BED_MOTOR_2_X,BED_MOTOR_2_Y);
float h3 = plane.z(BED_MOTOR_3_X,BED_MOTOR_3_Y);
// h1 is reference heights, h2 => motor 0, h3 => motor 1
h2 -= h1;
h3 -= h1;
MotorDriverInterface *motor2 = getMotorDriver(0);
MotorDriverInterface *motor3 = getMotorDriver(1);
motor2->setCurrentAs(0);
motor3->setCurrentAs(0);
motor2->gotoPosition(h2);
motor3->gotoPosition(h3);
motor2->disable();
motor3->disable(); // now bed is even
Printer::currentPositionSteps[Z_AXIS] = h1 * Printer::axisStepsPerMM[Z_AXIS];
#else
#error Unknown bed correction method set
#endif
}
/*
Implementation of the G32 command
G32 S<0..2> - Autolevel print bed. S = 1 measure zLength, S = 2 Measure and store new zLength
S = 0 : Do not update length - use this if you have not homed before or you mess up zlength!
S = 1 : Measure zLength so homing works
S = 2 : Like s = 1 plus store results in EEPROM for next connection.
*/
void runBedLeveling(GCode *com) {
float h1,h2,h3,hc,oldFeedrate = Printer::feedrate;
int s = com->hasS() ? com->S : -1;
#if DISTORTION_CORRECTION
bool distEnabled = Printer::distortion.isEnabled();
Printer::distortion.disable(false); // if level has changed, distortion is also invalid
#endif
Printer::setAutolevelActive(false); // iterate
Printer::resetTransformationMatrix(true); // in case we switch from matrix to motorized!
#if DRIVE_SYSTEM == DELTA
// It is not possible to go to the edges at the top, also users try
// it often and wonder why the coordinate system is then wrong.
// For that reason we ensure a correct behavior by code.
Printer::homeAxis(true, true, true);
Printer::moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE, EEPROM::zProbeBedDistance() + EEPROM::zProbeHeight(), IGNORE_COORDINATE, Printer::homingFeedrate[Z_AXIS]);
#endif
Printer::startProbing(true);
//GCode::executeFString(Com::tZProbeStartScript);
Printer::coordinateOffset[X_AXIS] = Printer::coordinateOffset[Y_AXIS] = Printer::coordinateOffset[Z_AXIS] = 0;
Plane plane;
#if BED_CORRECTION_METHOD == 1
for(int r = 0; r < BED_LEVELING_REPETITIONS; r++) {
#if DRIVE_SYSTEM == DELTA
if(r > 0) {
Printer::finishProbing();
Printer::homeAxis(true, true, true);
Printer::moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE, EEPROM::zProbeBedDistance() + EEPROM::zProbeHeight(), IGNORE_COORDINATE, Printer::homingFeedrate[Z_AXIS]);
Printer::startProbing(true);
}
#endif
#endif
if(!measureAutolevelPlane(plane)) {
Com::printErrorFLN(PSTR("Probing had returned errors - autoleveling canceled."));
return;
}
correctAutolevel(com,plane);
// Leveling is finished now update own positions and store leveling data if needed
float currentZ = plane.z((float)Printer::currentPositionSteps[X_AXIS] * Printer::invAxisStepsPerMM[X_AXIS],(float)Printer::currentPositionSteps[Y_AXIS] * Printer::invAxisStepsPerMM[Y_AXIS]);
Com::printF(PSTR("CurrentZ:"),currentZ);Com::printFLN(PSTR(" atZ:"),Printer::currentPosition[Z_AXIS]);
// With max z endstop we adjust zlength so after next homing we have also a calibrated printer
Printer::zMin = 0;
#if MAX_HARDWARE_ENDSTOP_Z
float xRot,yRot,zRot;
#if BED_CORRECTION_METHOD != 1
Printer::transformFromPrinter(Printer::currentPosition[X_AXIS],Printer::currentPosition[Y_AXIS],Printer::currentPosition[Z_AXIS],xRot,yRot,zRot);
Com::printFLN(PSTR("Z after rotation:"),zRot);
#else
zRot = Printer::currentPosition[Z_AXIS];
#endif
// With max z endstop we adjust zlength so after next homing we have also a calibrated printer
if(s != 0) {
Printer::zLength += currentZ - zRot;
Com::printFLN(Com::tZProbePrinterHeight, Printer::zLength);
}
#endif
Printer::currentPositionSteps[Z_AXIS] = currentZ * Printer::axisStepsPerMM[Z_AXIS];
Printer::updateCurrentPosition(true);
#if BED_CORRECTION_METHOD == 1
if(fabs(plane.a) < 0.00025 && fabsf(plane.b) < 0.00025 )
break; // we reached achievable precision so we can stop
}
#endif
Printer::updateDerivedParameter();
Printer::finishProbing();
#if BED_CORRECTION_METHOD != 1
Printer::setAutolevelActive(true); // only for software correction or we can spare the comp. time
#endif
if(s >= 2) {
EEPROM::storeDataIntoEEPROM();
}
Printer::updateCurrentPosition(true);
Commands::printCurrentPosition(PSTR("G32 "));
#if DISTORTION_CORRECTION
if(distEnabled)
Printer::distortion.enable(false); // if level has changed, distortion is also invalid
#endif
#if DRIVE_SYSTEM == DELTA
Printer::homeAxis(true, true, true); // shifting z makes positioning invalid, need to recalibrate
#endif
Printer::feedrate = oldFeedrate;
}
#endif
void Printer::setAutolevelActive(bool on)
{
#if FEATURE_AUTOLEVEL
if(on == isAutolevelActive()) return;
flag0 = (on ? flag0 | PRINTER_FLAG0_AUTOLEVEL_ACTIVE : flag0 & ~PRINTER_FLAG0_AUTOLEVEL_ACTIVE);
if(on)
Com::printInfoFLN(Com::tAutolevelEnabled);
else
Com::printInfoFLN(Com::tAutolevelDisabled);
updateCurrentPosition(false);
#endif // FEATURE_AUTOLEVEL
}
#if MAX_HARDWARE_ENDSTOP_Z
float Printer::runZMaxProbe()
{
#if NONLINEAR_SYSTEM
long startZ = realDeltaPositionSteps[Z_AXIS] = currentDeltaPositionSteps[Z_AXIS]; // update real
#endif
Commands::waitUntilEndOfAllMoves();
long probeDepth = 2*(Printer::zMaxSteps-Printer::zMinSteps);
stepsRemainingAtZHit = -1;
setZProbingActive(true);
PrintLine::moveRelativeDistanceInSteps(0,0,probeDepth,0,EEPROM::zProbeSpeed(),true,true);
if(stepsRemainingAtZHit < 0)
{
Com::printErrorFLN(Com::tZProbeFailed);
return -1;
}
setZProbingActive(false);
currentPositionSteps[Z_AXIS] -= stepsRemainingAtZHit;
#if NONLINEAR_SYSTEM
probeDepth -= (realDeltaPositionSteps[Z_AXIS] - startZ);
#else
probeDepth -= stepsRemainingAtZHit;
#endif
float distance = (float)probeDepth * invAxisStepsPerMM[Z_AXIS];
Com::printF(Com::tZProbeMax,distance);
Com::printF(Com::tSpaceXColon,realXPosition());
Com::printFLN(Com::tSpaceYColon,realYPosition());
PrintLine::moveRelativeDistanceInSteps(0,0,-probeDepth,0,EEPROM::zProbeSpeed(),true,true);
return distance;
}
#endif
#if FEATURE_Z_PROBE
void Printer::startProbing(bool runScript) {
float oldOffX = Printer::offsetX;
float oldOffY = Printer::offsetY;
float oldOffZ = Printer::offsetZ;
if(runScript)
GCode::executeFString(Com::tZProbeStartScript);
float maxStartHeight = EEPROM::zProbeBedDistance() + (EEPROM::zProbeHeight() > 0 ? EEPROM::zProbeHeight() : 0) + 0.1;
if(currentPosition[Z_AXIS] > maxStartHeight) {
moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE, maxStartHeight, IGNORE_COORDINATE, homingFeedrate[Z_AXIS]);
}
Printer::offsetX = -EEPROM::zProbeXOffset();
Printer::offsetY = -EEPROM::zProbeYOffset();
Printer::offsetZ = 0; // we correct this with probe height
PrintLine::moveRelativeDistanceInSteps((Printer::offsetX - oldOffX) * Printer::axisStepsPerMM[X_AXIS],
(Printer::offsetY - oldOffY) * Printer::axisStepsPerMM[Y_AXIS],
0, 0, EEPROM::zProbeXYSpeed(), true, ALWAYS_CHECK_ENDSTOPS);
}
void Printer::finishProbing() {
float oldOffX = Printer::offsetX;
float oldOffY = Printer::offsetY;
float oldOffZ = Printer::offsetZ;
GCode::executeFString(Com::tZProbeEndScript);
if(Extruder::current)
{
Printer::offsetX = -Extruder::current->xOffset * Printer::invAxisStepsPerMM[X_AXIS];
Printer::offsetY = -Extruder::current->yOffset * Printer::invAxisStepsPerMM[Y_AXIS];
Printer::offsetZ = -Extruder::current->zOffset * Printer::invAxisStepsPerMM[Z_AXIS];
}
PrintLine::moveRelativeDistanceInSteps((Printer::offsetX - oldOffX) * Printer::axisStepsPerMM[X_AXIS],
(Printer::offsetY - oldOffY) * Printer::axisStepsPerMM[Y_AXIS],
(Printer::offsetZ - oldOffZ) * Printer::axisStepsPerMM[Z_AXIS], 0, EEPROM::zProbeXYSpeed(), true, ALWAYS_CHECK_ENDSTOPS);
}
/*
This is the most important function for bed leveling. It does
1. Run probe start script if first = true and runStartScript = true
2. Position zProbe at current position if first = true. If we are more then maxStartHeight away from bed we also go down to that distance.
3. Measure the the steps until probe hits the bed.
4. Undo positioning to z probe and run finish script if last = true.
Now we compute the nozzle height as follows:
a) Compute average height from repeated measurements
b) Add zProbeHeight to correct difference between triggering point and nozzle height above bed
c) If Z_PROBE_Z_OFFSET_MODE == 1 we add zProbeZOffset() that is coating thickness if we measure below coating with indictive sensor.
d) Add distortion correction.
e) Add bending correction
Then we return the measured and corrected z distance.
*/
float Printer::runZProbe(bool first,bool last,uint8_t repeat,bool runStartScript)
{
float oldOffX = Printer::offsetX;
float oldOffY = Printer::offsetY;
float oldOffZ = Printer::offsetZ;
if(first)
startProbing(runStartScript);
Commands::waitUntilEndOfAllMoves();
int32_t sum = 0, probeDepth;
int32_t shortMove = static_cast<int32_t>((float)Z_PROBE_SWITCHING_DISTANCE * axisStepsPerMM[Z_AXIS]); // distance to go up for repeated moves
int32_t lastCorrection = currentPositionSteps[Z_AXIS]; // starting position
#if NONLINEAR_SYSTEM
realDeltaPositionSteps[Z_AXIS] = currentDeltaPositionSteps[Z_AXIS]; // update real
#endif
//int32_t updateZ = 0;
waitForZProbeStart();
for(int8_t r = 0; r < repeat; r++)
{
probeDepth = 2 * (Printer::zMaxSteps - Printer::zMinSteps); // probe should always hit within this distance
stepsRemainingAtZHit = -1; // Marker that we did not hit z probe
//int32_t offx = axisStepsPerMM[X_AXIS] * EEPROM::zProbeXOffset();
//int32_t offy = axisStepsPerMM[Y_AXIS] * EEPROM::zProbeYOffset();
//PrintLine::moveRelativeDistanceInSteps(-offx,-offy,0,0,EEPROM::zProbeXYSpeed(),true,true);
setZProbingActive(true);
PrintLine::moveRelativeDistanceInSteps(0, 0, -probeDepth, 0, EEPROM::zProbeSpeed(), true, true);
if(stepsRemainingAtZHit < 0)
{
Com::printErrorFLN(Com::tZProbeFailed);
return -1;
}
setZProbingActive(false);
#if NONLINEAR_SYSTEM
stepsRemainingAtZHit = realDeltaPositionSteps[C_TOWER] - currentDeltaPositionSteps[C_TOWER]; // nonlinear moves may split z so stepsRemainingAtZHit is only what is left from last segment not total move. This corrects the problem.
#endif
#if DRIVE_SYSTEM == DELTA
currentDeltaPositionSteps[A_TOWER] += stepsRemainingAtZHit; // Update difference
currentDeltaPositionSteps[B_TOWER] += stepsRemainingAtZHit;
currentDeltaPositionSteps[C_TOWER] += stepsRemainingAtZHit;
#endif
currentPositionSteps[Z_AXIS] += stepsRemainingAtZHit; // now current position is correct
sum += lastCorrection - currentPositionSteps[Z_AXIS];
if(r + 1 < repeat) // go only shortest possible move up for repetitions
PrintLine::moveRelativeDistanceInSteps(0, 0, shortMove, 0, EEPROM::zProbeSpeed(), true, false);
}
float distance = static_cast<float>(sum) * invAxisStepsPerMM[Z_AXIS] / static_cast<float>(repeat) + EEPROM::zProbeHeight();
#if Z_PROBE_Z_OFFSET_MODE == 1
distance += EEPROM::zProbeZOffset(); // We measured including coating, so we need to add coating thickness!
#endif
#if DISTORTION_CORRECTION
float zCorr = 0;
if(Printer::distortion.isEnabled()) {
zCorr = distortion.correct(currentPositionSteps[X_AXIS] + EEPROM::zProbeXOffset() * axisStepsPerMM[X_AXIS],currentPositionSteps[Y_AXIS]
+ EEPROM::zProbeYOffset() * axisStepsPerMM[Y_AXIS],0) * invAxisStepsPerMM[Z_AXIS];
distance += zCorr;
}
#endif
distance += bendingCorrectionAt(currentPosition[X_AXIS], currentPosition[Y_AXIS]);
Com::printF(Com::tZProbe, distance);
Com::printF(Com::tSpaceXColon, realXPosition());
#if DISTORTION_CORRECTION
if(Printer::distortion.isEnabled()) {
Com::printF(Com::tSpaceYColon, realYPosition());
Com::printFLN(PSTR(" zCorr:"), zCorr);
} else {
Com::printFLN(Com::tSpaceYColon, realYPosition());
}
#else
Com::printFLN(Com::tSpaceYColon, realYPosition());
#endif
// Go back to start position
PrintLine::moveRelativeDistanceInSteps(0, 0, lastCorrection - currentPositionSteps[Z_AXIS], 0, EEPROM::zProbeSpeed(), true, false);
//PrintLine::moveRelativeDistanceInSteps(offx,offy,0,0,EEPROM::zProbeXYSpeed(),true,true);
if(last)
finishProbing();
return distance;
}
float Printer::bendingCorrectionAt(float x, float y) {
RVector3 p0(EEPROM::zProbeX1(),EEPROM::zProbeY1(),EEPROM::bendingCorrectionA());
RVector3 p1(EEPROM::zProbeX2(),EEPROM::zProbeY2(),EEPROM::bendingCorrectionB());
RVector3 p2(EEPROM::zProbeX3(),EEPROM::zProbeY3(),EEPROM::bendingCorrectionC());
RVector3 a = p1-p0,b = p2 - p0;
RVector3 n = a.cross(b);
RVector3 l0(x,y,0);
return ((p0 - l0).scalar(n)) / n.z;
}
void Printer::waitForZProbeStart()
{
#if Z_PROBE_WAIT_BEFORE_TEST
Endstops::update();
Endstops::update(); // double test to get right signal. Needed for crosstalk protection.
if(Endstops::zProbe()) return;
#if UI_DISPLAY_TYPE != NO_DISPLAY
uid.setStatusP(Com::tHitZProbe);
uid.refreshPage();
#endif
#ifdef DEBUG_PRINT
debugWaitLoop = 3;
#endif
while(!Endstops::zProbe())
{
defaultLoopActions();
Endstops::update();
Endstops::update(); // double test to get right signal. Needed for crosstalk protection.
}
#ifdef DEBUG_PRINT
debugWaitLoop = 4;
#endif
HAL::delayMilliseconds(30);
while(Endstops::zProbe())
{
defaultLoopActions();
Endstops::update();
Endstops::update(); // double test to get right signal. Needed for crosstalk protection.
}
HAL::delayMilliseconds(30);
UI_CLEAR_STATUS;
#endif
}
#endif
#if FEATURE_AUTOLEVEL
void Printer::transformToPrinter(float x,float y,float z,float &transX,float &transY,float &transZ)
{
#if FEATURE_AXISCOMP
// Axis compensation:
x = x + y * EEPROM::axisCompTanXY() + z * EEPROM::axisCompTanXZ();
y = y + z * EEPROM::axisCompTanYZ();
#endif
transX = x * autolevelTransformation[0] + y * autolevelTransformation[3] + z * autolevelTransformation[6];
transY = x * autolevelTransformation[1] + y * autolevelTransformation[4] + z * autolevelTransformation[7];
transZ = x * autolevelTransformation[2] + y * autolevelTransformation[5] + z * autolevelTransformation[8];
}
void Printer::transformFromPrinter(float x,float y,float z,float &transX,float &transY,float &transZ)
{
transX = x * autolevelTransformation[0] + y * autolevelTransformation[1] + z * autolevelTransformation[2];
transY = x * autolevelTransformation[3] + y * autolevelTransformation[4] + z * autolevelTransformation[5];
transZ = x * autolevelTransformation[6] + y * autolevelTransformation[7] + z * autolevelTransformation[8];
#if FEATURE_AXISCOMP
// Axis compensation:
transY = transY - transZ * EEPROM::axisCompTanYZ();
transX = transX - transY * EEPROM::axisCompTanXY() - transZ * EEPROM::axisCompTanXZ();
#endif
}
void Printer::resetTransformationMatrix(bool silent)
{
autolevelTransformation[0] = autolevelTransformation[4] = autolevelTransformation[8] = 1;
autolevelTransformation[1] = autolevelTransformation[2] = autolevelTransformation[3] =
autolevelTransformation[5] = autolevelTransformation[6] = autolevelTransformation[7] = 0;
if(!silent)
Com::printInfoFLN(Com::tAutolevelReset);
}
void Printer::buildTransformationMatrix(float h1,float h2,float h3)
{
float ax = EEPROM::zProbeX2()-EEPROM::zProbeX1();
float ay = EEPROM::zProbeY2()-EEPROM::zProbeY1();
float az = h1-h2;
float bx = EEPROM::zProbeX3()-EEPROM::zProbeX1();
float by = EEPROM::zProbeY3()-EEPROM::zProbeY1();
float bz = h1-h3;
// First z direction
autolevelTransformation[6] = ay * bz - az * by;
autolevelTransformation[7] = az * bx - ax * bz;
autolevelTransformation[8] = ax * by - ay * bx;
float len = sqrt(autolevelTransformation[6] * autolevelTransformation[6] + autolevelTransformation[7] * autolevelTransformation[7] + autolevelTransformation[8] * autolevelTransformation[8]);
if(autolevelTransformation[8] < 0) len = -len;
autolevelTransformation[6] /= len;
autolevelTransformation[7] /= len;
autolevelTransformation[8] /= len;
autolevelTransformation[3] = 0;
autolevelTransformation[4] = autolevelTransformation[8];
autolevelTransformation[5] = -autolevelTransformation[7];
// cross(y,z)
autolevelTransformation[0] = autolevelTransformation[4] * autolevelTransformation[8] - autolevelTransformation[5] * autolevelTransformation[7];
autolevelTransformation[1] = autolevelTransformation[5] * autolevelTransformation[6];// - autolevelTransformation[3] * autolevelTransformation[8];
autolevelTransformation[2] = /*autolevelTransformation[3] * autolevelTransformation[7]*/ - autolevelTransformation[4] * autolevelTransformation[6];
len = sqrt(autolevelTransformation[0] * autolevelTransformation[0] + autolevelTransformation[1] * autolevelTransformation[1] + autolevelTransformation[2] * autolevelTransformation[2]);
autolevelTransformation[0] /= len;
autolevelTransformation[1] /= len;
autolevelTransformation[2] /= len;
len = sqrt(autolevelTransformation[4] * autolevelTransformation[4] + autolevelTransformation[5] * autolevelTransformation[5]);
autolevelTransformation[4] /= len;
autolevelTransformation[5] /= len;
Com::printArrayFLN(Com::tTransformationMatrix,autolevelTransformation, 9, 6);
}
#endif

View file

@ -21,7 +21,7 @@
#include "Repetier.h"
const uint8_t sensitive_pins[] PROGMEM = SENSITIVE_PINS; // Sensitive pin list for M42
const int8_t sensitive_pins[] PROGMEM = SENSITIVE_PINS; // Sensitive pin list for M42
int Commands::lowestRAMValue = MAX_RAM;
int Commands::lowestRAMValueSend = MAX_RAM;
@ -161,6 +161,7 @@ void Commands::printCurrentPosition(FSTRINGPARAM(s))
void Commands::printTemperatures(bool showRaw)
{
#if NUM_EXTRUDER > 0
float temp = Extruder::current->tempControl.currentTemperatureC;
#if HEATED_BED_SENSOR_TYPE == 0
Com::printF(Com::tTColon,temp);
@ -198,8 +199,15 @@ void Commands::printTemperatures(bool showRaw)
Com::printF(Com::tColon,(1023 << (2 - ANALOG_REDUCE_BITS)) - extruder[i].tempControl.currentTemperature);
}
}
#elif NUM_EXTRUDER == 1
if(showRaw)
{
Com::printF(Com::tSpaceRaw,(int)0);
Com::printF(Com::tColon,(1023 << (2 - ANALOG_REDUCE_BITS)) - extruder[0].tempControl.currentTemperature);
}
#endif
Com::println();
#endif
}
void Commands::changeFeedrateMultiply(int factor)
{
@ -222,27 +230,39 @@ void Commands::changeFlowrateMultiply(int factor)
Com::printFLN(Com::tFlowMultiply, factor);
}
#if FEATURE_FAN_CONTROL
uint8_t fanKickstart;
void Commands::setFanSpeed(int speed,bool wait)
#endif
#if FEATURE_FAN2_CONTROL
uint8_t fan2Kickstart;
#endif
void Commands::setFanSpeed(int speed, bool immediately)
{
#if FAN_PIN>-1 && FEATURE_FAN_CONTROL
#if FAN_PIN >- 1 && FEATURE_FAN_CONTROL
if(Printer::fanSpeed == speed)
return;
speed = constrain(speed,0,255);
Printer::setMenuMode(MENU_MODE_FAN_RUNNING,speed != 0);
if(wait)
Commands::waitUntilEndOfAllMoves(); // use only if neededthis to change the speed exactly at that point, but it may cause blobs if you do!
if(speed != pwm_pos[NUM_EXTRUDER + 2])
{
Com::printFLN(Com::tFanspeed,speed); // send only new values to break update loops!
#if FAN_KICKSTART_TIME
if(fanKickstart == 0 && speed > pwm_pos[NUM_EXTRUDER + 2] && speed < 85)
{
if(pwm_pos[NUM_EXTRUDER + 2]) fanKickstart = FAN_KICKSTART_TIME/100;
else fanKickstart = FAN_KICKSTART_TIME/25;
Printer::fanSpeed = speed;
if(PrintLine::linesCount == 0 || immediately) {
if(Printer::mode == PRINTER_MODE_FFF)
{
for(fast8_t i = 0; i < PRINTLINE_CACHE_SIZE; i++)
PrintLine::lines[i].secondSpeed = speed; // fill all printline buffers with new fan speed value
}
Printer::setFanSpeedDirectly(speed);
}
Com::printFLN(Com::tFanspeed,speed); // send only new values to break update loops!
#endif
}
pwm_pos[NUM_EXTRUDER + 2] = speed;
#endif
}
void Commands::setFan2Speed(int speed)
{
#if FAN2_PIN >- 1 && FEATURE_FAN2_CONTROL
speed = constrain(speed,0,255);
Printer::setFan2SpeedDirectly(speed);
Com::printFLN(Com::tFan2speed,speed); // send only new values to break update loops!
#endif
}
void Commands::reportPrinterUsage()
@ -252,9 +272,10 @@ void Commands::reportPrinterUsage()
Com::printF(Com::tPrintedFilament, dist, 2);
Com::printF(Com::tSpacem);
bool alloff = true;
#if NUM_EXTRUDER > 0
for(uint8_t i = 0; i < NUM_EXTRUDER; i++)
if(tempController[i]->targetTemperatureC > 15) alloff = false;
#endif
int32_t seconds = (alloff ? 0 : (HAL::timeInMilliseconds() - Printer::msecondsPrinting) / 1000) + HAL::eprGetInt32(EPR_PRINTING_TIME);
int32_t tmp = seconds / 86400;
seconds -= tmp * 86400;
@ -860,7 +881,7 @@ void Commands::processArc(GCode *com)
return;
}
// Invert the sign of h_x2_div_d if the circle is counter clockwise (see sketch below)
if (com->G==3)
if (com->G == 3)
{
h_x2_div_d = -h_x2_div_d;
}
@ -892,8 +913,8 @@ void Commands::processArc(GCode *com)
r = -r; // Finished with r. Set to positive for mc_arc
}
// Complete the operation by calculating the actual center of the arc
offset[0] = 0.5*(x-(y*h_x2_div_d));
offset[1] = 0.5*(y+(x*h_x2_div_d));
offset[0] = 0.5 * (x - (y * h_x2_div_d));
offset[1] = 0.5 * (y + (x * h_x2_div_d));
}
else // Offset mode specific computations
@ -906,7 +927,7 @@ void Commands::processArc(GCode *com)
PrintLine::arc(position, target, offset, r, isclockwise);
}
#endif
extern void runBedLeveling(GCode *com);
/**
\brief Execute the G command stored in com.
*/
@ -917,6 +938,13 @@ void Commands::processGCode(GCode *com)
{
case 0: // G0 -> G1
case 1: // G1
#if defined(SUPPORT_LASER) && SUPPORT_LASER
{ // disable laser for G0 moves
bool laserOn = LaserDriver::laserOn;
if(com->G == 0 && Printer::mode == PRINTER_MODE_LASER) {
LaserDriver::laserOn = false;
}
#endif // defined
if(com->hasS()) Printer::setNoDestinationCheck(com->S != 0);
if(Printer::setDestinationStepsFromGCode(com)) // For X Y Z E F
#if NONLINEAR_SYSTEM
@ -941,18 +969,33 @@ void Commands::processGCode(GCode *com)
int lc = (int)PrintLine::linesCount;
int lp = (int)PrintLine::linesPos;
int wp = (int)PrintLine::linesWritePos;
int n = (wp-lp);
int n = (wp - lp);
if(n < 0) n += PRINTLINE_CACHE_SIZE;
noInts.unprotect();
if(n != lc)
Com::printFLN(PSTR("Buffer corrupted"));
}
#endif
#if defined(SUPPORT_LASER) && SUPPORT_LASER
LaserDriver::laserOn = laserOn;
}
#endif // defined
break;
#if ARC_SUPPORT
case 2: // CW Arc
case 3: // CCW Arc MOTION_MODE_CW_ARC: case MOTION_MODE_CCW_ARC:
#if defined(SUPPORT_LASER) && SUPPORT_LASER
{ // disable laser for G0 moves
bool laserOn = LaserDriver::laserOn;
if(com->G == 0 && Printer::mode == PRINTER_MODE_LASER) {
LaserDriver::laserOn = false;
}
#endif // defined
processArc(com);
#if defined(SUPPORT_LASER) && SUPPORT_LASER
LaserDriver::laserOn = laserOn;
}
#endif // defined
break;
#endif
case 4: // G4 dwell
@ -1034,7 +1077,7 @@ void Commands::processGCode(GCode *com)
Printer::homeAxis(true,true,true);
#else
Printer::currentPositionSteps[Z_AXIS] = sum * Printer::axisStepsPerMM[Z_AXIS];
Printer::zLength = Printer::runZMaxProbe() + sum-ENDSTOP_Z_BACK_ON_HOME;
Printer::zLength = Printer::runZMaxProbe() + sum - ENDSTOP_Z_BACK_ON_HOME;
#endif
Com::printInfoFLN(Com::tZProbeZReset);
Com::printFLN(Com::tZProbePrinterHeight,Printer::zLength);
@ -1074,7 +1117,10 @@ void Commands::processGCode(GCode *com)
break;
#if FEATURE_AUTOLEVEL
case 32: // G32 Auto-Bed leveling
runBedLeveling(com);
#if 0
{
#if DISTORTION_CORRECTION
Printer::distortion.disable(true); // if level has changed, distortion is also invalid
#endif
@ -1082,7 +1128,7 @@ void Commands::processGCode(GCode *com)
#if DRIVE_SYSTEM == DELTA
// It is not possible to go to the edges at the top, also users try
// it often and wonder why the coordinate system is then wrong.
// For that reason we ensure a correct behaviour by code.
// For that reason we ensure a correct behavior by code.
Printer::homeAxis(true, true, true);
Printer::moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE, EEPROM::zProbeBedDistance() + EEPROM::zProbeHeight(), IGNORE_COORDINATE, Printer::homingFeedrate[Z_AXIS]);
#endif
@ -1099,18 +1145,6 @@ void Commands::processGCode(GCode *com)
Printer::moveTo(EEPROM::zProbeX3(),EEPROM::zProbeY3(),IGNORE_COORDINATE,IGNORE_COORDINATE,EEPROM::zProbeXYSpeed());
h3 = Printer::runZProbe(false,true);
if(h3 < -1) break;
// Zprobe with force feedback may bed bed differently for different points.
// these settings allow correction of the bending distance so leveling is correct afterwards.
// Values are normally negative with bending amount on trigger.
#ifdef ZPROBE_1_BENDING_CORRECTION
h1 += ZPROBE_1_BENDING_CORRECTION;
#endif
#ifdef ZPROBE_2_BENDING_CORRECTION
h2 += ZPROBE_2_BENDING_CORRECTION;
#endif
#ifdef ZPROBE_3_BENDING_CORRECTION
h3 += ZPROBE_3_BENDING_CORRECTION;
#endif
#if defined(MOTORIZED_BED_LEVELING) && defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS >= 2
// h1 is reference heights, h2 => motor 0, h3 => motor 1
h2 -= h1;
@ -1179,8 +1213,29 @@ void Commands::processGCode(GCode *com)
#endif
Printer::feedrate = oldFeedrate;
}
#endif
break;
#endif
#endif
#if DISTORTION_CORRECTION
case 33: {
if(com->hasL()) { // G33 L0 - List distortion matrix
Printer::distortion.showMatrix();
} else if(com->hasR()) { // G33 R0 - Reset distortion matrix
Printer::distortion.resetCorrection();
} else if(com->hasX() || com->hasY() || com->hasZ()) { // G33 X<xpos> Y<ypos> Z<zCorrection> - Set correction for nearest point
if(com->hasX() && com->hasY() && com->hasZ()) {
Printer::distortion.set(com->X, com->Y, com->Z);
} else {
Com::printErrorFLN(PSTR("You need to define X, Y and Z to set a point!"));
}
} else { // G33
float oldFeedrate = Printer::feedrate;
Printer::measureDistortion();
Printer::feedrate = oldFeedrate;
}
}
break;
#endif
case 90: // G90
Printer::relativeCoordinateMode = false;
@ -1345,6 +1400,7 @@ void Commands::processGCode(GCode *com)
EEPROM::setDeltaTowerZOffsetSteps(offz);
}
#endif
PrintLine::moveRelativeDistanceInSteps(0, 0, -5*Printer::axisStepsPerMM[Z_AXIS], 0, Printer::homingFeedrate[Z_AXIS], true, true);
Printer::homeAxis(true,true,true);
}
break;
@ -1364,17 +1420,18 @@ void Commands::processGCode(GCode *com)
// similar to comment above, this will get a different answer from any different starting point
// so it is unclear how this is helpful. It must start at a well defined point.
Printer::deltaMoveToTopEndstops(Printer::homingFeedrate[Z_AXIS]);
int32_t offx = HOME_DISTANCE_STEPS-Printer::stepsRemainingAtXHit;
int32_t offy = HOME_DISTANCE_STEPS-Printer::stepsRemainingAtYHit;
int32_t offz = HOME_DISTANCE_STEPS-Printer::stepsRemainingAtZHit;
int32_t offx = HOME_DISTANCE_STEPS - Printer::stepsRemainingAtXHit;
int32_t offy = HOME_DISTANCE_STEPS - Printer::stepsRemainingAtYHit;
int32_t offz = HOME_DISTANCE_STEPS - Printer::stepsRemainingAtZHit;
Com::printFLN(Com::tTower1,offx);
Com::printFLN(Com::tTower2,offy);
Com::printFLN(Com::tTower3,offz);
Printer::setAutolevelActive(oldAuto);
PrintLine::moveRelativeDistanceInSteps(0, 0, Printer::axisStepsPerMM[Z_AXIS] * -ENDSTOP_Z_BACK_MOVE, 0, Printer::homingFeedrate[Z_AXIS] / ENDSTOP_X_RETEST_REDUCTION_FACTOR, true, false);
Printer::homeAxis(true,true,true);
}
break;
case 134: // G134
case 135: // G135
Com::printF(PSTR("CompDelta:"),Printer::currentDeltaPositionSteps[A_TOWER]);
Com::printF(Com::tComma,Printer::currentDeltaPositionSteps[B_TOWER]);
Com::printFLN(Com::tComma,Printer::currentDeltaPositionSteps[C_TOWER]);
@ -1389,6 +1446,31 @@ void Commands::processGCode(GCode *com)
break;
#endif // DRIVE_SYSTEM
#if FEATURE_Z_PROBE
case 134: // - G134 Px Sx Zx - Calibrate nozzle height difference (need z probe in nozzle!) Px = reference extruder, Sx = only measure extrude x against reference, Zx = add to measured z distance for Sx for correction.
{
float z = com->hasZ() ? com->Z : 0;
int p = com->hasP() ? com->P : 0;
int s = com->hasS() ? com->S : -1;
extruder[p].zOffset = 0;
Extruder::selectExtruderById(p);
float refHeight = Printer::runZProbe(true,false,true);
for(int i = 0;i < NUM_EXTRUDER;i++) {
if(i == p) continue;
if(s >= 0 && i != s) continue;
extruder[i].zOffset = 0;
Extruder::selectExtruderById(i);
float height = Printer::runZProbe(false,false);
extruder[i].zOffset = (height - refHeight + z)*Printer::axisStepsPerMM[Z_AXIS];
}
Extruder::selectExtruderById(p);
Printer::runZProbe(false,true);
#if EEPROM_MODE != 0
EEPROM::storeDataIntoEEPROM(0);
#endif
}
break;
#endif
#if defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS > 0
case 201:
commandG201(*com);
@ -1417,13 +1499,56 @@ void Commands::processGCode(GCode *com)
*/
void Commands::processMCode(GCode *com)
{
uint32_t codenum; //throw away variable
switch( com->M )
{
case 3: // Spindle/laser on
#if defined(SUPPORT_LASER) && SUPPORT_LASER
if(Printer::mode == PRINTER_MODE_LASER) {
if(com->hasS())
LaserDriver::intensity = constrain(com->S,0,255);
LaserDriver::laserOn = true;
Com::printFLN(PSTR("LaserOn:"),(int)LaserDriver::intensity);
}
#endif // defined
#if defined(SUPPORT_CNC) && SUPPORT_CNC
if(Printer::mode == PRINTER_MODE_CNC) {
waitUntilEndOfAllMoves();
CNCDriver::spindleOnCW(com->hasS() ? com->S : 0);
}
#endif // defined
break;
case 4: // Spindle CCW
#if defined(SUPPORT_CNC) && SUPPORT_CNC
if(Printer::mode == PRINTER_MODE_CNC) {
waitUntilEndOfAllMoves();
CNCDriver::spindleOnCCW(com->hasS() ? com->S : 0);
}
#endif // defined
break;
case 5: // Spindle/laser off
#if defined(SUPPORT_LASER) && SUPPORT_LASER
if(Printer::mode == PRINTER_MODE_LASER) {
LaserDriver::laserOn = false;
}
#endif // defined
#if defined(SUPPORT_CNC) && SUPPORT_CNC
if(Printer::mode == PRINTER_MODE_CNC) {
waitUntilEndOfAllMoves();
CNCDriver::spindleOff();
}
#endif // defined
break;
#if SDSUPPORT
case 20: // M20 - list SD card
#if JSON_OUTPUT
if (com->hasString() && com->text[1] == '2') { // " S2 P/folder"
if (com->text[3] == 'P') {
sd.lsJSON(com->text + 4);
}
} else sd.ls();
#else
sd.ls();
#endif
break;
case 21: // M21 - init SD card
sd.mount();
@ -1473,6 +1598,13 @@ void Commands::processMCode(GCode *com)
sd.makeDirectory(com->text);
}
break;
#endif
#if JSON_OUTPUT && SDSUPPORT
case 36: // M36 JSON File Info
if (com->hasString()) {
sd.JSONFileInfo(com->text);
}
break;
#endif
case 42: //M42 -Change pin status via gcode
if (com->hasP())
@ -1687,9 +1819,10 @@ void Commands::processMCode(GCode *com)
previousMillisCmd = HAL::timeInMilliseconds();
break;
case 190: // M190 - Wait bed for heater to reach target.
{
#if HAVE_HEATED_BED
if(Printer::debugDryrun()) break;
UI_STATUS_UPD(UI_TEXT_HEATING_BED);
UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_HEATING_BED_ID));
Commands::waitUntilEndOfAllMoves();
#if HAVE_HEATED_BED
if (com->hasS()) Extruder::setHeatedBedTemperature(com->S,com->hasF() && com->F > 0);
@ -1697,6 +1830,7 @@ void Commands::processMCode(GCode *com)
if(abs(heatedBedController.currentTemperatureC - heatedBedController.targetTemperatureC) < SKIP_M190_IF_WITHIN) break;
#endif
EVENT_WAITING_HEATER(-1);
uint32_t codenum; //throw away variable
codenum = HAL::timeInMilliseconds();
while(heatedBedController.currentTemperatureC + 0.5 < heatedBedController.targetTemperatureC && heatedBedController.targetTemperatureC > 25.0)
{
@ -1712,7 +1846,9 @@ void Commands::processMCode(GCode *com)
#endif
UI_CLEAR_STATUS;
previousMillisCmd = HAL::timeInMilliseconds();
}
break;
#if NUM_TEMPERATURE_LOOPS > 0
case 116: // Wait for temperatures to reach target temperature
for(fast8_t h = 0; h < NUM_TEMPERATURE_LOOPS; h++)
{
@ -1721,42 +1857,48 @@ void Commands::processMCode(GCode *com)
EVENT_HEATING_FINISHED(h < NUM_EXTRUDER ? h : -1);
}
break;
#endif
#if FAN_PIN>-1 && FEATURE_FAN_CONTROL
case 106: // M106 Fan On
if(!(Printer::flag2 & PRINTER_FLAG2_IGNORE_M106_COMMAND))
{
setFanSpeed(com->hasS() ? com->S : 255, com->hasP());
if(com->hasP() && com->P == 1)
setFan2Speed(com->hasS() ? com->S : 255);
else
setFanSpeed(com->hasS() ? com->S : 255);
}
break;
case 107: // M107 Fan Off
setFanSpeed(0, com->hasP());
if(com->hasP() && com->P == 1)
setFan2Speed(0);
else
setFanSpeed(0);
break;
#endif
case 111: // M111 enable/disable run time debug flags
if(com->hasS()) Printer::debugLevel = com->S;
if(com->hasS()) Printer::setDebugLevel(static_cast<uint8_t>(com->S));
if(com->hasP())
{
if (com->P > 0) Printer::debugLevel |= com->P;
else Printer::debugLevel &= ~(-com->P);
if (com->P > 0) Printer::debugSet(static_cast<uint8_t>(com->P));
else Printer::debugReset(static_cast<uint8_t>(-com->P));
}
if(Printer::debugDryrun()) // simulate movements without printing
{
Extruder::setTemperatureForExtruder(0, 0);
#if NUM_EXTRUDER>1
#if NUM_EXTRUDER > 1
for(uint8_t i = 0; i < NUM_EXTRUDER; i++)
Extruder::setTemperatureForExtruder(0, i);
#else
Extruder::setTemperatureForExtruder(0, 0);
#endif
#if HEATED_BED_TYPE!=0
target_bed_raw = 0;
#if HAVE_HEATED_BED != 0
Extruder::setHeatedBedTemperature(0,false);
#endif
}
break;
case 115: // M115
Com::printFLN(Com::tFirmware);
reportPrinterUsage();
Printer::reportPrinterMode();
break;
case 114: // M114
printCurrentPosition(PSTR("M114 "));
@ -1783,6 +1925,7 @@ void Commands::processMCode(GCode *com)
case 163: // M163 S<extruderNum> P<weight> - Set weight for this mixing extruder drive
if(com->hasS() && com->hasP() && com->S < NUM_EXTRUDER && com->S >= 0)
Extruder::setMixingWeight(com->S, com->P);
Extruder::recomputeMixingExtruderSteps();
break;
case 164: /// M164 S<virtNum> P<0 = dont store eeprom,1 = store to eeprom> - Store weights as virtual extruder S
if(!com->hasS() || com->S < 0 || com->S >= VIRTUAL_EXTRUDER) break; // ignore illigal values
@ -1847,8 +1990,8 @@ void Commands::processMCode(GCode *com)
TemperatureController *temp = &Extruder::current->tempControl;
if(com->hasS())
{
if(com->S<0) break;
if(com->S<NUM_EXTRUDER) temp = &extruder[com->S].tempControl;
if(com->S < 0) break;
if(com->S < NUM_EXTRUDER) temp = &extruder[com->S].tempControl;
#if HAVE_HEATED_BED
else temp = &heatedBedController;
#else
@ -1894,6 +2037,22 @@ void Commands::processMCode(GCode *com)
case 221: // M221 S<Extrusion flow multiplier in percent>
changeFlowrateMultiply(com->getS(100));
break;
case 228: // M228 P<pin> S<state 0/1> - Wait for pin getting state S
if(!com->hasS() || !com->hasP())
break;
{
bool comp = com->S;
if(com->hasX()) {
if(com->X == 0)
HAL::pinMode(com->S,INPUT);
else
HAL::pinMode(com->S,INPUT_PULLUP);
}
do {
Commands::checkForPeriodicalActions(true);
} while(HAL::digitalRead(com->P) != comp);
}
break;
#if USE_ADVANCE
case 223: // M223 Extruder interrupt test
if(com->hasS())
@ -1909,10 +2068,10 @@ void Commands::processMCode(GCode *com)
#endif
Com::printFLN(Com::tCommaSpeedEqual,maxadvspeed);
#if ENABLE_QUADRATIC_ADVANCE
maxadv=0;
maxadv = 0;
#endif
maxadv2=0;
maxadvspeed=0;
maxadv2 = 0;
maxadvspeed = 0;
break;
#endif
#if USE_ADVANCE
@ -2088,6 +2247,38 @@ void Commands::processMCode(GCode *com)
case 402: // M402 Go to stored position
Printer::GoToMemoryPosition(com->hasX(),com->hasY(),com->hasZ(),com->hasE(),(com->hasF() ? com->F : Printer::feedrate));
break;
#if JSON_OUTPUT
case 408:
Printer::showJSONStatus(com->hasS() ? static_cast<int>(com->S) : 0);
break;
#endif
case 450:
Printer::reportPrinterMode();
break;
case 451:
Printer::mode = PRINTER_MODE_FFF;
Printer::reportPrinterMode();
break;
case 452:
#if defined(SUPPORT_LASER) && SUPPORT_LASER
Printer::mode = PRINTER_MODE_LASER;
#endif
Printer::reportPrinterMode();
break;
case 453:
#if defined(SUPPORT_CNC) && SUPPORT_CNC
Printer::mode = PRINTER_MODE_CNC;
#endif
Printer::reportPrinterMode();
break;
#if FAN_THERMO_PIN > -1
case 460: // M460 X<minTemp> Y<maxTemp> : Set temperature range for thermo controlled fan
if(com->hasX())
Printer::thermoMinTemp = com->X;
if(com->hasY())
Printer::thermoMaxTemp = com->Y;
break;
#endif
case 500: // M500
{
#if EEPROM_MODE != 0
@ -2251,6 +2442,31 @@ void Commands::processMCode(GCode *com)
dacCommitEeprom();
#endif
break;
#if 0 && UI_DISPLAY_TYPE != NO_DISPLAY
// some debuggingcommands normally disabled
case 888:
Com::printFLN(PSTR("Selected language:"),(int)Com::selectedLanguage);
Com::printF(PSTR("Translation:"));
Com::printFLN(Com::translatedF(0));
break;
case 889:
uid.showLanguageSelectionWizard();
break;
case 890:
{
if(com->hasX() && com->hasY()) {
float c = Printer::bendingCorrectionAt(com->X,com->Y);
Com::printF(PSTR("Bending at ("),com->X);
Com::printF(PSTR(","),com->Y);
Com::printFLN(PSTR(") = "),c);
}
}
break;
case 891:
if(com->hasS())
EEPROM::setVersion(com->S);
break;
#endif
default:
if(!EVENT_UNHANDLED_M_CODE(com) && Printer::debugErrors())
{
@ -2291,6 +2507,14 @@ void Commands::executeGCode(GCode *com)
com->printCommand();
}
}
#ifdef DEBUG_DRYRUN_ERROR
if(Printer::debugDryrun()) {
Com::printFLN("Dryrun was enabled");
com->printCommand();
Printer::debugReset(8);
}
#endif
}
void Commands::emergencyStop()
@ -2303,7 +2527,7 @@ void Commands::emergencyStop()
Extruder::manageTemperatures();
for(uint8_t i = 0; i < NUM_EXTRUDER + 3; i++)
pwm_pos[i] = 0;
#if EXT0_HEATER_PIN > -1
#if EXT0_HEATER_PIN > -1 && NUM_EXTRUDER > 0
WRITE(EXT0_HEATER_PIN,HEATER_PINS_INVERTED);
#endif
#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN > -1 && NUM_EXTRUDER > 1
@ -2324,10 +2548,10 @@ void Commands::emergencyStop()
#if FAN_PIN > -1 && FEATURE_FAN_CONTROL
WRITE(FAN_PIN, 0);
#endif
#if HEATED_BED_HEATER_PIN > -1
#if HAVE_HEATED_BED && HEATED_BED_HEATER_PIN > -1
WRITE(HEATED_BED_HEATER_PIN, HEATER_PINS_INVERTED);
#endif
UI_STATUS_UPD(UI_TEXT_KILLED);
UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_KILLED_ID));
HAL::delayMilliseconds(200);
InterruptProtectedBlock noInts;
while(1) {}
@ -2349,5 +2573,3 @@ void Commands::writeLowestFreeRAM()
Com::printFLN(Com::tFreeRAM, lowestRAMValue);
}
}

View file

@ -37,7 +37,8 @@ public:
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 setFanSpeed(int speed, bool immediately = false); /// Set fan speed 0..255
static void setFan2Speed(int speed); /// Set fan speed 0..255
static void changeFeedrateMultiply(int factorInPercent);
static void changeFlowrateMultiply(int factorInPercent);
static void reportPrinterUsage();
@ -50,5 +51,3 @@ private:
};
#endif // COMMANDS_H_INCLUDED

View file

@ -21,15 +21,23 @@
#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")
#if UI_DISPLAY_TYPE != NO_DISPLAY
uint8_t Com::selectedLanguage;
#endif
#ifndef MACHINE_TYPE
#if DRIVE_SYSTEM == DELTA
#define MACHINE_TYPE "Delta"
#elif DRIVE_SYSTEM == CARTESIAN
#define MACHINE_TYPE "Mendel"
#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
#define MACHINE_TYPE "Core_XY"
#endif
#endif
#ifndef FIRMWARE_URL
#define FIRMWARE_URL "https://github.com/repetier/Repetier-Firmware/"
#endif // FIRMWARE_URL
FSTRINGVALUE(Com::tFirmware,"FIRMWARE_NAME:Repetier_" REPETIER_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:1.0 MACHINE_TYPE:" MACHINE_TYPE " EXTRUDER_COUNT:" XSTR(NUM_EXTRUDER) " REPETIER_PROTOCOL:3")
FSTRINGVALUE(Com::tDebug,"Debug:")
FSTRINGVALUE(Com::tOk,"ok")
FSTRINGVALUE(Com::tNewline,"\r\n")
@ -83,9 +91,23 @@ FSTRINGVALUE(Com::tSpaceRaw," RAW")
FSTRINGVALUE(Com::tColon,":")
FSTRINGVALUE(Com::tSlash,"/")
FSTRINGVALUE(Com::tSpaceSlash," /")
#if JSON_OUTPUT
FSTRINGVALUE(Com::tJSONDir,"{\"dir\":\"")
FSTRINGVALUE(Com::tJSONFiles,"\",\"files\":[")
FSTRINGVALUE(Com::tJSONArrayEnd,"]}")
FSTRINGVALUE(Com::tJSONErrorStart,"{\"err\":\"")
FSTRINGVALUE(Com::tJSONErrorEnd,"\"}")
FSTRINGVALUE(Com::tJSONFileInfoStart, "{\"err\":0,\"size\":");
FSTRINGVALUE(Com::tJSONFileInfoHeight, ",\"height\":");
FSTRINGVALUE(Com::tJSONFileInfoLayerHeight, ",\"layerHeight\":");
FSTRINGVALUE(Com::tJSONFileInfoFilament, ",\"filament\":[");
FSTRINGVALUE(Com::tJSONFileInfoGeneratedBy, "],\"generatedBy\":\"");
FSTRINGVALUE(Com::tJSONFileInfoName, ",\"fileName\":\"");
#endif // JSON_OUTPUT
FSTRINGVALUE(Com::tSpeedMultiply,"SpeedMultiply:")
FSTRINGVALUE(Com::tFlowMultiply,"FlowMultiply:")
FSTRINGVALUE(Com::tFanspeed,"Fanspeed:")
FSTRINGVALUE(Com::tFan2speed,"Fanspeed2:")
FSTRINGVALUE(Com::tPrintedFilament,"Printed filament:")
FSTRINGVALUE(Com::tPrintingTime,"Printing time:")
FSTRINGVALUE(Com::tSpacem,"m ")
@ -122,7 +144,6 @@ 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")
@ -235,6 +256,7 @@ FSTRINGVALUE(Com::tWait,WAITING_IDENTIFIER)
#if EEPROM_MODE == 0
FSTRINGVALUE(Com::tNoEEPROMSupport,"No EEPROM support compiled.\r\n")
#else
FSTRINGVALUE(Com::tZProbeOffsetZ, "Coating thickness [mm]")
#if FEATURE_Z_PROBE
FSTRINGVALUE(Com::tZProbeHeight,"Z-probe height [mm]")
FSTRINGVALUE(Com::tZProbeBedDitance,"Max. z-probe - bed dist. [mm]")
@ -242,12 +264,15 @@ 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")
FSTRINGVALUE(Com::tZProbeX1,"Z-probe X1 [mm]")
FSTRINGVALUE(Com::tZProbeY1,"Z-probe Y1 [mm]")
FSTRINGVALUE(Com::tZProbeX2,"Z-probe X2 [mm]")
FSTRINGVALUE(Com::tZProbeY2,"Z-probe Y2 [mm]")
FSTRINGVALUE(Com::tZProbeX3,"Z-probe X3 [mm]")
FSTRINGVALUE(Com::tZProbeY3,"Z-probe Y3 [mm]")
FSTRINGVALUE(Com::zZProbeBendingCorA,"Z-probe bending correction A [mm]")
FSTRINGVALUE(Com::zZProbeBendingCorB,"Z-probe bending correction B [mm]")
FSTRINGVALUE(Com::zZProbeBendingCorC,"Z-probe bending correction C [mm]")
#endif
#if FEATURE_AXISCOMP
FSTRINGVALUE(Com::tAxisCompTanXY,"tanXY Axis Compensation")
@ -267,6 +292,7 @@ FSTRINGVALUE(Com::tEPR1,"EPR:1 ")
FSTRINGVALUE(Com::tEPR2,"EPR:2 ")
FSTRINGVALUE(Com::tEPR3,"EPR:3 ")
FSTRINGVALUE(Com::tEPRBaudrate,"Baudrate")
FSTRINGVALUE(Com::tLanguage,"Language")
FSTRINGVALUE(Com::tEPRFilamentPrinted,"Filament printed [m]")
FSTRINGVALUE(Com::tEPRPrinterActive,"Printer active [s]")
FSTRINGVALUE(Com::tEPRMaxInactiveTime,"Max. inactive time [ms,0=off]")
@ -281,6 +307,7 @@ 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]")
FSTRINGVALUE(Com::tEPRAccelerationFactorAtTop,"Acceleration factor at top [%,100=like bottom]")
#if DRIVE_SYSTEM==DELTA
FSTRINGVALUE(Com::tEPRZAcceleration,"Acceleration [mm/s^2]")
FSTRINGVALUE(Com::tEPRZTravelAcceleration,"Travel acceleration [mm/s^2]")
@ -357,8 +384,8 @@ 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::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")
@ -401,6 +428,12 @@ FSTRINGVALUE(Com::tExtrDot,"Extr.")
FSTRINGVALUE(Com::tMCPEpromSettings, "MCP4728 DAC EEPROM Settings:")
FSTRINGVALUE(Com::tMCPCurrentSettings,"MCP4728 DAC Current Settings:")
#endif
FSTRINGVALUE(Com::tPrinterModeFFF,"PrinterMode:FFF")
FSTRINGVALUE(Com::tPrinterModeLaser,"PrinterMode:Laser")
FSTRINGVALUE(Com::tPrinterModeCNC,"PrinterMode:CNC")
#ifdef STARTUP_GCODE
FSTRINGVALUE(Com::tStartupGCode,STARTUP_GCODE)
#endif
void Com::config(FSTRINGPARAM(text)) {
printF(tConfig);
@ -590,4 +623,3 @@ void Com::printFloat(float number, uint8_t digits)
}
}

View file

@ -66,7 +66,20 @@ FSTRINGVAR(tUnknownCommand)
FSTRINGVAR(tFreeRAM)
FSTRINGVAR(tXColon)
FSTRINGVAR(tSlash)
FSTRINGVAR(tSpaceSlash)
FSTRINGVAR(tSpaceSlash)
#if JSON_OUTPUT
FSTRINGVAR(tJSONDir)
FSTRINGVAR(tJSONFiles)
FSTRINGVAR(tJSONArrayEnd)
FSTRINGVAR(tJSONErrorStart)
FSTRINGVAR(tJSONErrorEnd)
FSTRINGVAR(tJSONFileInfoStart)
FSTRINGVAR(tJSONFileInfoHeight)
FSTRINGVAR(tJSONFileInfoLayerHeight)
FSTRINGVAR(tJSONFileInfoFilament)
FSTRINGVAR(tJSONFileInfoGeneratedBy)
FSTRINGVAR(tJSONFileInfoName)
#endif
FSTRINGVAR(tSpaceXColon)
FSTRINGVAR(tSpaceYColon)
FSTRINGVAR(tSpaceZColon)
@ -82,6 +95,7 @@ FSTRINGVAR(tColon)
FSTRINGVAR(tSpeedMultiply)
FSTRINGVAR(tFlowMultiply)
FSTRINGVAR(tFanspeed)
FSTRINGVAR(tFan2speed)
FSTRINGVAR(tPrintedFilament)
FSTRINGVAR(tPrintingTime)
FSTRINGVAR(tSpacem)
@ -117,7 +131,6 @@ FSTRINGVAR(tCommaSpeedEqual)
FSTRINGVAR(tLinearLColon)
FSTRINGVAR(tQuadraticKColon)
FSTRINGVAR(tEEPROMUpdated)
FSTRINGVAR(tExtruderJam)
FSTRINGVAR(tFilamentSlipping)
FSTRINGVAR(tPauseCommunication)
FSTRINGVAR(tContinueCommunication)
@ -236,6 +249,7 @@ FSTRINGVAR(tWait)
#if EEPROM_MODE==0
FSTRINGVAR(tNoEEPROMSupport)
#else
FSTRINGVAR(tZProbeOffsetZ)
#if FEATURE_Z_PROBE
FSTRINGVAR(tZProbeHeight)
FSTRINGVAR(tZProbeOffsetX)
@ -248,6 +262,9 @@ FSTRINGVAR(tZProbeX2)
FSTRINGVAR(tZProbeY2)
FSTRINGVAR(tZProbeX3)
FSTRINGVAR(tZProbeY3)
FSTRINGVAR(zZProbeBendingCorA)
FSTRINGVAR(zZProbeBendingCorB)
FSTRINGVAR(zZProbeBendingCorC)
#endif
#if FEATURE_AUTOLEVEL
FSTRINGVAR(tAutolevelActive)
@ -265,6 +282,7 @@ FSTRINGVAR(tEPR0)
FSTRINGVAR(tEPR1)
FSTRINGVAR(tEPR2)
FSTRINGVAR(tEPR3)
FSTRINGVAR(tLanguage)
FSTRINGVAR(tEPRBaudrate)
FSTRINGVAR(tEPRFilamentPrinted)
FSTRINGVAR(tEPRPrinterActive)
@ -282,10 +300,11 @@ FSTRINGVAR(tEPRYBacklash)
FSTRINGVAR(tEPRZBacklash)
FSTRINGVAR(tEPRZAcceleration)
FSTRINGVAR(tEPRZTravelAcceleration)
FSTRINGVAR(tEPRAccelerationFactorAtTop)
FSTRINGVAR(tEPRZStepsPerMM)
FSTRINGVAR(tEPRZMaxFeedrate)
FSTRINGVAR(tEPRZHomingFeedrate)
#if DRIVE_SYSTEM!=DELTA
#if DRIVE_SYSTEM != DELTA
FSTRINGVAR(tEPRMaxZJerk)
FSTRINGVAR(tEPRXStepsPerMM)
FSTRINGVAR(tEPRYStepsPerMM)
@ -342,8 +361,8 @@ FSTRINGVAR(tEPRAdvanceK)
FSTRINGVAR(tEPRAdvanceL)
#endif
#if SDSUPPORT
FSTRINGVAR(tSDRemoved)
FSTRINGVAR(tSDInserted)
//FSTRINGVAR(tSDRemoved)
//FSTRINGVAR(tSDInserted)
FSTRINGVAR(tSDInitFail)
FSTRINGVAR(tErrorWritingToFile)
FSTRINGVAR(tBeginFileList)
@ -386,6 +405,12 @@ FSTRINGVAR(tExtrDot)
FSTRINGVAR(tMCPEpromSettings)
FSTRINGVAR(tMCPCurrentSettings)
#endif
FSTRINGVAR(tPrinterModeFFF)
FSTRINGVAR(tPrinterModeLaser)
FSTRINGVAR(tPrinterModeCNC)
#ifdef STARTUP_GCODE
FSTRINGVAR(tStartupGCode)
#endif
static void config(FSTRINGPARAM(text));
static void config(FSTRINGPARAM(text),int value);
@ -422,6 +447,11 @@ 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');}
#if UI_DISPLAY_TYPE != NO_DISPLAY
static const char* translatedF(int textId);
static void selectLanguage(fast8_t lang);
static uint8_t selectedLanguage;
#endif
protected:
private:
};
@ -444,5 +474,3 @@ static inline void println() {HAL::serialWriteByte('\r');HAL::serialWriteByte('\
#endif
#endif // COMMUNICATION_H

View file

@ -43,8 +43,17 @@
// ################## EDIT THESE SETTINGS MANUALLY ################
// ################ END MANUAL SETTINGS ##########################
#undef FAN_PIN
#define FAN_PIN -1
#undef FAN_BOARD_PIN
#define FAN_BOARD_PIN -1
#define FAN_THERMO_PIN -1
#define FAN_THERMO_MIN_PWM 128
#define FAN_THERMO_MAX_PWM 255
#define FAN_THERMO_MIN_TEMP 45
#define FAN_THERMO_MAX_TEMP 60
#define FAN_THERMO_THERMISTOR_PIN -1
#define FAN_THERMO_THERMISTOR_TYPE 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
@ -77,7 +86,7 @@
#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_PIN ORIG_E0_ENABLE_PIN
#define EXT0_ENABLE_ON 0
#define EXT0_MAX_FEEDRATE 50
#define EXT0_MAX_START_FEEDRATE 20
@ -112,7 +121,7 @@
#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_PIN ORIG_E1_ENABLE_PIN
#define EXT1_ENABLE_ON 0
#define EXT1_MAX_FEEDRATE 50
#define EXT1_MAX_START_FEEDRATE 20
@ -198,11 +207,60 @@
#define MIN_DEFECT_TEMPERATURE -10
#define MAX_DEFECT_TEMPERATURE 290
// ##########################################################################################
// ## Laser configuration ##
// ##########################################################################################
/*
If the firmware is in laser mode, it can control a laser output to cut or engrave materials.
Please use this feature only if you know about safety and required protection. Lasers are
dangerous and can hurt or make you blind!!!
The default laser driver only supports laser on and off. Here you control the eíntensity with
your feedrate. For exchangeable diode lasers this is normally enough. If you need more control
you can set the intensity in a range 0-255 with a custom extension to the driver. See driver.h
and comments on how to extend the functions non invasive with our event system.
If you have a laser - powder system you will like your E override. If moves contain a
increasing extruder position it will laser that move. With this trick you can
use existing fdm slicers to laser the output. Laser width is extrusion width.
Other tools may use M3 and M5 to enable/disable laser. Here G1/G2/G3 moves have laser enabled
and G0 moves have it disables.
In any case, laser only enables while moving. At the end of a move it gets
automatically disabled.
*/
#define SUPPORT_LASER 0
#define LASER_PIN -1
#define LASER_ON_HIGH 1
// ## CNC configuration ##
/*
If the firmware is in CNC mode, it can control a mill with M3/M4/M5. It works
similar to laser mode, but mill keeps enabled during G0 moves and it allows
setting rpm (only with event extension that supports this) and milling direction.
It also can add a delay to wait for spindle to run on full speed.
*/
#define SUPPORT_CNC 0
#define CNC_WAIT_ON_ENABLE 300
#define CNC_WAIT_ON_DISABLE 0
#define CNC_ENABLE_PIN -1
#define CNC_ENABLE_WITH 1
#define CNC_DIRECTION_PIN -1
#define CNC_DIRECTION_CW 1
#define DEFAULT_PRINTER_MODE 0
// ################ Endstop configuration #####################
#define ENDSTOP_PULLUP_X_MIN true
#define ENDSTOP_X_MIN_INVERTING true
#define MIN_HARDWARE_ENDSTOP_X true
#define ENDSTOP_X_MIN_INVERTING false
#define MIN_HARDWARE_ENDSTOP_X false
#define ENDSTOP_PULLUP_Y_MIN true
#define ENDSTOP_Y_MIN_INVERTING true
#define MIN_HARDWARE_ENDSTOP_Y true
@ -210,8 +268,8 @@
#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_X_MAX_INVERTING true
#define MAX_HARDWARE_ENDSTOP_X true
#define ENDSTOP_PULLUP_Y_MAX true
#define ENDSTOP_Y_MAX_INVERTING false
#define MAX_HARDWARE_ENDSTOP_Y false
@ -220,10 +278,10 @@
#define MAX_HARDWARE_ENDSTOP_Z true
#define max_software_endstop_r true
#define min_software_endstop_x false
#define min_software_endstop_x true
#define min_software_endstop_y false
#define min_software_endstop_z true
#define max_software_endstop_x true
#define max_software_endstop_x false
#define max_software_endstop_y true
#define max_software_endstop_z false
#define ENDSTOP_X_BACK_MOVE 5
@ -232,7 +290,7 @@
#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_X_BACK_ON_HOME 10
#define ENDSTOP_Y_BACK_ON_HOME 1
#define ENDSTOP_Z_BACK_ON_HOME 0
#define ALWAYS_CHECK_ENDSTOPS 0
@ -249,23 +307,27 @@
#define INVERT_X_DIR 0
#define INVERT_Y_DIR 0
#define INVERT_Z_DIR 0
#define X_HOME_DIR -1
#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_MAX_LENGTH 155
#define Y_MAX_LENGTH 155
#define Z_MAX_LENGTH 145
#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_POINTS 3
#define DISTORTION_CORRECTION_R 100
#define DISTORTION_PERMANENT 1
#define DISTORTION_PERMANENT 0
#define DISTORTION_UPDATE_FREQUENCY 15
#define DISTORTION_START_DEGRADE 0.5
#define DISTORTION_END_HEIGHT 1
#define DISTORTION_EXTRAPOLATE_CORNERS 0
#define DISTORTION_XMIN 0
#define DISTORTION_YMIN 0
#define DISTORTION_XMAX 155
#define DISTORTION_YMAX 155
// ##########################################################################################
// ## Movement settings ##
@ -312,6 +374,8 @@
#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 INTERPOLATE_ACCELERATION_WITH_Z 0
#define ACCELERATION_FACTOR_TOP 100
#define MAX_JERK 20
#define MAX_ZJERK 0.3
#define PRINTLINE_CACHE_SIZE 16
@ -320,15 +384,19 @@
#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 X2_ENABLE_PIN ORIG_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 Y2_ENABLE_PIN ORIG_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 Z2_ENABLE_PIN ORIG_E1_ENABLE_PIN
#define FEATURE_THREE_ZSTEPPER 0
#define Z3_STEP_PIN ORIG_E2_STEP_PIN
#define Z3_DIR_PIN ORIG_E2_DIR_PIN
#define Z3_ENABLE_PIN ORIG_E2_ENABLE_PIN
#define FEATURE_DITTO_PRINTING 0
#define USE_ADVANCE 0
#define ENABLE_QUADRATIC_ADVANCE 0
@ -343,8 +411,10 @@
#define ACK_WITH_LINENUMBER 1
#define WAITING_IDENTIFIER "wait"
#define ECHO_ON_EXECUTE 1
#define EEPROM_MODE 0
#define EEPROM_MODE 2
#undef PS_ON_PIN
#define PS_ON_PIN ORIG_PS_ON_PIN
#define JSON_OUTPUT 0
/* ======== Servos =======
Control the servos with
@ -379,20 +449,33 @@ WARNING: Servos can draw a considerable amount of current. Make sure your system
#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_SPEED 100
#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_HEIGHT 6.9
#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 Z_PROBE_X1 5
#define Z_PROBE_Y1 5
#define Z_PROBE_X2 150
#define Z_PROBE_Y2 5
#define Z_PROBE_X3 150
#define Z_PROBE_Y3 150
#define BED_LEVELING_METHOD 0
#define BED_CORRECTION_METHOD 0
#define BED_LEVELING_GRID_SIZE 5
#define BED_LEVELING_REPETITIONS 5
#define BED_MOTOR_1_X 0
#define BED_MOTOR_1_Y 0
#define BED_MOTOR_2_X 200
#define BED_MOTOR_2_Y 0
#define BED_MOTOR_3_X 100
#define BED_MOTOR_3_Y 200
#define BENDING_CORRECTION_A 0
#define BENDING_CORRECTION_B 0
#define BENDING_CORRECTION_C 0
#define FEATURE_AXISCOMP 0
#define AXISCOMP_TANXY 0
#define AXISCOMP_TANYZ 0
@ -400,6 +483,7 @@ WARNING: Servos can draw a considerable amount of current. Make sure your system
#ifndef SDSUPPORT // Some boards have sd support on board. These define the values already in pins.h
#define SDSUPPORT 0
#undef SDCARDDETECT
#define SDCARDDETECT -1
#define SDCARDDETECTINVERTED 0
#endif
@ -410,8 +494,19 @@ WARNING: Servos can draw a considerable amount of current. Make sure your system
#define FEATURE_MEMORY_POSITION 0
#define FEATURE_CHECKSUM_FORCED 0
#define FEATURE_FAN_CONTROL 0
#define FEATURE_FAN2_CONTROL 0
#define FEATURE_CONTROLLER 0
#define UI_LANGUAGE 0
#define LANGUAGE_EN_ACTIVE 1
#define LANGUAGE_DE_ACTIVE 1
#define LANGUAGE_NL_ACTIVE 1
#define LANGUAGE_PT_ACTIVE 1
#define LANGUAGE_IT_ACTIVE 1
#define LANGUAGE_ES_ACTIVE 1
#define LANGUAGE_SE_ACTIVE 1
#define LANGUAGE_FR_ACTIVE 1
#define LANGUAGE_CZ_ACTIVE 1
#define LANGUAGE_PL_ACTIVE 1
#define LANGUAGE_TR_ACTIVE 1
#define UI_PRINTER_NAME "RepRap"
#define UI_PRINTER_COMPANY "Home made"
#define UI_PAGES_DURATION 4000
@ -471,7 +566,7 @@ Values must be in range 1..255
"zStepsPerMM": 200,
"xInvert": 0,
"xInvertEnable": 0,
"eepromMode": 0,
"eepromMode": 2,
"yInvert": 0,
"yInvertEnable": 0,
"zInvert": 0,
@ -515,7 +610,7 @@ Values must be in range 1..255
"name": "Extruder 0",
"step": "ORIG_E0_STEP_PIN",
"dir": "ORIG_E0_DIR_PIN",
"enable": "E0_ENABLE_PIN"
"enable": "ORIG_E0_ENABLE_PIN"
},
"advanceBacklashSteps": 0,
"decoupleTestPeriod": 12,
@ -560,7 +655,7 @@ Values must be in range 1..255
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
"enable": "ORIG_E1_ENABLE_PIN"
},
"advanceBacklashSteps": 0,
"decoupleTestPeriod": 12,
@ -570,10 +665,10 @@ Values must be in range 1..255
],
"uiLanguage": 0,
"uiController": 0,
"xMinEndstop": 1,
"xMinEndstop": 0,
"yMinEndstop": 1,
"zMinEndstop": 0,
"xMaxEndstop": 0,
"xMaxEndstop": 1,
"yMaxEndstop": 0,
"zMaxEndstop": 1,
"motherboard": 33,
@ -617,18 +712,18 @@ Values must be in range 1..255
"xMinPos": 0,
"yMinPos": 0,
"zMinPos": 0,
"xLength": 200,
"yLength": 180,
"zLength": 135,
"xLength": 155,
"yLength": 155,
"zLength": 145,
"alwaysCheckEndstops": "0",
"disableX": "0",
"disableY": "0",
"disableZ": "0",
"disableE": "0",
"xHomeDir": "-1",
"xHomeDir": "1",
"yHomeDir": "-1",
"zHomeDir": "1",
"xEndstopBack": 1,
"xEndstopBack": 10,
"yEndstopBack": 1,
"zEndstopBack": 0,
"deltaSegmentsPerSecondPrint": 180,
@ -673,21 +768,28 @@ Values must be in range 1..255
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
"enable": "ORIG_E1_ENABLE_PIN"
},
"mirrorY": 0,
"mirrorYMotor": {
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
"enable": "ORIG_E1_ENABLE_PIN"
},
"mirrorZ": 0,
"mirrorZMotor": {
"name": "Extruder 1",
"step": "ORIG_E1_STEP_PIN",
"dir": "ORIG_E1_DIR_PIN",
"enable": "E1_ENABLE_PIN"
"enable": "ORIG_E1_ENABLE_PIN"
},
"mirrorZ3": "0",
"mirrorZ3Motor": {
"name": "Extruder 2",
"step": "ORIG_E2_STEP_PIN",
"dir": "ORIG_E2_DIR_PIN",
"enable": "ORIG_E2_ENABLE_PIN"
},
"dittoPrinting": "0",
"featureServos": "0",
@ -766,17 +868,20 @@ Values must be in range 1..255
"userTable0": {
"r1": 0,
"r2": 4700,
"temps": []
"temps": [],
"numEntries": 0
},
"userTable1": {
"r1": 0,
"r2": 4700,
"temps": []
"temps": [],
"numEntries": 0
},
"userTable2": {
"r1": 0,
"r2": 4700,
"temps": []
"temps": [],
"numEntries": 0
},
"tempHysteresis": 0,
"pidControlRange": 20,
@ -792,6 +897,15 @@ Values must be in range 1..255
"sdExtendedDir": "1",
"featureFanControl": "0",
"fanPin": -1,
"featureFan2Control": "0",
"fan2Pin": "ORIG_FAN2_PIN",
"fanThermoPin": -1,
"fanThermoMinPWM": 128,
"fanThermoMaxPWM": 255,
"fanThermoMinTemp": 45,
"fanThermoMaxTemp": 60,
"fanThermoThermistorPin": -1,
"fanThermoThermistorType": 1,
"scalePidToMax": 0,
"zProbePin": "ORIG_Z_MIN_PIN",
"zProbeBedDistance": 10,
@ -800,18 +914,18 @@ Values must be in range 1..255
"zProbeXOffset": 6.4,
"zProbeYOffset": 0,
"zProbeWaitBeforeTest": "0",
"zProbeSpeed": 8,
"zProbeSpeed": 100,
"zProbeXYSpeed": 150,
"zProbeHeight": 7.4,
"zProbeHeight": 6.9,
"zProbeStartScript": "",
"zProbeFinishedScript": "",
"featureAutolevel": "1",
"zProbeX1": 20,
"zProbeY1": 20,
"zProbeX2": 160,
"zProbeY2": 20,
"zProbeX3": 100,
"zProbeY3": 160,
"zProbeX1": 5,
"zProbeY1": 5,
"zProbeX2": 150,
"zProbeY2": 5,
"zProbeX3": 150,
"zProbeY3": 150,
"zProbeSwitchingDistance": 1,
"zProbeRepetitions": 1,
"sdSupport": "0",
@ -849,13 +963,17 @@ Values must be in range 1..255
"pauseStartCommands": "",
"pauseEndCommands": "",
"distortionCorrection": "0",
"distortionCorrectionPoints": 5,
"distortionCorrectionPoints": 3,
"distortionCorrectionR": 100,
"distortionPermanent": "1",
"distortionPermanent": "0",
"distortionUpdateFrequency": 15,
"distortionStartDegrade": 0.5,
"distortionEndDegrade": 1,
"distortionExtrapolateCorners": "0",
"distortionXMin": 0,
"distortionXMax": 155,
"distortionYMin": 0,
"distortionYMax": 155,
"sdRunOnStop": "",
"sdStopHeaterMotorsOnStop": "1",
"featureRetraction": "0",
@ -966,6 +1084,46 @@ Values must be in range 1..255
"zProbeZOffsetMode": 0,
"zProbeZOffset": 0,
"uiBedCoating": "1",
"langEN": "1",
"langDE": "1",
"langNL": "1",
"langPT": "1",
"langIT": "1",
"langES": "1",
"langSE": "1",
"langFR": "1",
"langCZ": "1",
"langPL": "1",
"langTR": "1",
"interpolateAccelerationWithZ": 0,
"accelerationFactorTop": 100,
"bendingCorrectionA": 0,
"bendingCorrectionB": 0,
"bendingCorrectionC": 0,
"preventZDisableOnStepperTimeout": "0",
"supportLaser": "0",
"laserPin": -1,
"laserOnHigh": "1",
"defaultPrinterMode": 0,
"supportCNC": "0",
"cncWaitOnEnable": 300,
"cncWaitOnDisable": 0,
"cncEnablePin": -1,
"cncEnableWith": "1",
"cncDirectionPin": -1,
"cncDirectionCW": "1",
"startupGCode": "",
"jsonOutput": "0",
"bedLevelingMethod": 0,
"bedCorrectionMethod": 0,
"bedLevelingGridSize": 5,
"bedLevelingRepetitions": 5,
"bedMotor1X": 0,
"bedMotor1Y": 0,
"bedMotor2X": 200,
"bedMotor2Y": 0,
"bedMotor3X": 100,
"bedMotor3Y": 200,
"hasMAX6675": false,
"hasMAX31855": false,
"hasGeneric1": false,
@ -975,7 +1133,7 @@ Values must be in range 1..255
"hasUser1": false,
"hasUser2": false,
"numExtruder": 2,
"version": 92.4,
"version": 92.8,
"primaryPortName": ""
}
========== End configuration string ==========

View file

@ -1,102 +1,215 @@
#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
#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
#if defined(SUPPORT_LASER) && SUPPORT_LASER
uint8_t LaserDriver::intensity = 255; // Intensity to use for next move queued if we want lasers. This is NOT the current value!
bool LaserDriver::laserOn = false;
void LaserDriver::initialize()
{
if(EVENT_INITALIZE_LASER)
{
#if LASER_PIN > -1
SET_OUTPUT(LASER_PIN);
#endif
}
changeIntensity(0);
}
void LaserDriver::changeIntensity(uint8_t newIntensity)
{
if(EVENT_SET_LASER(newIntensity))
{
// Default implementation
#if LASER_PIN > -1
WRITE(LASER_PIN,(LASER_ON_HIGH ? newIntensity > 199 : newIntensity < 200));
#endif
}
}
#endif // SUPPORT_LASER
#if defined(SUPPORT_CNC) && SUPPORT_CNC
/**
The CNC driver differs a bit from laser driver. Here only M3,M4,M5 have an influence on the spindle.
The motor also keeps running for G0 moves. M3 and M4 wait for old moves to be finished and then enables
the motor. It then waits CNC_WAIT_ON_ENABLE milliseconds for the spindle to reach target speed.
*/
int8_t CNCDriver::direction = 0;
/** Initialize cnc pins. EVENT_INITALIZE_CNC should return false to prevent default initalization.*/
void CNCDriver::initialize()
{
if(EVENT_INITALIZE_CNC)
{
#if CNC_ENABLE_PIN > -1
SET_OUTPUT(CNC_ENABLE_PIN);
WRITE(CNC_ENABLE_PIN,!CNC_ENABLE_WITH);
#endif
#if CNC_DIRECTION_PIN > -1
SET_OUTPUT(CNC_DIRECTION_PIN);
#endif
}
}
/** Turns off spindle. For event override implement
EVENT_SPINDLE_OFF
returning false.
*/
void CNCDriver::spindleOff()
{
if(direction == 0) return; // already off
if(EVENT_SPINDLE_OFF)
{
#if CNC_ENABLE_PIN > -1
WRITE(CNC_ENABLE_PIN,!CNC_ENABLE_WITH);
#endif
}
HAL::delayMilliseconds(CNC_WAIT_ON_DISABLE);
direction = 0;
}
/** Turns spindle on. Default implementation uses a enable pin CNC_ENABLE_PIN. If
CNC_DIRECTION_PIN is not -1 it sets direction to CNC_DIRECTION_CW. rpm is ignored.
To override with event system, return false for the event
EVENT_SPINDLE_CW(rpm)
*/
void CNCDriver::spindleOnCW(int32_t rpm)
{
if(direction == 1)
return;
spindleOff();
direction = 1;
if(EVENT_SPINDLE_CW(rpm)) {
#if CNC_DIRECTION_PIN > -1
WRITE(CNC_DIRECTION_PIN, CNC_DIRECTION_CW);
#endif
#if CNC_ENABLE_PIN > -1
WRITE(CNC_ENABLE_PIN, CNC_ENABLE_WITH);
#endif
}
HAL::delayMilliseconds(CNC_WAIT_ON_ENABLE);
}
/** Turns spindle on. Default implementation uses a enable pin CNC_ENABLE_PIN. If
CNC_DIRECTION_PIN is not -1 it sets direction to !CNC_DIRECTION_CW. rpm is ignored.
To override with event system, return false for the event
EVENT_SPINDLE_CCW(rpm)
*/
void CNCDriver::spindleOnCCW(int32_t rpm)
{
if(direction == -1)
return;
spindleOff();
direction = -1;
if(EVENT_SPINDLE_CW(rpm)) {
#if CNC_DIRECTION_PIN > -1
WRITE(CNC_DIRECTION_PIN, !CNC_DIRECTION_CW);
#endif
#if CNC_ENABLE_PIN > -1
WRITE(CNC_ENABLE_PIN, CNC_ENABLE_WITH);
#endif
}
HAL::delayMilliseconds(CNC_WAIT_ON_ENABLE);
}
#endif

View file

@ -20,7 +20,7 @@ the main code.
*/
class MotorDriverInterface
{
public:
public:
virtual void initialize() = 0;
virtual float getPosition() = 0;
virtual void setCurrentAs(float newPos) = 0;
@ -43,12 +43,12 @@ public:
{
stepsPerMM = _stepsPerMM;
delayUS = 500000 / (speed * stepsPerMM);
}
void initialize() {
}
void initialize() {
HAL::pinMode(enablePin, OUTPUT);
HAL::pinMode(stepPin, OUTPUT);
HAL::pinMode(dirPin, OUTPUT);
HAL::digitalWrite(enablePin, !invertEnable);
HAL::digitalWrite(enablePin, !invertEnable);
}
float getPosition()
{
@ -59,7 +59,7 @@ public:
position = floor(newPos * stepsPerMM + 0.5f);
}
void gotoPosition(float newPos)
{
{
enable();
int32_t target = floor(newPos * stepsPerMM + 0.5f) - position;
position += target;
@ -74,9 +74,9 @@ public:
HAL::delayMicroseconds(delayUS);
HAL::digitalWrite(stepPin, LOW);
HAL::delayMicroseconds(delayUS);
target--;
HAL::pingWatchdog();
if((target & 127) == 0)
target--;
HAL::pingWatchdog();
if((target & 127) == 0)
Commands::checkForPeriodicalActions(false);
}
}
@ -88,19 +88,66 @@ public:
{
HAL::digitalWrite(enablePin, !invertEnable);
}
};
#if defined(NUM_MOTOR_DRIVERS) && NUM_MOTOR_DRIVERS > 0
class GCode;
};
#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
extern void commandG204(GCode &code);
extern void disableAllMotorDrivers();
extern MotorDriverInterface *getMotorDriver(int idx);
extern void initializeAllMotorDrivers();
#endif
#if defined(SUPPORT_LASER) && SUPPORT_LASER
/**
With laser support you can exchange a extruder by a laser. A laser gets controlled by a digital pin.
By default all intensities > 200 are always on, and lower values are always off. You can overwrite
this with a programmed event EVENT_SET_LASER(intensity) that return false to signal the default
implementation that it has set it's value already.
EVENT_INITALIZE_LASER should return false to prevent default initialization.
*/
class LaserDriver {
public:
static uint8_t intensity; // Intensity to use for next move queued. This is NOT the current value!
static bool laserOn; // Enabled by M3?
static void initialize();
static void changeIntensity(uint8_t newIntensity);
};
#endif
#if defined(SUPPORT_CNC) && SUPPORT_CNC
/**
The CNC driver differs a bit from laser driver. Here only M3,M4,M5 have an influence on the spindle.
The motor also keeps running for G0 moves. M3 and M4 wait for old moves to be finished and then enables
the motor. It then waits CNC_WAIT_ON_ENABLE milliseconds for the spindle to reach target speed.
*/
class CNCDriver {
public:
static int8_t direction;
/** Initialize cnc pins. EVENT_INITALIZE_CNC should return false to prevent default initalization.*/
static void initialize();
/** Turns off spindle. For event override implement
EVENT_SPINDLE_OFF
returning false.
*/
static void spindleOff();
/** Turns spindle on. Default implementation uses a enable pin CNC_ENABLE_PIN. If
CNC_DIRECTION_PIN is not -1 it sets direction to CNC_DIRECTION_CW. rpm is ignored.
To override with event system, return false for the event
EVENT_SPINDLE_CW(rpm)
*/
static void spindleOnCW(int32_t rpm);
/** Turns spindle on. Default implementation uses a enable pin CNC_ENABLE_PIN. If
CNC_DIRECTION_PIN is not -1 it sets direction to !CNC_DIRECTION_CW. rpm is ignored.
To override with event system, return false for the event
EVENT_SPINDLE_CCW(rpm)
*/
static void spindleOnCCW(int32_t rpm);
};
#endif
#endif // DRIVERS_H_INCLUDED

View file

@ -232,7 +232,7 @@ void EEPROM::restoreEEPROMSettingsFromConfiguration()
e->advanceL = EXT3_ADVANCE_L;
#endif
#endif // NUM_EXTRUDER > 3
#if NUM_EXTRUDER>4
#if NUM_EXTRUDER > 4
e = &extruder[4];
e->stepsPerMM = EXT4_STEPS_PER_MM;
e->maxFeedrate = EXT4_MAX_FEEDRATE;
@ -262,7 +262,7 @@ void EEPROM::restoreEEPROMSettingsFromConfiguration()
e->advanceL = EXT4_ADVANCE_L;
#endif
#endif // NUM_EXTRUDER > 4
#if NUM_EXTRUDER>5
#if NUM_EXTRUDER > 5
e = &extruder[5];
e->stepsPerMM = EXT5_STEPS_PER_MM;
e->maxFeedrate = EXT5_MAX_FEEDRATE;
@ -385,6 +385,9 @@ void EEPROM::storeDataIntoEEPROM(uint8_t corrupted)
HAL::eprSetByte(EPR_AUTOLEVEL_ACTIVE,Printer::isAutolevelActive());
for(uint8_t i = 0; i < 9; i++)
HAL::eprSetFloat(EPR_AUTOLEVEL_MATRIX + (((int)i) << 2),Printer::autolevelTransformation[i]);
#endif
#if UI_DISPLAY_TYPE != NO_DISPLAY
HAL::eprSetByte(EPR_SELECTED_LANGUAGE,Com::selectedLanguage);
#endif
// now the extruder
for(uint8_t i = 0; i < NUM_EXTRUDER; i++)
@ -453,6 +456,7 @@ void EEPROM::initalizeUncached()
HAL::eprSetFloat(EPR_Z_PROBE_XY_SPEED,Z_PROBE_XY_SPEED);
HAL::eprSetFloat(EPR_Z_PROBE_X_OFFSET,Z_PROBE_X_OFFSET);
HAL::eprSetFloat(EPR_Z_PROBE_Y_OFFSET,Z_PROBE_Y_OFFSET);
HAL::eprSetFloat(EPR_Z_PROBE_Z_OFFSET,Z_PROBE_Z_OFFSET);
HAL::eprSetFloat(EPR_Z_PROBE_X1,Z_PROBE_X1);
HAL::eprSetFloat(EPR_Z_PROBE_Y1,Z_PROBE_Y1);
HAL::eprSetFloat(EPR_Z_PROBE_X2,Z_PROBE_X2);
@ -463,6 +467,7 @@ void EEPROM::initalizeUncached()
HAL::eprSetFloat(EPR_AXISCOMP_TANYZ,AXISCOMP_TANYZ);
HAL::eprSetFloat(EPR_AXISCOMP_TANXZ,AXISCOMP_TANXZ);
HAL::eprSetFloat(EPR_Z_PROBE_BED_DISTANCE,Z_PROBE_BED_DISTANCE);
Printer::zBedOffset = HAL::eprGetFloat(EPR_Z_PROBE_Z_OFFSET);
#if DRIVE_SYSTEM == DELTA
HAL::eprSetFloat(EPR_DELTA_DIAGONAL_ROD_LENGTH,DELTA_DIAGONAL_ROD);
HAL::eprSetFloat(EPR_DELTA_HORIZONTAL_RADIUS,ROD_RADIUS);
@ -495,6 +500,10 @@ void EEPROM::initalizeUncached()
HAL::eprSetFloat(EPR_RETRACTION_UNDO_EXTRA_LONG_LENGTH,RETRACTION_UNDO_EXTRA_LONG_LENGTH);
HAL::eprSetFloat(EPR_RETRACTION_UNDO_SPEED,RETRACTION_UNDO_SPEED);
HAL::eprSetByte(EPR_AUTORETRACT_ENABLED,AUTORETRACT_ENABLED);
HAL::eprSetFloat(EPR_BENDING_CORRECTION_A,BENDING_CORRECTION_A);
HAL::eprSetFloat(EPR_BENDING_CORRECTION_B,BENDING_CORRECTION_B);
HAL::eprSetFloat(EPR_BENDING_CORRECTION_C,BENDING_CORRECTION_C);
HAL::eprSetFloat(EPR_ACCELERATION_FACTOR_TOP,Z_ACCELERATION_TOP);
}
@ -502,6 +511,7 @@ void EEPROM::readDataFromEEPROM(bool includeExtruder)
{
#if EEPROM_MODE != 0
uint8_t version = HAL::eprGetByte(EPR_VERSION); // This is the saved version. Don't copy data not set in older versions!
//Com::printFLN(PSTR("Detected EEPROM version:"),(int)version);
baudrate = HAL::eprGetInt32(EPR_BAUDRATE);
maxInactiveTime = HAL::eprGetInt32(EPR_MAX_INACTIVE_TIME);
stepperInactiveTime = HAL::eprGetInt32(EPR_STEPPER_INACTIVE_TIME);
@ -705,6 +715,21 @@ void EEPROM::readDataFromEEPROM(bool includeExtruder)
HAL::eprSetFloat(EPR_RETRACTION_UNDO_SPEED,RETRACTION_UNDO_SPEED);
HAL::eprSetByte(EPR_AUTORETRACT_ENABLED,AUTORETRACT_ENABLED);
}
if(version < 14) {
HAL::eprSetFloat(EPR_Z_PROBE_Z_OFFSET,Z_PROBE_Z_OFFSET);
}
if(version < 15) {
HAL::eprSetByte(EPR_SELECTED_LANGUAGE, 254); // activate selector on startup
#if UI_DISPLAY_TYPE != NO_DISPLAY
Com::selectedLanguage = 254;
#endif
}
if(version < 16) {
HAL::eprSetFloat(EPR_BENDING_CORRECTION_A,BENDING_CORRECTION_A);
HAL::eprSetFloat(EPR_BENDING_CORRECTION_B,BENDING_CORRECTION_B);
HAL::eprSetFloat(EPR_BENDING_CORRECTION_C,BENDING_CORRECTION_C);
HAL::eprSetFloat(EPR_ACCELERATION_FACTOR_TOP,ACCELERATION_FACTOR_TOP);
}
/* if (version<8) {
#if DRIVE_SYSTEM==DELTA
// Prior to verion 8, the cartesian max was stored in the zmax
@ -723,6 +748,10 @@ void EEPROM::readDataFromEEPROM(bool includeExtruder)
storeDataIntoEEPROM(false); // Store new fields for changed version
}
Printer::zBedOffset = HAL::eprGetFloat(EPR_Z_PROBE_Z_OFFSET);
#if UI_DISPLAY_TYPE != NO_DISPLAY
Com::selectLanguage(HAL::eprGetByte(EPR_SELECTED_LANGUAGE));
#endif
Printer::updateDerivedParameter();
Extruder::initHeatedBed();
#endif
@ -733,7 +762,7 @@ void EEPROM::initBaudrate()
// Invariant - baudrate is intitalized with or without eeprom!
baudrate = BAUDRATE;
#if EEPROM_MODE != 0
if(HAL::eprGetByte(EPR_MAGIC_BYTE)==EEPROM_MODE)
if(HAL::eprGetByte(EPR_MAGIC_BYTE) == EEPROM_MODE)
{
baudrate = HAL::eprGetInt32(EPR_BAUDRATE);
}
@ -762,7 +791,7 @@ void EEPROM::init()
if(newcheck != HAL::eprGetByte(EPR_INTEGRITY_BYTE))
HAL::eprSetByte(EPR_INTEGRITY_BYTE,newcheck);
}
Com::printFLN(PSTR("EEprom baud rate restored from configuration."));
Com::printFLN(PSTR("EEPROM baud rate restored from configuration."));
Com::printFLN(PSTR("RECOMPILE WITH USE_CONFIGURATION_BAUD_RATE == 0 to alter baud rate via EEPROM"));
}
}
@ -805,6 +834,7 @@ With
void EEPROM::writeSettings()
{
#if EEPROM_MODE != 0
writeByte(EPR_SELECTED_LANGUAGE,Com::tLanguage);
writeLong(EPR_BAUDRATE, Com::tEPRBaudrate);
writeFloat(EPR_PRINTING_DISTANCE, Com::tEPRFilamentPrinted);
writeLong(EPR_PRINTING_TIME, Com::tEPRPrinterActive);
@ -852,6 +882,9 @@ void EEPROM::writeSettings()
#if DRIVE_SYSTEM == DELTA
writeFloat(EPR_Z_MAX_ACCEL, Com::tEPRZAcceleration);
writeFloat(EPR_Z_MAX_TRAVEL_ACCEL, Com::tEPRZTravelAcceleration);
#if defined(INTERPOLATE_ACCELERATION_WITH_Z) && INTERPOLATE_ACCELERATION_WITH_Z != 0
writeFloat(EPR_ACCELERATION_FACTOR_TOP, Com::tEPRAccelerationFactorAtTop);
#endif
writeFloat(EPR_DELTA_DIAGONAL_ROD_LENGTH, Com::tEPRDiagonalRodLength);
writeFloat(EPR_DELTA_HORIZONTAL_RADIUS, Com::tEPRHorizontalRadius);
writeFloat(EPR_DELTA_MAX_RADIUS, Com::tEPRDeltaMaxRadius);
@ -876,8 +909,12 @@ void EEPROM::writeSettings()
writeFloat(EPR_X_MAX_TRAVEL_ACCEL, Com::tEPRXTravelAcceleration);
writeFloat(EPR_Y_MAX_TRAVEL_ACCEL, Com::tEPRYTravelAcceleration);
writeFloat(EPR_Z_MAX_TRAVEL_ACCEL, Com::tEPRZTravelAcceleration);
#if defined(INTERPOLATE_ACCELERATION_WITH_Z) && INTERPOLATE_ACCELERATION_WITH_Z != 0
writeFloat(EPR_ACCELERATION_FACTOR_TOP, Com::tEPRAccelerationFactorAtTop);
#endif
#endif
#endif
writeFloat(EPR_Z_PROBE_Z_OFFSET, Com::tZProbeOffsetZ);
#if FEATURE_Z_PROBE
writeFloat(EPR_Z_PROBE_HEIGHT, Com::tZProbeHeight);
writeFloat(EPR_Z_PROBE_BED_DISTANCE, Com::tZProbeBedDitance);
@ -891,6 +928,9 @@ void EEPROM::writeSettings()
writeFloat(EPR_Z_PROBE_Y2, Com::tZProbeY2);
writeFloat(EPR_Z_PROBE_X3, Com::tZProbeX3);
writeFloat(EPR_Z_PROBE_Y3, Com::tZProbeY3);
writeFloat(EPR_BENDING_CORRECTION_A, Com::zZProbeBendingCorA);
writeFloat(EPR_BENDING_CORRECTION_B, Com::zZProbeBendingCorB);
writeFloat(EPR_BENDING_CORRECTION_C, Com::zZProbeBendingCorC);
#endif
#if FEATURE_AUTOLEVEL
writeByte(EPR_AUTOLEVEL_ACTIVE, Com::tAutolevelActive);
@ -1092,5 +1132,3 @@ void EEPROM::setZCorrection(int32_t c,int index)
#endif

View file

@ -20,7 +20,7 @@
#define _EEPROM_H
// Id to distinguish version changes
#define EEPROM_PROTOCOL_VERSION 13
#define EEPROM_PROTOCOL_VERSION 16
/** Where to start with our datablock in memory. Can be moved if you
have problems with other modules using the eeprom */
@ -112,15 +112,21 @@ have problems with other modules using the eeprom */
#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_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
#define EPR_RETRACTION_UNDO_SPEED 1016
#define EPR_AUTORETRACT_ENABLED 1020
#define EPR_Z_PROBE_Z_OFFSET 1024
#define EPR_SELECTED_LANGUAGE 1028
#define EPR_ACCELERATION_FACTOR_TOP 1032
#define EPR_BENDING_CORRECTION_A 1036
#define EPR_BENDING_CORRECTION_B 1040
#define EPR_BENDING_CORRECTION_C 1044
#if EEPROM_MODE != 0
#define EEPROM_FLOAT(x) HAL::eprGetFloat(EPR_##x)
@ -128,9 +134,9 @@ have problems with other modules using the eeprom */
#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_FLOAT(x) (float)(x)
#define EEPROM_INT32(x) (int32_t)(x)
#define EEPROM_BYTE(x) (uint8_t)(x)
#define EEPROM_SET_BYTE(x,val)
#endif
@ -189,7 +195,26 @@ public:
static void writeSettings();
static void update(GCode *com);
static void updatePrinterUsage();
static inline void setVersion(uint8_t v) {
#if EEPROM_MODE != 0
HAL::eprSetByte(EPR_VERSION,v);
HAL::eprSetByte(EPR_INTEGRITY_BYTE,computeChecksum());
#endif
}
static inline uint8_t getStoredLanguage() {
#if EEPROM_MODE != 0
return HAL::eprGetByte(EPR_SELECTED_LANGUAGE);
#else
return 0;
#endif
}
static inline float zProbeZOffset() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_Z_OFFSET);
#else
return Z_PROBE_Z_OFFSET;
#endif
}
static inline float zProbeSpeed() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_Z_PROBE_SPEED);
@ -516,7 +541,34 @@ static inline void setTowerZFloor(float newZ) {
return 0;
#endif
}
static inline float bendingCorrectionA() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_BENDING_CORRECTION_A);
#else
return BENDING_CORRECTION_A;
#endif
}
static inline float bendingCorrectionB() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_BENDING_CORRECTION_B);
#else
return BENDING_CORRECTION_B;
#endif
}
static inline float bendingCorrectionC() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_BENDING_CORRECTION_C);
#else
return BENDING_CORRECTION_C;
#endif
}
static inline float accelarationFactorTop() {
#if EEPROM_MODE != 0
return HAL::eprGetFloat(EPR_ACCELERATION_FACTOR_TOP);
#else
return ACCELERATION_FACTOR_TOP;
#endif
}
};
#endif

View file

@ -1,71 +1,84 @@
#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
#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) {}
// Called to initalize laser pins. Return false to prevent default initalization.
#define EVENT_INITALIZE_LASER true
// Set laser to intensity level 0 = off, 255 = full. Return false if you have overridden the setting routine.
// with true the default solution will set it as digital value.
#define EVENT_SET_LASER(intensity) true
// Called to initalize cnc pins. Return false to prevent default initalization.
#define EVENT_INITALIZE_CNC true
// Turn off spindle
#define EVENT_SPINDLE_OFF true
// Turn spindle clockwise
#define EVENT_SPINDLE_CW(rpm) true
// Turn spindle counter clockwise
#define EVENT_SPINDLE_CCW(rpm) true
// 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

View file

@ -66,11 +66,35 @@ void Extruder::manageTemperatures()
HAL::pingWatchdog();
#endif // FEATURE_WATCHDOG
uint8_t errorDetected = 0;
#ifdef RED_BLUE_STATUS_LEDS
bool hot = false;
#endif
bool newDefectFound = false;
millis_t time = HAL::timeInMilliseconds(); // compare time for decouple tests
#if NUM_TEMPERATURE_LOOPS > 0
for(uint8_t controller = 0; controller < NUM_TEMPERATURE_LOOPS; controller++)
{
TemperatureController *act = tempController[controller];
// Get Temperature
act->updateCurrentTemperature();
#if FAN_THERMO_PIN > -1
// Special case thermistor controlled fan
if(act == &thermoController) {
if(act->currentTemperatureC < Printer::thermoMinTemp)
pwm_pos[PWM_FAN_THERMO] = 0;
else if(act->currentTemperatureC > Printer::thermoMaxTemp)
pwm_pos[PWM_FAN_THERMO] = FAN_THERMO_MAX_PWM;
else {
// Interpolate target speed
float out = FAN_THERMO_MIN_PWM + (FAN_THERMO_MAX_PWM-FAN_THERMO_MIN_PWM) * (act->currentTemperatureC - Printer::thermoMinTemp) / (Printer::thermoMaxTemp - Printer::thermoMinTemp);
if(out > 255)
pwm_pos[PWM_FAN_THERMO] = FAN_THERMO_MAX_PWM;
else
pwm_pos[PWM_FAN_THERMO] = static_cast<uint8_t>(out);
}
continue;
}
#endif
// Handle automatic cooling of extruders
if(controller < NUM_EXTRUDER)
{
@ -87,25 +111,22 @@ void Extruder::manageTemperatures()
}
}
#if SHARED_COOLER_BOARD_EXT
if(pwm_pos[NUM_EXTRUDER + 1]) enable = true;
if(pwm_pos[PWM_BOARD_FAN]) enable = true;
#endif
extruder[0].coolerPWM = (enable ? extruder[0].coolerSpeed : 0);
}
} // controller == 0
#else
if(act->currentTemperatureC < EXTRUDER_FAN_COOL_TEMP && act->targetTemperatureC < EXTRUDER_FAN_COOL_TEMP)
extruder[controller].coolerPWM = 0;
else
extruder[controller].coolerPWM = extruder[controller].coolerSpeed;
#endif // NUM_EXTRUDER
}
} // extruder controller
// do skip temperature control while auto tuning is in progress
if(controller == autotuneIndex) continue;
#if MIXING_EXTRUDER
if(controller > 0 && controller < NUM_EXTRUDER) continue; // Mixing extruder only test for ext 0
#endif
// Get Temperature
act->updateCurrentTemperature();
#endif // MIXING_EXTRUDER
// Check for obvious sensor errors
@ -119,14 +140,36 @@ void Extruder::manageTemperatures()
act->flags |= TEMPERATURE_CONTROLLER_FLAG_SENSDEFECT;
if(!Printer::isAnyTempsensorDefect())
{
newDefectFound = true;
Printer::setAnyTempsensorDefect();
reportTempsensorError();
}
EVENT_HEATER_DEFECT(controller);
}
}
#if HAVE_HEATED_BED
else if(controller == NUM_EXTRUDER && Extruder::getHeatedBedTemperature() > HEATED_BED_MAX_TEMP + 5) {
errorDetected = 1;
if(extruderTempErrors < 10) // Ignore short temporary failures
extruderTempErrors++;
else
{
act->flags |= TEMPERATURE_CONTROLLER_FLAG_SENSDEFECT;
Com::printErrorFLN(PSTR("Heated bed exceeded max temperature!"));
if(!Printer::isAnyTempsensorDefect())
{
newDefectFound = true;
Printer::setAnyTempsensorDefect();
reportTempsensorError();
}
EVENT_HEATER_DEFECT(controller);
}
}
#endif // HAVE_HEATED_BED
#ifdef RED_BLUE_STATUS_LEDS
if(act->currentTemperatureC > 50)
hot = true;
#endif // RED_BLUE_STATUS_LEDS
if(Printer::isAnyTempsensorDefect()) continue;
uint8_t on = act->currentTemperatureC >= act->targetTemperatureC ? LOW : HIGH;
// Make a sound if alarm was set on reaching target temperature
@ -137,7 +180,7 @@ void Extruder::manageTemperatures()
}
// Run test if heater and sensor are decoupled
bool decoupleTestRequired = act->decoupleTestPeriod > 0 && (time - act->lastDecoupleTest) > act->decoupleTestPeriod; // time enough for temperature change?
bool decoupleTestRequired = !errorDetected && act->decoupleTestPeriod > 0 && (time - act->lastDecoupleTest) > act->decoupleTestPeriod; // time enough for temperature change?
if(decoupleTestRequired && act->isDecoupleFullOrHold() && Printer::isPowerOn()) // Only test when powered
{
if(act->isDecoupleFull()) // Phase 1: Heating fully until target range is reached
@ -149,7 +192,12 @@ void Extruder::manageTemperatures()
if(extruderTempErrors > 10) // Ignore short temporary failures
{
act->flags |= TEMPERATURE_CONTROLLER_FLAG_SENSDECOUPLED;
Printer::setAnyTempsensorDefect();
if(!Printer::isAnyTempsensorDefect())
{
Printer::setAnyTempsensorDefect();
newDefectFound = true;
}
UI_ERROR_P(Com::tHeaterDecoupled);
Com::printErrorFLN(Com::tHeaterDecoupledWarning);
Com::printF(PSTR("Error:Temp. raised to slow. Rise = "),act->currentTemperatureC - act->lastDecoupleTemp);
@ -173,7 +221,11 @@ void Extruder::manageTemperatures()
if(extruderTempErrors > 10) // Ignore short temporary failures
{
act->flags |= TEMPERATURE_CONTROLLER_FLAG_SENSDECOUPLED;
Printer::setAnyTempsensorDefect();
if(!Printer::isAnyTempsensorDefect())
{
Printer::setAnyTempsensorDefect();
newDefectFound = true;
}
UI_ERROR_P(Com::tHeaterDecoupled);
Com::printErrorFLN(Com::tHeaterDecoupledWarning);
Com::printF(PSTR("Error:Could not hold temperature "),act->lastDecoupleTemp);
@ -218,7 +270,7 @@ void Extruder::manageTemperatures()
pidTerm += dgain;
#if SCALE_PID_TO_MAX == 1
pidTerm = (pidTerm * act->pidMax) * 0.0039215;
#endif
#endif // SCALE_PID_TO_MAX
output = constrain((int)pidTerm, 0, act->pidMax);
}
else if(act->heatManager == HTR_DEADTIME) // dead-time control
@ -229,7 +281,7 @@ void Extruder::manageTemperatures()
output = (act->currentTemperatureC + act->tempIState * act->deadTime > act->targetTemperatureC ? 0 : act->pidDriveMax);
}
else // bang bang and slow bang bang
#endif
#endif // TEMP_PID
if(act->heatManager == HTR_SLOWBANG) // Bang-bang with reduced change frequency to save relais life
{
if (time - act->lastTemperatureUpdate > HEATED_BED_SET_INTERVAL)
@ -251,19 +303,22 @@ void Extruder::manageTemperatures()
#ifdef MAXTEMP
if(act->currentTemperatureC > MAXTEMP) // Force heater off if MAXTEMP is exceeded
output = 0;
#endif
#endif // MAXTEMP
pwm_pos[act->pwmIndex] = output; // set pwm signal
#if LED_PIN > -1
if(act == &Extruder::current->tempControl)
WRITE(LED_PIN,on);
#endif
#endif // LED_PIN
} // for controller
#ifdef RED_BLUE_STATUS_LEDS
if(Printer::isAnyTempsensorDefect()) {
if(Printer::isAnyTempsensorDefect())
{
WRITE(BLUE_STATUS_LED,HIGH);
WRITE(RED_STATUS_LED,HIGH);
} else {
}
else
{
WRITE(BLUE_STATUS_LED,!hot);
WRITE(RED_STATUS_LED,hot);
}
@ -271,14 +326,12 @@ void Extruder::manageTemperatures()
if(errorDetected == 0 && extruderTempErrors > 0)
extruderTempErrors--;
if(Printer::isAnyTempsensorDefect()
#if HAVE_HEATED_BED
|| Extruder::getHeatedBedTemperature() > HEATED_BED_MAX_TEMP + 5
#endif
)
if(newDefectFound)
{
Com::printFLN(PSTR("Disabling all heaters due to detected sensor defect."));
for(uint8_t i = 0; i < NUM_TEMPERATURE_LOOPS; i++)
{
tempController[i]->targetTemperatureC = 0;
pwm_pos[tempController[i]->pwmIndex] = 0;
}
#if defined(KILL_IF_SENSOR_DEFECT) && KILL_IF_SENSOR_DEFECT > 0
@ -286,12 +339,13 @@ void Extruder::manageTemperatures()
{
#if SDSUPPORT
sd.stopPrint();
#endif
#endif // SDSUPPORT
Printer::kill(0);
}
#endif
Printer::debugLevel |= 8; // Go into dry mode
}
#endif // KILL_IF_SENSOR_DEFECT
Printer::debugSet(8); // Go into dry mode
} // any sensor defect
#endif // NUM_TEMPERATURE_LOOPS
}
@ -509,7 +563,7 @@ void TemperatureController::updateTempControlVars()
/** \brief Select extruder ext_num.
This function changes and initalizes a new extruder. This is also called, after the eeprom values are changed.
This function changes and initializes a new extruder. This is also called, after the eeprom values are changed.
*/
void Extruder::selectExtruderById(uint8_t extruderId)
{
@ -520,10 +574,14 @@ void Extruder::selectExtruderById(uint8_t extruderId)
activeMixingExtruder = extruderId;
for(uint8_t i = 0; i < NUM_EXTRUDER; i++)
Extruder::setMixingWeight(i, extruder[i].virtualWeights[extruderId]);
Com::printFLN(PSTR("SelectExtruder:"),static_cast<int>(extruderId));
extruderId = 0;
#endif
if(extruderId >= NUM_EXTRUDER)
extruderId = 0;
#if !MIXING_EXTRUDER
Com::printFLN(PSTR("SelectExtruder:"),static_cast<int>(extruderId));
#endif
#if NUM_EXTRUDER > 1 && MIXING_EXTRUDER == 0
bool executeSelect = false;
if(extruderId != Extruder::current->id)
@ -536,19 +594,23 @@ void Extruder::selectExtruderById(uint8_t extruderId)
Extruder::current->extrudePosition = Printer::currentPositionSteps[E_AXIS];
Extruder::current = &extruder[extruderId];
#ifdef SEPERATE_EXTRUDER_POSITIONS
// Use seperate extruder positions only if beeing told. Slic3r e.g. creates a continuous extruder position increment
// Use separate extruder positions only if being told. Slic3r e.g. creates a continuous extruder position increment
Printer::currentPositionSteps[E_AXIS] = Extruder::current->extrudePosition;
#endif
Printer::destinationSteps[E_AXIS] = Printer::currentPositionSteps[E_AXIS];
Printer::axisStepsPerMM[E_AXIS] = Extruder::current->stepsPerMM;
Printer::invAxisStepsPerMM[E_AXIS] = 1.0f / Printer::axisStepsPerMM[E_AXIS];
#if MIXING_EXTRUDER
recomputeMixingExtruderSteps();
#else
Printer::destinationSteps[E_AXIS] = Printer::currentPositionSteps[E_AXIS];
Printer::axisStepsPerMM[E_AXIS] = Extruder::current->stepsPerMM;
Printer::invAxisStepsPerMM[E_AXIS] = 1.0f / Printer::axisStepsPerMM[E_AXIS];
#endif
Printer::maxFeedrate[E_AXIS] = Extruder::current->maxFeedrate;
// max_start_speed_units_per_second[E_AXIS] = Extruder::current->maxStartFeedrate;
Printer::maxAccelerationMMPerSquareSecond[E_AXIS] = Printer::maxTravelAccelerationMMPerSquareSecond[E_AXIS] = Extruder::current->maxAcceleration;
Printer::maxTravelAccelerationStepsPerSquareSecond[E_AXIS] =
Printer::maxPrintAccelerationStepsPerSquareSecond[E_AXIS] = Printer::maxAccelerationMMPerSquareSecond[E_AXIS] * Printer::axisStepsPerMM[E_AXIS];
#if USE_ADVANCE
Printer::maxExtruderSpeed = (uint8_t)floor(HAL::maxExtruderTimerFrequency() / (Extruder::current->maxFeedrate*Extruder::current->stepsPerMM));
Printer::maxExtruderSpeed = (ufast8_t)floor(HAL::maxExtruderTimerFrequency() / (Extruder::current->maxFeedrate * Extruder::current->stepsPerMM));
#if CPU_ARCH == ARCH_ARM
if(Printer::maxExtruderSpeed > 40) Printer::maxExtruderSpeed = 40;
#else
@ -581,9 +643,25 @@ void Extruder::selectExtruderById(uint8_t extruderId)
#endif
#endif
}
#if MIXING_EXTRUDER
void Extruder::recomputeMixingExtruderSteps() {
int32_t sum_w = 0;
float sum = 0;
for(fast8_t i = 0; i < NUM_EXTRUDER; i++) {
sum_w += extruder[i].mixingW;
sum += extruder[i].stepsPerMM * extruder[i].mixingW;
}
sum /= sum_w;
Printer::currentPositionSteps[E_AXIS] = Printer::currentPositionSteps[E_AXIS] * sum / Printer::axisStepsPerMM[E_AXIS]; // reposition according resolution change
Printer::destinationSteps[E_AXIS] = Printer::currentPositionSteps[E_AXIS];
Printer::axisStepsPerMM[E_AXIS] = sum;
Printer::invAxisStepsPerMM[E_AXIS] = 1.0f / Printer::axisStepsPerMM[E_AXIS];
}
#endif
void Extruder::setTemperatureForExtruder(float temperatureInCelsius, uint8_t extr, bool beep, bool wait)
{
#if NUM_EXTRUDER > 0
#if MIXING_EXTRUDER
extr = 0; // map any virtual extruder number to 0
#endif // MIXING_EXTRUDER
@ -608,13 +686,15 @@ void Extruder::setTemperatureForExtruder(float temperatureInCelsius, uint8_t ext
if(Extruder::dittoMode && extr == 0)
{
TemperatureController *tc2 = tempController[1];
tc2->setTargetTemperature(temperatureInCelsius);
tc2->setTargetTemperature(temperatureInCelsius);
tc2->updateTempControlVars();
if(temperatureInCelsius >= EXTRUDER_FAN_COOL_TEMP) extruder[1].coolerPWM = extruder[1].coolerSpeed;
#if NUM_EXTRUDER > 2
if(Extruder::dittoMode > 1 && extr == 0)
{
TemperatureController *tc2 = tempController[2];
tc2->setTargetTemperature(temperatureInCelsius);
tc2->updateTempControlVars();
if(temperatureInCelsius >= EXTRUDER_FAN_COOL_TEMP) extruder[2].coolerPWM = extruder[2].coolerSpeed;
}
#endif
@ -623,6 +703,7 @@ void Extruder::setTemperatureForExtruder(float temperatureInCelsius, uint8_t ext
{
TemperatureController *tc2 = tempController[3];
tc2->setTargetTemperature(temperatureInCelsius);
tc2->updateTempControlVars();
if(temperatureInCelsius >= EXTRUDER_FAN_COOL_TEMP) extruder[3].coolerPWM = extruder[3].coolerSpeed;
}
#endif
@ -635,7 +716,7 @@ void Extruder::setTemperatureForExtruder(float temperatureInCelsius, uint8_t ext
)
{
Extruder *actExtruder = &extruder[extr];
UI_STATUS_UPD(UI_TEXT_HEATING_EXTRUDER);
UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_HEATING_EXTRUDER_ID));
EVENT_WAITING_HEATER(actExtruder->id);
bool dirRising = actExtruder->tempControl.targetTemperature > actExtruder->tempControl.currentTemperature;
millis_t printedTime = HAL::timeInMilliseconds();
@ -695,7 +776,8 @@ void Extruder::setTemperatureForExtruder(float temperatureInCelsius, uint8_t ext
Printer::msecondsPrinting = HAL::timeInMilliseconds();
Printer::filamentPrinted = 0; // new print, new counter
Printer::flag2 &= ~PRINTER_FLAG2_RESET_FILAMENT_USAGE;
}
}
#endif
}
void Extruder::setHeatedBedTemperature(float temperatureInCelsius,bool beep)
@ -708,9 +790,9 @@ void Extruder::setHeatedBedTemperature(float temperatureInCelsius,bool beep)
if(beep && temperatureInCelsius>30) heatedBedController.setAlarm(true);
Com::printFLN(Com::tTargetBedColon,heatedBedController.targetTemperatureC,0);
if(temperatureInCelsius > 15)
pwm_pos[NUM_EXTRUDER + 1] = 255; // turn on the mainboard cooling fan
pwm_pos[PWM_BOARD_FAN] = 255; // turn on the mainboard cooling fan
else if(Printer::areAllSteppersDisabled())
pwm_pos[NUM_EXTRUDER + 1] = 0; // turn off the mainboard cooling fan only if steppers disabled
pwm_pos[PWM_BOARD_FAN] = 0; // turn off the mainboard cooling fan only if steppers disabled
#endif
}
@ -737,7 +819,46 @@ void Extruder::setMixingWeight(uint8_t extr,int weight)
}
}
void Extruder::step()
{
{
if(PrintLine::cur != NULL && PrintLine::cur->isAllEMotors()) {
#if NUM_EXTRUDER > 0
WRITE(EXT0_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT0_JAM_PIN) && EXT0_JAM_PIN > -1
TEST_EXTRUDER_JAM(0)
#endif
#endif
#if NUM_EXTRUDER > 1
WRITE(EXT1_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT1_JAM_PIN) && EXT1_JAM_PIN > -1
TEST_EXTRUDER_JAM(1)
#endif
#endif
#if NUM_EXTRUDER > 2
WRITE(EXT2_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT2_JAM_PIN) && EXT2_JAM_PIN > -1
TEST_EXTRUDER_JAM(2)
#endif
#endif
#if NUM_EXTRUDER > 3
WRITE(EXT3_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT3_JAM_PIN) && EXT3_JAM_PIN > -1
TEST_EXTRUDER_JAM(3)
#endif
#endif
#if NUM_EXTRUDER > 4
WRITE(EXT4_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT4_JAM_PIN) && EXT4_JAM_PIN > -1
TEST_EXTRUDER_JAM(4)
#endif
#endif
#if NUM_EXTRUDER > 5
WRITE(EXT5_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT5_JAM_PIN) && EXT5_JAM_PIN > -1
TEST_EXTRUDER_JAM(5)
#endif
#endif
return;
}
uint8_t best = 255,i;
int bestError;
if(mixingDir)
@ -775,7 +896,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 0
if(best == 0)
{
WRITE(EXT0_STEP_PIN, HIGH);
WRITE(EXT0_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT0_JAM_PIN) && EXT0_JAM_PIN > -1
TEST_EXTRUDER_JAM(0)
#endif
@ -784,7 +905,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 1
if(best == 1)
{
WRITE(EXT1_STEP_PIN, HIGH);
WRITE(EXT1_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT1_JAM_PIN) && EXT1_JAM_PIN > -1
TEST_EXTRUDER_JAM(1)
#endif
@ -793,7 +914,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 2
if(best == 2)
{
WRITE(EXT2_STEP_PIN, HIGH);
WRITE(EXT2_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT2_JAM_PIN) && EXT2_JAM_PIN > -1
TEST_EXTRUDER_JAM(2)
#endif
@ -802,7 +923,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 3
if(best == 3)
{
WRITE(EXT3_STEP_PIN, HIGH);
WRITE(EXT3_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT3_JAM_PIN) && EXT3_JAM_PIN > -1
TEST_EXTRUDER_JAM(3)
#endif
@ -811,7 +932,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 4
if(best == 4)
{
WRITE(EXT4_STEP_PIN, HIGH);
WRITE(EXT4_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT4_JAM_PIN) && EXT4_JAM_PIN > -1
TEST_EXTRUDER_JAM(4)
#endif
@ -820,7 +941,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 5
if(best == 5)
{
WRITE(EXT5_STEP_PIN, HIGH);
WRITE(EXT5_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT5_JAM_PIN) && EXT5_JAM_PIN > -1
TEST_EXTRUDER_JAM(5)
#endif
@ -831,22 +952,22 @@ void Extruder::step()
void Extruder::unstep()
{
#if NUM_EXTRUDER > 0
WRITE(EXT0_STEP_PIN, LOW);
WRITE(EXT0_STEP_PIN, !START_STEP_WITH_HIGH);
#endif
#if NUM_EXTRUDER > 1
WRITE(EXT1_STEP_PIN, LOW);
WRITE(EXT1_STEP_PIN, !START_STEP_WITH_HIGH);
#endif
#if NUM_EXTRUDER > 2
WRITE(EXT2_STEP_PIN, LOW);
WRITE(EXT2_STEP_PIN, !START_STEP_WITH_HIGH);
#endif
#if NUM_EXTRUDER > 3
WRITE(EXT3_STEP_PIN, LOW);
WRITE(EXT3_STEP_PIN, !START_STEP_WITH_HIGH);
#endif
#if NUM_EXTRUDER > 4
WRITE(EXT4_STEP_PIN, LOW);
WRITE(EXT4_STEP_PIN, !START_STEP_WITH_HIGH);
#endif
#if NUM_EXTRUDER > 5
WRITE(EXT5_STEP_PIN, LOW);
WRITE(EXT5_STEP_PIN, !START_STEP_WITH_HIGH);
#endif
}
@ -925,7 +1046,7 @@ Call this function only, if interrupts are disabled.
void Extruder::step()
{
#if NUM_EXTRUDER == 1
WRITE(EXT0_STEP_PIN, HIGH);
WRITE(EXT0_STEP_PIN, START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT0_JAM_PIN) && EXT0_JAM_PIN > -1
TEST_EXTRUDER_JAM(0)
#endif
@ -934,21 +1055,21 @@ void Extruder::step()
{
case 0:
#if NUM_EXTRUDER > 0
WRITE(EXT0_STEP_PIN,HIGH);
WRITE(EXT0_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT0_JAM_PIN) && EXT0_JAM_PIN > -1
TEST_EXTRUDER_JAM(0)
#endif
#if FEATURE_DITTO_PRINTING
if(Extruder::dittoMode)
{
WRITE(EXT1_STEP_PIN,HIGH);
WRITE(EXT1_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT1_JAM_PIN) && EXT1_JAM_PIN > -1
TEST_EXTRUDER_JAM(1)
#endif
#if NUM_EXTRUDER > 2
if(Extruder::dittoMode > 1)
{
WRITE(EXT2_STEP_PIN,HIGH);
WRITE(EXT2_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT2_JAM_PIN) && EXT2_JAM_PIN > -1
TEST_EXTRUDER_JAM(2)
#endif
@ -957,7 +1078,7 @@ void Extruder::step()
#if NUM_EXTRUDER > 3
if(Extruder::dittoMode > 2)
{
WRITE(EXT3_STEP_PIN,HIGH);
WRITE(EXT3_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT3_JAM_PIN) && EXT3_JAM_PIN > -1
TEST_EXTRUDER_JAM(3)
#endif
@ -969,7 +1090,7 @@ void Extruder::step()
break;
#if defined(EXT1_STEP_PIN) && NUM_EXTRUDER > 1
case 1:
WRITE(EXT1_STEP_PIN,HIGH);
WRITE(EXT1_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT1_JAM_PIN) && EXT1_JAM_PIN > -1
TEST_EXTRUDER_JAM(1)
#endif
@ -977,7 +1098,7 @@ void Extruder::step()
#endif
#if defined(EXT2_STEP_PIN) && NUM_EXTRUDER > 2
case 2:
WRITE(EXT2_STEP_PIN,HIGH);
WRITE(EXT2_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT2_JAM_PIN) && EXT2_JAM_PIN > -1
TEST_EXTRUDER_JAM(2)
#endif
@ -985,7 +1106,7 @@ void Extruder::step()
#endif
#if defined(EXT3_STEP_PIN) && NUM_EXTRUDER > 3
case 3:
WRITE(EXT3_STEP_PIN,HIGH);
WRITE(EXT3_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT3_JAM_PIN) && EXT3_JAM_PIN > -1
TEST_EXTRUDER_JAM(3)
#endif
@ -993,7 +1114,7 @@ void Extruder::step()
#endif
#if defined(EXT4_STEP_PIN) && NUM_EXTRUDER > 4
case 4:
WRITE(EXT4_STEP_PIN,HIGH);
WRITE(EXT4_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT4_JAM_PIN) && EXT4_JAM_PIN > -1
TEST_EXTRUDER_JAM(4)
#endif
@ -1001,7 +1122,7 @@ void Extruder::step()
#endif
#if defined(EXT5_STEP_PIN) && NUM_EXTRUDER > 5
case 5:
WRITE(EXT5_STEP_PIN,HIGH);
WRITE(EXT5_STEP_PIN,START_STEP_WITH_HIGH);
#if EXTRUDER_JAM_CONTROL && defined(EXT5_JAM_PIN) && EXT5_JAM_PIN > -1
TEST_EXTRUDER_JAM(5)
#endif
@ -1019,27 +1140,27 @@ Call this function only, if interrupts are disabled.
void Extruder::unstep()
{
#if NUM_EXTRUDER == 1
WRITE(EXT0_STEP_PIN,LOW);
WRITE(EXT0_STEP_PIN,!START_STEP_WITH_HIGH);
#else
switch(Extruder::current->id)
{
case 0:
#if NUM_EXTRUDER > 0
WRITE(EXT0_STEP_PIN,LOW);
WRITE(EXT0_STEP_PIN,!START_STEP_WITH_HIGH);
#if FEATURE_DITTO_PRINTING
if(Extruder::dittoMode)
{
WRITE(EXT1_STEP_PIN,LOW);
WRITE(EXT1_STEP_PIN,!START_STEP_WITH_HIGH);
#if NUM_EXTRUDER > 2
if(Extruder::dittoMode > 1)
{
WRITE(EXT2_STEP_PIN,LOW);
WRITE(EXT2_STEP_PIN,!START_STEP_WITH_HIGH);
}
#endif
#if NUM_EXTRUDER > 3
if(Extruder::dittoMode > 2)
{
WRITE(EXT3_STEP_PIN,LOW);
WRITE(EXT3_STEP_PIN,!START_STEP_WITH_HIGH);
}
#endif // NUM_EXTRUDER > 3
}
@ -1048,27 +1169,27 @@ void Extruder::unstep()
break;
#if defined(EXT1_STEP_PIN) && NUM_EXTRUDER > 1
case 1:
WRITE(EXT1_STEP_PIN,LOW);
WRITE(EXT1_STEP_PIN,!START_STEP_WITH_HIGH);
break;
#endif
#if defined(EXT2_STEP_PIN) && NUM_EXTRUDER > 2
case 2:
WRITE(EXT2_STEP_PIN,LOW);
WRITE(EXT2_STEP_PIN,!START_STEP_WITH_HIGH);
break;
#endif
#if defined(EXT3_STEP_PIN) && NUM_EXTRUDER > 3
case 3:
WRITE(EXT3_STEP_PIN,LOW);
WRITE(EXT3_STEP_PIN,!START_STEP_WITH_HIGH);
break;
#endif
#if defined(EXT4_STEP_PIN) && NUM_EXTRUDER > 4
case 4:
WRITE(EXT4_STEP_PIN,LOW);
WRITE(EXT4_STEP_PIN,!START_STEP_WITH_HIGH);
break;
#endif
#if defined(EXT5_STEP_PIN) && NUM_EXTRUDER > 5
case 5:
WRITE(EXT5_STEP_PIN,LOW);
WRITE(EXT5_STEP_PIN,!START_STEP_WITH_HIGH);
break;
#endif
}
@ -1283,7 +1404,7 @@ const short temptable_4[NUMTEMPS_4][2] PROGMEM =
{478*4, 46*8},{531*4, 41*8},{584*4, 35*8},{637*4, 30*8},{690*4, 25*8},{743*4, 20*8},{796*4, 14*8},{849*4, 7*8},{902*4, 0*8},
{955*4, -11*8},{1008*4, -35*8}
};
// ATC 104GT
#define NUMTEMPS_8 34
const short temptable_8[NUMTEMPS_8][2] PROGMEM =
{
@ -1325,6 +1446,12 @@ const short temptable_12[NUMTEMPS_12][2] PROGMEM =
{351*4, 140*8},{386*4, 134*8},{421*4, 128*8},{456*4, 122*8},{491*4, 117*8},{526*4, 112*8},{561*4, 107*8},{596*4, 102*8},{631*4, 97*8},{666*4, 91*8},
{701*4, 86*8},{736*4, 81*8},{771*4, 76*8},{806*4, 70*8},{841*4, 63*8},{876*4, 56*8},{911*4, 48*8},{946*4, 38*8},{981*4, 23*8},{1005*4, 5*8},{1016*4, 0*8}
};
#define NUMTEMPS_13 19
const short temptable_13[NUMTEMPS_13][2] PROGMEM =
{
{0,0},{908,8},{942,10*8},{982,20*8},{1015,8*30},{1048,8*40},{1080,8*50},{1113,8*60},{1146,8*70},{1178,8*80},{1211,8*90},{1276,8*110},{1318,8*120}
,{1670,8*230},{2455,8*500},{3445,8*900},{3666,8*1000},{3871,8*1100},{4095,8*2000}
};
#if NUM_TEMPS_USERTHERMISTOR0 > 0
const short temptable_5[NUM_TEMPS_USERTHERMISTOR0][2] PROGMEM = USER_THERMISTORTABLE0 ;
#endif
@ -1334,7 +1461,7 @@ const short temptable_6[NUM_TEMPS_USERTHERMISTOR1][2] PROGMEM = USER_THERMISTORT
#if NUM_TEMPS_USERTHERMISTOR2 > 0
const short temptable_7[NUM_TEMPS_USERTHERMISTOR2][2] PROGMEM = USER_THERMISTORTABLE2 ;
#endif
const short * const temptables[12] PROGMEM = {(short int *)&temptable_1[0][0],(short int *)&temptable_2[0][0],(short int *)&temptable_3[0][0],(short int *)&temptable_4[0][0]
const short * const temptables[13] PROGMEM = {(short int *)&temptable_1[0][0],(short int *)&temptable_2[0][0],(short int *)&temptable_3[0][0],(short int *)&temptable_4[0][0]
#if NUM_TEMPS_USERTHERMISTOR0 > 0
,(short int *)&temptable_5[0][0]
#else
@ -1355,9 +1482,10 @@ const short * const temptables[12] PROGMEM = {(short int *)&temptable_1[0][0],(s
,(short int *)&temptable_10[0][0]
,(short int *)&temptable_11[0][0]
,(short int *)&temptable_12[0][0]
,(short int *)&temptable_13[0][0]
};
const uint8_t temptables_num[12] PROGMEM = {NUMTEMPS_1,NUMTEMPS_2,NUMTEMPS_3,NUMTEMPS_4,NUM_TEMPS_USERTHERMISTOR0,NUM_TEMPS_USERTHERMISTOR1,NUM_TEMPS_USERTHERMISTOR2,NUMTEMPS_8,
NUMTEMPS_9,NUMTEMPS_10,NUMTEMPS_11,NUMTEMPS_12
const uint8_t temptables_num[13] PROGMEM = {NUMTEMPS_1,NUMTEMPS_2,NUMTEMPS_3,NUMTEMPS_4,NUM_TEMPS_USERTHERMISTOR0,NUM_TEMPS_USERTHERMISTOR1,NUM_TEMPS_USERTHERMISTOR2,NUMTEMPS_8,
NUMTEMPS_9,NUMTEMPS_10,NUMTEMPS_11,NUMTEMPS_12,NUMTEMPS_13
};
@ -1370,7 +1498,7 @@ void TemperatureController::updateCurrentTemperature()
case 0:
currentTemperature = 25;
break;
#if ANALOG_INPUTS>0
#if ANALOG_INPUTS > 0
case 1:
case 2:
case 3:
@ -1388,12 +1516,13 @@ void TemperatureController::updateCurrentTemperature()
case 99:
currentTemperature = (1023 << (2 - ANALOG_REDUCE_BITS)) - (osAnalogInputValues[sensorPin] >> (ANALOG_REDUCE_BITS)); // Convert to 10 bit result
break;
case 13: // PT100 E3D
case 50: // User defined PTC table
case 51:
case 52:
case 60: // HEATER_USES_AD8495 (Delivers 5mV/degC)
case 61: // HEATER_USES_AD8495 (Delivers 5mV/degC) 1.25v offset
case 100: // AD595
case 100: // AD595 / AD597
currentTemperature = (osAnalogInputValues[sensorPin] >> (ANALOG_REDUCE_BITS));
break;
#endif
@ -1431,14 +1560,14 @@ void TemperatureController::updateCurrentTemperature()
case 12:
{
type--;
uint8_t num = pgm_read_byte(&temptables_num[type])<<1;
uint8_t i=2;
const short *temptable = (const short *)pgm_read_word(&temptables[type]); //pgm_read_word_near(&temptables[type]);
short oldraw = pgm_read_word(&temptable[0]);
short oldtemp = pgm_read_word(&temptable[1]);
short newraw,newtemp;
currentTemperature = (1023<<(2-ANALOG_REDUCE_BITS))-currentTemperature;
while(i<num)
uint8_t num = pgm_read_byte(&temptables_num[type]) << 1;
uint8_t i = 2;
const int16_t *temptable = (const int16_t *)pgm_read_word(&temptables[type]); //pgm_read_word_near(&temptables[type]);
int16_t oldraw = pgm_read_word(&temptable[0]);
int16_t oldtemp = pgm_read_word(&temptable[1]);
int16_t newraw,newtemp = 0;
currentTemperature = (1023 << (2 - ANALOG_REDUCE_BITS)) - currentTemperature;
while(i < num)
{
newraw = pgm_read_word(&temptable[i++]);
newtemp = pgm_read_word(&temptable[i++]);
@ -1446,7 +1575,7 @@ void TemperatureController::updateCurrentTemperature()
{
//OUT_P_I("RC O:",oldtemp);OUT_P_I_LN(" OR:",oldraw);
//OUT_P_I("RC N:",newtemp);OUT_P_I_LN(" NR:",newraw);
currentTemperatureC = TEMP_INT_TO_FLOAT(oldtemp + (float)(currentTemperature-oldraw)*(float)(newtemp-oldtemp)/(newraw-oldraw));
currentTemperatureC = TEMP_INT_TO_FLOAT(oldtemp + (float)(currentTemperature-oldraw)*(float)(newtemp - oldtemp) / (newraw - oldraw));
return;
}
oldtemp = newtemp;
@ -1456,18 +1585,22 @@ void TemperatureController::updateCurrentTemperature()
currentTemperatureC = TEMP_INT_TO_FLOAT(newtemp);
}
break;
case 13:
case 50: // User defined PTC thermistor
case 51:
case 52:
{
type-=46;
uint8_t num = pgm_read_byte(&temptables_num[type])<<1;
uint8_t i=2;
const short *temptable = (const short *)pgm_read_word(&temptables[type]); //pgm_read_word_near(&temptables[type]);
short oldraw = pgm_read_word(&temptable[0]);
short oldtemp = pgm_read_word(&temptable[1]);
short newraw,newtemp;
while(i<num)
if(type > 49)
type -= 46;
else
type--;
uint8_t num = pgm_read_byte(&temptables_num[type]) << 1;
uint8_t i = 2;
const int16_t *temptable = (const int16_t *)pgm_read_word(&temptables[type]); //pgm_read_word_near(&temptables[type]);
int16_t oldraw = pgm_read_word(&temptable[0]);
int16_t oldtemp = pgm_read_word(&temptable[1]);
int16_t newraw,newtemp = 0;
while(i < num)
{
newraw = pgm_read_word(&temptable[i++]);
newtemp = pgm_read_word(&temptable[i++]);
@ -1497,12 +1630,16 @@ void TemperatureController::updateCurrentTemperature()
currentTemperatureC = ((float)currentTemperature * 660.0f / (1024 << (2 - ANALOG_REDUCE_BITS))) - 250.0f;
#endif
break;
case 100: // AD595
case 100: // AD595 / AD597 10mV/°C
//return (int)((long)raw_temp * 500/(1024<<(2-ANALOG_REDUCE_BITS)));
#if CPU_ARCH == ARCH_AVR
currentTemperatureC = ((float)currentTemperature * 500.0f / (1024 << (2 - ANALOG_REDUCE_BITS)));
#else
#if FEATURE_CONTROLLER == CONTROLLER_LCD_MP_PHARAOH_DUE
currentTemperatureC = ((float)currentTemperature * 500.0f / (1024 << (2 - ANALOG_REDUCE_BITS)));
#else
currentTemperatureC = ((float)currentTemperature * 330.0f / (1024 << (2 - ANALOG_REDUCE_BITS)));
#endif
#endif
break;
#ifdef SUPPORT_MAX6675
@ -1607,24 +1744,28 @@ void TemperatureController::setTargetTemperature(float target)
targetTemperature = (1023<<(2-ANALOG_REDUCE_BITS))-newraw;
break;
}
case 13: // PT100 E3D
case 50: // user defined PTC thermistor
case 51:
case 52:
{
type -= 46;
if(type > 49)
type -= 46;
else
type--;
uint8_t num = pgm_read_byte(&temptables_num[type]) << 1;
uint8_t i = 2;
const short *temptable = (const short *)pgm_read_word(&temptables[type]); //pgm_read_word(&temptables[type]);
short oldraw = pgm_read_word(&temptable[0]);
short oldtemp = pgm_read_word(&temptable[1]);
short newraw = 0,newtemp;
while(i<num)
while(i < num)
{
newraw = pgm_read_word(&temptable[i++]);
newtemp = pgm_read_word(&temptable[i++]);
if (newtemp > temp)
{
targetTemperature = oldraw + (int32_t)(oldtemp-temp) * (int32_t)(oldraw-newraw) / (oldtemp-newtemp);
targetTemperature = oldraw + (int32_t)(oldtemp - temp) * (int32_t)(oldraw - newraw) / (oldtemp-newtemp);
return;
}
oldtemp = newtemp;
@ -1694,14 +1835,16 @@ void TemperatureController::setTargetTemperature(float target)
uint8_t autotuneIndex = 255;
void Extruder::disableAllHeater()
{
for(uint8_t i=0; i<NUM_TEMPERATURE_LOOPS; i++)
{
#if NUM_TEMPERATURE_LOOPS > 0
for(uint8_t i = 0; i < NUM_TEMPERATURE_LOOPS; i++)
{
TemperatureController *c = tempController[i];
c->targetTemperature = 0;
c->targetTemperatureC = 0;
pwm_pos[c->pwmIndex] = 0;
}
}
#endif
autotuneIndex = 255;
}
@ -1862,7 +2005,8 @@ void writeMonitor()
}
bool reportTempsensorError()
{
{
#if NUM_TEMPERATURE_LOOPS > 0
if(!Printer::isAnyTempsensorDefect()) return false;
for(uint8_t i = 0; i < NUM_TEMPERATURE_LOOPS; i++)
{
@ -1875,20 +2019,29 @@ bool reportTempsensorError()
Com::printFLN(Com::tTempSensorWorking);
}
Com::printErrorFLN(Com::tDryModeUntilRestart);
return true;
return true;
#else
return false;
#endif
}
#ifdef SUPPORT_MAX6675
int16_t read_max6675(uint8_t ss_pin)
{
int16_t max6675_temp = 0;
HAL::spiInit(2);
HAL::digitalWrite(ss_pin, 0); // enable TT_MAX6675
HAL::delayMicroseconds(1); // ensure 100ns delay - a bit extra is fine
max6675_temp = HAL::spiReceive(0);
max6675_temp <<= 8;
max6675_temp |= HAL::spiReceive(0);
HAL::digitalWrite(ss_pin, 1); // disable TT_MAX6675
static millis_t last_max6675_read = 0;
static int16_t max6675_temp = 0;
if (HAL::timeInMilliseconds() - last_max6675_read > 230)
{
HAL::spiInit(2);
HAL::digitalWrite(ss_pin, 0); // enable TT_MAX6675
HAL::delayMicroseconds(1); // ensure 100ns delay - a bit extra is fine
max6675_temp = HAL::spiReceive(0);
max6675_temp <<= 8;
max6675_temp |= HAL::spiReceive(0);
HAL::digitalWrite(ss_pin, 1); // disable TT_MAX6675
last_max6675_read = HAL::timeInMilliseconds();
}
return max6675_temp & 4 ? 2000 : max6675_temp >> 3; // thermocouple open?
}
#endif
@ -1934,7 +2087,13 @@ void Extruder::retractDistance(float dist)
int32_t distance = static_cast<int32_t>(dist * stepsPerMM / Printer::extrusionFactor);
int32_t oldEPos = Printer::currentPositionSteps[E_AXIS];
float speed = distance > 0 ? EEPROM_FLOAT(RETRACTION_SPEED) : EEPROM_FLOAT(RETRACTION_UNDO_SPEED);
#if MIXING_EXTRUDER
Printer::setAllEMotors(true);
#endif
PrintLine::moveRelativeDistanceInSteps(0, 0, 0, -distance, RMath::max(speed, 1.f), false, false);
#if MIXING_EXTRUDER
Printer::setAllEMotors(false);
#endif
Printer::currentPositionSteps[E_AXIS] = oldEPos; // restore previous extruder position
Printer::feedrate = oldFeedrate;
}
@ -1942,27 +2101,28 @@ void Extruder::retractDistance(float dist)
void Extruder::retract(bool isRetract,bool isLong)
{
float oldFeedrate = Printer::feedrate;
float distance = (isLong ? EEPROM_FLOAT( RETRACTION_LONG_LENGTH) : EEPROM_FLOAT(RETRACTION_LENGTH));
int32_t zlift = static_cast<int32_t>(EEPROM_FLOAT(RETRACTION_Z_LIFT) * Printer::axisStepsPerMM[Z_AXIS]);
int32_t oldZPos = Printer::currentPositionSteps[Z_AXIS];
float oldZPosF = Printer::currentPosition[Z_AXIS];
float distance = (isLong ? EEPROM_FLOAT( RETRACTION_LONG_LENGTH) : EEPROM_FLOAT(RETRACTION_LENGTH));
float zLiftF = EEPROM_FLOAT(RETRACTION_Z_LIFT);
int32_t zlift = static_cast<int32_t>(zLiftF * Printer::axisStepsPerMM[Z_AXIS]);
if(isRetract && !isRetracted())
{
retractDistance(distance);
setRetracted(true);
if(zlift > 0)
PrintLine::moveRelativeDistanceInStepsReal(0,0,zlift,0,Printer::maxFeedrate[Z_AXIS], false);
if(zlift > 0) {
PrintLine::moveRelativeDistanceInStepsReal(0,0,zlift,0,Printer::maxFeedrate[Z_AXIS], false);
Printer::coordinateOffset[Z_AXIS] -= zLiftF;
}
}
else if(!isRetract && isRetracted())
{
distance += (isLong ? EEPROM_FLOAT(RETRACTION_UNDO_EXTRA_LONG_LENGTH) : EEPROM_FLOAT(RETRACTION_UNDO_EXTRA_LENGTH) );
if(zlift > 0)
PrintLine::moveRelativeDistanceInStepsReal(0,0,-zlift,0,Printer::maxFeedrate[Z_AXIS], false);
if(zlift > 0) {
PrintLine::moveRelativeDistanceInStepsReal(0,0,-zlift,0,Printer::maxFeedrate[Z_AXIS], false);
Printer::coordinateOffset[Z_AXIS] += zLiftF;
}
retractDistance(-distance);
setRetracted(false);
}
Printer::currentPositionSteps[Z_AXIS] = oldZPos; // z lift should have no visible impact
Printer::currentPosition[Z_AXIS] = oldZPosF;
Printer::feedrate = oldFeedrate;
}
#endif
@ -2165,45 +2325,55 @@ Extruder extruder[NUM_EXTRUDER] =
#endif // NUM_EXTRUDER
#if HAVE_HEATED_BED
#define NUM_TEMPERATURE_LOOPS NUM_EXTRUDER+1
TemperatureController heatedBedController = {NUM_EXTRUDER,HEATED_BED_SENSOR_TYPE,BED_SENSOR_INDEX,0,0,0,0,0,HEATED_BED_HEAT_MANAGER
TemperatureController heatedBedController = {PWM_HEATED_BED,HEATED_BED_SENSOR_TYPE,BED_SENSOR_INDEX,0,0,0,0,0,HEATED_BED_HEAT_MANAGER
#if TEMP_PID
,0,HEATED_BED_PID_INTEGRAL_DRIVE_MAX,HEATED_BED_PID_INTEGRAL_DRIVE_MIN,HEATED_BED_PID_PGAIN_OR_DEAD_TIME,HEATED_BED_PID_IGAIN,HEATED_BED_PID_DGAIN,HEATED_BED_PID_MAX,0,0,0,{0,0,0,0}
#endif
,0,0,0,HEATED_BED_DECOUPLE_TEST_PERIOD
};
#else
#define NUM_TEMPERATURE_LOOPS NUM_EXTRUDER
,0,0,0,HEATED_BED_DECOUPLE_TEST_PERIOD};
#endif
#if FAN_THERMO_PIN > -1
TemperatureController thermoController = {PWM_FAN_THERMO,FAN_THERMO_THERMISTOR_TYPE,THERMO_ANALOG_INDEX,0,0,0,0,0,0
#if TEMP_PID
,0,255,0,10,1,1,255,0,0,0,{0,0,0,0}
#endif
,0,0,0,0};
#endif
#if NUM_TEMPERATURE_LOOPS > 0
TemperatureController *tempController[NUM_TEMPERATURE_LOOPS] =
{
#if NUM_EXTRUDER>0
#if NUM_EXTRUDER > 0
&extruder[0].tempControl
#endif
#if NUM_EXTRUDER>1
#if NUM_EXTRUDER > 1
,&extruder[1].tempControl
#endif
#if NUM_EXTRUDER>2
#if NUM_EXTRUDER > 2
,&extruder[2].tempControl
#endif
#if NUM_EXTRUDER>3
#if NUM_EXTRUDER > 3
,&extruder[3].tempControl
#endif
#if NUM_EXTRUDER>4
#if NUM_EXTRUDER > 4
,&extruder[4].tempControl
#endif
#if NUM_EXTRUDER>5
#if NUM_EXTRUDER > 5
,&extruder[5].tempControl
#endif
#if HAVE_HEATED_BED
#if NUM_EXTRUDER==0
#if NUM_EXTRUDER == 0
&heatedBedController
#else
,&heatedBedController
#endif
#endif
#if FAN_THERMO_PIN > -1
#if NUM_EXTRUDER == 0 && !HAVE_HEATED_BED
&thermoController
#else
,&thermoController
#endif
#endif // FAN_THERMO_PIN
};
#endif

View file

@ -147,7 +147,8 @@ public:
class Extruder;
extern Extruder extruder[];
#if EXTRUDER_JAM_CONTROL
#if EXTRUDER_JAM_CONTROL
#if JAM_METHOD == 1
#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) {\
@ -156,10 +157,23 @@ extern Extruder extruder[];
} else if(abs(extruder[x].jamStepsSinceLastSignal) > JAM_ERROR_STEPS && !Printer::isDebugJamOrDisabled() && !extruder[x].tempControl.isJammed()) \
extruder[x].tempControl.setJammed(true);\
}
#define RESET_EXTRUDER_JAM(x,dir) extruder[x].jamLastDir = dir ? 1 : -1;
#elif JAM_METHOD == 2
#define _TEST_EXTRUDER_JAM(x,pin) {\
uint8_t sig = READ(pin);\
if(sig){extruder[x].tempControl.setJammed(true);} else if(!Printer::isDebugJamOrDisabled() && !extruder[x].tempControl.isJammed()) {extruder[x].resetJamSteps();}}
#define RESET_EXTRUDER_JAM(x,dir)
#elif JAM_METHOD == 3
#define _TEST_EXTRUDER_JAM(x,pin) {\
uint8_t sig = !READ(pin);\
if(sig){extruder[x].tempControl.setJammed(true);} else if(!Printer::isDebugJamOrDisabled() && !extruder[x].tempControl.isJammed()) {extruder[x].resetJamSteps();}}
#define RESET_EXTRUDER_JAM(x,dir)
#else
#error Unknown value for JAM_METHOD
#endif
#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;
#define TEST_EXTRUDER_JAM(x) __TEST_EXTRUDER_JAM(x)
#else
#define TEST_EXTRUDER_JAM(x)
#define RESET_EXTRUDER_JAM(x,dir)
@ -184,10 +198,11 @@ public:
static int mixingS; ///< Sum of all weights
static uint8_t mixingDir; ///< Direction flag
static uint8_t activeMixingExtruder;
static void recomputeMixingExtruderSteps();
#endif
uint8_t id;
int32_t xOffset;
int32_t yOffset;
int32_t yOffset;
int32_t zOffset;
float stepsPerMM; ///< Steps per mm.
int8_t enablePin; ///< Pin to enable extruder stepper motor.
@ -274,19 +289,27 @@ public:
};
#if HAVE_HEATED_BED
#define NUM_TEMPERATURE_LOOPS NUM_EXTRUDER+1
#define HEATED_BED_INDEX NUM_EXTRUDER
extern TemperatureController heatedBedController;
#else
#define NUM_TEMPERATURE_LOOPS NUM_EXTRUDER
#define HEATED_BED_INDEX NUM_EXTRUDER-1
#endif
#if FAN_THERMO_PIN > -1
#define THERMO_CONTROLLER_INDEX HEATED_BED_INDEX+1
extern TemperatureController thermoController;
#else
#define THERMO_CONTROLLER_INDEX HEATED_BED_INDEX
#endif
#define NUM_TEMPERATURE_LOOPS THERMO_CONTROLLER_INDEX+1
#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 Extruder *Extruder::current;
#if NUM_TEMPERATURE_LOOPS > 0
extern TemperatureController *tempController[NUM_TEMPERATURE_LOOPS];
#endif
extern uint8_t autotuneIndex;
#endif // EXTRUDER_H_INCLUDED

View file

@ -416,5 +416,3 @@ static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
}
#endif // FatStructs_h

File diff suppressed because it is too large Load diff

View file

@ -70,7 +70,9 @@ All known arduino boards use 64. This value is needed for the extruder timing. *
#endif
#include <inttypes.h>
#include "Print.h"
#ifdef EXTERNALSERIAL
#define SERIAL_RX_BUFFER_SIZE 128
#endif
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
@ -132,7 +134,7 @@ public:
#define I2C_WRITE 0
#if NONLINEAR_SYSTEM
// Maximum speed with 100% inerrupt utilization is 27000 hz at 16MHz cpu
// Maximum speed with 100% interrupt 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
@ -174,9 +176,16 @@ typedef uint8_t ufast8_t;
*/
#define SERIAL_BUFFER_SIZE 128
#define SERIAL_BUFFER_MASK 127
#define SERIAL_BUFFER_MASK 127
#undef SERIAL_TX_BUFFER_SIZE
#undef SERIAL_TX_BUFFER_MASK
#ifdef BIG_OUTPUT_BUFFER
#define SERIAL_TX_BUFFER_SIZE 128
#define SERIAL_TX_BUFFER_MASK 127
#else
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_TX_BUFFER_MASK 63
#endif
struct ring_buffer
{
@ -251,8 +260,11 @@ extern RFHardwareSerial RFSerial;
#define OUT_LN Com::println()
class HAL
{
public:
{
public:
#if FEATURE_WATCHDOG
static bool wdPinged;
#endif
HAL();
virtual ~HAL();
static inline void hwSetup(void)
@ -601,7 +613,7 @@ public:
SET_OUTPUT(SDSSORIG);
#endif
// set SS high - may be chip select for another SPI device
#if SET_SPI_SS_HIGH
#if defined(SET_SPI_SS_HIGH) && SET_SPI_SS_HIGH
WRITE(SDSS, HIGH);
#endif // SET_SPI_SS_HIGH
#endif
@ -710,8 +722,8 @@ public:
}
inline static void pingWatchdog()
{
#if FEATURE_WATCHDOG
wdt_reset();
#if FEATURE_WATCHDOG
wdPinged = true;
#endif
};
inline static float maxExtruderTimerFrequency()
@ -756,5 +768,3 @@ private:
#define PWM_OCIE OCIE0B
//#endif
#endif // HAL_H

File diff suppressed because it is too large Load diff

View file

@ -93,7 +93,8 @@ union wizardVar
#define PRINTER_FLAG2_IGNORE_M106_COMMAND 8
#define PRINTER_FLAG2_DEBUG_JAM 16
#define PRINTER_FLAG2_JAMCONTROL_DISABLED 32
#define PRINTER_FLAG2_HOMING 64
#define PRINTER_FLAG2_HOMING 64
#define PRINTER_FLAG2_ALL_E_MOTORS 128 // Set all e motors flag
// List of possible interrupt events (1-255 allowed)
#define PRINTER_INTERRUPT_EVENT_JAM_DETECTED 1
@ -106,7 +107,7 @@ union wizardVar
// define an integer number of steps more than large enough to get to endstop from anywhere
#define HOME_DISTANCE_STEPS (Printer::zMaxSteps-Printer::zMinSteps+1000)
#define HOME_DISTANCE_MM (HOME_DISTANCE_STEPS * invAxisStepsPerMM[Z_AXIS])
// Some dfines to make clearer reading, as we overload these cartesion memory locations for delta
// Some defines to make clearer reading, as we overload these cartesian memory locations for delta
#define towerAMaxSteps Printer::xMaxSteps
#define towerBMaxSteps Printer::yMaxSteps
#define towerCMaxSteps Printer::zMaxSteps
@ -126,18 +127,27 @@ public:
int32_t correct(int32_t x, int32_t y, int32_t z) const;
void updateDerived();
void reportStatus();
bool isEnabled() {return enabled;}
int32_t zMaxSteps() {return zEnd;}
void set(float x,float y,float z);
void showMatrix();
void resetCorrection();
private:
INLINE int matrixIndex(fast8_t x, fast8_t y) const;
INLINE int32_t getMatrix(int index) const;
INLINE void setMatrix(int32_t val, int index);
int matrixIndex(fast8_t x, fast8_t y) const;
int32_t getMatrix(int index) const;
void setMatrix(int32_t val, int index);
bool isCorner(fast8_t i, fast8_t j) const;
INLINE int32_t extrapolatePoint(fast8_t x1, fast8_t y1, fast8_t x2, fast8_t y2) const;
void extrapolateCorner(fast8_t x, fast8_t y, fast8_t dx, fast8_t dy);
void extrapolateCorners();
void resetCorrection();
// attributes
#if DRIVE_SYSTEM == DELTA
int32_t step;
int32_t radiusCorrectionSteps;
#else
int32_t xCorrectionSteps,xOffsetSteps;
int32_t yCorrectionSteps,yOffsetSteps;
#endif
int32_t zStart,zEnd;
#if !DISTORTION_PERMANENT
int32_t matrix[DISTORTION_CORRECTION_POINTS * DISTORTION_CORRECTION_POINTS];
@ -167,9 +177,11 @@ private:
class Endstops {
static flag8_t lastState;
static flag8_t lastRead;
static flag8_t accumulator;
#ifdef EXTENDED_ENDSTOPS
static flag8_t lastState2;
static flag8_t lastRead2;
static flag8_t accumulator2;
#endif
public:
static void update();
@ -177,6 +189,18 @@ public:
static INLINE bool anyXYZMax() {
return (lastState & (ENDSTOP_X_MAX_ID|ENDSTOP_Z_MAX_ID|ENDSTOP_Z_MAX_ID)) != 0;
}
static INLINE void resetAccumulator() {
accumulator = 0;
#ifdef EXTENDED_ENDSTOPS
accumulator2 = 0;
#endif
}
static INLINE void fillFromAccumulator() {
lastState = accumulator;
#ifdef EXTENDED_ENDSTOPS
lastState2 = accumulator2;
#endif
}
static INLINE bool xMin() {
#if (X_MIN_PIN > -1) && MIN_HARDWARE_ENDSTOP_X
return (lastState & ENDSTOP_X_MIN_ID) != 0;
@ -234,13 +258,26 @@ public:
#endif
}
};
#ifndef DEFAULT_PRINTER_MODE
#if NUM_EXTRUDER > 0
#define DEFAULT_PRINTER_MODE PRINTER_MODE_FFF
#elif defined(SUPPORT_LASER) && SUPPORT_LASER
#define DEFAULT_PRINTER_MODE PRINTER_MODE_LASER
#elif defined(SUPPORT_CNC) && SUPPORT_CNC
#define DEFAULT_PRINTER_MODE PRINTER_MODE_CNC
#else
#error No supported printer mode compiled
#endif
#endif
class Printer
{
static uint8_t debugLevel;
public:
#if USE_ADVANCE
static volatile int extruderStepsNeeded; ///< This many extruder steps are still needed, <0 = reverse steps needed.
static uint8_t maxExtruderSpeed; ///< Timer delay for end extruder speed
static ufast8_t maxExtruderSpeed; ///< Timer delay for end extruder speed
//static uint8_t extruderAccelerateDelay; ///< delay between 2 speec increases
static int advanceStepsSet;
#if ENABLE_QUADRATIC_ADVANCE
@ -259,12 +296,13 @@ public:
static uint8_t relativeCoordinateMode; ///< Determines absolute (false) or relative Coordinates (true).
static uint8_t relativeExtruderCoordinateMode; ///< Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
static uint8_t unitIsInches;
static uint8_t debugLevel;
static uint8_t unitIsInches;
static uint8_t mode;
static uint8_t fanSpeed; // Last fan speed set with M106/M107
static float zBedOffset;
static uint8_t flag0,flag1; // 1 = stepper disabled, 2 = use external extruder interrupt, 4 = temp Sensor defect, 8 = homed
static uint8_t flag2;
static uint8_t stepsPerTimerCall;
static fast8_t stepsPerTimerCall;
static uint32_t interval; ///< Last step duration in ticks.
static uint32_t timer; ///< used for acceleration/deceleration timing
static uint32_t stepNumber; ///< Step number in current move.
@ -293,15 +331,17 @@ public:
static int16_t travelMovesPerSecond;
static int16_t printMovesPerSecond;
static float radius0;
#else
static int32_t zCorrectionStepsIncluded;
#endif
#if FEATURE_Z_PROBE || MAX_HARDWARE_ENDSTOP_Z || NONLINEAR_SYSTEM
static int32_t stepsRemainingAtZHit;
#endif
#if DRIVE_SYSTEM==DELTA
#if DRIVE_SYSTEM == DELTA
static int32_t stepsRemainingAtXHit;
static int32_t stepsRemainingAtYHit;
#endif
#if SOFTWARE_LEVELING
#ifdef SOFTWARE_LEVELING
static int32_t levelingP1[3];
static int32_t levelingP2[3];
static int32_t levelingP3[3];
@ -309,7 +349,11 @@ public:
#if FEATURE_AUTOLEVEL
static float autolevelTransformation[9]; ///< Transformation matrix
#endif
static int8_t zBabystepsMissing;
#if FAN_THERMO_PIN > -1
static float thermoMinTemp;
static float thermoMaxTemp;
#endif
static int16_t zBabystepsMissing;
static float minimumSpeed; ///< lowest allowed speed to keep integration error small
static float minimumZSpeed; ///< lowest allowed speed to keep integration error small
static int32_t xMaxSteps; ///< For software endstops, limit of move in positive direction.
@ -343,9 +387,6 @@ public:
static float backlashY;
static float backlashZ;
static uint8_t backlashDir;
#endif
#ifdef DEBUG_STEPCOUNT
static long totalStepsRemaining;
#endif
static float memoryX;
static float memoryY;
@ -372,7 +413,7 @@ public:
if(highPriority || interruptEvent == 0)
interruptEvent = evt;
}
static void reportPrinterMode();
static INLINE void setMenuMode(uint8_t mode,bool on)
{
if(on)
@ -383,54 +424,63 @@ public:
static INLINE bool isMenuMode(uint8_t mode)
{
return (menuMode & mode)==mode;
return (menuMode & mode) == mode;
}
static void setDebugLevel(uint8_t newLevel);
static void toggleEcho();
static void toggleInfo();
static void toggleErrors();
static void toggleDryRun();
static void toggleCommunication();
static void toggleNoMoves();
static INLINE uint8_t getDebugLevel() {return debugLevel;}
static INLINE bool debugEcho()
{
return ((debugLevel & 1)!=0);
return ((debugLevel & 1) != 0);
}
static INLINE bool debugInfo()
{
return ((debugLevel & 2)!=0);
return ((debugLevel & 2) != 0);
}
static INLINE bool debugErrors()
{
return ((debugLevel & 4)!=0);
return ((debugLevel & 4) != 0);
}
static INLINE bool debugDryrun()
{
return ((debugLevel & 8)!=0);
return ((debugLevel & 8) != 0);
}
static INLINE bool debugCommunication()
{
return ((debugLevel & 16)!=0);
return ((debugLevel & 16) != 0);
}
static INLINE bool debugNoMoves()
{
return ((debugLevel & 32)!=0);
return ((debugLevel & 32) != 0);
}
static INLINE bool debugFlag(unsigned long flags)
static INLINE bool debugFlag(uint8_t flags)
{
return (debugLevel & flags);
}
static INLINE void debugSet(unsigned long flags)
static INLINE void debugSet(uint8_t flags)
{
debugLevel |= flags;
setDebugLevel(debugLevel | flags);
}
static INLINE void debugReset(unsigned long flags)
static INLINE void debugReset(uint8_t flags)
{
debugLevel &= ~flags;
}
setDebugLevel(debugLevel & ~flags);
}
/** Sets the pwm for the fan speed. Gets called by motion control ot Commands::setFanSpeed. */
static void setFanSpeedDirectly(uint8_t speed);
static void setFan2SpeedDirectly(uint8_t speed);
/** \brief Disable stepper motor for x direction. */
static INLINE void disableXStepper()
{
@ -460,6 +510,9 @@ public:
#endif
#if FEATURE_TWO_ZSTEPPER && (Z2_ENABLE_PIN > -1)
WRITE(Z2_ENABLE_PIN, !Z_ENABLE_ON);
#endif
#if FEATURE_THREE_ZSTEPPER && (Z3_ENABLE_PIN > -1)
WRITE(Z3_ENABLE_PIN, !Z_ENABLE_ON);
#endif
}
@ -492,6 +545,9 @@ public:
#endif
#if FEATURE_TWO_ZSTEPPER && (Z2_ENABLE_PIN > -1)
WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON);
#endif
#if FEATURE_THREE_ZSTEPPER && (Z3_ENABLE_PIN > -1)
WRITE(Z3_ENABLE_PIN, Z_ENABLE_ON);
#endif
}
@ -537,6 +593,9 @@ public:
WRITE(Z_DIR_PIN, !INVERT_Z_DIR);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_DIR_PIN, !INVERT_Z_DIR);
#endif
#if FEATURE_THREE_ZSTEPPER
WRITE(Z3_DIR_PIN, !INVERT_Z_DIR);
#endif
}
else
@ -544,6 +603,9 @@ public:
WRITE(Z_DIR_PIN, INVERT_Z_DIR);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_DIR_PIN, INVERT_Z_DIR);
#endif
#if FEATURE_THREE_ZSTEPPER
WRITE(Z3_DIR_PIN, INVERT_Z_DIR);
#endif
}
}
@ -697,6 +759,15 @@ public:
{
flag2 = (b ? flag2 | PRINTER_FLAG2_HOMING : flag2 & ~PRINTER_FLAG2_HOMING);
}
static INLINE uint8_t isAllEMotors()
{
return flag2 & PRINTER_FLAG2_ALL_E_MOTORS;
}
static INLINE void setAllEMotors(uint8_t b)
{
flag2 = (b ? flag2 | PRINTER_FLAG2_ALL_E_MOTORS : flag2 & ~PRINTER_FLAG2_ALL_E_MOTORS);
}
static INLINE uint8_t isDebugJam()
{
@ -744,8 +815,8 @@ public:
static INLINE void unsetAllSteppersDisabled()
{
flag0 &= ~PRINTER_FLAG0_STEPPER_DISABLED;
#if FAN_BOARD_PIN>-1
pwm_pos[NUM_EXTRUDER + 1] = 255;
#if FAN_BOARD_PIN > -1
pwm_pos[PWM_BOARD_FAN] = 255;
#endif // FAN_BOARD_PIN
}
static INLINE bool isAnyTempsensorDefect()
@ -786,33 +857,33 @@ public:
#if (GANTRY)
if(motorX <= -2)
{
WRITE(X_STEP_PIN,HIGH);
WRITE(X_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,HIGH);
WRITE(X2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorX += 2;
}
else if(motorX >= 2)
{
WRITE(X_STEP_PIN,HIGH);
WRITE(X_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,HIGH);
WRITE(X2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorX -= 2;
}
if(motorYorZ <= -2)
{
WRITE(Y_STEP_PIN,HIGH);
WRITE(Y_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_YSTEPPER
WRITE(Y2_STEP_PIN,HIGH);
WRITE(Y2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorYorZ += 2;
}
else if(motorYorZ >= 2)
{
WRITE(Y_STEP_PIN,HIGH);
WRITE(Y_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_YSTEPPER
WRITE(Y2_STEP_PIN,HIGH);
WRITE(Y2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorYorZ -= 2;
}
@ -823,53 +894,86 @@ public:
#if (GANTRY)
if(motorX <= -2)
{
WRITE(X_STEP_PIN,HIGH);
WRITE(X_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,HIGH);
WRITE(X2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorX += 2;
}
else if(motorX >= 2)
{
WRITE(X_STEP_PIN,HIGH);
WRITE(X_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,HIGH);
WRITE(X2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorX -= 2;
}
if(motorYorZ <= -2)
{
//ANALYZER_ON(ANALYZER_CH3); // I dont think i can use these as they are for the y - possible bug area though
WRITE(Z_STEP_PIN,HIGH);
WRITE(Z_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_STEP_PIN,HIGH);
WRITE(Z2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
#if FEATURE_THREE_ZSTEPPER
WRITE(Z3_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorYorZ += 2;
}
else if(motorYorZ >= 2)
{
//ANALYZER_ON(ANALYZER_CH3); // I dont think i can use these as they are for the y - possible bug area though
WRITE(Z_STEP_PIN,HIGH);
WRITE(Z_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_STEP_PIN,HIGH);
WRITE(Z2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
#if FEATURE_THREE_ZSTEPPER
WRITE(Z3_STEP_PIN,START_STEP_WITH_HIGH);
#endif
motorYorZ -= 2;
}
#endif
}
static INLINE void startXStep()
{
WRITE(X_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
}
static INLINE void startYStep()
{
WRITE(Y_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_YSTEPPER
WRITE(Y2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
}
static INLINE void startZStep()
{
WRITE(Z_STEP_PIN,START_STEP_WITH_HIGH);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_STEP_PIN,START_STEP_WITH_HIGH);
#endif
#if FEATURE_THREE_ZSTEPPER
WRITE(Z3_STEP_PIN,START_STEP_WITH_HIGH);
#endif
}
static INLINE void endXYZSteps()
{
WRITE(X_STEP_PIN,LOW);
WRITE(X_STEP_PIN,!START_STEP_WITH_HIGH);
#if FEATURE_TWO_XSTEPPER
WRITE(X2_STEP_PIN,LOW);
WRITE(X2_STEP_PIN,!START_STEP_WITH_HIGH);
#endif
WRITE(Y_STEP_PIN,LOW);
WRITE(Y_STEP_PIN,!START_STEP_WITH_HIGH);
#if FEATURE_TWO_YSTEPPER
WRITE(Y2_STEP_PIN,LOW);
WRITE(Y2_STEP_PIN,!START_STEP_WITH_HIGH);
#endif
WRITE(Z_STEP_PIN,LOW);
WRITE(Z_STEP_PIN,!START_STEP_WITH_HIGH);
#if FEATURE_TWO_ZSTEPPER
WRITE(Z2_STEP_PIN,LOW);
WRITE(Z2_STEP_PIN,!START_STEP_WITH_HIGH);
#endif
#if FEATURE_THREE_ZSTEPPER
WRITE(Z3_STEP_PIN,!START_STEP_WITH_HIGH);
#endif
}
static INLINE speed_t updateStepsPerTimerCall(speed_t vbase)
@ -956,13 +1060,17 @@ public:
static void defaultLoopActions();
static uint8_t setDestinationStepsFromGCode(GCode *com);
static uint8_t moveTo(float x,float y,float z,float e,float f);
static uint8_t moveToReal(float x,float y,float z,float e,float f);
static uint8_t moveToReal(float x,float y,float z,float e,float f,bool pathOptimize = true);
static void homeAxis(bool xaxis,bool yaxis,bool zaxis); /// Home axis
static void setOrigin(float xOff,float yOff,float zOff);
static bool isPositionAllowed(float x,float y,float z);
static INLINE int getFanSpeed()
{
return (int)pwm_pos[NUM_EXTRUDER + 2];
return (int)pwm_pos[PWM_FAN1];
}
static INLINE int getFan2Speed()
{
return (int)pwm_pos[PWM_FAN2];
}
#if NONLINEAR_SYSTEM
static INLINE void setDeltaPositions(long xaxis, long yaxis, long zaxis)
@ -977,8 +1085,11 @@ public:
static float runZMaxProbe();
#endif
#if FEATURE_Z_PROBE
static void startProbing(bool runScript);
static void finishProbing();
static float runZProbe(bool first,bool last,uint8_t repeat = Z_PROBE_REPETITIONS,bool runStartScript = true);
static void waitForZProbeStart();
static float bendingCorrectionAt(float x,float y);
#endif
// Moved outside FEATURE_Z_PROBE to allow auto-level functional test on
// system without Z-probe
@ -1010,7 +1121,10 @@ public:
}
static void showConfiguration();
static void setCaseLight(bool on);
static void reportCaseLightStatus();
static void reportCaseLightStatus();
#if JSON_OUTPUT
static void showJSONStatus(int type);
#endif
private:
static void homeXAxis();
static void homeYAxis();
@ -1018,5 +1132,3 @@ private:
};
#endif // PRINTER_H_INCLUDED

View file

@ -1,875 +0,0 @@
<?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>

File diff suppressed because it is too large Load diff

View file

@ -23,15 +23,16 @@
#define _REPETIER_H
#include <math.h>
#define REPETIER_VERSION "0.92.3"
#include <stdint.h>
#define REPETIER_VERSION "0.92.8"
// ##########################################################################################
// ## 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};
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
@ -62,6 +63,8 @@ usage or for seraching for memory induced errors. Switch it off for production,
//#define DEBUG_SEGMENT_LENGTH
// Find the maximum real jerk during a print
//#define DEBUG_REAL_JERK
// Debug reason for not mounting a sd card
//#define DEBUG_SD_ERROR
// Uncomment the following line to enable debugging. You can better control debugging below the following line
//#define DEBUG
@ -150,6 +153,8 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define CONTROLLER_SPARKLCD 19
#define CONTROLLER_BAM_DICE_DUE 20
#define CONTROLLER_VIKI2 21
#define CONTROLLER_LCD_MP_PHARAOH_DUE 22
#define CONTROLLER_SPARKLCD_ADAPTER 23
#define CONTROLLER_FELIX_DUE 405
//direction flags
@ -174,9 +179,27 @@ usage or for seraching for memory induced errors. Switch it off for production,
// add pid control
#define TEMP_PID 1
#define PRINTER_MODE_FFF 0
#define PRINTER_MODE_LASER 1
#define PRINTER_MODE_CNC 2
// we can not prevent this as some configs need a parameter and others not
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#include "Configuration.h"
inline void memcopy2(void *dest,void *source) {
*((int16_t*)dest) = *((int16_t*)source);
}
inline void memcopy4(void *dest,void *source) {
*((int32_t*)dest) = *((int32_t*)source);
}
#ifndef JSON_OUTPUT
#define JSON_OUTPUT 0
#endif
#if FEATURE_Z_PROBE && Z_PROBE_PIN < 0
#error You need to define Z_PROBE_PIN to use z probe!
#endif
@ -230,10 +253,12 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define SPEED_MAX_MILLIS 60
#define SPEED_MAGNIFICATION 100.0f
#define SOFTWARE_LEVELING (FEATURE_SOFTWARE_LEVELING && (DRIVE_SYSTEM==DELTA))
#define SOFTWARE_LEVELING (defined(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).
*/
#ifndef ROD_RADIUS
#define ROD_RADIUS (PRINTER_RADIUS-END_EFFECTOR_HORIZONTAL_OFFSET-CARRIAGE_HORIZONTAL_OFFSET)
#endif
#ifndef UI_SPEEDDEPENDENT_POSITIONING
#define UI_SPEEDDEPENDENT_POSITIONING true
@ -276,16 +301,28 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define SHARED_COOLER 0
#endif
#ifndef START_STEP_WITH_HIGH
#define START_STEP_WITH_HIGH 1
#endif
#if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE == 101
#define SUPPORT_MAX6675
#endif
#if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE == 102
#define SUPPORT_MAX31855
#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
#define SHARED_COOLER_BOARD_EXT 1
#else
#define SHARED_COOLER_BOARD_EXT 0
#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
#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)
@ -293,6 +330,9 @@ usage or for seraching for memory induced errors. Switch it off for production,
#else
#define EXTRUDER_JAM_CONTROL 0
#endif
#ifndef JAM_METHOD
#define JAM_METHOD 1
#endif
#if NUM_EXTRUDER > 0 && EXT0_TEMPSENSOR_TYPE < 101
#define EXT0_ANALOG_INPUTS 1
@ -306,7 +346,7 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define EXT0_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER>1 && EXT1_TEMPSENSOR_TYPE<101
#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
@ -318,7 +358,7 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define EXT1_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER>2 && EXT2_TEMPSENSOR_TYPE<101
#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
@ -354,7 +394,7 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define EXT4_ANALOG_CHANNEL
#endif
#if NUM_EXTRUDER>5 && EXT5_TEMPSENSOR_TYPE<101
#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
@ -370,12 +410,22 @@ usage or for seraching for memory induced errors. Switch it off for production,
#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 ,
#undef BEKOMMA
#define BED_KOMMA ,
#else
#define BED_ANALOG_INPUTS 0
#define BED_SENSOR_INDEX HEATED_BED_SENSOR_PIN
#define BED_ANALOG_CHANNEL
#define BED_KOMMA ACCOMMA5
#endif
#if FAN_THERMO_THERMISTOR_PIN > -1 && FAN_THERMO_PIN > -1
#define THERMO_ANALOG_INPUTS 1
#define THERMO_ANALOG_INDEX EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS
#define THERMO_ANALOG_CHANNEL BED_KOMMA FAN_THERMO_THERMISTOR_PIN
#else
#define THERMO_ANALOG_INPUTS 0
#define THERMO_ANALOG_CHANNEL
#endif
#ifndef DEBUG_FREE_MEMORY
@ -385,10 +435,10 @@ usage or for seraching for memory induced errors. Switch it off for production,
#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
#define ANALOG_INPUTS (EXT0_ANALOG_INPUTS+EXT1_ANALOG_INPUTS+EXT2_ANALOG_INPUTS+EXT3_ANALOG_INPUTS+EXT4_ANALOG_INPUTS+EXT5_ANALOG_INPUTS+BED_ANALOG_INPUTS+THERMO_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}
#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 THERMO_ANALOG_CHANNEL}
#endif
#define MENU_MODE_SD_MOUNTED 1
@ -399,6 +449,22 @@ usage or for seraching for memory induced errors. Switch it off for production,
#define MENU_MODE_FULL_PID 32
#define MENU_MODE_DEADTIME 64
#ifndef BENDING_CORRECTION_A
#define BENDING_CORRECTION_A 0
#endif
#ifndef BENDING_CORRECTION_B
#define BENDING_CORRECTION_B 0
#endif
#ifndef BENDING_CORRECTION_C
#define BENDING_CORRECTION_C 0
#endif
#ifndef Z_ACCELERATION_TOP
#define Z_ACCELERATION_TOP 0
#endif
#include "HAL.h"
#include "gcode.h"
#define MAX_VFAT_ENTRIES (2)
@ -411,9 +477,9 @@ usage or for seraching for memory induced errors. Switch it off for production,
#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
#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
@ -442,65 +508,271 @@ usage or for seraching for memory induced errors. Switch it off for production,
#undef min
#undef max
class RMath {
class RMath
{
public:
static inline float min(float a,float b) {
if(a<b) return a;
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;
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;
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 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 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;
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;
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;
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;
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;
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;}
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;}
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;}
static inline float sqr(float a)
{
return a*a;
}
};
class RVector3
{
public:
float x, y, z;
RVector3(float _x = 0,float _y = 0,float _z = 0):x(_x),y(_y),z(_z) {};
RVector3(const RVector3 &a):x(a.x),y(a.y),z(a.z) {};
/* const float &operator[](std::size_t idx) const
{
if(idx == 0) return x;
if(idx == 1) return y;
return z;
};
float &operator[](std::size_t idx)
{
switch(idx) {
case 0: return x;
case 1: return y;
case 2: return z;
}
return 0;
};*/
inline bool operator==(const RVector3 &rhs)
{
return x==rhs.x && y==rhs.y && z==rhs.z;
}
inline bool operator!=(const RVector3 &rhs)
{
return !(*this==rhs);
}
inline RVector3& operator=(const RVector3 &rhs)
{
if(this!=&rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
}
return *this;
}
inline RVector3& operator+=(const RVector3 &rhs)
{
x += rhs.x;
y += rhs.y;
z += rhs.z;
return *this;
}
inline RVector3& operator-=(const RVector3 &rhs)
{
x -= rhs.x;
y -= rhs.y;
z -= rhs.z;
return *this;
}
inline RVector3 operator-() const
{
return RVector3(-x,-y,-z);
}
inline float length() const
{
return sqrt(x * x + y * y + z * z);
}
inline float lengthSquared() const
{
return (x*x+y*y+z*z);
}
inline RVector3 cross(const RVector3 &b) const
{
return RVector3(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);
}
inline float scalar(const RVector3 &b) const
{
return (x*b.x+y*b.y+z*b.z);
}
inline RVector3 scale(float factor) const
{
return RVector3(x*factor,y*factor,z*factor);
}
inline void scaleIntern(float factor)
{
x*=factor;
y*=factor;
z*=factor;
}
inline void setMinimum(const RVector3 &b)
{
x = RMath::min(x,b.x);
y = RMath::min(y,b.y);
z = RMath::min(z,b.z);
}
inline void setMaximum(const RVector3 &b)
{
x = RMath::max(x,b.x);
y = RMath::max(y,b.y);
z = RMath::max(z,b.z);
}
inline float distance(const RVector3 &b) const
{
float dx = b.x-x,dy = b.y-y, dz = b.z-z;
return (sqrt(dx*dx+dy*dy+dz*dz));
}
inline float angle(RVector3 &direction)
{
return static_cast<float>(acos(scalar(direction)/(length()*direction.length())));
}
inline RVector3 normalize() const
{
float len = length();
if(len != 0) len = static_cast<float>(1.0/len);
return RVector3(x*len,y*len,z*len);
}
inline RVector3 interpolatePosition(const RVector3 &b, float pos) const
{
float pos2 = 1.0f - pos;
return RVector3(x * pos2 + b.x * pos, y * pos2 + b.y * pos, z * pos2 + b.z * pos);
}
inline RVector3 interpolateDirection(const RVector3 &b,float pos) const
{
//float pos2 = 1.0f - pos;
float dot = scalar(b);
if (dot > 0.9995 || dot < -0.9995)
return interpolatePosition(b,pos); // cases cause trouble, use linear interpolation here
float theta = acos(dot) * pos; // interpolated position
float st = sin(theta);
RVector3 t(b);
t -= scale(dot);
float lengthSq = t.lengthSquared();
float dl = st * ((lengthSq < 0.0001f) ? 1.0f : 1.0f / sqrt(lengthSq));
t.scaleIntern(dl);
t += scale(cos(theta));
return t.normalize();
}
};
inline RVector3 operator+(RVector3 lhs, const RVector3& rhs) // first arg by value, second by const ref
{
lhs.x += rhs.x;
lhs.y += rhs.y;
lhs.z += rhs.z;
return lhs;
}
inline RVector3 operator-(RVector3 lhs, const RVector3& rhs) // first arg by value, second by const ref
{
lhs.x -= rhs.x;
lhs.y -= rhs.y;
lhs.z -= rhs.z;
return lhs;
}
inline RVector3 operator*(const RVector3 &lhs,float rhs) {
return lhs.scale(rhs);
}
inline RVector3 operator*(float lhs,const RVector3 &rhs) {
return rhs.scale(lhs);
}
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
//extern uint8 osAnalogInputPos; // Current sampling position
#if ANALOG_INPUTS > 0
extern volatile uint osAnalogInputValues[ANALOG_INPUTS];
#endif
#define PWM_HEATED_BED NUM_EXTRUDER
#define PWM_BOARD_FAN PWM_HEATED_BED+1
#define PWM_FAN1 PWM_BOARD_FAN+1
#define PWM_FAN2 PWM_FAN1+1
#define PWM_FAN_THERMO PWM_FAN2+1
#define NUM_PWM PWM_FAN_THERMO+1
extern uint8_t pwm_pos[NUM_PWM]; // 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;
@ -542,10 +814,6 @@ 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"
@ -554,8 +822,12 @@ extern unsigned int counterPeriodical;
extern volatile uint8_t executePeriodical;
extern uint8_t counter250ms;
extern void writeMonitor();
#if FEATURE_FAN_CONTROL
extern uint8_t fanKickstart;
#endif
#if FEATURE_FAN2_CONTROL
extern uint8_t fan2Kickstart;
#endif
#if SDSUPPORT
extern char tempLongFilename[LONG_FILENAME_LENGTH+1];
@ -564,51 +836,65 @@ extern char fullName[LONG_FILENAME_LENGTH*SD_MAX_FOLDER_DEPTH+SD_MAX_FOLDER_DEPT
#include "SdFat.h"
enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
class SDCard {
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;
SdFat fat;
//Sd2Card card; // ~14 Byte
//SdVolume volume;
//SdFile root;
//SdFile dir[SD_MAX_FOLDER_DEPTH+1];
SdFile file;
#if JSON_OUTPUT
GCodeFileInfo fileInfo;
#endif
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();
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();
#if JSON_OUTPUT
void lsJSON(const char *filename);
void JSONFileInfo(const char *filename);
static void printEscapeChars(const char *s);
#endif
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();
void writeToFile();
#endif
private:
uint8_t lsRecursive(SdBaseFile *parent,uint8_t level,char *findFilename);
// SdFile *getDirectory(char* name);
uint8_t lsRecursive(SdBaseFile *parent,uint8_t level,char *findFilename);
// SdFile *getDirectory(char* name);
};
extern SDCard sd;
@ -652,5 +938,3 @@ extern int debugWaitLoop;
#endif
#endif

View file

@ -39,7 +39,7 @@ 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
- G10 S<1 = long retract, 0 = short retract = default> retracts filament according 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.
@ -47,19 +47,21 @@ Implemented Codes
- 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
- G32 S<0..2> P<0..1> - Autolevel print bed. S = 1 measure zLength, S = 2 Measure and store new zLength
- G90 - Use absolute coordinates
- G91 - Use relative coordinates
- G92 - Set current position to cordinates given
- G92 - Set current position to coordinates 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.
- G133 - measure steps until max endstops for deltas. Can be used to detect lost steps within tolerances of endstops.
- G134 Px Sx Zx - Calibrate nozzle height difference (need z probe in nozzle!) Px = reference extruder, Sx = only measure extrude x against reference, Zx = add to measured z distance for Sx for correction.
RepRap M Codes
- M104 - Set extruder target temp
- M105 - Read current temp
- M106 - Fan on
- M107 - Fan off
- M106 S<speed> P<fan> - Fan on speed = 0..255, P = 0 or 1, 0 is default and can be omitted
- M107 P<fan> - Fan off, P = 0 or 1, 0 is default and can be omitted
- M109 - Wait for extruder current temp to reach target temp.
- M114 - Display current position
@ -108,7 +110,8 @@ Custom M Codes
- 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
- M221 S<Extrusion flow multiplier in percent> - Increase/decrease given flow rate
- M228 P<pin> S<state 0/1> - Wait for pin getting state S. Add X0 to init as input without pullup and X1 for input with pullup.
- 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
@ -128,7 +131,12 @@ Custom M Codes
- 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.
- M402 - Go to stored position. If X, Y or Z is specified, only these coordinates are used. F changes feedrate fo rthat move.
- M450 - Reports printer mode
- M451 - Set printer mode to FFF
- M452 - Set printer mode to laser
- M453 - Set printer mode to CNC
- M460 X<minTemp> Y<maxTemp> : Set temperature range for thermistor controlled fan
- 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!
@ -163,5 +171,3 @@ void loop()

View file

@ -1,213 +0,0 @@
<?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>

View file

@ -41,25 +41,26 @@ void SDCard::automount()
#if SDCARDDETECT > -1
if(READ(SDCARDDETECT) != SDCARDDETECTINVERTED)
{
if(sdactive) // Card removed
if(sdactive || sdmode == 100) // 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);
UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_SD_REMOVED_ID));
}
}
else
{
if(!sdactive)
if(!sdactive && sdmode != 100)
{
UI_STATUS(UI_TEXT_SD_INSERTED);
Com::printFLN(PSTR("SD card inserted")); // Not translateable or host will not understand signal
initsd();
UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_SD_INSERTED_ID));
mount();
if(sdmode != 100) // send message only if we have success
Com::printFLN(PSTR("SD card inserted")); // Not translatable or host will not understand signal
#if UI_DISPLAY_TYPE != NO_DISPLAY
if(sdactive) {
if(sdactive && !uid.isWizardActive()) { // Wizards have priority
Printer::setAutomount(true);
uid.executeAction(UI_ACTION_SD_PRINT + UI_ACTION_TOPMENU, true);
}
@ -77,11 +78,13 @@ void SDCard::initsd()
if(READ(SDCARDDETECT) != SDCARDDETECTINVERTED)
return;
#endif
HAL::delayMilliseconds(50); // wait for stabilization of contacts, bootup ...
/*if(dir[0].isOpen())
dir[0].close();*/
if(!fat.begin(SDSS, SPI_FULL_SPEED))
{
Com::printFLN(Com::tSDInitFail);
sdmode = 100; // prevent automount loop!
return;
}
sdactive = true;
@ -176,27 +179,31 @@ void SDCard::stopPrint()
void SDCard::writeCommand(GCode *code)
{
unsigned int sum1=0,sum2=0; // for fletcher-16 checksum
unsigned int sum1 = 0, sum2 = 0; // for fletcher-16 checksum
uint8_t buf[100];
uint8_t p=2;
uint8_t p = 2;
file.writeError = false;
int params = 128 | (code->params & ~1);
*(int*)buf = params;
uint16_t params = 128 | (code->params & ~1);
memcopy2(buf,&params);
//*(int*)buf = params;
if(code->isV2()) // Read G,M as 16 bit value
{
*(int*)&buf[p] = code->params2;
p+=2;
memcopy2(&buf[p],&code->params2);
//*(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;
memcopy2(&buf[p],&code->M);
//*(int*)&buf[p] = code->M;
p += 2;
}
if(code->hasG())
{
*(int*)&buf[p]= code->G;
p+=2;
memcopy2(&buf[p],&code->G);
//*(int*)&buf[p]= code->G;
p += 2;
}
}
else
@ -212,28 +219,33 @@ void SDCard::writeCommand(GCode *code)
}
if(code->hasX())
{
*(float*)&buf[p] = code->X;
p+=4;
memcopy4(&buf[p],&code->X);
//*(float*)&buf[p] = code->X;
p += 4;
}
if(code->hasY())
{
*(float*)&buf[p] = code->Y;
p+=4;
memcopy4(&buf[p],&code->Y);
//*(float*)&buf[p] = code->Y;
p += 4;
}
if(code->hasZ())
{
*(float*)&buf[p] = code->Z;
p+=4;
memcopy4(&buf[p],&code->Z);
//*(float*)&buf[p] = code->Z;
p += 4;
}
if(code->hasE())
{
*(float*)&buf[p] = code->E;
p+=4;
memcopy4(&buf[p],&code->E);
//*(float*)&buf[p] = code->E;
p += 4;
}
if(code->hasF())
{
*(float*)&buf[p] = code->F;
p+=4;
memcopy4(&buf[p],&code->F);
//*(float*)&buf[p] = code->F;
p += 4;
}
if(code->hasT())
{
@ -241,23 +253,81 @@ void SDCard::writeCommand(GCode *code)
}
if(code->hasS())
{
*(long int*)&buf[p] = code->S;
p+=4;
memcopy4(&buf[p],&code->S);
//*(int32_t*)&buf[p] = code->S;
p += 4;
}
if(code->hasP())
{
*(long int*)&buf[p] = code->P;
p+=4;
memcopy4(&buf[p],&code->P);
//*(int32_t*)&buf[p] = code->P;
p += 4;
}
if(code->hasI())
{
*(float*)&buf[p] = code->I;
p+=4;
memcopy4(&buf[p],&code->I);
//*(float*)&buf[p] = code->I;
p += 4;
}
if(code->hasJ())
{
*(float*)&buf[p] = code->J;
p+=4;
memcopy4(&buf[p],&code->J);
//*(float*)&buf[p] = code->J;
p += 4;
}
if(code->hasR())
{
memcopy4(&buf[p],&code->R);
//*(float*)&buf[p] = code->R;
p += 4;
}
if(code->hasD())
{
memcopy4(&buf[p],&code->D);
//*(float*)&buf[p] = code->D;
p += 4;
}
if(code->hasC())
{
memcopy4(&buf[p],&code->C);
//*(float*)&buf[p] = code->C;
p += 4;
}
if(code->hasH())
{
memcopy4(&buf[p],&code->H);
//*(float*)&buf[p] = code->H;
p += 4;
}
if(code->hasA())
{
memcopy4(&buf[p],&code->A);
//*(float*)&buf[p] = code->A;
p += 4;
}
if(code->hasB())
{
memcopy4(&buf[p],&code->B);
//*(float*)&buf[p] = code->B;
p += 4;
}
if(code->hasK())
{
memcopy4(&buf[p],&code->K);
//*(float*)&buf[p] = code->K;
p += 4;
}
if(code->hasL())
{
memcopy4(&buf[p],&code->L);
//*(float*)&buf[p] = code->L;
p += 4;
}
if(code->hasO())
{
memcopy4(&buf[p],&code->O);
//*(float*)&buf[p] = code->O;
p += 4;
}
if(code->hasString()) // read 16 uint8_t into string
{
@ -269,7 +339,7 @@ void SDCard::writeCommand(GCode *code)
}
else
{
for(uint8_t i=0; i<16; ++i) buf[p++] = *sp++;
for(uint8_t i = 0; i < 16; ++i) buf[p++] = *sp++;
}
}
uint8_t *ptr = buf;
@ -281,14 +351,19 @@ void SDCard::writeCommand(GCode *code)
do
{
sum1 += *ptr++;
if(sum1>=255) sum1-=255;
if(sum1 >= 255) sum1 -= 255;
sum2 += sum1;
if(sum2>=255) sum2-=255;
if(sum2 >= 255) sum2 -= 255;
}
while (--tlen);
}
buf[p++] = sum1;
buf[p++] = sum2;
// Debug
/*Com::printF(PSTR("Buf: "));
for(int i=0;i<p;i++)
Com::printF(PSTR(" "),(int)buf[i]);
Com::println();*/
if(params == 128)
{
Com::printErrorFLN(Com::tAPIDFinished);
@ -351,12 +426,98 @@ void SDCard::ls()
file.ls(0, 0);
Com::printFLN(Com::tEndFileList);
}
#if JSON_OUTPUT
void SDCard::lsJSON(const char *filename)
{
SdBaseFile dir;
fat.chdir();
if (*filename == 0) {
dir.openRoot(fat.vol());
} else {
if (!dir.open(fat.vwd(), filename, O_READ) || !dir.isDir()) {
Com::printF(Com::tJSONErrorStart);
Com::printF(Com::tFileOpenFailed);
Com::printFLN(Com::tJSONErrorEnd);
return;
}
}
Com::printF(Com::tJSONDir);
SDCard::printEscapeChars(filename);
Com::printF(Com::tJSONFiles);
dir.lsJSON();
Com::printFLN(Com::tJSONArrayEnd);
}
void SDCard::printEscapeChars(const char *s) {
for (unsigned int i = 0; i < strlen(s); ++i) {
switch (s[i]) {
case '"':
case '/':
case '\b':
case '\f':
case '\n':
case '\r':
case '\t':
case '\\':
Com::print('\\');
break;
}
Com::print(s[i]);
}
}
void SDCard::JSONFileInfo(const char* filename) {
SdBaseFile targetFile;
GCodeFileInfo *info,tmpInfo;
if (strlen(filename) == 0) {
targetFile = file;
info = &fileInfo;
} else {
if (!targetFile.open(fat.vwd(), filename, O_READ) || targetFile.isDir()) {
Com::printF(Com::tJSONErrorStart);
Com::printF(Com::tFileOpenFailed);
Com::printFLN(Com::tJSONErrorEnd);
return;
}
info = &tmpInfo;
info->init(targetFile);
}
if (!targetFile.isOpen()) {
Com::printF(Com::tJSONErrorStart);
Com::printF(Com::tNotSDPrinting);
Com::printFLN(Com::tJSONErrorEnd);
return;
}
// {"err":0,"size":457574,"height":4.00,"layerHeight":0.25,"filament":[6556.3],"generatedBy":"Slic3r 1.1.7 on 2014-11-09 at 17:11:32"}
Com::printF(Com::tJSONFileInfoStart);
Com::print(info->fileSize);
Com::printF(Com::tJSONFileInfoHeight);
Com::print(info->objectHeight);
Com::printF(Com::tJSONFileInfoLayerHeight);
Com::print(info->layerHeight);
Com::printF(Com::tJSONFileInfoFilament);
Com::print(info->filamentNeeded);
Com::printF(Com::tJSONFileInfoGeneratedBy);
Com::print(info->generatedBy);
Com::print('"');
if (strlen(filename) == 0) {
Com::printF(Com::tJSONFileInfoName);
file.printName();
Com::print('"');
}
Com::print('}');
Com::println();
};
#endif
bool SDCard::selectFile(const char *filename, bool silent)
{
SdBaseFile parent;
const char *oldP = filename;
boolean bFound;
if(!sdactive) return false;
sdmode = 0;
@ -375,7 +536,10 @@ bool SDCard::selectFile(const char *filename, bool silent)
{
Com::printF(Com::tFileOpened, oldP);
Com::printFLN(Com::tSpaceSizeColon,file.fileSize());
}
}
#if JSON_OUTPUT
fileInfo.init(file);
#endif
sdpos = 0;
filesize = file.fileSize();
Com::printFLN(Com::tFileSelected);
@ -414,7 +578,7 @@ void SDCard::startWrite(char *filename)
}
else
{
UI_STATUS(UI_TEXT_UPLOADING);
UI_STATUS_F(Com::translatedF(UI_TEXT_UPLOADING_ID));
savetosd = true;
Com::printFLN(Com::tWritingToFile,filename);
}
@ -480,5 +644,3 @@ void SDCard::writeToFile()
#endif

View file

@ -32,11 +32,6 @@ extern int8_t RFstrnicmp(const char* s1, const char* s2, size_t n);
//#define GLENN_DEBUG
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static void pstrPrint(FSTRINGPARAM(str)) {
Com::printF(str);
}
//------------------------------------------------------------------------------
static void pstrPrintln(FSTRINGPARAM(str)) {
Com::printFLN(str);
@ -652,11 +647,12 @@ void SdBaseFile::ls(uint8_t flags) {
ls(flags, 0);
}
uint8_t SdBaseFile::lsRecursive(SdBaseFile *parent, uint8_t level, char *findFilename, SdBaseFile *pParentFound)
uint8_t SdBaseFile::lsRecursive(SdBaseFile *parent, uint8_t level, char *findFilename, SdBaseFile *pParentFound, bool isJson)
{
dir_t *p = NULL;
uint8_t cnt=0;
char *oldpathend = pathend;
//uint8_t cnt=0;
//char *oldpathend = pathend;
bool firstFile = true;
parent->rewind();
@ -665,21 +661,29 @@ uint8_t SdBaseFile::lsRecursive(SdBaseFile *parent, uint8_t level, char *findFil
HAL::pingWatchdog();
if (! (DIR_IS_FILE(p) || DIR_IS_SUBDIR(p))) continue;
if (strcmp(tempLongFilename, "..") == 0) continue;
if( DIR_IS_SUBDIR(p))
{
if(level>=SD_MAX_FOLDER_DEPTH) continue; // can't go deeper
if(level<SD_MAX_FOLDER_DEPTH)
{
if (findFilename == NULL)
{
if(level)
{
Com::print(fullName);
Com::printF(Com::tSlash);
}
Com::print(tempLongFilename);
Com::printFLN(Com::tSlash); //End with / to mark it as directory entry, so we can see empty directories.
}
if (tempLongFilename[0] == '.') continue; // MAC CRAP
if (DIR_IS_SUBDIR(p)) {
if (level >= SD_MAX_FOLDER_DEPTH) continue; // can't go deeper
if (level < SD_MAX_FOLDER_DEPTH && findFilename == NULL) {
if (level && !isJson) {
Com::print(fullName);
Com::printF(Com::tSlash);
}
#if JSON_OUTPUT
if (isJson) {
if (!firstFile) Com::print(',');
Com::print('"');Com::print('*');
SDCard::printEscapeChars(tempLongFilename);
Com::print('"');
firstFile = false;
} else {
Com::print(tempLongFilename);
Com::printFLN(Com::tSlash); // End with / to mark it as directory entry, so we can see empty directories.
}
#else
Com::print(tempLongFilename);
Com::printFLN(Com::tSlash); // End with / to mark it as directory entry, so we can see empty directories.
#endif
}
SdBaseFile next;
char *tmp;
@ -689,11 +693,11 @@ uint8_t SdBaseFile::lsRecursive(SdBaseFile *parent, uint8_t level, char *findFil
strcat(fullName, tempLongFilename);
uint16_t index = (parent->curPosition()-31) >> 5;
if(next.open(parent, index, O_READ))
{
if (next.lsRecursive(&next,level+1, findFilename, pParentFound))
if(!isJson && next.open(parent, index, O_READ))
{
if (next.lsRecursive(&next,level+1, findFilename, pParentFound,false))
return true;
}
}
parent->seekSet(32 * (index + 1));
if ((tmp = strrchr(fullName, '/'))!= NULL)
*tmp = 0;
@ -721,16 +725,27 @@ uint8_t SdBaseFile::lsRecursive(SdBaseFile *parent, uint8_t level, char *findFil
}
else
{
if(level)
if(level && !isJson)
{
Com::print(fullName);
Com::printF(Com::tSlash);
}
#if JSON_OUTPUT
if (isJson) {
if (!firstFile) Com::printF(Com::tComma);
Com::print('"');
SDCard::printEscapeChars(tempLongFilename);
Com::print('"');
firstFile = false;
} else
#endif
{
Com::print(tempLongFilename);
#if SD_EXTENDED_DIR
Com::printF(Com::tSpace, (long) p->fileSize);
#endif
Com::println();
}
Com::print(tempLongFilename);
#if SD_EXTENDED_DIR
Com::printF(Com::tSpace,(long)p->fileSize);
#endif
Com::println();
}
}
}
@ -753,21 +768,31 @@ uint8_t SdBaseFile::lsRecursive(SdBaseFile *parent, uint8_t level, char *findFil
* \param[in] indent Amount of space before file name. Used for recursive
* list to indicate subdirectory level.
*/
void SdBaseFile::ls(uint8_t flags, uint8_t indent) {
SdBaseFile parent;
void SdBaseFile::ls(uint8_t flags, uint8_t indent) {
SdBaseFile parent;
rewind();
*fullName = 0;
pathend = fullName;
parent = *this;
lsRecursive(&parent, 0, NULL, NULL, false);
}
#if JSON_OUTPUT
void SdBaseFile::lsJSON() {
SdBaseFile parent;
rewind();
*fullName = 0;
parent = *this;
lsRecursive(&parent, 0, NULL, NULL, true);
}
#endif
rewind();
*fullName = 0;
pathend = fullName;
parent = *this;
lsRecursive(&parent, 0, NULL, NULL);
}
//------------------------------------------------------------------------------
// saves 32 bytes on stack for ls recursion
// return 0 - EOF, 1 - normal file, or 2 - directory
int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
dir_t dir;
uint8_t w = 0;
//uint8_t w = 0;
while (1) {
if (read(&dir, sizeof(dir)) != sizeof(dir)) return 0;
if (dir.name[0] == DIR_NAME_FREE) return 0;
@ -876,8 +901,6 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const char* path, bool pFlag) {
{
return mkdir(&newParent, dname);
}
fail:
return false;
}
//------------------------------------------------------------------------------
@ -886,13 +909,13 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t *dname) {
if (!parent->isDir()) {
DBG_FAIL_MACRO;
goto fail;
return false;
}
// create a normal file
if (!open(parent, dname, O_CREAT | O_EXCL | O_RDWR, true)) {
DBG_FAIL_MACRO;
goto fail;
return false;
}
// make entry for '.'
@ -908,7 +931,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t *dname) {
for (uint8_t i = 1; i < 11; i++) d.name[i] = ' ';
if (write(&d, sizeof(dir_t)) < 0)
goto fail;
return false;
sync();
// make entry for '..'
@ -921,18 +944,16 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t *dname) {
d.firstClusterHigh = parent->firstCluster_ >> 16;
}
if (write(&d, sizeof(dir_t)) < 0)
goto fail;
return false;
sync();
memset(&d, 0, sizeof(dir_t));
if (write(&d, sizeof(dir_t)) < 0)
goto fail;
return false;
sync();
// fileSize_ = 0;
type_ = FAT_FILE_TYPE_SUBDIR;
flags_ |= F_FILE_DIR_DIRTY;
return true;
fail:
return false;
}
//------------------------------------------------------------------------------
/** Open a file in the current working directory.
@ -1005,10 +1026,10 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t *dname) {
SdBaseFile *newParent, boolean bMakeDirs) {
SdBaseFile dir1, dir2;
SdBaseFile *parent = dirFile;
dir_t *pEntry;
//dir_t *pEntry;
SdBaseFile *sub = &dir1;
char *p;
boolean bFound;
//boolean bFound;
#ifdef GLENN_DEBUG
Commands::checkFreeMemory();
@ -1052,7 +1073,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t *dname) {
Commands::checkFreeMemory();
Commands::writeLowestFreeRAM();
#endif
bFound = false;
//bFound = false;
if (!sub->open(parent, dname, O_READ, false))
{
if (!bMakeDirs)
@ -1093,7 +1114,6 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char* path, uint8_t oflag)
return open(&parent, dname, oflag, false);
}
fail:
return false;
}
@ -1113,11 +1133,11 @@ uint8_t SdBaseFile::lfn_checksum(const unsigned char *pFCBName)
bool SdBaseFile::open(SdBaseFile* dirFile,const uint8_t *dname, uint8_t oflag, bool bDir) {
bool emptyFound = false;
uint8_t index = 0;
dir_t tempDir, *p;
dir_t tempDir, *p = NULL;
const char *tempPtr;
char newName[SHORT_FILENAME_LENGTH+2];
boolean bShortName = false;
int8_t cVFATNeeded = -1, wIndex, cVFATFoundCur;
int8_t cVFATNeeded = -1, cVFATFoundCur;
uint32_t wIndexPos = 0;
uint8_t cbFilename;
char *Filename = (char *)dname;
@ -1570,6 +1590,9 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
bool SdBaseFile::openRoot(SdVolume* vol) {
// error if file is already open
if (isOpen()) {
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("Root already open"));
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -1587,6 +1610,10 @@ bool SdBaseFile::openRoot(SdVolume* vol) {
}
} else {
// volume is not initialized, invalid, or FAT12 without support
#if defined(DEBUG_SD_ERROR)
Com::printErrorF(PSTR("volume is not initialized, invalid, or FAT12 without support, type:"));
Com::print((int)vol->fatType());Com::println();
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -1603,6 +1630,9 @@ bool SdBaseFile::openRoot(SdVolume* vol) {
return true;
fail:
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("SD open root dir failed"));
#endif
return false;
}
//------------------------------------------------------------------------------
@ -2055,7 +2085,7 @@ dir_t *SdBaseFile::getLongFilename(dir_t *dir, char *longFilename, int8_t cVFATN
bool SdBaseFile::findSpace(dir_t *dir, int8_t cVFATNeeded, int8_t *pcVFATFound, uint32_t *pwIndexPos)
{
int16_t n;
//int16_t n; // unused
int8_t cVFATFound = 0;
// if not a directory file or miss-positioned return an error
if (!isDir()) return -1;
@ -2081,7 +2111,7 @@ bool SdBaseFile::findSpace(dir_t *dir, int8_t cVFATNeeded, int8_t *pcVFATFound,
{
if (DIR_IS_LONG_NAME(dir))
{
vfat_t *VFAT = (vfat_t*)dir;
//vfat_t *VFAT = (vfat_t*)dir; // unused
cVFATFound++;
}
else
@ -3202,7 +3232,7 @@ uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {
#if USE_SD_CRC
// form message
uint8_t d[6] = {cmd | 0X40, pa[3], pa[2], pa[1], pa[0]};
uint8_t d[6] = {static_cast<uint8_t>(cmd | static_cast<uint8_t>(0X40)), pa[3], pa[2], pa[1], pa[0]};
// add crc
d[5] = CRC7(d, 5);
@ -3415,6 +3445,9 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
fail:
chipSelectHigh();
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("SD card initalization failed"));
#endif
return false;
}
//------------------------------------------------------------------------------
@ -3469,7 +3502,7 @@ bool Sd2Card::readData(uint8_t* dst, size_t count) {
goto fail;
}
// transfer data
if (status_ = spiRec(dst, count)) {
if ((status_ = spiRec(dst, count))) {
error(SD_CARD_ERROR_SPI_DMA);
goto fail;
}
@ -4224,7 +4257,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
cacheStatus_ = 0; // cacheSync() will write block if true
cacheBlockNumber_ = 0XFFFFFFFF;
cacheFatOffset_ = 0;
#if USE_SERARATEFAT_CACHE
#if defined(USE_SERARATEFAT_CACHE) && USE_SERARATEFAT_CACHE
cacheFatStatus_ = 0; // cacheSync() will write block if true
cacheFatBlockNumber_ = 0XFFFFFFFF;
#endif // USE_SERARATEFAT_CACHE
@ -4232,11 +4265,17 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
// if part > 0 assume mbr volume with partition table
if (part) {
if (part > 4) {
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("volume init: illegal part"));
#endif
DBG_FAIL_MACRO;
goto fail;
}
pc = cacheFetch(volumeStartBlock, CACHE_FOR_READ);
if (!pc) {
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("volume init: cache fetch failed"));
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -4245,6 +4284,9 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
p->totalSectors < 100 ||
p->firstSector == 0) {
// not a valid partition
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("volume init: invalid partition"));
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -4252,6 +4294,9 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
}
pc = cacheFetch(volumeStartBlock, CACHE_FOR_READ);
if (!pc) {
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("volume init: cache fetch failed"));
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -4261,6 +4306,13 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
fbs->reservedSectorCount == 0 ||
fbs->sectorsPerCluster == 0) {
// not valid FAT volume
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("volume init: not a valid FAT volume"));
Com::printFLN(PSTR("BytesPerSector:"),fbs->bytesPerSector);
Com::printFLN(PSTR("fatCount:"),fbs->fatCount);
Com::printFLN(PSTR("reservedSectorCount:"),fbs->reservedSectorCount);
Com::printFLN(PSTR("sectorsPerCluster:"),fbs->sectorsPerCluster);
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -4303,6 +4355,9 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
if (clusterCount_ < 4085) {
fatType_ = 12;
if (!FAT12_SUPPORT) {
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("volume init: No FAT 12 support"));
#endif
DBG_FAIL_MACRO;
goto fail;
}
@ -4315,6 +4370,9 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
return true;
fail:
#if defined(DEBUG_SD_ERROR)
Com::printErrorFLN(PSTR("SD volume open failed"));
#endif
return false;
}
// =============== SdFile.cpp ====================
@ -4434,5 +4492,3 @@ void SdFatUtil::SerialPrintln_P(FSTRINGPARAM(str)) {
#endif // SDSUPPORT

View file

@ -1937,7 +1937,7 @@ class SdBaseFile {
uint8_t lfn_checksum(const unsigned char *pFCBName);
bool openParentReturnFile(SdBaseFile* dirFile, const char* path, uint8_t *dname, SdBaseFile *newParent, boolean bMakeDirs);
/** \return True if this is a directory else false. */
bool isDir() const {return type_ >= FAT_FILE_TYPE_MIN_DIR;}
/** \return True if this is a normal file else false. */
@ -2057,7 +2057,7 @@ class SdBaseFile {
dir_t* readDirCacheSpecial();
dir_t *getLongFilename(dir_t *dir, char *longFilename, int8_t cVFATNeeded, uint32_t *pwIndexPos);
bool findSpace(dir_t *dir, int8_t cVFATNeeded, int8_t *pcVFATFound, uint32_t *pwIndexPos);
uint8_t lsRecursive(SdBaseFile *parent, uint8_t level, char *findFilename, SdBaseFile *pParentFound);
uint8_t lsRecursive(SdBaseFile *parent, uint8_t level, char *findFilename, SdBaseFile *pParentFound, bool isJson);
bool setDirSize();
//------------------------------------------------------------------------------
@ -2208,6 +2208,9 @@ class SdBaseFile {
static bool remove(SdBaseFile& dirFile, const char* path) // NOLINT
__attribute__((error("use remove(&dirFile, path)")));
#endif // ALLOW_DEPRECATED_FUNCTIONS
#if JSON_OUTPUT
void lsJSON();
#endif
};
//------------------------------------------------------------------------------
/**
@ -2321,5 +2324,3 @@ class SdFat {
SdBaseFile vwd_;
};
#endif // SdFat_h

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3735,5 +3735,3 @@ pins
#endif /* _ARDUINO_H */

View file

@ -183,11 +183,11 @@ void GCode::checkAndPushCommand()
}
#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
} else if(M == 668) {
lastLineNumber = 0; // simulate a reset so lines are out of resend buffer
}
#endif // DEBUG_COM_ERRORS
}
@ -222,10 +222,10 @@ void GCode::checkAndPushCommand()
}
lastLineNumber = actLineNumber;
}
pushCommand();
pushCommand();
#ifdef DEBUG_COM_ERRORS
if(M == 667)
return; // omit ok
if(hasM() && M == 667)
return; // omit ok
#endif
#if ACK_WITH_LINENUMBER
Com::printFLN(Com::tOkSpace, actLineNumber);
@ -342,7 +342,7 @@ void GCode::readFromSerial()
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;
@ -428,7 +428,7 @@ void GCode::readFromSerial()
}
}
#if SDSUPPORT
if(sd.sdmode == 0 || commandsReceivingWritePosition != 0) // not reading or incoming serial command
if(sd.sdmode == 0 || sd.sdmode >= 100 || 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
{
@ -520,7 +520,7 @@ void GCode::readFromSerial()
bool GCode::parseBinary(uint8_t *buffer,bool fromSerial)
{
internalCommand = !fromSerial;
unsigned int sum1 = 0,sum2 = 0; // for fletcher-16 checksum
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;
@ -549,13 +549,13 @@ bool GCode::parseBinary(uint8_t *buffer,bool fromSerial)
return false;
}
p = buffer;
params = *(unsigned int *)p;
params = *(uint16_t *)p;
p += 2;
uint8_t textlen = 16;
if(isV2())
{
params2 = *(unsigned int *)p;
p+=2;
params2 = *(uint16_t *)p;
p += 2;
if(hasString())
textlen = *p++;
}
@ -563,16 +563,16 @@ bool GCode::parseBinary(uint8_t *buffer,bool fromSerial)
if(params & 1)
{
actLineNumber = N = *(uint16_t *)p;
p+=2;
p += 2;
}
if(isV2()) // Read G,M as 16 bit value
{
if(params & 2)
if(hasM())
{
M = *(uint16_t *)p;
p += 2;
}
if(params & 4)
if(hasG())
{
G = *(uint16_t *)p;
p += 2;
@ -580,51 +580,51 @@ bool GCode::parseBinary(uint8_t *buffer,bool fromSerial)
}
else
{
if(params & 2)
if(hasM())
{
M = *p++;
}
if(params & 4)
if(hasG())
{
G = *p++;
}
}
//if(code->params & 8) {memcpy(&code->X,p,4);p+=4;}
if(params & 8)
if(hasX())
{
X = *(float *)p;
p += 4;
}
if(params & 16)
if(hasY())
{
Y = *(float *)p;
p += 4;
}
if(params & 32)
if(hasZ())
{
Z = *(float *)p;
p += 4;
}
if(params & 64)
if(hasE())
{
E = *(float *)p;
p += 4;
}
if(params & 256)
if(hasF())
{
F = *(float *)p;
p += 4;
}
if(params & 512)
if(hasT())
{
T = *p++;
}
if(params & 1024)
if(hasS())
{
S = *(int32_t*)p;
p += 4;
}
if(params & 2048)
if(hasP())
{
P = *(int32_t*)p;
p += 4;
@ -688,7 +688,7 @@ bool GCode::parseBinary(uint8_t *buffer,bool fromSerial)
{
text = (char*)p;
text[textlen] = 0; // Terminate string overwriting checksum
waitUntilAllCommandsAreParsed=true; // Don't destroy string until executed
waitUntilAllCommandsAreParsed = true; // Don't destroy string until executed
}
formatErrors = 0;
return true;
@ -705,7 +705,8 @@ bool GCode::parseAscii(char *line,bool fromSerial)
internalCommand = !fromSerial;
char c;
while ( (c = *(pos++)) )
{
{
if(c == '(' || c == '%') break; // alternative comment or program block
switch(c)
{
case 'N':
@ -728,10 +729,10 @@ bool GCode::parseAscii(char *line,bool fromSerial)
case 'm':
{
M = parseLongValue(pos) & 0xffff;
params |=2;
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)
if (M == 20 || M == 23 || M == 28 || M == 29 || M == 30 || M == 32 || M == 36 || M == 117)
{
// after M command we got a filename or text
char digit;
@ -749,7 +750,7 @@ bool GCode::parseAscii(char *line,bool fromSerial)
text = pos;
while (*pos)
{
if((M != 117 && *pos==' ') || *pos=='*') break;
if((M != 117 && M != 20 && *pos==' ') || *pos=='*') break;
pos++; // find a space as file name end
}
*pos = 0; // truncate filename by erasing space with nul, also skips checksum
@ -845,12 +846,68 @@ bool GCode::parseAscii(char *line,bool fromSerial)
params2 |= 8;
params |= 4096; // Needs V2 for saving
break;
}
}
case 'C':
case 'c':
{
D = parseFloatValue(pos);
params2 |= 16;
params |= 4096; // Needs V2 for saving
break;
}
case 'H':
case 'h':
{
D = parseFloatValue(pos);
params2 |= 32;
params |= 4096; // Needs V2 for saving
break;
}
case 'A':
case 'a':
{
D = parseFloatValue(pos);
params2 |= 64;
params |= 4096; // Needs V2 for saving
break;
}
case 'B':
case 'b':
{
D = parseFloatValue(pos);
params2 |= 128;
params |= 4096; // Needs V2 for saving
break;
}
case 'K':
case 'k':
{
D = parseFloatValue(pos);
params2 |= 256;
params |= 4096; // Needs V2 for saving
break;
}
case 'L':
case 'l':
{
D = parseFloatValue(pos);
params2 |= 512;
params |= 4096; // Needs V2 for saving
break;
}
case 'O':
case 'o':
{
D = parseFloatValue(pos);
params2 |= 1024;
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++;
while(line != (pos - 1)) checksum ^= *line++;
#if FEATURE_CHECKSUM_FORCED
Printer::flag0 |= PRINTER_FLAG0_FORCE_CHECKSUM;
#endif
@ -869,12 +926,12 @@ bool GCode::parseAscii(char *line,bool fromSerial)
}// end switch
}// end while
if(hasFormatError() || (params & 518)==0) // Must contain G, M or T command and parameter need to have variables!
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;
if(formatErrors < 3) return false;
}
else formatErrors = 0;
return true;
@ -885,7 +942,7 @@ void GCode::printCommand()
{
if(hasN()) {
Com::print('N');
Com::print((long)N);
Com::print((int32_t)N);
Com::print(' ');
}
if(hasM())
@ -952,5 +1009,193 @@ void GCode::printCommand()
}
Com::println();
}
#if JSON_OUTPUT
// --------------------------------------------------------------- //
// Code that gets gcode information is adapted from RepRapFirmware //
// Originally licenced under GPL //
// Authors: reprappro, dc42, dcnewman, others //
// Source: https://github.com/dcnewman/RepRapFirmware //
// Copy date: 15 Nov 2015 //
// --------------------------------------------------------------- //
void GCodeFileInfo::init(SdBaseFile &file) {
this->fileSize = file.fileSize();
this->filamentNeeded = 0.0;
this->objectHeight = 0.0;
this->layerHeight = 0.0;
if (!file.isOpen()) return;
bool genByFound = false, layerHeightFound = false, filamentNeedFound = false;
#if CPU_ARCH==ARCH_AVR
#define GCI_BUF_SIZE 120
#else
#define GCI_BUF_SIZE 1024
#endif
// READ 4KB FROM THE BEGINNING
char buf[GCI_BUF_SIZE];
for (int i = 0; i < 4096; i += GCI_BUF_SIZE-50) {
if(!file.seekSet(i)) break;
file.read(buf, GCI_BUF_SIZE);
if (!genByFound && findGeneratedBy(buf, this->generatedBy)) genByFound = true;
if (!layerHeightFound && findLayerHeight(buf, this->layerHeight)) layerHeightFound = true;
if (!filamentNeedFound && findFilamentNeed(buf, this->filamentNeeded)) filamentNeedFound = true;
if(genByFound && layerHeightFound && filamentNeedFound) goto get_objectHeight;
}
// READ 4KB FROM END
for (int i = 0; i < 4096; i += GCI_BUF_SIZE-50) {
if(!file.seekEnd(-4096 + i)) break;
file.read(buf, GCI_BUF_SIZE);
if (!genByFound && findGeneratedBy(buf, this->generatedBy)) genByFound = true;
if (!layerHeightFound && findLayerHeight(buf, this->layerHeight)) layerHeightFound = true;
if (!filamentNeedFound && findFilamentNeed(buf, this->filamentNeeded)) filamentNeedFound = true;
if(genByFound && layerHeightFound && filamentNeedFound) goto get_objectHeight;
}
get_objectHeight:
// MOVE FROM END UP IN 1KB BLOCKS UP TO 30KB
for (int i = GCI_BUF_SIZE; i < 30000; i += GCI_BUF_SIZE-50) {
if(!file.seekEnd(-i)) break;
file.read(buf, GCI_BUF_SIZE);
if (findTotalHeight(buf, this->objectHeight)) break;
}
file.seekSet(0);
}
bool GCodeFileInfo::findGeneratedBy(char *buf, char *genBy) {
// Slic3r & S3D
const char* generatedByString = PSTR("generated by ");
char* pos = strstr_P(buf, generatedByString);
if (pos) {
pos += strlen_P(generatedByString);
size_t i = 0;
while (i < GENBY_SIZE - 1 && *pos >= ' ') {
char c = *pos++;
if (c == '"' || c == '\\') {
// Need to escape the quote-mark for JSON
if (i > GENBY_SIZE - 3) break;
genBy[i++] = '\\';
}
genBy[i++] = c;
}
genBy[i] = 0;
return true;
}
// CURA
const char* slicedAtString = PSTR(";Sliced at: ");
pos = strstr_P(buf, slicedAtString);
if (pos) {
strcpy_P(genBy, PSTR("Cura"));
return true;
}
// UNKNOWN
strcpy_P(genBy, PSTR("Unknown"));
return false;
}
bool GCodeFileInfo::findLayerHeight(char *buf, float &layerHeight) {
// SLIC3R
layerHeight = 0;
const char* layerHeightSlic3r = PSTR("; layer_height ");
char *pos = strstr_P(buf, layerHeightSlic3r);
if (pos) {
pos += strlen_P(layerHeightSlic3r);
while (*pos == ' ' || *pos == 't' || *pos == '=' || *pos == ':') {
++pos;
}
layerHeight = strtod(pos, NULL);
return true;
}
// CURA
const char* layerHeightCura = PSTR("Layer height: ");
pos = strstr_P(buf, layerHeightCura);
if (pos) {
pos += strlen_P(layerHeightCura);
while (*pos == ' ' || *pos == 't' || *pos == '=' || *pos == ':') {
++pos;
}
layerHeight = strtod(pos, NULL);
return true;
}
return false;
}
bool GCodeFileInfo::findFilamentNeed(char *buf, float &filament) {
const char* filamentUsedStr = PSTR("filament used");
const char* pos = strstr_P(buf, filamentUsedStr);
filament = 0;
if (pos != NULL) {
pos += strlen_P(filamentUsedStr);
while (*pos == ' ' || *pos == 't' || *pos == '=' || *pos == ':') {
++pos; // this allows for " = " from default slic3r comment and ": " from default Cura comment
}
if (isDigit(*pos)) {
char *q;
filament += strtod(pos, &q);
if (*q == 'm' && *(q + 1) != 'm') {
filament *= 1000.0; // Cura outputs filament used in metres not mm
}
}
return true;
}
return false;
}
bool GCodeFileInfo::findTotalHeight(char *buf, float &height) {
int len = 1024;
bool inComment, inRelativeMode = false;
unsigned int zPos;
for (int i = len - 5; i > 0; i--) {
if (inRelativeMode) {
inRelativeMode = !(buf[i] == 'G' && buf[i + 1] == '9' && buf[i + 2] == '1' && buf[i + 3] <= ' ');
} else if (buf[i] == 'G') {
// Ignore G0/G1 codes if absolute mode was switched back using G90 (typical for Cura files)
if (buf[i + 1] == '9' && buf[i + 2] == '0' && buf[i + 3] <= ' ') {
inRelativeMode = true;
} else if ((buf[i + 1] == '0' || buf[i + 1] == '1') && buf[i + 2] == ' ') {
// Look for last "G0/G1 ... Z#HEIGHT#" command as generated by common slicers
// Looks like we found a controlled move, however it could be in a comment, especially when using slic3r 1.1.1
inComment = false;
size_t j = i;
while (j != 0) {
--j;
char c = buf[j];
if (c == '\n' || c == '\r') break;
if (c == ';') {
// It is in a comment, so give up on this one
inComment = true;
break;
}
}
if (inComment) continue;
// Find 'Z' position and grab that value
zPos = 0;
for (int j = i + 3; j < len - 2; j++) {
char c = buf[j];
if (c < ' ') {
// Skip all whitespaces...
while (j < len - 2 && c <= ' ') {
c = buf[++j];
}
// ...to make sure ";End" doesn't follow G0 .. Z#HEIGHT#
if (zPos != 0) {
//debugPrintf("Found at offset %u text: %.100s\n", zPos, &buf[zPos + 1]);
height = strtod(&buf[zPos + 1], NULL);
return true;
}
break;
} else if (c == ';') break;
else if (c == 'Z') zPos = j;
}
}
}
}
return false;
}
#endif // JSON_OUTPUT

View file

@ -18,23 +18,24 @@
#ifndef _GCODE_H
#define _GCODE_H
#define MAX_CMD_SIZE 96
#define MAX_CMD_SIZE 96
#define ARRAY_SIZE(_x) (sizeof(_x)/sizeof(_x[0]))
class SDCard;
class GCode // 52 uint8_ts per command needed
{
unsigned int params;
unsigned int params2;
uint16_t params;
uint16_t params2;
public:
unsigned int N; // Line number
unsigned int M;
unsigned int G;
uint16_t N; // Line number
uint16_t M;
uint16_t G;
float X;
float Y;
float Z;
float E;
float F;
long S;
long P;
int32_t S;
int32_t P;
float I;
float J;
float R;
@ -191,13 +192,15 @@ private:
inline float parseFloatValue(char *s)
{
char *endPtr;
while(*s == 32) s++; // skip spaces
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;
char *endPtr;
while(*s == 32) s++; // skip spaces
long l = (strtol(s, &endPtr, 10));
if(s == endPtr) l=0; // treat empty string argument "p " as "p0"
return l;
@ -221,8 +224,26 @@ private:
static uint8_t formatErrors; ///< Number of sequential format errors
};
#if JSON_OUTPUT
#include "SdFat.h"
// Struct to hold Gcode file information 32 bytes
#define GENBY_SIZE 16
class GCodeFileInfo {
public:
void init(SdBaseFile &file);
unsigned long fileSize;
float objectHeight;
float layerHeight;
float filamentNeeded;
char generatedBy[GENBY_SIZE];
bool findGeneratedBy(char *buf, char *genBy);
bool findLayerHeight(char *buf, float &layerHeight);
bool findFilamentNeed(char *buf, float &filament);
bool findTotalHeight(char *buf, float &objectHeight);
};
#endif
#endif

View file

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

View file

@ -1,8 +0,0 @@
#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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +0,0 @@
#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

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

View file

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

View file

@ -2,7 +2,8 @@
// File generated by LCD Assistant
// http://en.radzio.dxp.pl/bitmap_converter/
//------------------------------------------------------------------------------
#ifndef CUSTOM_LOGO
#define LOGO_WIDTH 60
#define LOGO_HEIGHT 64
@ -39,41 +40,7 @@ const unsigned char logo[] PROGMEM = { //AVR-GCC, WinAVR
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
*/
};
#else
LOGO_BITMAP
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -101,30 +101,30 @@ What display type do you use?
#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
// 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
// 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
//#define U8GLIB_KS0108_FAST
// UI_DISPLAY_RS_PIN = CS
// UI_DISPLAY_D5_PIN = A0
//#define U8GLIB_ST7565_NHD_C2832_HW_SPI
//#define U8GLIB_ST7565_NHD_C2832_HW_SPI
#define UI_LCD_WIDTH 128
#define UI_LCD_HEIGHT 64
@ -225,13 +225,13 @@ Define the pin
#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
// 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
@ -378,7 +378,7 @@ void uiInitKeys() {
// UI_KEYS_INIT_MATRIX(32,47,45,43,41,39,37,35);
#endif
}
void uiCheckKeys(int &action) {
void uiCheckKeys(uint16_t &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.
@ -402,7 +402,7 @@ inline void uiCheckSlowEncoder() {
HAL::i2cWrite(0x12); // GIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ);
unsigned int keymask = HAL::i2cReadAck();
uint16_t keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak()<<8);
#endif
HAL::i2cStop();
@ -410,7 +410,7 @@ inline void uiCheckSlowEncoder() {
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) {
void uiCheckSlowKeys(uint16_t &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);
@ -421,7 +421,7 @@ void uiCheckSlowKeys(int &action) {
HAL::i2cWrite(0x12); // GPIOA
HAL::i2cStop();
HAL::i2cStartWait(UI_DISPLAY_I2C_ADDRESS+I2C_READ);
unsigned int keymask = HAL::i2cReadAck();
uint16_t keymask = HAL::i2cReadAck();
keymask = keymask + (HAL::i2cReadNak()<<8);
#endif
HAL::i2cStop();
@ -447,9 +447,7 @@ void uiCheckSlowKeys(int &action) {
}
#endif
#endif
#endif

6065
Repetier/uilang.cpp Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff