Commit fff64606 authored by MagoKimbra's avatar MagoKimbra

Adjust only tab

parent 24eb4064
......@@ -377,19 +377,19 @@ float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1
bool cancel_heatup = false ;
#ifdef FILAMENT_SENSOR
//Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off
float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100
int delay_index1=0; //index into ring buffer
int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
float delay_dist=0; //delay distance counter
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
//Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off
float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100
int delay_index1=0; //index into ring buffer
int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
float delay_dist=0; //delay distance counter
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
#endif
#ifdef LASERBEAM
int laser_ttl_modulation = 0;
int laser_ttl_modulation = 0;
#endif
//===========================================================================
......@@ -507,8 +507,7 @@ extern "C"{
//needs overworking someday
void enquecommand(const char *cmd)
{
if(buflen < BUFSIZE)
{
if(buflen < BUFSIZE) {
//this is dangerous if a mixing of serial and this happens
strcpy(&(cmdbuffer[bufindw][0]),cmd);
SERIAL_ECHO_START;
......@@ -522,8 +521,7 @@ void enquecommand(const char *cmd)
void enquecommand_P(const char *cmd)
{
if(buflen < BUFSIZE)
{
if(buflen < BUFSIZE) {
//this is dangerous if a mixing of serial and this happens
strcpy_P(&(cmdbuffer[bufindw][0]),cmd);
SERIAL_ECHO_START;
......@@ -759,7 +757,7 @@ void get_command()
if(serial_char == '\n' ||
serial_char == '\r' ||
(serial_char == ':' && comment_mode == false) ||
serial_count >= (MAX_CMD_SIZE - 1) )
serial_count >= (MAX_CMD_SIZE - 1))
{
if(!serial_count) { //if empty line
comment_mode = false; //for new command
......@@ -773,7 +771,7 @@ void get_command()
{
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) ) {
if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL)) {
SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
SERIAL_ERRORLN(gcode_LastN);
......@@ -783,8 +781,7 @@ void get_command()
return;
}
if(strchr(cmdbuffer[bufindw], '*') != NULL)
{
if(strchr(cmdbuffer[bufindw], '*') != NULL) {
byte checksum = 0;
byte count = 0;
while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
......@@ -799,9 +796,7 @@ void get_command()
return;
}
//if no errors, continue parsing
}
else
{
} else {
SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN);
......@@ -812,11 +807,8 @@ void get_command()
gcode_LastN = gcode_N;
//if no errors, continue parsing
}
else // if we don't receive 'N' but still see '*'
{
if((strchr(cmdbuffer[bufindw], '*') != NULL))
{
} else { // if we don't receive 'N' but still see '*'
if((strchr(cmdbuffer[bufindw], '*') != NULL)) {
SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN);
......@@ -824,18 +816,17 @@ void get_command()
return;
}
}
if((strchr(cmdbuffer[bufindw], 'G') != NULL)){
if((strchr(cmdbuffer[bufindw], 'G') != NULL)) {
strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))){
switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))) {
case 0:
case 1:
case 2:
case 3:
if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
#ifdef SDSUPPORT
if(card.saving)
break;
#endif //SDSUPPORT
#ifdef SDSUPPORT
if(card.saving) break;
#endif //SDSUPPORT
SERIAL_PROTOCOLLNPGM(MSG_OK);
}
else {
......@@ -864,7 +855,7 @@ void get_command()
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
}
}
#ifdef SDSUPPORT
#ifdef SDSUPPORT
if(!card.sdprinting || serial_count!=0){
return;
}
......@@ -910,11 +901,11 @@ void get_command()
return; //if empty line
}
cmdbuffer[bufindw][serial_count] = 0; //terminate string
// if(!comment_mode){
// if(!comment_mode){
fromsd[bufindw] = true;
buflen += 1;
bufindw = (bufindw + 1)%BUFSIZE;
// }
// }
comment_mode = false; //for new command
serial_count = 0; //clear buffer
}
......@@ -924,9 +915,7 @@ void get_command()
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
}
}
#endif //SDSUPPORT
#endif //SDSUPPORT
}
......@@ -1504,7 +1493,8 @@ float z_probe() {
return mm;
}
void calibrate_print_surface(float z_offset) {
void calibrate_print_surface(float z_offset)
{
float probe_bed_z, probe_z, probe_h, probe_l;
int probe_count;
......@@ -1553,7 +1543,8 @@ void calibrate_print_surface(float z_offset) {
}
}
float probe_bed(float x, float y) {
float probe_bed(float x, float y)
{
//Probe bed at specified location and return z height of bed
float probe_bed_z, probe_z, probe_h, probe_l;
int probe_count;
......@@ -1609,7 +1600,8 @@ float probe_bed(float x, float y) {
return probe_bed_z;
}
float z_probe_accuracy(){
float z_probe_accuracy()
{
//Perform z-probe accuracy test
float probe_h[7];
float probe_l[7];
......@@ -1649,7 +1641,8 @@ float z_probe_accuracy(){
return range_h - range_l;
}
void bed_probe_all(){
void bed_probe_all()
{
//Probe all bed positions & store carriage positions
bed_level_c = probe_bed(0.0, 0.0);
save_carriage_positions(0);
......@@ -1665,9 +1658,10 @@ void bed_probe_all(){
save_carriage_positions(5);
bed_level_ox = probe_bed(SIN_60 * bed_radius, COS_60 * bed_radius);
save_carriage_positions(6);
}
}
void calibration_report(){
void calibration_report()
{
//Display Report
SERIAL_ECHOLN("\tZ-Tower\t\t\tEndstop Offsets");
......@@ -1709,13 +1703,15 @@ void calibration_report(){
SERIAL_ECHOLN("");
}
void save_carriage_positions(int position_num) {
void save_carriage_positions(int position_num)
{
for(int8_t i=0; i < NUM_AXIS; i++) {
saved_positions[position_num][i] = saved_position[i];
}
}
void home_delta_axis(){
void home_delta_axis()
{
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
feedmultiply = 100;
......@@ -1763,7 +1759,8 @@ void home_delta_axis(){
endstops_hit_on_purpose();
}
void prepare_move_raw(){
void prepare_move_raw()
{
previous_millis_cmd = millis();
calculate_delta(destination);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
......@@ -1782,7 +1779,8 @@ void refresh_cmd_timeout(void)
}
#ifdef FWRETRACT
void retract(bool retracting, bool swapretract = false) {
void retract(bool retracting, bool swapretract = false)
{
if(retracting && !retracted[active_extruder]) {
destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS];
......@@ -1832,7 +1830,7 @@ void refresh_cmd_timeout(void)
prepare_move();
feedrate = oldFeedrate;
}
} //retract
}
#endif //FWRETRACT
#ifdef Z_PROBE_SLED
......@@ -1842,7 +1840,8 @@ void refresh_cmd_timeout(void)
// dock[in] If true, move to MAX_X and engage the electromagnet
// offset[in] The additional distance to move to adjust docking location
//
static void dock_sled(bool dock, int offset=0) {
static void dock_sled(bool dock, int offset=0)
{
int z_loc;
if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) {
......@@ -1878,15 +1877,13 @@ void process_commands()
#ifdef ENABLE_AUTO_BED_LEVELING
float x_tmp, y_tmp, z_tmp, real_z;
#endif
if(code_seen('G'))
{
switch((int)code_value())
{
if(code_seen('G')) {
switch((int)code_value()) {
case 0: // G0 -> G1
case 1: // G1
if(Stopped == false) {
get_coordinates(); // For X Y Z E F
#ifdef FWRETRACT
#ifdef FWRETRACT
if(autoretract_enabled)
if( !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
float echange=destination[E_AXIS]-current_position[E_AXIS];
......@@ -1897,12 +1894,13 @@ void process_commands()
return;
}
}
#endif //FWRETRACT
#endif //FWRETRACT
prepare_move();
//ClearToSend();
return;
}
break;
#ifndef SCARA //disable arc support
case 2: // G2 - CW ARC
if(Stopped == false) {
......@@ -1919,6 +1917,7 @@ void process_commands()
}
break;
#endif // no SCARA
case 4: // G4 dwell
LCD_MESSAGEPGM(MSG_DWELL);
codenum = 0;
......@@ -1934,28 +1933,29 @@ void process_commands()
lcd_update();
}
break;
#ifdef FWRETRACT
#ifdef FWRETRACT
case 10: // G10 retract
#if EXTRUDERS > 1
#if EXTRUDERS > 1
retracted_swap[active_extruder]=(code_seen('S') && code_value_long() == 1); // checks for swap retract argument
retract(true,retracted_swap[active_extruder]);
#else
#else
retract(true);
#endif
#endif
break;
case 11: // G11 retract_recover
#if EXTRUDERS > 1
#if EXTRUDERS > 1
retract(false,retracted_swap[active_extruder]);
#else
#else
retract(false);
#endif
#endif
break;
#endif //FWRETRACT
#endif //FWRETRACT
case 28: //G28 Home all Axis one at a time
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef ENABLE_AUTO_BED_LEVELING
plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data)
#endif //ENABLE_AUTO_BED_LEVELING
#endif //ENABLE_AUTO_BED_LEVELING
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
......@@ -1971,7 +1971,7 @@ void process_commands()
home_all_axis = !((code_seen(axis_codes[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS])) || (code_seen(axis_codes[E_AXIS])));
#ifdef NPR2
#ifdef NPR2
if((home_all_axis) || (code_seen(axis_codes[E_AXIS]))) {
active_driver = active_extruder = 1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], -200, COLOR_HOMERATE, active_extruder, active_driver);
......@@ -1979,9 +1979,9 @@ void process_commands()
old_color = 99;
active_driver = active_extruder = 0;
}
#endif
#endif
#ifdef DELTA
#ifdef DELTA
// A delta can only safely home all axis at the same time
// all axis have to home at the same time
// Move all carriages up together until the first endstop is hit.
......@@ -2011,33 +2011,36 @@ void process_commands()
calculate_delta(current_position);
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
#else // NOT DELTA
#else // NOT DELTA
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
HOMEAXIS(Z);
}
#endif
#endif
#ifdef QUICK_HOME
#ifdef QUICK_HOME
if((home_all_axis)||( code_seen(axis_codes[X_AXIS]) && code_seen(axis_codes[Y_AXIS]))) { //first diagonal move
current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0;
current_position[X_AXIS] = 0;
current_position[Y_AXIS] = 0;
#ifndef DUAL_X_CARRIAGE
#ifndef DUAL_X_CARRIAGE
int x_axis_home_dir = home_dir(X_AXIS);
#else
#else
int x_axis_home_dir = x_home_dir(active_extruder);
extruder_duplication_enabled = false;
#endif
#endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;
destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
feedrate = homing_feedrate[X_AXIS];
if(homing_feedrate[Y_AXIS]<feedrate)
feedrate = homing_feedrate[Y_AXIS];
if (max_length(X_AXIS) > max_length(Y_AXIS)) {
feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1);
} else {
}
else {
feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1);
}
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, active_driver);
......@@ -2055,14 +2058,14 @@ void process_commands()
current_position[X_AXIS] = destination[X_AXIS];
current_position[Y_AXIS] = destination[Y_AXIS];
#ifndef SCARA
#ifndef SCARA
current_position[Z_AXIS] = destination[Z_AXIS];
#endif
#endif
}
#endif // QUICK_HOME
#endif // QUICK_HOME
if((home_all_axis) || (code_seen(axis_codes[X_AXIS]))) {
#ifdef DUAL_X_CARRIAGE
#ifdef DUAL_X_CARRIAGE
int tmp_extruder = active_extruder;
extruder_duplication_enabled = false;
active_extruder = !active_extruder;
......@@ -2074,9 +2077,9 @@ void process_commands()
memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
delayed_move_time = 0;
active_extruder_parked = true;
#else
#else
HOMEAXIS(X);
#endif // DUAL_X_CARRIAGE
#endif // DUAL_X_CARRIAGE
}
if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
......@@ -2085,28 +2088,28 @@ void process_commands()
if(code_seen(axis_codes[X_AXIS])) {
if(code_value_long() != 0) {
#ifdef SCARA
#ifdef SCARA
current_position[X_AXIS]=code_value();
#else
#else
current_position[X_AXIS]=code_value()+add_homing[0];
#endif
#endif
}
}
if(code_seen(axis_codes[Y_AXIS])) {
if(code_value_long() != 0) {
#ifdef SCARA
#ifdef SCARA
current_position[Y_AXIS]=code_value();
#else
#else
current_position[Y_AXIS]=code_value()+add_homing[1];
#endif
#endif
}
}
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
#ifndef Z_SAFE_HOMING
#if Z_HOME_DIR < 0 // If homing towards BED do Z last
#ifndef Z_SAFE_HOMING
if (code_seen('M')) { // Manual G28
#ifdef ULTIPANEL
#ifdef ULTIPANEL
if(home_all_axis) {
boolean zig = true;
int xGridSpacing = (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION);
......@@ -2117,7 +2120,8 @@ void process_commands()
xProbe = LEFT_PROBE_BED_POSITION;
xInc = xGridSpacing;
zig = false;
} else { // zag
}
else { // zag
xProbe = RIGHT_PROBE_BED_POSITION;
xInc = -xGridSpacing;
zig = true;
......@@ -2141,19 +2145,19 @@ void process_commands()
manage_inactivity();
lcd_update();
if(beepbutton) {
#if BEEPER > 0
#if BEEPER > 0
SET_OUTPUT(BEEPER);
WRITE(BEEPER,HIGH);
delay(100);
WRITE(BEEPER,LOW);
delay(3);
#else
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
#else
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
lcd_buzz(1000/6,100);
#else
#else
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ);
#endif
#endif
#endif
#endif
beepbutton=false;
}
}
......@@ -2166,18 +2170,18 @@ void process_commands()
enquecommand("G4 P0");
enquecommand("G4 P0");
}
#endif // ULTIPANEL
#endif // ULTIPANEL
}
else if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
#if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0)
#if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0)
destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed
feedrate = max_feedrate[Z_AXIS];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder, active_driver);
st_synchronize();
#endif
#endif
HOMEAXIS(Z);
}
#else // Z Safe mode activated.
#else // Z Safe mode activated.
if(home_all_axis) {
destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER);
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
......@@ -2209,18 +2213,20 @@ void process_commands()
st_synchronize();
HOMEAXIS(Z);
} else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) {
}
else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) {
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
} else {
}
else {
LCD_MESSAGEPGM(MSG_ZPROBE_OUT);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT);
}
}
#endif // Z_SAFE_HOMING
#endif // Z_HOME_DIR < 0
#endif // Z_SAFE_HOMING
#endif // Z_HOME_DIR < 0
if(code_seen(axis_codes[Z_AXIS])) {
if(code_value_long() != 0) {
......@@ -2228,23 +2234,23 @@ void process_commands()
}
}
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef ENABLE_AUTO_BED_LEVELING
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative)
}
#endif
#endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#endif // else DELTA
#endif // else DELTA
#ifdef SCARA
#ifdef SCARA
calculate_delta(current_position);
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
#endif SCARA
#endif SCARA
#ifdef ENDSTOPS_ONLY_FOR_HOMING
#ifdef ENDSTOPS_ONLY_FOR_HOMING
enable_endstops(false);
#endif
#endif
feedrate = saved_feedrate;
feedmultiply = saved_feedmultiply;
......@@ -2252,12 +2258,12 @@ void process_commands()
endstops_hit_on_purpose();
break;
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef ENABLE_AUTO_BED_LEVELING
case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
{
#if Z_MIN_PIN == -1
#error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
#endif
#if Z_MIN_PIN == -1
#error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin."
#endif
// Prevent user from running a G29 without first homing in X and Y
if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) ) {
......@@ -2267,9 +2273,9 @@ void process_commands()
break; // abort G29, since we don't know where we are
}
#ifdef Z_PROBE_SLED
#ifdef Z_PROBE_SLED
dock_sled(false);
#endif // Z_PROBE_SLED
#endif // Z_PROBE_SLED
st_synchronize();
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
......@@ -2285,7 +2291,7 @@ void process_commands()
setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
#ifdef AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
int r_probe_bed_position = RIGHT_PROBE_BED_POSITION;
int l_probe_bed_position = LEFT_PROBE_BED_POSITION;
int f_probe_bed_position = FRONT_PROBE_BED_POSITION;
......@@ -2353,7 +2359,8 @@ void process_commands()
//xEnd = RIGHT_PROBE_BED_POSITION;
xInc = xGridSpacing;
zig = false;
} else // zag
}
else // zag
{
xProbe = r_probe_bed_position;
//xEnd = LEFT_PROBE_BED_POSITION;
......@@ -2368,7 +2375,8 @@ void process_commands()
{
// raise before probing
z_before = Z_RAISE_BEFORE_PROBING;
} else
}
else
{
// raise extruder
z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
......@@ -2402,7 +2410,7 @@ void process_commands()
free(plane_equation_coefficients);
#else // AUTO_BED_LEVELING_GRID not defined
#else // AUTO_BED_LEVELING_GRID not defined
// Probe at 3 arbitrary points
// probe 1
......@@ -2418,7 +2426,7 @@ void process_commands()
set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
#endif // AUTO_BED_LEVELING_GRID
#endif // AUTO_BED_LEVELING_GRID
st_synchronize();
// The following code correct the Z height difference from z-probe position and hotend tip position.
......@@ -2432,13 +2440,13 @@ void process_commands()
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#ifdef Z_PROBE_SLED
#ifdef Z_PROBE_SLED
dock_sled(true, -SLED_DOCKING_OFFSET); // correct for over travel.
#endif // Z_PROBE_SLED
#endif // Z_PROBE_SLED
}
break;
#ifndef Z_PROBE_SLED
#ifndef Z_PROBE_SLED
case 30: // G30 Single Z Probe
{
engage_z_probe(); // Engage Z Servo endstop if available
......@@ -2462,7 +2470,7 @@ void process_commands()
retract_z_probe(); // Retract Z Servo endstop if available
}
break;
#else
#else
case 31: // G31 - dock the sled
dock_sled(true);
break;
......@@ -2527,7 +2535,9 @@ void process_commands()
}
break;
}
if (code_seen('F')) {probing_feedrate=code_value();}
if (code_seen('F')) {
probing_feedrate=code_value();
}
if (code_seen('X') and code_seen('Y')) {
//Probe specified X,Y point
float x = code_seen('X') ? code_value():0.00;
......@@ -2643,7 +2653,8 @@ void process_commands()
set_delta_constants();
SERIAL_ECHOPAIR("Adjusting Z-Height to: ", max_pos[Z_AXIS]);
SERIAL_ECHOLN(" mm..");
} else {
}
else {
if ((bed_level_x < -ac_prec) or (bed_level_x > ac_prec) or (bed_level_y < -ac_prec) or (bed_level_y > ac_prec) or (bed_level_z < -ac_prec) or (bed_level_z > ac_prec)) {
//Endstops req adjustment
SERIAL_ECHOLN("Adjusting Endstops..");
......@@ -2666,27 +2677,33 @@ void process_commands()
SERIAL_ECHOPAIR("Adjusting Z-Height to: ", max_pos[Z_AXIS]);
SERIAL_ECHOLN(" mm..");
}
} else {
}
else {
SERIAL_ECHOLN("Endstops: OK");
adj_r_target = (bed_level_x + bed_level_y + bed_level_z) / 3;
adj_dr_target = (bed_level_ox + bed_level_oy + bed_level_oz) / 3;
//Determine which parameters require adjustment
if ((bed_level_c >= adj_r_target - ac_prec) and (bed_level_c <= adj_r_target + ac_prec)) adj_r_done = true; else adj_r_done = false;
if ((adj_dr_target >= adj_r_target - ac_prec) and (adj_dr_target <= adj_r_target + ac_prec)) adj_dr_done = true; else adj_dr_done = false;
if ((bed_level_x != bed_level_ox) or (bed_level_y != bed_level_oy) or (bed_level_z != bed_level_oz)) adj_tower_done = false; else adj_tower_done = true;
if ((bed_level_c >= adj_r_target - ac_prec) and (bed_level_c <= adj_r_target + ac_prec)) adj_r_done = true;
else adj_r_done = false;
if ((adj_dr_target >= adj_r_target - ac_prec) and (adj_dr_target <= adj_r_target + ac_prec)) adj_dr_done = true;
else adj_dr_done = false;
if ((bed_level_x != bed_level_ox) or (bed_level_y != bed_level_oy) or (bed_level_z != bed_level_oz)) adj_tower_done = false;
else adj_tower_done = true;
if ((adj_r_done == false) or (adj_dr_done == false) or (adj_tower_done == false)) {
//delta geometry adjustment required
SERIAL_ECHOLN("Adjusting Delta Geometry..");
//set inital direction and magnitude for delta radius & diagonal rod adjustment
if (adj_r == 0) {
if (adj_r_target > bed_level_c) adj_r = 1; else adj_r = -1;
if (adj_r_target > bed_level_c) adj_r = 1;
else adj_r = -1;
}
if (adj_dr == 0) {
if (adj_r_target > adj_dr_target) adj_dr = 1; else adj_dr = -1;
if (adj_r_target > adj_dr_target) adj_dr = 1;
else adj_dr = -1;
}
//Don't adjust tower positions on first iteration
......@@ -2731,7 +2748,8 @@ void process_commands()
and (bed_level_ox >= -ac_prec) and (bed_level_ox <= ac_prec)
and (bed_level_oy >= -ac_prec) and (bed_level_oy <= ac_prec)
and (bed_level_oz >= -ac_prec) and (bed_level_oz <= ac_prec)) loopcount = iterations;
} else {
}
else {
if ((bed_level_x >= -ac_prec) and (bed_level_x <= ac_prec)
and (bed_level_y >= -ac_prec) and (bed_level_y <= ac_prec)
and (bed_level_z >= -ac_prec) and (bed_level_z <= ac_prec)
......@@ -2752,35 +2770,41 @@ void process_commands()
radiusErrorB = bed_level_y - bed_level_oy;
radiusErrorC = bed_level_z - bed_level_oz;
if ((radiusErrorA >= (radiusErrorB - 0.02)) and (radiusErrorA <= (radiusErrorB + 0.02))) equalAB = true; else equalAB = false;
if ((radiusErrorB >= (radiusErrorC - 0.02)) and (radiusErrorB <= (radiusErrorC + 0.02))) equalBC = true; else equalBC = false;
if ((radiusErrorC >= (radiusErrorA - 0.02)) and (radiusErrorC <= (radiusErrorA + 0.02))) equalCA = true; else equalCA = false;
if ((radiusErrorA >= (radiusErrorB - 0.02)) and (radiusErrorA <= (radiusErrorB + 0.02))) equalAB = true;
else equalAB = false;
if ((radiusErrorB >= (radiusErrorC - 0.02)) and (radiusErrorB <= (radiusErrorC + 0.02))) equalBC = true;
else equalBC = false;
if ((radiusErrorC >= (radiusErrorA - 0.02)) and (radiusErrorC <= (radiusErrorA + 0.02))) equalCA = true;
else equalCA = false;
#ifdef DEBUG_MESSAGES
#ifdef DEBUG_MESSAGES
if (equalAB == true) {
SERIAL_ECHOPAIR("Tower AB Equal (A=",radiusErrorA);
SERIAL_ECHOPAIR(" B=",radiusErrorB);
SERIAL_ECHOLN(")");
} else SERIAL_ECHOLN("equalAB=false");
}
else SERIAL_ECHOLN("equalAB=false");
if (equalBC == true) {
SERIAL_ECHOPAIR("Tower BC Equal (B=",radiusErrorB);
SERIAL_ECHOPAIR(" C=",radiusErrorC);
SERIAL_ECHOLN(")");
} else SERIAL_ECHOLN("equalBC=false");
}
else SERIAL_ECHOLN("equalBC=false");
if (equalCA == true) {
SERIAL_ECHOPAIR("Tower CA Equal (C=",radiusErrorC);
SERIAL_ECHOPAIR(" A=",radiusErrorA);
SERIAL_ECHOLN(")");
} else SERIAL_ECHOLN("equalCA=false");
#endif // DEBUG_MESSAGES
}
else SERIAL_ECHOLN("equalCA=false");
#endif // DEBUG_MESSAGES
if ((equalAB == true) and (equalBC == true) and (equalCA == true)) {
// all tower radius out by the same amount (within 0.02) - allow adjustment with delta rod length
#ifdef DEBUG_MESSAGES
#ifdef DEBUG_MESSAGES
SERIAL_ECHOLN("All tower radius errors equal");
#endif
#endif
adj_RadiusA = adj_RadiusB = adj_RadiusC = 0;
}
......@@ -2790,10 +2814,10 @@ void process_commands()
if (adj_RadiusC == 0) {
if (bed_level_z < bed_level_oz) adj_RadiusC = 0.5;
if (bed_level_z > bed_level_oz) adj_RadiusC = -0.5;
#ifdef DEBUG_MESSAGES
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("adj_RadiusC set to ",adj_RadiusC);
SERIAL_ECHOLN("");
#endif
#endif
}
}
if ((equalBC == true) and (equalAB == false) and (equalCA == false)) {
......@@ -2802,10 +2826,10 @@ void process_commands()
if (adj_RadiusA == 0) {
if (bed_level_x < bed_level_ox) adj_RadiusA = 0.5;
if (bed_level_x > bed_level_ox) adj_RadiusA = -0.5;
#ifdef DEBUG_MESSAGES
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("adj_RadiusA set to ",adj_RadiusA);
SERIAL_ECHOLN("");
#endif
#endif
}
}
if ((equalCA == true) and (equalAB == false) and (equalBC == false)) {
......@@ -2814,10 +2838,10 @@ void process_commands()
if (adj_RadiusB == 0) {
if (bed_level_y < bed_level_oy) adj_RadiusB = 0.5;
if (bed_level_y > bed_level_oy) adj_RadiusB = -0.5;
#ifdef DEBUG_MESSAGES
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("adj_RadiusB set to ",adj_RadiusB);
SERIAL_ECHOLN("");
#endif
#endif
}
}
......@@ -2837,12 +2861,14 @@ void process_commands()
if (((adj_RadiusC > 0) and (bed_level_z > bed_level_oz)) or ((adj_RadiusC < 0) and (bed_level_z < bed_level_oz))) adj_RadiusC = -(adj_RadiusC / 2);
//Delta radius adjustment complete?
if ((bed_level_c >= (adj_r_target - ac_prec)) and (bed_level_c <= (adj_r_target + ac_prec))) adj_r_done = true; else adj_r_done = false;
if ((bed_level_c >= (adj_r_target - ac_prec)) and (bed_level_c <= (adj_r_target + ac_prec))) adj_r_done = true;
else adj_r_done = false;
//Diag Rod adjustment complete?
if ((adj_dr_target >= (adj_r_target - ac_prec)) and (adj_dr_target <= (adj_r_target + ac_prec))) adj_dr_done = true; else adj_dr_done = false;
if ((adj_dr_target >= (adj_r_target - ac_prec)) and (adj_dr_target <= (adj_r_target + ac_prec))) adj_dr_done = true;
else adj_dr_done = false;
#ifdef DEBUG_MESSAGES
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("c: ", bed_level_c);
SERIAL_ECHOPAIR(" x: ", bed_level_x);
SERIAL_ECHOPAIR(" y: ", bed_level_y);
......@@ -2857,9 +2883,11 @@ void process_commands()
SERIAL_PROTOCOL_F(delta_diagonal_rod, 4);
SERIAL_ECHOLN("");
SERIAL_ECHO("Radius Adj Complete: ");
if (adj_r_done == true) SERIAL_ECHO("Yes"); else SERIAL_ECHO("No");
if (adj_r_done == true) SERIAL_ECHO("Yes");
else SERIAL_ECHO("No");
SERIAL_ECHO(" DiagRod Adj Complete: ");
if (adj_dr_done == true) SERIAL_ECHO("Yes"); else SERIAL_ECHO("No");
if (adj_dr_done == true) SERIAL_ECHO("Yes");
else SERIAL_ECHO("No");
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("RadiusA Error: ",radiusErrorA);
SERIAL_ECHOPAIR(" (adjust: ",adj_RadiusA);
......@@ -2876,10 +2904,12 @@ void process_commands()
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("DeltaAlphaC: ",adj_AlphaC);
SERIAL_ECHOLN("");
#endif
#endif
} while (((adj_r_done == false) or (adj_dr_done = false)) and (loopcount < iterations));
} else {
}
while (((adj_r_done == false) or (adj_dr_done = false)) and (loopcount < iterations));
}
else {
SERIAL_ECHOLN("Delta Geometry: OK");
}
}
......@@ -2901,7 +2931,8 @@ void process_commands()
and (bed_level_ox >= -ac_prec) and (bed_level_ox <= ac_prec)
and (bed_level_oy >= -ac_prec) and (bed_level_oy <= ac_prec)
and (bed_level_oz >= -ac_prec) and (bed_level_oz <= ac_prec)) loopcount = iterations;
} else {
}
else {
if ((bed_level_x >= -ac_prec) and (bed_level_x <= ac_prec)
and (bed_level_y >= -ac_prec) and (bed_level_y <= ac_prec)
and (bed_level_z >= -ac_prec) and (bed_level_z <= ac_prec)
......@@ -2910,7 +2941,8 @@ void process_commands()
}
loopcount ++;
} while(loopcount < iterations);
}
while(loopcount < iterations);
SERIAL_ECHOLN("Auto Calibration Complete");
SERIAL_ECHOLN("Issue M500 Command to save calibration settings to EPROM (if enabled)");
......@@ -2971,15 +3003,12 @@ void process_commands()
prepare_move();
}
break;
case 90: // G90
relative_mode = false;
break;
case 91: // G91
relative_mode = true;
break;
case 92: // G92
if(!code_seen(axis_codes[E_AXIS]))
st_synchronize();
......@@ -2988,16 +3017,18 @@ void process_commands()
if(i == E_AXIS) {
current_position[i] = code_value();
plan_set_e_position(current_position[E_AXIS]);
} else {
#ifdef SCARA
}
else {
#ifdef SCARA
if (i == X_AXIS || i == Y_AXIS) {
current_position[i] = code_value();
} else {
}
else {
current_position[i] = code_value()+add_homing[i];
}
#else
#else
current_position[i] = code_value()+add_homing[i];
#endif
#endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
}
......@@ -3005,11 +3036,9 @@ void process_commands()
break;
}
}
else if(code_seen('M')){
switch((int)code_value()){
else if(code_seen('M'))
{
switch( (int)code_value() )
{
#ifdef ULTIPANEL
case 0: // M0 - Unconditional stop - Wait for user button press on LCD
case 1: // M1 - Conditional stop - Wait for user button press on LCD
......@@ -3028,7 +3057,8 @@ void process_commands()
manage_inactivity();
lcd_update();
}
}else{
}
else {
while(!lcd_clicked()){
manage_heater();
manage_inactivity();
......@@ -3041,7 +3071,7 @@ void process_commands()
#endif
#ifdef LASERBEAM
case 03: // M03 S - Setting laser beam
case 3: // M03 S - Setting laser beam
{
if(code_seen('S')) {
laser_ttl_modulation=constrain(code_value(),0,255);
......@@ -3051,11 +3081,11 @@ void process_commands()
}
}
break;
case 04: // M04 - Turn on laser beam
case 4: // M04 - Turn on laser beam
digitalWrite(LASER_PWR_PIN, HIGH);
laser_ttl_modulation = 0;
break;
case 05: // M05 - Turn off laser beam
case 5: // M05 - Turn off laser beam
digitalWrite(LASER_PWR_PIN, LOW);
laser_ttl_modulation=0;
break;
......@@ -3078,13 +3108,10 @@ void process_commands()
SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
break;
case 21: // M21 - init SD card
card.initsd();
break;
case 22: //M22 - release SD card
card.release();
break;
case 23: //M23 - Select file
starpos = (strchr(strchr_pointer + 4,'*'));
......@@ -3136,28 +3163,24 @@ void process_commands()
{
if(card.sdprinting) {
st_synchronize();
}
starpos = (strchr(strchr_pointer + 4,'*'));
char* namestartpos = (strchr(strchr_pointer + 4,'!')); //find ! to indicate filename string start.
if(namestartpos==NULL)
{
if(namestartpos==NULL) {
namestartpos=strchr_pointer + 4; //default name position, 4 letters after the M
}
else
else {
namestartpos++; //to skip the '!'
}
if(starpos!=NULL)
*(starpos)='\0';
if(starpos!=NULL) *(starpos)='\0';
bool call_procedure=(code_seen('P'));
if(strchr_pointer>namestartpos)
call_procedure=false; //false alert, 'P' found within filename
if(strchr_pointer>namestartpos) call_procedure=false; //false alert, 'P' found within filename
if( card.cardOK )
{
if(card.cardOK) {
card.openFile(namestartpos,true,!call_procedure);
if(code_seen('S'))
if(strchr_pointer<namestartpos) //only if "S" is occuring _before_ the filename
......@@ -3166,8 +3189,10 @@ void process_commands()
if(!call_procedure)
starttime=millis(); //procedure calls count as normal print time.
}
} break;
}
break;
case 928: //M928 - Start SD write
{
starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos != NULL){
char* npos = strchr(cmdbuffer[bufindr], 'N');
......@@ -3175,8 +3200,8 @@ void process_commands()
*(starpos) = '\0';
}
card.openLogFile(strchr_pointer+5);
}
break;
#endif //SDSUPPORT
case 31: //M31 take time since the start of the SD print or an M109 command
......@@ -3195,8 +3220,8 @@ void process_commands()
}
break;
case 42: //M42 -Change pin status via gcode
if (code_seen('S'))
{
if (code_seen('S')) {
int pin_status = code_value();
int pin_number = LED_PIN;
if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
......@@ -3209,45 +3234,25 @@ void process_commands()
break;
}
}
#if defined(FAN_PIN) && FAN_PIN > -1
if (pin_number == FAN_PIN)
fanSpeed = pin_status;
#endif
if (pin_number > -1)
{
#if defined(FAN_PIN) && FAN_PIN > -1
if (pin_number == FAN_PIN) fanSpeed = pin_status;
#endif
if (pin_number > -1) {
pinMode(pin_number, OUTPUT);
digitalWrite(pin_number, pin_status);
analogWrite(pin_number, pin_status);
}
}
}
break;
/**********************************************************************\
****************** Firmware Marlin by MagoKimbra **********************\
***********************************************************************\
* M49 Z-Probe repeatability measurement function.
*
* Usage: M49 <n #_samples> <X X_position_for_samples> <Y Y_position_for_samples> <V Verbose_Level> <Engage_probe_for_each_reading> <L legs_of_movement_prior_to_doing_probe>
*
* This function assumes the bed has been homed. Specificaly, that a G28 command
* as been issued prior to invoking the M49 Z-Probe repeatability measurement function.
* Any information generated by a prior G29 Bed leveling command will be lost and need to be
* regenerated.
*
* The number of samples will default to 10 if not specified. You can use upper or lower case
* letters for any of the options EXCEPT n. n must be in lower case because Marlin uses a capital
* N for its communication protocol and will get horribly confused if you send it a capital N.
*
***********************************************************************/
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef Z_PROBE_REPEATABILITY_TEST
case 49: // M49 Z-Probe repeatability
{
#if Z_MIN_PIN == -1
#error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
#endif
#if Z_MIN_PIN == -1
#error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
#endif
double sum=0.0;
double mean=0.0;
......@@ -3284,12 +3289,11 @@ void process_commands()
Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
ext_position = st_get_position_mm(E_AXIS);
if (code_seen('E') || code_seen('e') )
engage_probe_for_each_reading++;
if (code_seen('E') || code_seen('e')) engage_probe_for_each_reading++;
if (code_seen('X') || code_seen('x') ) {
if (code_seen('X') || code_seen('x')) {
X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
if (X_probe_location<X_MIN_POS || X_probe_location>X_MAX_POS ) {
if (X_probe_location<X_MIN_POS || X_probe_location>X_MAX_POS) {
SERIAL_PROTOCOLPGM("?Specified X position out of range.\n");
goto Sigma_Exit;
}
......@@ -3313,9 +3317,9 @@ void process_commands()
}
}
//
// Do all the preliminary setup work. First raise the probe.
//
//
// Do all the preliminary setup work. First raise the probe.
//
st_synchronize();
plan_bed_level_matrix.set_to_identity();
......@@ -3325,11 +3329,11 @@ void process_commands()
active_extruder, active_driver);
st_synchronize();
//
// Now get everything to the specified probe point So we can safely do a probe to
// get us close to the bed. If the Z-Axis is far from the bed, we don't want to
// use that as a starting point for each probe.
//
//
// Now get everything to the specified probe point So we can safely do a probe to
// get us close to the bed. If the Z-Axis is far from the bed, we don't want to
// use that as a starting point for each probe.
//
if (verbose_level > 2)
SERIAL_PROTOCOL("Positioning probe for the test.\n");
......@@ -3344,10 +3348,10 @@ void process_commands()
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS);
//
// OK, do the inital probe to get us close to the bed.
// Then retrace the right amount and use that in subsequent probes
//
//
// OK, do the inital probe to get us close to the bed.
// Then retrace the right amount and use that in subsequent probes
//
engage_z_probe();
......@@ -3364,8 +3368,7 @@ void process_commands()
st_synchronize();
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
if (engage_probe_for_each_reading)
retract_z_probe();
if (engage_probe_for_each_reading) retract_z_probe();
for( n=0; n<n_samples; n++) {
......@@ -3379,10 +3382,10 @@ void process_commands()
radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go
theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians
//SERIAL_ECHOPAIR("starting radius: ",radius);
//SERIAL_ECHOPAIR(" theta: ",theta);
//SERIAL_ECHOPAIR(" direction: ",rotational_direction);
//SERIAL_PROTOCOLLNPGM("");
//SERIAL_ECHOPAIR("starting radius: ",radius);
//SERIAL_ECHOPAIR(" theta: ",theta);
//SERIAL_ECHOPAIR(" direction: ",rotational_direction);
//SERIAL_PROTOCOLLNPGM("");
for( l=0; l<n_legs-1; l++) {
if (rotational_direction==1)
......@@ -3428,18 +3431,18 @@ void process_commands()
sample_set[n] = current_position[Z_AXIS];
//
// Get the current mean for the data points we have so far
//
//
// Get the current mean for the data points we have so far
//
sum=0.0;
for( j=0; j<=n; j++) {
sum = sum + sample_set[j];
}
mean = sum / (double (n+1));
//
// Now, use that mean to calculate the standard deviation for the
// data points we have so far
//
//
// Now, use that mean to calculate the standard deviation for the
// data points we have so far
//
sum=0.0;
for( j=0; j<=n; j++) {
......@@ -3481,7 +3484,7 @@ void process_commands()
clean_up_after_endstop_move();
// enable_endstops(true);
// enable_endstops(true);
if (verbose_level > 0) {
SERIAL_PROTOCOLPGM("Mean: ");
......@@ -3489,9 +3492,9 @@ void process_commands()
SERIAL_PROTOCOLPGM("\n");
}
SERIAL_PROTOCOLPGM("Standard Deviation: ");
SERIAL_PROTOCOL_F(sigma, 6);
SERIAL_PROTOCOLPGM("\n\n");
SERIAL_PROTOCOLPGM("Standard Deviation: ");
SERIAL_PROTOCOL_F(sigma, 6);
SERIAL_PROTOCOLPGM("\n\n");
Sigma_Exit:
break;
......@@ -3531,17 +3534,17 @@ Sigma_Exit:
case 105 : // M105
if(setTargetedHotend(105)) break;
if(debugDryrun()) break;
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
#if defined(TEMP_0_PIN) && TEMP_0_PIN > -1
SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetBed(),1);
#endif //TEMP_BED_PIN
#endif //TEMP_BED_PIN
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(cur_extruder);
......@@ -3550,34 +3553,34 @@ Sigma_Exit:
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetHotend(cur_extruder),1);
}
#else // no TEMP_0_PIN
#else // no TEMP_0_PIN
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
#endif //end TEMP_0_PIN
#endif //end TEMP_0_PIN
SERIAL_PROTOCOLPGM(" @:");
#ifdef HOTEND_WATTS
#ifdef HOTEND_WATTS
SERIAL_PROTOCOL((HOTEND_WATTS * getHeaterPower(tmp_hotend))/127);
SERIAL_PROTOCOLPGM("W");
#else
#else
SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
#endif
#endif
SERIAL_PROTOCOLPGM(" B@:");
#ifdef BED_WATTS
#ifdef BED_WATTS
SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1))/127);
SERIAL_PROTOCOLPGM("W");
#else
#else
SERIAL_PROTOCOL(getHeaterPower(-1));
#endif
#endif
#ifdef SHOW_TEMP_ADC_VALUES
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
#ifdef SHOW_TEMP_ADC_VALUES
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" ADC B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(rawBedTemp()/OVERSAMPLENR,0);
#endif
#endif
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(cur_extruder);
......@@ -3586,7 +3589,7 @@ Sigma_Exit:
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
}
#endif
#endif
SERIAL_PROTOCOLLN("");
return;
......@@ -3596,9 +3599,9 @@ Sigma_Exit:
if(setTargetedHotend(109)) break;
if(debugDryrun()) break;
LCD_MESSAGEPGM(MSG_HEATING);
#ifdef AUTOTEMP
#ifdef AUTOTEMP
autotemp_enabled=false;
#endif
#endif
if (code_seen('S')) {
setTargetHotend(code_value(), tmp_extruder);
#ifdef DUAL_X_CARRIAGE
......@@ -3606,7 +3609,8 @@ Sigma_Exit:
setTargetHotend1(code_value() == 0.0 ? 0.0 : code_value() + duplicate_extruder_temp_offset);
#endif
CooldownNoWait = true;
} else if (code_seen('R')) {
}
else if (code_seen('R')) {
setTargetHotend(code_value(), tmp_extruder);
#ifdef DUAL_X_CARRIAGE
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && tmp_extruder == 0)
......@@ -3614,7 +3618,7 @@ Sigma_Exit:
#endif
CooldownNoWait = false;
}
#ifdef AUTOTEMP
#ifdef AUTOTEMP
if (code_seen('S')) autotemp_min=code_value();
if (code_seen('B')) autotemp_max=code_value();
if (code_seen('F'))
......@@ -3622,7 +3626,7 @@ Sigma_Exit:
autotemp_factor=code_value();
autotemp_enabled=true;
}
#endif
#endif
setWatch();
codenum = millis();
......@@ -3632,23 +3636,23 @@ Sigma_Exit:
cancel_heatup = false;
#ifdef TEMP_RESIDENCY_TIME
#ifdef TEMP_RESIDENCY_TIME
long residencyStart;
residencyStart = -1;
/* continue to loop until we have reached the target temp
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
while((!cancel_heatup)&&((residencyStart == -1) ||
(residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL)))) ) {
#else
#else
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
#endif //TEMP_RESIDENCY_TIME
#endif //TEMP_RESIDENCY_TIME
if( (millis() - codenum) > 1000UL )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL((int)tmp_extruder);
#ifdef TEMP_RESIDENCY_TIME
#ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
{
......@@ -3659,15 +3663,15 @@ Sigma_Exit:
{
SERIAL_PROTOCOLLN( "?" );
}
#else
#else
SERIAL_PROTOCOLLN("");
#endif
#endif
codenum = millis();
}
manage_heater();
manage_inactivity();
lcd_update();
#ifdef TEMP_RESIDENCY_TIME
#ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder)-TEMP_WINDOW))) ||
......@@ -3676,7 +3680,7 @@ Sigma_Exit:
{
residencyStart = millis();
}
#endif //TEMP_RESIDENCY_TIME
#endif //TEMP_RESIDENCY_TIME
}
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
starttime=millis();
......@@ -3684,13 +3688,14 @@ Sigma_Exit:
}
break;
case 190: // M190 - Wait for bed heater to reach target.
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
if(debugDryrun()) break;
LCD_MESSAGEPGM(MSG_BED_HEATING);
if (code_seen('S')) {
setTargetBed(code_value());
CooldownNoWait = true;
} else if (code_seen('R')) {
}
else if (code_seen('R')) {
setTargetBed(code_value());
CooldownNoWait = false;
}
......@@ -3719,10 +3724,10 @@ Sigma_Exit:
}
LCD_MESSAGEPGM(MSG_BED_DONE);
previous_millis_cmd = millis();
#endif
#endif
break;
#if defined(FAN_PIN) && FAN_PIN > -1
#if defined(FAN_PIN) && FAN_PIN > -1
case 106: //M106 Fan On
if (code_seen('S')){
fanSpeed=constrain(code_value(),0,255);
......@@ -3734,10 +3739,10 @@ Sigma_Exit:
case 107: //M107 Fan Off
fanSpeed = 0;
break;
#endif //FAN_PIN
#ifdef BARICUDA
#endif //FAN_PIN
#ifdef BARICUDA
// PWM for HEATER_1_PIN
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1
case 126: //M126 valve open
if (code_seen('S')){
ValvePressure=constrain(code_value(),0,255);
......@@ -3749,10 +3754,10 @@ Sigma_Exit:
case 127: //M127 valve closed
ValvePressure = 0;
break;
#endif //HEATER_1_PIN
#endif //HEATER_1_PIN
// PWM for HEATER_2_PIN
#if defined(HEATER_2_PIN) && HEATER_2_PIN > -1
#if defined(HEATER_2_PIN) && HEATER_2_PIN > -1
case 128: //M128 valve open
if (code_seen('S')){
EtoPPressure=constrain(code_value(),0,255);
......@@ -3764,10 +3769,10 @@ Sigma_Exit:
case 129: //M129 valve closed
EtoPPressure = 0;
break;
#endif //HEATER_2_PIN
#endif
#endif //HEATER_2_PIN
#endif
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
case 80: // M80 - Turn on Power Supply
SET_OUTPUT(PS_ON_PIN); //GND
WRITE(PS_ON_PIN, PS_ON_AWAKE);
......@@ -3775,18 +3780,18 @@ Sigma_Exit:
// If you have a switch on suicide pin, this is useful
// if you want to start another print with suicide feature after
// a print without suicide...
#if defined SUICIDE_PIN && SUICIDE_PIN > -1
#if defined SUICIDE_PIN && SUICIDE_PIN > -1
SET_OUTPUT(SUICIDE_PIN);
WRITE(SUICIDE_PIN, HIGH);
#endif
#endif
#ifdef ULTIPANEL
#ifdef ULTIPANEL
powersupply = true;
LCD_MESSAGEPGM(WELCOME_MSG);
lcd_update();
#endif
#endif
break;
#endif
#endif
case 81: // M81 - Turn off Power Supply
disable_heater();
......@@ -3794,18 +3799,18 @@ Sigma_Exit:
finishAndDisableSteppers();
fanSpeed = 0;
delay(1000); // Wait a little before to switch off
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
st_synchronize();
suicide();
#elif defined(PS_ON_PIN) && PS_ON_PIN > -1
#elif defined(PS_ON_PIN) && PS_ON_PIN > -1
SET_OUTPUT(PS_ON_PIN);
WRITE(PS_ON_PIN, PS_ON_ASLEEP);
#endif
#ifdef ULTIPANEL
#endif
#ifdef ULTIPANEL
powersupply = false;
LCD_MESSAGEPGM(MACHINE_NAME" "MSG_OFF".");
lcd_update();
#endif
#endif
break;
case 82:
......@@ -3833,14 +3838,14 @@ Sigma_Exit:
if(code_seen('X')) disable_x();
if(code_seen('Y')) disable_y();
if(code_seen('Z')) disable_z();
#if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
#if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS
if(code_seen('E')) {
disable_e0();
disable_e1();
disable_e2();
disable_e3();
}
#endif
#endif
}
}
break;
......@@ -3926,37 +3931,37 @@ Sigma_Exit:
break;
case 119: // M119
SERIAL_PROTOCOLLN(MSG_M119_REPORT);
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
SERIAL_PROTOCOLPGM(MSG_X_MIN);
SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
#endif
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
SERIAL_PROTOCOLPGM(MSG_X_MAX);
SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
#endif
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
SERIAL_PROTOCOLPGM(MSG_Y_MIN);
SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
#endif
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
SERIAL_PROTOCOLPGM(MSG_Y_MAX);
SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
#endif
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
SERIAL_PROTOCOLPGM(MSG_Z_MIN);
SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
#endif
#if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
SERIAL_PROTOCOLPGM(MSG_Z_MAX);
SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#if defined(E_MIN_PIN) && E_MIN_PIN > -1
#endif
#if defined(E_MIN_PIN) && E_MIN_PIN > -1
SERIAL_PROTOCOLPGM(MSG_E_MIN);
SERIAL_PROTOCOLLN(((READ(E_MIN_PIN)^E_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif
#endif
break;
//TODO: update for all axis, use for loop
#ifdef BLINKM
#ifdef BLINKM
case 150: // M150
{
byte red;
......@@ -3970,7 +3975,7 @@ Sigma_Exit:
SendColors(red,grn,blu);
}
break;
#endif //BLINKM
#endif //BLINKM
case 200: // M200 D<millimeters> set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
{
float area = .0;
......@@ -3979,10 +3984,12 @@ Sigma_Exit:
radius = (float)code_value() * .5;
if(radius == 0) {
area = 1;
} else {
}
else {
area = M_PI * pow(radius, 2);
}
} else {
}
else {
//reserved for setting filament diameter via UFID or filament measuring device
break;
......@@ -4011,13 +4018,13 @@ Sigma_Exit:
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
reset_acceleration_rates();
break;
#if 0 // Not used for Sprinter/grbl gen6
#if 0 // Not used for Sprinter/grbl gen6
case 202: // M202
for(int8_t i=0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
}
break;
#endif
#endif
case 203: // M203 max feedrate mm/sec
for(int8_t i=0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) max_feedrate[i] = code_value();
......@@ -4044,7 +4051,7 @@ Sigma_Exit:
{
if(code_seen(axis_codes[i])) add_homing[i] = code_value();
}
#ifdef SCARA
#ifdef SCARA
if(code_seen('T')) // Theta
{
add_homing[0] = code_value() ;
......@@ -4053,7 +4060,7 @@ Sigma_Exit:
{
add_homing[1] = code_value() ;
}
#endif
#endif
break;
#ifdef ENABLE_AUTO_BED_LEVELING
......@@ -4115,7 +4122,8 @@ Sigma_Exit:
float pz = code_value();
if ( !(code_seen(axis_codes[0]) || code_seen(axis_codes[1]) || code_seen(axis_codes[2]) ) ) { // Allow direct set of Z offset without an axis code
z_probe_offset[Z_AXIS]= pz;
} else {
}
else {
for(int8_t i=0; i < 3; i++) {
if (code_seen(axis_codes[i])) z_probe_offset[i] = code_value();
}
......@@ -4154,7 +4162,7 @@ Sigma_Exit:
}
break;
#endif // Delta
#ifdef FWRETRACT
#ifdef FWRETRACT
case 207: //M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]
{
if(code_seen('S'))
......@@ -4169,7 +4177,8 @@ Sigma_Exit:
{
retract_zlift = code_value() ;
}
}break;
}
break;
case 208: // M208 - set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
{
if(code_seen('S'))
......@@ -4180,7 +4189,8 @@ Sigma_Exit:
{
retract_recover_feedrate = code_value()/60 ;
}
}break;
}
break;
case 209: // M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
{
if(code_seen('S'))
......@@ -4192,30 +4202,32 @@ Sigma_Exit:
{
autoretract_enabled=false;
retracted[0]=false;
#if EXTRUDERS > 1
#if EXTRUDERS > 1
retracted[1]=false;
#endif
#if EXTRUDERS > 2
#endif
#if EXTRUDERS > 2
retracted[2]=false;
#endif
#if EXTRUDERS > 3
#endif
#if EXTRUDERS > 3
retracted[3]=false;
#endif
}break;
#endif
}
break;
case 1:
{
autoretract_enabled=true;
retracted[0]=false;
#if EXTRUDERS > 1
#if EXTRUDERS > 1
retracted[1]=false;
#endif
#if EXTRUDERS > 2
#endif
#if EXTRUDERS > 2
retracted[2]=false;
#endif
#if EXTRUDERS > 3
#endif
#if EXTRUDERS > 3
retracted[3]=false;
#endif
}break;
#endif
}
break;
default:
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND);
......@@ -4224,12 +4236,12 @@ Sigma_Exit:
}
}
}break;
#endif // FWRETRACT
}
break;
#endif // FWRETRACT
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
#if EXTRUDERS > 1
case 218: // M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
{
if(setTargetedHotend(218)){
......@@ -4243,12 +4255,12 @@ Sigma_Exit:
{
extruder_offset[Y_AXIS][tmp_extruder] = code_value();
}
#ifdef DUAL_X_CARRIAGE
#ifdef DUAL_X_CARRIAGE
if(code_seen('Z'))
{
extruder_offset[Z_AXIS][tmp_extruder] = code_value();
}
#endif
#endif
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
......@@ -4257,15 +4269,17 @@ Sigma_Exit:
SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
SERIAL_ECHO(",");
SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
#ifdef DUAL_X_CARRIAGE
#ifdef DUAL_X_CARRIAGE
SERIAL_ECHO(",");
SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
#endif
#endif
}
SERIAL_ECHOLN("");
}break;
#endif //EXTRUDERS
}
break;
#endif //EXTRUDERS
#endif // SINGLENOZZLE
case 220: // M220 S<factor in percent>- set speed factor override percentage
{
if(code_seen('S'))
......@@ -4293,7 +4307,6 @@ Sigma_Exit:
}
}
break;
case 226: // M226 P<pin number> S<pin state>- Wait until the specified pin reaches the state required
{
if(code_seen('P')){
......@@ -4345,7 +4358,7 @@ Sigma_Exit:
}
break;
#if NUM_SERVOS > 0
#if NUM_SERVOS > 0
case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
{
int servo_index = -1;
......@@ -4381,11 +4394,13 @@ Sigma_Exit:
}
}
break;
#endif // NUM_SERVOS > 0
#endif // NUM_SERVOS > 0
#if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
#if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
case 299: // M299 turn on/off beep sound temp
{
beeptemponoff = !beeptemponoff;
}
break;
case 300: // M300
{
......@@ -4393,15 +4408,15 @@ Sigma_Exit:
int beepP = code_seen('P') ? code_value() : 1000;
if (beepS > 0)
{
#if BEEPER > 0
#if BEEPER > 0
tone(BEEPER, beepS);
delay(beepP);
noTone(BEEPER);
#elif defined(ULTRALCD)
#elif defined(ULTRALCD)
lcd_buzz(beepS, beepP);
#elif defined(LCD_USE_I2C_BUZZER)
#elif defined(LCD_USE_I2C_BUZZER)
lcd_buzz(beepP, beepS);
#endif
#endif
}
else
{
......@@ -4409,18 +4424,18 @@ Sigma_Exit:
}
}
break;
#endif // M299 - M300
#endif // M299 - M300
#ifdef PIDTEMP
#ifdef PIDTEMP
case 301: // M301
{
if(code_seen('P')) Kp[active_extruder] = code_value();
if(code_seen('I')) Ki[active_extruder] = scalePID_i(code_value());
if(code_seen('D')) Kd[active_extruder] = scalePID_d(code_value());
#ifdef PID_ADD_EXTRUSION_RATE
#ifdef PID_ADD_EXTRUSION_RATE
if(code_seen('C')) Kc = code_value();
#endif
#endif
updatePID();
SERIAL_PROTOCOL(MSG_OK);
......@@ -4430,16 +4445,17 @@ Sigma_Exit:
SERIAL_PROTOCOL(unscalePID_i(Ki[active_extruder]));
SERIAL_PROTOCOL(" d:");
SERIAL_PROTOCOL(unscalePID_d(Kd[active_extruder]));
#ifdef PID_ADD_EXTRUSION_RATE
#ifdef PID_ADD_EXTRUSION_RATE
SERIAL_PROTOCOL(" c:");
//Kc does not have scaling applied above, or in resetting defaults
SERIAL_PROTOCOL(Kc);
#endif
#endif
SERIAL_PROTOCOLLN("");
}
break;
#endif //PIDTEMP
#ifdef PIDTEMPBED
#endif //PIDTEMP
#ifdef PIDTEMPBED
case 304: // M304
{
if(code_seen('P')) bedKp = code_value();
......@@ -4457,19 +4473,19 @@ Sigma_Exit:
SERIAL_PROTOCOLLN("");
}
break;
#endif //PIDTEMP
#endif //PIDTEMP
case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
{
#ifdef CHDK
#ifdef CHDK
SET_OUTPUT(CHDK);
WRITE(CHDK, HIGH);
chdkHigh = millis();
chdkActive = true;
#else
#else
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
const uint8_t NUM_PULSES=16;
const float PULSE_LENGTH=0.01524;
for(int i=0; i < NUM_PULSES; i++) {
......@@ -4485,8 +4501,8 @@ Sigma_Exit:
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
#endif
#endif //chdk end if
#endif
#endif //chdk end if
}
break;
#ifdef DOGLCD
......@@ -4501,7 +4517,8 @@ Sigma_Exit:
}
break;
#endif
#ifdef PREVENT_DANGEROUS_EXTRUDE
#ifdef PREVENT_DANGEROUS_EXTRUDE
case 302: // allow cold extrudes, or set the minimum extrude temperature
{
float temp = .0;
......@@ -4509,15 +4526,15 @@ Sigma_Exit:
set_extrude_min_temp(temp);
}
break;
#endif
#endif
case 303: // M303 PID autotune
{
float temp = 150.0;
int e=0;
int c=5;
if (code_seen('E')) e=code_value();
if (e<0)
temp=70;
if (e<0) temp=70;
if (code_seen('S')) temp=code_value();
if (code_seen('C')) c=code_value();
PID_autotune(temp, e, c);
......@@ -4542,7 +4559,6 @@ Sigma_Exit:
return;
}
break;
case 361: // SCARA Theta pos2
SERIAL_ECHOLN(" Cal: Theta 90 ");
//SoftEndsEnabled = false; // Ignore soft endstops during calibration
......@@ -4629,13 +4645,13 @@ Sigma_Exit:
st_synchronize();
}
break;
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(SERVO_ENDSTOPS) && not defined(Z_PROBE_SLED)
case 401:
{
engage_z_probe(); // Engage Z Servo endstop if available
}
break;
case 402:
{
retract_z_probe(); // Retract Z Servo endstop if enabled
......@@ -4644,31 +4660,27 @@ Sigma_Exit:
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef FILAMENT_SENSOR
case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
{
#if (FILWIDTH_PIN > -1)
#if (FILWIDTH_PIN > -1)
if(code_seen('N')) filament_width_nominal=code_value();
else{
SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
SERIAL_PROTOCOLLN(filament_width_nominal);
}
#endif
#endif
}
break;
case 405: //M405 Turn on filament sensor for control
{
if(code_seen('D')) meas_delay_cm=code_value();
if(meas_delay_cm> MAX_MEASUREMENT_DELAY)
meas_delay_cm = MAX_MEASUREMENT_DELAY;
if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY;
if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup
{
int temp_ratio = widthFil_to_size_ratio();
for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){
measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte
}
......@@ -4677,35 +4689,25 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
filament_sensor = true ;
//SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
//SERIAL_PROTOCOL(filament_width_meas);
//SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
//SERIAL_PROTOCOL(extrudemultiply);
}
break;
case 406: //M406 Turn off filament sensor for control
{
filament_sensor = false ;
}
break;
case 407: //M407 Display measured filament diameter
{
SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
SERIAL_PROTOCOLLN(filament_width_meas);
}
break;
#endif // FILAMENT_SENSOR
case 500: // M500 Store settings in EEPROM
{
Config_StoreSettings();
......@@ -4726,15 +4728,15 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
Config_PrintSettings();
}
break;
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
case 540:
{
if(code_seen('S')) abort_on_endstop_hit = code_value() > 0;
}
break;
#endif
#endif
#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET:
{
float value;
......@@ -4768,9 +4770,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
break;
}
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
#ifdef FILAMENTCHANGEENABLE
#ifdef FILAMENTCHANGEENABLE
case 600: //M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
{
float target[4];
......@@ -4789,9 +4791,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
else
{
#ifdef FILAMENTCHANGE_FIRSTRETRACT
#ifdef FILAMENTCHANGE_FIRSTRETRACT
target[E_AXIS]+= FILAMENTCHANGE_FIRSTRETRACT ;
#endif
#endif
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
......@@ -4802,9 +4804,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
else
{
#ifdef FILAMENTCHANGE_ZADD
#ifdef FILAMENTCHANGE_ZADD
target[Z_AXIS]+= FILAMENTCHANGE_ZADD ;
#endif
#endif
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
......@@ -4815,9 +4817,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
else
{
#ifdef FILAMENTCHANGE_XPOS
#ifdef FILAMENTCHANGE_XPOS
target[X_AXIS]= FILAMENTCHANGE_XPOS ;
#endif
#endif
}
if(code_seen('Y'))
{
......@@ -4825,9 +4827,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
else
{
#ifdef FILAMENTCHANGE_YPOS
#ifdef FILAMENTCHANGE_YPOS
target[Y_AXIS]= FILAMENTCHANGE_YPOS ;
#endif
#endif
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
......@@ -4838,9 +4840,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
else
{
#ifdef FILAMENTCHANGE_FINALRETRACT
#ifdef FILAMENTCHANGE_FINALRETRACT
target[E_AXIS]+= FILAMENTCHANGE_FINALRETRACT ;
#endif
#endif
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder, active_driver);
......@@ -4862,20 +4864,20 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
lcd_update();
if(cnt==0)
{
#if BEEPER > 0
#if BEEPER > 0
SET_OUTPUT(BEEPER);
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
delay(3);
#else
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
#else
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
lcd_buzz(1000/6,100);
#else
#else
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ);
#endif
#endif
#endif
#endif
}
}
......@@ -4886,9 +4888,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
else
{
#ifdef FILAMENTCHANGE_FINALRETRACT
#ifdef FILAMENTCHANGE_FINALRETRACT
target[E_AXIS]+=(-1)*FILAMENTCHANGE_FINALRETRACT ;
#endif
#endif
}
current_position[E_AXIS]=target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
plan_set_e_position(current_position[E_AXIS]);
......@@ -5023,6 +5025,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
break;
#endif // NPR2
case 999: // M999: Restart after being stopped
Stopped = false;
lcd_reset_alert_level();
......@@ -5031,27 +5034,20 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
break;
}
}
else if(code_seen('T'))
{
else if(code_seen('T')) {
tmp_extruder = code_value();
long csteps;
if(tmp_extruder >= EXTRUDERS)
{
if(tmp_extruder >= EXTRUDERS) {
SERIAL_ECHO_START;
SERIAL_ECHO("T");
SERIAL_ECHO(tmp_extruder);
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
}
else
{
} else {
boolean make_move = false;
if(code_seen('F'))
{
if(code_seen('F')) {
make_move = true;
next_feedrate = code_value();
if(next_feedrate > 0.0)
{
if(next_feedrate > 0.0) {
feedrate = next_feedrate;
}
}
......@@ -5134,11 +5130,27 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
st_synchronize(); // Finish all movement
disable_e0();
disable_e1();
switch(tmp_extruder){
case 0: WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E1E3_CHOICE_PIN,LOW); active_driver=0; break;
case 1: WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E1E3_CHOICE_PIN,LOW); active_driver=1; break;
case 2: WRITE(E0E2_CHOICE_PIN,HIGH); WRITE(E1E3_CHOICE_PIN,LOW); active_driver=0; break;
case 3: WRITE(E0E2_CHOICE_PIN,LOW); WRITE(E1E3_CHOICE_PIN,HIGH); active_driver=1; break;
switch(tmp_extruder) {
case 0:
WRITE(E0E2_CHOICE_PIN,LOW);
WRITE(E1E3_CHOICE_PIN,LOW);
active_driver=0;
break;
case 1:
WRITE(E0E2_CHOICE_PIN,LOW);
WRITE(E1E3_CHOICE_PIN,LOW);
active_driver=1;
break;
case 2:
WRITE(E0E2_CHOICE_PIN,HIGH);
WRITE(E1E3_CHOICE_PIN,LOW);
active_driver=0;
break;
case 3:
WRITE(E0E2_CHOICE_PIN,LOW);
WRITE(E1E3_CHOICE_PIN,HIGH);
active_driver=1;
break;
}
delay(DELAY_R); // ritardo per commutazione rele
enable_e0();
......@@ -5147,10 +5159,19 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
#elif (EXTRUDERS == 3) && (E0E2_CHOICE_PIN >1)
st_synchronize(); // Finish all movement
disable_e0();
switch(tmp_extruder){
case 0: WRITE(E0E2_CHOICE_PIN,LOW); active_driver=0; break;
case 1: WRITE(E0E2_CHOICE_PIN,LOW); active_driver=1; break;
case 2: WRITE(E0E2_CHOICE_PIN,HIGH); active_driver=0; break;
switch(tmp_extruder) {
case 0:
WRITE(E0E2_CHOICE_PIN,LOW);
active_driver=0;
break;
case 1:
WRITE(E0E2_CHOICE_PIN,LOW);
active_driver=1;
break;
case 2:
WRITE(E0E2_CHOICE_PIN,HIGH);
active_driver=0;
break;
}
delay(DELAY_R); // ritardo per commutazione rele
enable_e0();
......@@ -5158,9 +5179,15 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
#elif (EXTRUDERS == 2) && (E0E1_CHOICE_PIN >1)
st_synchronize(); // Finish all movement
disable_e0();
switch(tmp_extruder){
case 0: WRITE(E0E1_CHOICE_PIN,LOW); active_driver=0; break;
case 1: WRITE(E0E1_CHOICE_PIN,HIGH); active_driver=0; break;
switch(tmp_extruder) {
case 0:
WRITE(E0E1_CHOICE_PIN,LOW);
active_driver=0;
break;
case 1:
WRITE(E0E1_CHOICE_PIN,HIGH);
active_driver=0;
break;
}
delay(DELAY_R); // ritardo per commutazione rele
enable_e0();
......@@ -5176,7 +5203,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
#elif defined(NPR2)
st_synchronize(); // Finish all movement
if (old_color == 99){
if (old_color == 99) {
csteps = (color_position[tmp_extruder]) * color_step_moltiplicator;
}
else{
......@@ -5260,7 +5287,7 @@ void get_coordinates()
if(next_feedrate > 0.0) feedrate = next_feedrate;
}
#ifdef LASERBEAM
if(code_seen('L')){
if(code_seen('L')) {
laser_ttl_modulation=constrain(code_value(),0,255);
}
#endif // LASERBEAM
......@@ -5387,24 +5414,27 @@ void prepare_move()
clamp_to_software_endstops(destination);
previous_millis_cmd = millis();
#ifdef SCARA //for now same as delta-code
float difference[NUM_AXIS];
for (int8_t i=0; i < NUM_AXIS; i++) {
#ifdef SCARA //for now same as delta-code
float difference[NUM_AXIS];
for (int8_t i=0; i < NUM_AXIS; i++) {
difference[i] = destination[i] - current_position[i];
}
}
float cartesian_mm = sqrt( sq(difference[X_AXIS]) +
float cartesian_mm = sqrt( sq(difference[X_AXIS]) +
sq(difference[Y_AXIS]) +
sq(difference[Z_AXIS]));
if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
if (cartesian_mm < 0.000001) { return; }
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
int steps = max(1, int(scara_segments_per_second * seconds));
if (cartesian_mm < 0.000001) {
cartesian_mm = abs(difference[E_AXIS]);
}
if (cartesian_mm < 0.000001) {
return;
}
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
int steps = max(1, int(scara_segments_per_second * seconds));
//SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
//SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
//SERIAL_ECHOPGM(" steps="); SERIAL_ECHOLN(steps);
for (int s = 1; s <= steps; s++) {
for (int s = 1; s <= steps; s++) {
float fraction = float(s) / float(steps);
for(int8_t i=0; i < NUM_AXIS; i++) {
destination[i] = current_position[i] + difference[i] * fraction;
......@@ -5422,7 +5452,7 @@ for (int s = 1; s <= steps; s++) {
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
destination[E_AXIS], feedrate*feedmultiply/60/100.0,
active_extruder, active_driver);
}
}
#endif // SCARA
#ifdef DELTA
......@@ -5433,8 +5463,12 @@ for (int s = 1; s <= steps; s++) {
float cartesian_mm = sqrt(sq(difference[X_AXIS]) +
sq(difference[Y_AXIS]) +
sq(difference[Z_AXIS]));
if (cartesian_mm < 0.000001) { cartesian_mm = abs(difference[E_AXIS]); }
if (cartesian_mm < 0.000001) { return; }
if (cartesian_mm < 0.000001) {
cartesian_mm = abs(difference[E_AXIS]);
}
if (cartesian_mm < 0.000001) {
return;
}
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
int steps = max(1, int(DELTA_SEGMENTS_PER_SECOND * seconds));
// SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
......@@ -5519,7 +5553,8 @@ for (int s = 1; s <= steps; s++) {
}
}
void prepare_arc_move(char isclockwise) {
void prepare_arc_move(char isclockwise)
{
float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
// Trace the arc
......@@ -5535,13 +5570,11 @@ void prepare_arc_move(char isclockwise) {
}
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
#if defined(FAN_PIN)
#if CONTROLLERFAN_PIN == FAN_PIN
#error "You cannot set CONTROLLERFAN_PIN equal to FAN_PIN"
#endif
#endif
#if CONTROLLERFAN_PIN == FAN_PIN
#error "You cannot set CONTROLLERFAN_PIN equal to FAN_PIN"
#endif // CONTROLLERFAN_PIN == FAN_PIN
#endif // defined(FAN_PIN)
unsigned long lastMotor = 0; //Save the time for when a motor was turned on last
unsigned long lastMotorCheck = 0;
......@@ -5552,15 +5585,15 @@ void controllerFan()
lastMotorCheck = millis();
if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN) || (soft_pwm_bed > 0)
#if DRIVER_EXTRUDERS > 2
#if DRIVER_EXTRUDERS > 2
|| !READ(E2_ENABLE_PIN)
#endif
#if DRIVER_EXTRUDER > 1
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
#endif
#if DRIVER_EXTRUDER > 1
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
|| !READ(X2_ENABLE_PIN)
#endif
#endif
|| !READ(E1_ENABLE_PIN)
#endif
#endif
|| !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
{
lastMotor = millis(); //... set time to NOW so the fan will turn on
......@@ -5579,7 +5612,7 @@ void controllerFan()
}
}
}
#endif
#endif // defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
#ifdef SCARA
void calculate_SCARA_forward_Transform(float f_scara[3])
......@@ -5609,7 +5642,8 @@ void calculate_SCARA_forward_Transform(float f_scara[3])
//SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
}
void calculate_delta(float cartesian[3]){
void calculate_delta(float cartesian[3])
{
//reverse kinematics.
// Perform reversed kinematics, and place results in delta[3]
// The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014
......@@ -5620,11 +5654,11 @@ void calculate_delta(float cartesian[3]){
SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y
SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor.
#if (Linkage_1 == Linkage_2)
#if (Linkage_1 == Linkage_2)
SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1;
#else
#else
SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000;
#endif
#endif
SCARA_S2 = sqrt( 1 - sq(SCARA_C2) );
......@@ -5656,15 +5690,14 @@ void calculate_delta(float cartesian[3]){
SERIAL_ECHOPGM(" Psi="); SERIAL_ECHOLN(SCARA_psi);
SERIAL_ECHOLN(" ");*/
}
#endif
#endif // SCARA
#ifdef TEMP_STAT_LEDS
static bool blue_led = false;
static bool red_led = false;
static uint32_t stat_update = 0;
void handle_status_leds(void) {
void handle_status_leds(void)
{
float max_temp = 0.0;
if(millis() > stat_update) {
stat_update += 500; // Update every 0.5s
......@@ -5672,10 +5705,10 @@ void handle_status_leds(void) {
max_temp = max(max_temp, degHotend(cur_extruder));
max_temp = max(max_temp, degTargetHotend(cur_extruder));
}
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
max_temp = max(max_temp, degTargetBed());
max_temp = max(max_temp, degBed());
#endif
#endif
if((max_temp > 55.0) && (red_led == false)) {
digitalWrite(STAT_LED_RED, 1);
digitalWrite(STAT_LED_BLUE, 0);
......@@ -5690,7 +5723,7 @@ void handle_status_leds(void) {
}
}
}
#endif
#endif // TEMP_STAT_LEDS
void manage_inactivity()
{
......@@ -5715,32 +5748,30 @@ void manage_inactivity()
}
}
#if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
#if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
if (beeptemponoff) temptone();
#endif
#endif
#ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
#ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH
if (chdkActive && (millis() - chdkHigh > CHDK_DELAY))
{
chdkActive = false;
WRITE(CHDK, LOW);
}
#endif
#endif
#if defined(KILL_PIN) && KILL_PIN > -1
if( 0 == READ(KILL_PIN) )
kill();
#endif
#if defined(KILL_PIN) && KILL_PIN > -1
if(0 == READ(KILL_PIN)) kill();
#endif
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
if( 0 == READ(PAUSE_PIN) )
pause();
#endif
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
if(0 == READ(PAUSE_PIN)) pause();
#endif
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif
#ifdef EXTRUDER_RUNOUT_PREVENT
#endif
#ifdef EXTRUDER_RUNOUT_PREVENT
if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
{
......@@ -5758,8 +5789,8 @@ void manage_inactivity()
st_synchronize();
WRITE(E0_ENABLE_PIN,oldstatus);
}
#endif
#if defined(DUAL_X_CARRIAGE)
#endif
#if defined(DUAL_X_CARRIAGE)
// handle delayed move timeout
if (delayed_move_time != 0 && (millis() - delayed_move_time) > 1000 && Stopped == false)
{
......@@ -5768,10 +5799,10 @@ void manage_inactivity()
memcpy(destination,current_position,sizeof(destination));
prepare_move();
}
#endif
#ifdef TEMP_STAT_LEDS
#endif
#ifdef TEMP_STAT_LEDS
handle_status_leds();
#endif
#endif
check_axes_activity();
}
......@@ -5802,48 +5833,45 @@ void kill()
#if (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
void temptone()
{
if (!isHeatingHotend(active_extruder) && degTargetHotend(active_extruder)!=0 && beeptemphe)
{
if (!isHeatingHotend(active_extruder) && degTargetHotend(active_extruder)!=0 && beeptemphe) {
int beepS = 200;
int beepP = 500;
int beepN = 3;
for (int i = 0; i < beepN; ++i)
{
#if BEEPER > 0
#if BEEPER > 0
tone(BEEPER, beepS);
delay(beepP);
noTone(BEEPER);
#elif defined(ULTRALCD)
#elif defined(ULTRALCD)
lcd_buzz(beepS, beepP);
#elif defined(LCD_USE_I2C_BUZZER)
#elif defined(LCD_USE_I2C_BUZZER)
lcd_buzz(beepP, beepS);
#endif
#endif
delay(beepP);
}
beeptemphe=false;
}
else if (!isHeatingBed() && degTargetBed()!=0 && beeptemphb)
{
else if (!isHeatingBed() && degTargetBed()!=0 && beeptemphb) {
int beepS = 100;
int beepP = 500;
int beepN = 2;
for (int i = 0; i < beepN; ++i)
{
#if BEEPER > 0
for (int i = 0; i < beepN; ++i) {
#if BEEPER > 0
tone(BEEPER, beepS);
delay(beepP);
noTone(BEEPER);
#elif defined(ULTRALCD)
#elif defined(ULTRALCD)
lcd_buzz(beepS, beepP);
#elif defined(LCD_USE_I2C_BUZZER)
#elif defined(LCD_USE_I2C_BUZZER)
lcd_buzz(beepP, beepS);
#endif
#endif
delay(beepP);
}
beeptemphb=false;
}
}
#endif
#endif // (LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)))
#if defined(PAUSE_PIN) && PAUSE_PIN > -1
void pause()
......@@ -5853,7 +5881,7 @@ void pause()
enquecommand("G4 P0");
enquecommand("G4 P0");
}
#endif
#endif // defined(PAUSE_PIN) && PAUSE_PIN > -1
void Stop()
{
......@@ -5873,79 +5901,77 @@ bool IsStopped() { return Stopped; };
void setPwmFrequency(uint8_t pin, int val)
{
val &= 0x07;
switch(digitalPinToTimer(pin))
{
#if defined(TCCR0A)
switch(digitalPinToTimer(pin)) {
#if defined(TCCR0A)
case TIMER0A:
case TIMER0B:
// TCCR0B &= ~(_BV(CS00) | _BV(CS01) | _BV(CS02));
// TCCR0B |= val;
//TCCR0B &= ~(_BV(CS00) | _BV(CS01) | _BV(CS02));
//TCCR0B |= val;
break;
#endif
#endif
#if defined(TCCR1A)
#if defined(TCCR1A)
case TIMER1A:
case TIMER1B:
// TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
// TCCR1B |= val;
//TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
//TCCR1B |= val;
break;
#endif
#endif
#if defined(TCCR2)
#if defined(TCCR2)
case TIMER2:
case TIMER2:
TCCR2 &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
TCCR2 |= val;
break;
#endif
#endif
#if defined(TCCR2A)
#if defined(TCCR2A)
case TIMER2A:
case TIMER2B:
TCCR2B &= ~(_BV(CS20) | _BV(CS21) | _BV(CS22));
TCCR2B |= val;
break;
#endif
#endif
#if defined(TCCR3A)
#if defined(TCCR3A)
case TIMER3A:
case TIMER3B:
case TIMER3C:
TCCR3B &= ~(_BV(CS30) | _BV(CS31) | _BV(CS32));
TCCR3B |= val;
break;
#endif
#endif
#if defined(TCCR4A)
#if defined(TCCR4A)
case TIMER4A:
case TIMER4B:
case TIMER4C:
TCCR4B &= ~(_BV(CS40) | _BV(CS41) | _BV(CS42));
TCCR4B |= val;
break;
#endif
#endif
#if defined(TCCR5A)
#if defined(TCCR5A)
case TIMER5A:
case TIMER5B:
case TIMER5C:
TCCR5B &= ~(_BV(CS50) | _BV(CS51) | _BV(CS52));
TCCR5B |= val;
break;
#endif
#endif
}
}
#endif //FAST_PWM_FAN
bool setTargetedHotend(int code){
bool setTargetedHotend(int code) {
tmp_extruder = active_extruder;
if(code_seen('T')) {
tmp_extruder = code_value();
if(tmp_extruder >= EXTRUDERS) {
SERIAL_ECHO_START;
switch(code){
switch(code) {
case 104:
SERIAL_ECHO(MSG_M104_INVALID_EXTRUDER);
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment