From a8c1bdabd292c93c7cb12ec4882cbdee1781c1ef Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Sun, 15 Mar 2015 17:25:31 +0100 Subject: [PATCH 001/118] Update: readme.md for K8200 example * readme.md: updated typo and URLs --- Marlin/example_configurations/K8200/readme.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Marlin/example_configurations/K8200/readme.md b/Marlin/example_configurations/K8200/readme.md index 79cb6e039e..7f0761360a 100644 --- a/Marlin/example_configurations/K8200/readme.md +++ b/Marlin/example_configurations/K8200/readme.md @@ -2,7 +2,7 @@ * Configuration files for **Vellemann K8200** (with VM8201 - LCD Option for K8200) * K8200 is a 3Drag clone - configuration should work with 3Drag http://reprap.org/wiki/3drag, too. Please report. -* updated manually with parameters form genuine Vellemann Firmware "firmware_k8200_marlinv2" based on the recent development branch +* updated manually with parameters from genuine Vellemann Firmware "firmware_k8200_marlinv2" based on the recent development branch * VM8201 uses "DISPLAY_CHARSET_HD44870_JAPAN" and "ULTIMAKERCONTROLLER" * german (de) translation with umlaut is supported now - thanks to @AnHardt for the great hardware based umlaut support @@ -10,4 +10,11 @@ I (@CONSULitAS) tested the changes on my K8200 with 20x4-LCD and Arduino 1.0.5 for Windows (SD library added to IDE manually) - everything works well. **Source for genuine Vellemann Firmware V2 (with LCD/SD-Support):** -* [firmware_k8200_marlinv2.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv2.zip) \ No newline at end of file +* [firmware_k8200_v2.1.1.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_v2.1.1.zip) + * see also https://github.com/CONSULitAS/Marlin-K8200/tree/Vellemann_firmware_k8200_v2.1.1.zip + +* [firmware_k8200_marlinv2.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv2.zip) + * see also https://github.com/CONSULitAS/Marlin-K8200/tree/Vellemann_firmware_k8200_marlinv2.zip + +* [firmware_k8200_marlinv1.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv1.zip) + * see also https://github.com/CONSULitAS/Marlin-K8200/tree/Vellemann_firmware_k8200_marlinv1.zip From bcc04192fc046b766512cde5e5ec11958205ebc2 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 8 Apr 2015 12:56:38 +0200 Subject: [PATCH 002/118] Remove Contrast Menu for U8GLIB_ST7920 The other two devices we use in u8glib have more than only dummy code. Checked this in the library code. --- Marlin/Conditionals.h | 8 +++++++- Marlin/ultralcd.cpp | 16 +++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index 5d3213e0e3..c7d2e793f1 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -130,7 +130,6 @@ #define NEWPANEL #endif - #ifdef ULTIPANEL #define NEWPANEL //enable this if you have a click-encoder panel #define SDSUPPORT @@ -161,6 +160,13 @@ #define DEFAULT_LCD_CONTRAST 32 #endif + #ifdef DOGLCD + #define HAS_LCD_CONTRAST + #ifdef U8GLIB_ST7920 + #undefine HAS_LCD_CONTRAST + #endif + #endif + #else // CONFIGURATION_LCD #define CONDITIONALS_H diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index caaf55ab74..9e90d564b3 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -58,7 +58,7 @@ static void lcd_status_screen(); static void lcd_control_temperature_preheat_abs_settings_menu(); static void lcd_control_motion_menu(); static void lcd_control_volumetric_menu(); - #ifdef DOGLCD + #ifdef HAS_LCD_CONTRAST static void lcd_set_contrast(); #endif #ifdef FWRETRACT @@ -739,7 +739,7 @@ static void lcd_control_menu() { MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu); MENU_ITEM(submenu, MSG_VOLUMETRIC, lcd_control_volumetric_menu); - #ifdef DOGLCD + #ifdef HAS_LCD_CONTRAST //MENU_ITEM_EDIT(int3, MSG_CONTRAST, &lcd_contrast, 0, 63); MENU_ITEM(submenu, MSG_CONTRAST, lcd_set_contrast); #endif @@ -963,8 +963,7 @@ static void lcd_control_volumetric_menu() { END_MENU(); } -#ifdef DOGLCD - +#ifdef HAS_LCD_CONTRAST static void lcd_set_contrast() { if (encoderPosition != 0) { lcd_contrast -= encoderPosition; @@ -976,11 +975,9 @@ static void lcd_control_volumetric_menu() { if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu); } - -#endif // DOGLCD +#endif // HAS_LCD_CONTRAST #ifdef FWRETRACT - static void lcd_control_retract_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); @@ -998,16 +995,13 @@ static void lcd_control_volumetric_menu() { MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999); END_MENU(); } - #endif // FWRETRACT #if SDCARDDETECT == -1 - static void lcd_sd_refresh() { card.initsd(); currentMenuViewOffset = 0; } - #endif static void lcd_sd_updir() { @@ -1458,7 +1452,7 @@ void lcd_setalertstatuspgm(const char* message) { void lcd_reset_alert_level() { lcd_status_message_level = 0; } -#ifdef DOGLCD +#ifdef HAS_LCD_CONTRAST void lcd_setcontrast(uint8_t value) { lcd_contrast = value & 0x3F; u8g.setContrast(lcd_contrast); From 6a514f3dc96021b3057355dd20ee81abec02e291 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 8 Apr 2015 13:26:29 +0200 Subject: [PATCH 003/118] Aplied HAS_LCD_CONTRAST also to Marlin_main.cpp and cleaned typo. --- Marlin/Conditionals.h | 2 +- Marlin/Marlin_main.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index c7d2e793f1..c0095ca8d9 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -163,7 +163,7 @@ #ifdef DOGLCD #define HAS_LCD_CONTRAST #ifdef U8GLIB_ST7920 - #undefine HAS_LCD_CONTRAST + #undef HAS_LCD_CONTRAST #endif #endif diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8bf0909886..a9fb673ed2 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -4083,7 +4083,7 @@ inline void gcode_M226() { #endif // CHDK || PHOTOGRAPH_PIN -#ifdef DOGLCD +#ifdef HAS_LCD_CONTRAST /** * M250: Read and optionally set the LCD contrast @@ -4095,7 +4095,7 @@ inline void gcode_M226() { SERIAL_EOL; } -#endif // DOGLCD +#endif // HAS_LCD_CONTRAST #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -5081,11 +5081,11 @@ void process_commands() { break; #endif // CHDK || PHOTOGRAPH_PIN - #ifdef DOGLCD + #ifdef HAS_LCD_CONTRAST case 250: // M250 Set LCD contrast value: C (value 0..63) gcode_M250(); break; - #endif // DOGLCD + #endif // HAS_LCD_CONTRAST #ifdef PREVENT_DANGEROUS_EXTRUDE case 302: // allow cold extrudes, or set the minimum extrude temperature From 7dc64efe672a1417b2aa49a72a27448e09f06d05 Mon Sep 17 00:00:00 2001 From: Edward Patel Date: Wed, 8 Apr 2015 20:52:48 +0200 Subject: [PATCH 004/118] Added sanity check for MESH_NUM_X_POINTS and MESH_NUM_Y_POINTS --- Marlin/Configuration.h | 2 +- Marlin/SanityCheck.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index b0d97f15e7..b99d4f426f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -420,7 +420,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. //=========================================================================== -//============================ Manual Bed Leveling ========================== +//============================ Mesh Bed Leveling ============================ //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index d1be7703d9..7aeaa81a68 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -101,6 +101,9 @@ #ifdef ENABLE_AUTO_BED_LEVELING #error Select ENABLE_AUTO_BED_LEVELING or MESH_BED_LEVELING, not both #endif + #if MESH_NUM_X_POINTS > 7 || MESH_NUM_Y_POINTS > 7 + #error MESH_NUM_X_POINTS and MESH_NUM_Y_POINTS need to be less than 8 + #endif #endif /** From ea897654a466d24d0511c331e6c1e6b12df1014f Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 8 Apr 2015 21:53:58 +0200 Subject: [PATCH 005/118] Moved the definitions of the LCD_STR_* to Conditionals.h to avoid errors in Marlin_main.cpp. #1860 In the include tree of Marlin_main.cpp the decision between the display types is not made. To include the right LCD_STR_* ether 'dogm_lcd_implementation.h' or 'ultralcd_implementation_hitachi_HD44780.h' with all their code. A 'dogm_lcd_implementation.h.h' would be a curiosity. So i moved both of the definition blocks to conditionals.h On the long term it could make sense to use the same numbering for the u8glib and the hitachi symbols. --- Marlin/Conditionals.h | 43 ++++++++++++++++--- Marlin/dogm_lcd_implementation.h | 16 ------- .../ultralcd_implementation_hitachi_HD44780.h | 12 ------ 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index 5d3213e0e3..5b1024236e 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -144,16 +144,45 @@ #endif #else //no panel but just LCD #ifdef ULTRA_LCD - #ifdef DOGLCD // Change number of lines to match the 128x64 graphics display - #define LCD_WIDTH 22 - #define LCD_HEIGHT 5 - #else - #define LCD_WIDTH 16 - #define LCD_HEIGHT 2 - #endif + #ifdef DOGLCD // Change number of lines to match the 128x64 graphics display + #define LCD_WIDTH 22 + #define LCD_HEIGHT 5 + #else + #define LCD_WIDTH 16 + #define LCD_HEIGHT 2 + #endif #endif #endif + #ifdef DOGLCD + /* Custom characters defined in font font_6x10_marlin_symbols */ + // \x00 intentionally skipped to avoid problems in strings + #define LCD_STR_REFRESH "\x01" + #define LCD_STR_FOLDER "\x02" + #define LCD_STR_ARROW_RIGHT "\x03" + #define LCD_STR_UPLEVEL "\x04" + #define LCD_STR_CLOCK "\x05" + #define LCD_STR_FEEDRATE "\x06" + #define LCD_STR_BEDTEMP "\x07" + #define LCD_STR_THERMOMETER "\x08" + #define LCD_STR_DEGREE "\x09" + + #define LCD_STR_SPECIAL_MAX '\x09' + // Maximum here is 0x1f because 0x20 is ' ' (space) and the normal charsets begin. + // Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here. + #else + /* Custom characters defined in the first 8 characters of the LCD */ + #define LCD_STR_BEDTEMP "\x00" // this will have 'unexpected' results when used in a string! + #define LCD_STR_DEGREE "\x01" + #define LCD_STR_THERMOMETER "\x02" + #define LCD_STR_UPLEVEL "\x03" + #define LCD_STR_REFRESH "\x04" + #define LCD_STR_FOLDER "\x05" + #define LCD_STR_FEEDRATE "\x06" + #define LCD_STR_CLOCK "\x07" + #define LCD_STR_ARROW_RIGHT ">" /* from the default character set */ + #endif + /** * Default LCD contrast for dogm-like LCD displays */ diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 2a6d229b7f..fd52d645ed 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -108,22 +108,6 @@ #define START_ROW 0 -/* Custom characters defined in font font_6x10_marlin_symbols */ -// \x00 intentionally skipped to avoid problems in strings -#define LCD_STR_REFRESH "\x01" -#define LCD_STR_FOLDER "\x02" -#define LCD_STR_ARROW_RIGHT "\x03" -#define LCD_STR_UPLEVEL "\x04" -#define LCD_STR_CLOCK "\x05" -#define LCD_STR_FEEDRATE "\x06" -#define LCD_STR_BEDTEMP "\x07" -#define LCD_STR_THERMOMETER "\x08" -#define LCD_STR_DEGREE "\x09" - -#define LCD_STR_SPECIAL_MAX '\x09' -// Maximum here is 0x1f because 0x20 is ' ' (space) and the normal charsets begin. -// Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here. - // LCD selection #ifdef U8GLIB_ST7920 //U8GLIB_ST7920_128X64_RRD u8g(0,0,0); diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 5698fd94b9..aa348018ef 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -201,18 +201,6 @@ #define LCD_STR_PROGRESS "\x03\x04\x05" #endif -/* Custom characters defined in the first 8 characters of the LCD */ -#define LCD_STR_BEDTEMP "\x00" // this will have 'unexpected' results when used in a string! -#define LCD_STR_DEGREE "\x01" -#define LCD_STR_THERMOMETER "\x02" -#define LCD_STR_UPLEVEL "\x03" -#define LCD_STR_REFRESH "\x04" -#define LCD_STR_FOLDER "\x05" -#define LCD_STR_FEEDRATE "\x06" -#define LCD_STR_CLOCK "\x07" -//#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set. Only available on DISPLAY_CHARSET_HD44780_JAPAN - at this place!*/ -#define LCD_STR_ARROW_RIGHT ">" /* from the default character set */ - static void lcd_set_custom_characters( #ifdef LCD_PROGRESS_BAR bool progress_bar_set=true From 14d4419e161b26cb70bd6d28101ca554f0f099fd Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 8 Apr 2015 23:59:01 +0200 Subject: [PATCH 006/118] Replaced SERIAL_PROTOCOLPGM(MSG_BED) with SERIAL_PROTOCOLPGM("Bed") Resolved some warnings in Marlin_main.cpp regarding compares of signed and unsigned integers by replacing 'int' or 'uint16_t' with 'uint8_t'. --- Marlin/Marlin_main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8bf0909886..b48cfd849e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2514,7 +2514,7 @@ inline void gcode_G28() { feedrate = homing_feedrate[Z_AXIS]; run_z_probe(); - SERIAL_PROTOCOLPGM(MSG_BED); + SERIAL_PROTOCOLPGM("Bed"); SERIAL_PROTOCOLPGM(" X: "); SERIAL_PROTOCOL(current_position[X_AXIS] + 0.0001); SERIAL_PROTOCOLPGM(" Y: "); @@ -2852,8 +2852,8 @@ inline void gcode_M42() { inline void gcode_M48() { double sum = 0.0, mean = 0.0, sigma = 0.0, sample_set[50]; - int verbose_level = 1, n_samples = 10, n_legs = 0; - + uint8_t verbose_level = 1, n_samples = 10, n_legs = 0; + if (code_seen('V') || code_seen('v')) { verbose_level = code_value_short(); if (verbose_level < 0 || verbose_level > 4 ) { @@ -2960,7 +2960,7 @@ inline void gcode_M42() { if (deploy_probe_for_each_reading) stow_z_probe(); - for (uint16_t n=0; n < n_samples; n++) { + for (uint8_t n=0; n < n_samples; n++) { do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location @@ -2975,7 +2975,7 @@ inline void gcode_M42() { //SERIAL_ECHOPAIR(" direction: ",dir); //SERIAL_EOL; - for (int l = 0; l < n_legs - 1; l++) { + for (uint8_t l = 0; l < n_legs - 1; l++) { ms = millis(); theta += RADIANS(dir * (ms % 20L)); radius += (ms % 10L) - 5L; @@ -3014,7 +3014,7 @@ inline void gcode_M42() { // Get the current mean for the data points we have so far // sum = 0.0; - for (int j = 0; j <= n; j++) sum += sample_set[j]; + for (uint8_t j = 0; j <= n; j++) sum += sample_set[j]; mean = sum / (n + 1); // @@ -3022,7 +3022,7 @@ inline void gcode_M42() { // data points we have so far // sum = 0.0; - for (int j = 0; j <= n; j++) { + for (uint8_t j = 0; j <= n; j++) { float ss = sample_set[j] - mean; sum += ss * ss; } From 540dbb35e2c51767120c2765ae821a7e30e207c9 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Thu, 9 Apr 2015 01:16:06 +0200 Subject: [PATCH 007/118] And an other MSG_BED in Marlin_main.cpp --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b48cfd849e..b2e105809a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1365,7 +1365,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, #endif if (verbose_level > 2) { - SERIAL_PROTOCOLPGM(MSG_BED); + SERIAL_PROTOCOLPGM("Bed"); SERIAL_PROTOCOLPGM(" X: "); SERIAL_PROTOCOL_F(x, 3); SERIAL_PROTOCOLPGM(" Y: "); From 585eee6549a879fefee4cc1adb4cc200536f57bd Mon Sep 17 00:00:00 2001 From: Natealus Date: Wed, 8 Apr 2015 18:57:30 -0600 Subject: [PATCH 008/118] Z Probe inverting not present in example configs, causes error The line const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop is in the main configuration.h but wasn't present in the example configuration.h's. Causes a compiling error with Z Probe enabled. Just added it to all the configs. :) --- Marlin/example_configurations/Felix/Configuration.h | 3 ++- Marlin/example_configurations/Felix/Configuration_DUAL.h | 3 ++- Marlin/example_configurations/Hephestos/Configuration.h | 1 + Marlin/example_configurations/K8200/Configuration.h | 1 + Marlin/example_configurations/SCARA/Configuration.h | 1 + Marlin/example_configurations/WITBOX/Configuration.h | 1 + Marlin/example_configurations/delta/generic/Configuration.h | 3 ++- .../example_configurations/delta/kossel_mini/Configuration.h | 3 ++- Marlin/example_configurations/makibox/Configuration.h | 1 + Marlin/example_configurations/tvrrug/Round2/Configuration.h | 1 + 10 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index c30547a52b..1efcad88c7 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" @@ -305,6 +305,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. #define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index fe544ad162..dd5c371c08 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" @@ -305,6 +305,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. #define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 812bfe1fc9..2a331c9ece 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -328,6 +328,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index b3346bdda8..5adab57f5b 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -333,6 +333,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. #define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index ca9a756eb2..c0032d4bbc 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -357,6 +357,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 9ec5f506dc..757c1628ef 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -327,6 +327,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 544492a0b7..f1760f59e7 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" @@ -355,6 +355,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS #define DISABLE_MIN_ENDSTOPS // Deltas only use min endstops for probing diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 9b292ebdec..990c4e7628 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" @@ -355,6 +355,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS // Deltas only use min endstops for probing diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 5596faef3d..1eea3186cf 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -325,6 +325,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 618243ff36..8a3c3a8546 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -327,6 +327,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = true; // set to true to invert the logic of const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. +const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS From 1269c445ab1473cfb33db4b6fa1b6b978f22cec5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 01:40:48 -0700 Subject: [PATCH 009/118] Catch dangerous extrude before trying several --- Marlin/Marlin.h | 4 ++ Marlin/Marlin_main.cpp | 84 ++++++++++++++++++++++++------------------ Marlin/planner.cpp | 9 +---- Marlin/planner.h | 6 +-- 4 files changed, 54 insertions(+), 49 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 9cec9dd37a..40128de997 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -273,6 +273,10 @@ extern bool axis_known_position[3]; extern float zprobe_zoffset; #endif +#ifdef PREVENT_DANGEROUS_EXTRUDE + extern float extrude_min_temp; +#endif + extern int fanSpeed; #ifdef BARICUDA diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8bf0909886..27aa580435 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -380,12 +380,13 @@ bool target_direction; void get_arc_coordinates(); bool setTargetedHotend(int code); -void serial_echopair_P(const char *s_P, float v) - { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_P(const char *s_P, double v) - { serialprintPGM(s_P); SERIAL_ECHO(v); } -void serial_echopair_P(const char *s_P, unsigned long v) - { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_P(const char *s_P, float v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_P(const char *s_P, double v) { serialprintPGM(s_P); SERIAL_ECHO(v); } +void serial_echopair_P(const char *s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); } + +#ifdef PREVENT_DANGEROUS_EXTRUDE + float extrude_min_temp = EXTRUDE_MINTEMP; +#endif #ifdef SDSUPPORT #include "SdFatUtil.h" @@ -1009,8 +1010,11 @@ inline void line_to_current_position() { inline void line_to_z(float zPosition) { plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder); } +inline void line_to_destination(float mm_m) { + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], mm_m/60, active_extruder); +} inline void line_to_destination() { - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + line_to_destination(feedrate); } inline void sync_plan_position() { plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -4099,6 +4103,8 @@ inline void gcode_M226() { #ifdef PREVENT_DANGEROUS_EXTRUDE + void set_extrude_min_temp(float temp) { extrude_min_temp = temp; } + /** * M302: Allow cold extrudes, or set the minimum extrude S. */ @@ -5444,15 +5450,31 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_ void prepare_move() { clamp_to_software_endstops(destination); refresh_cmd_timeout(); - + + #ifdef PREVENT_DANGEROUS_EXTRUDE + float de = destination[E_AXIS] - current_position[E_AXIS]; + if (de) { + if (degHotend(active_extruder) < extrude_min_temp) { + current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); + } + #ifdef PREVENT_LENGTHY_EXTRUDE + if (labs(de) > EXTRUDE_MAXLENGTH) { + current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); + } + #endif + } + #endif + #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]) + - sq(difference[Y_AXIS]) + - sq(difference[Z_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; @@ -5464,9 +5486,7 @@ void prepare_move() { 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; - } + for (int8_t i = 0; i < NUM_AXIS; i++) destination[i] = current_position[i] + difference[i] * fraction; calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); @@ -5476,9 +5496,7 @@ void prepare_move() { //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], - destination[E_AXIS], feedrate*feedmultiply/60/100.0, - active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA @@ -5488,9 +5506,7 @@ void prepare_move() { 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]) + - sq(difference[Y_AXIS]) + - sq(difference[Z_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; @@ -5507,9 +5523,7 @@ void prepare_move() { #ifdef ENABLE_AUTO_BED_LEVELING adjust_delta(destination); #endif - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], - destination[E_AXIS], feedrate*feedmultiply/60/100.0, - active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // DELTA @@ -5519,8 +5533,8 @@ void prepare_move() { if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) { // move duplicate extruder into correct duplication position. plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS], - current_position[E_AXIS], max_feedrate[X_AXIS], 1); + plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, + current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[X_AXIS], 1); sync_plan_position(); st_synchronize(); extruder_duplication_enabled = true; @@ -5528,23 +5542,21 @@ void prepare_move() { } else if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE) { // handle unparking of head if (current_position[E_AXIS] == destination[E_AXIS]) { - // this is a travel move - skit it but keep track of current position (so that it can later - // be used as start of first non-travel move) + // This is a travel move (with no extrusion) + // Skip it, but keep track of the current position + // (so it can be used as the start of the next non-travel move) if (delayed_move_time != 0xFFFFFFFFUL) { set_current_to_destination(); - if (destination[Z_AXIS] > raised_parked_position[Z_AXIS]) - raised_parked_position[Z_AXIS] = destination[Z_AXIS]; + if (destination[Z_AXIS] > raised_parked_position[Z_AXIS]) raised_parked_position[Z_AXIS] = destination[Z_AXIS]; delayed_move_time = millis(); return; } } delayed_move_time = 0; // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower - plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder); - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], - current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder); - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], - current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder); + plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], min(max_feedrate[X_AXIS], max_feedrate[Y_AXIS]), active_extruder); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder); active_extruder_parked = false; } } @@ -5552,7 +5564,7 @@ void prepare_move() { #if !defined(DELTA) && !defined(SCARA) // Do not use feedmultiply for E or Z only moves - if ( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) { + if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) { line_to_destination(); } else { @@ -5560,7 +5572,7 @@ void prepare_move() { mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder); return; #else - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder); + line_to_destination(feedrate * feedmultiply / 100.0); #endif // MESH_BED_LEVELING } #endif // !(DELTA || SCARA) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 76ec037887..77af203252 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -113,9 +113,6 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro //=========================================================================== //=============================private variables ============================ //=========================================================================== -#ifdef PREVENT_DANGEROUS_EXTRUDE - float extrude_min_temp = EXTRUDE_MINTEMP; -#endif #ifdef XY_FREQUENCY_LIMIT // Used for the frequency limit #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT) @@ -508,7 +505,7 @@ float junction_deviation = 0.1; #ifdef PREVENT_DANGEROUS_EXTRUDE if (de) { if (degHotend(active_extruder) < extrude_min_temp) { - position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part + position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part de = 0; // no difference SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); @@ -998,10 +995,6 @@ void plan_set_e_position(const float &e) { st_set_e_position(position[E_AXIS]); } -#ifdef PREVENT_DANGEROUS_EXTRUDE - void set_extrude_min_temp(float temp) { extrude_min_temp = temp; } -#endif - // Calculate the steps/s^2 acceleration rates, based on the mm/s^s void reset_acceleration_rates() { for (int i = 0; i < NUM_AXIS; i++) diff --git a/Marlin/planner.h b/Marlin/planner.h index 41471a2b0f..c617d6d481 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -161,10 +161,6 @@ FORCE_INLINE block_t *plan_get_current_block() { return NULL; } -#ifdef PREVENT_DANGEROUS_EXTRUDE - void set_extrude_min_temp(float temp); -#endif - void reset_acceleration_rates(); -#endif //PLANNER_H +#endif // PLANNER_H From a95544f92ac7ab15d66f12ce46616d54a7dad3b8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 02:04:06 -0700 Subject: [PATCH 010/118] Spell adjustment --- Marlin/ConfigurationStore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/ConfigurationStore.cpp b/Marlin/ConfigurationStore.cpp index 56de816848..0154691de0 100644 --- a/Marlin/ConfigurationStore.cpp +++ b/Marlin/ConfigurationStore.cpp @@ -669,7 +669,7 @@ void Config_PrintSettings(bool forReplay) { #ifdef DELTA SERIAL_ECHO_START; if (!forReplay) { - SERIAL_ECHOLNPGM("Endstop adjustement (mm):"); + SERIAL_ECHOLNPGM("Endstop adjustment (mm):"); SERIAL_ECHO_START; } SERIAL_ECHOPAIR(" M666 X", endstop_adj[X_AXIS] ); @@ -686,7 +686,7 @@ void Config_PrintSettings(bool forReplay) { #elif defined(Z_DUAL_ENDSTOPS) SERIAL_ECHO_START; if (!forReplay) { - SERIAL_ECHOLNPGM("Z2 Endstop adjustement (mm):"); + SERIAL_ECHOLNPGM("Z2 Endstop adjustment (mm):"); SERIAL_ECHO_START; } SERIAL_ECHOPAIR(" M666 Z", z_endstop_adj ); From df50523605e73c7d503b4e042b7eede96009112e Mon Sep 17 00:00:00 2001 From: AnHardt Date: Thu, 9 Apr 2015 12:26:45 +0200 Subject: [PATCH 011/118] Made encoderPosition and quick_feedback dependant on NEWPANEL where the hardware is available. Fix for #1873 --- Marlin/ultralcd.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 9e90d564b3..42d150adf4 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -251,9 +251,10 @@ float raw_Ki, raw_Kd; static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool feedback=true) { if (currentMenu != menu) { currentMenu = menu; - encoderPosition = encoder; - if (feedback) lcd_quick_feedback(); - + #if defined(NEWPANEL) + encoderPosition = encoder; + if (feedback) lcd_quick_feedback(); + #endif // For LCD_PROGRESS_BAR re-initialize the custom characters #ifdef LCD_PROGRESS_BAR lcd_set_custom_characters(menu == lcd_status_screen); @@ -1259,7 +1260,9 @@ int lcd_strlen_P(const char *s) { } void lcd_update() { - static unsigned long timeoutToStatus = 0; + #ifdef ULTIPANEL + static unsigned long timeoutToStatus = 0; + #endif #ifdef LCD_HAS_SLOW_BUTTONS slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context From a488445cbe89f44bb895eba2cfc874acbf4f5f60 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 03:41:31 -0700 Subject: [PATCH 012/118] Fix spelling of "too" --- Marlin/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 7aeaa81a68..857976bc30 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -186,7 +186,7 @@ #define Y_PROBE_ERROR #endif #ifdef Y_PROBE_ERROR - #error The Y axis probing range is to small to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS + #error The Y axis probing range is too small to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS #endif #undef PROBE_SIZE_X From 9189cc66ab3c3913c50f76a56d37f1639d2cb41c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 04:32:14 -0700 Subject: [PATCH 013/118] Fix moves for DELTA for MANUAL_BED_LEVELING - Use `line_to_current` in place of `plan_buffer_line` --- Marlin/Marlin_main.cpp | 2 +- Marlin/ultralcd.cpp | 184 ++++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2c364614af..f4f77ef634 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2929,7 +2929,7 @@ inline void gcode_M42() { // use that as a starting point for each probe. // if (verbose_level > 2) - SERIAL_PROTOCOL("Positioning the probe...\n"); + SERIAL_PROTOCOLPGM("Positioning the probe...\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, ext_position, diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 9e90d564b3..4a41b6bf02 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -643,8 +643,8 @@ static void lcd_prepare_menu() { } #ifdef DELTA_CALIBRATION_MENU -static void lcd_delta_calibrate_menu() -{ + + static void lcd_delta_calibrate_menu() { START_MENU(); MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); @@ -653,11 +653,31 @@ static void lcd_delta_calibrate_menu() MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Z, PSTR("G0 F8000 X0 Y90 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0")); END_MENU(); -} + } + #endif // DELTA_CALIBRATION_MENU +inline void line_to_current() { + #ifdef DELTA + calculate_delta(current_position); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); + #else + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); + #endif +} + float move_menu_scale; -static void lcd_move_menu_axis(); +static void lcd_move_menu_axis() { + START_MENU(); + MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); + MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); + MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); + if (move_menu_scale < 10.0) { + MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); + MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); + } + END_MENU(); +} static void _lcd_move(const char *name, int axis, int min, int max) { if (encoderPosition != 0) { @@ -666,12 +686,7 @@ static void _lcd_move(const char *name, int axis, int min, int max) { if (min_software_endstops && current_position[axis] < min) current_position[axis] = min; if (max_software_endstops && current_position[axis] > max) current_position[axis] = max; encoderPosition = 0; - #ifdef DELTA - calculate_delta(current_position); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder); - #else - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder); - #endif + line_to_current(); lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis])); @@ -685,30 +700,13 @@ static void lcd_move_e() { if (encoderPosition != 0) { current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; encoderPosition = 0; - #ifdef DELTA - calculate_delta(current_position); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS]/60, active_extruder); - #else - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS]/60, active_extruder); - #endif + line_to_current(); lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS])); if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); } -static void lcd_move_menu_axis() { - START_MENU(); - MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); - MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); - MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); - if (move_menu_scale < 10.0) { - MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); - MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); - } - END_MENU(); -} - static void lcd_move_menu_10mm() { move_menu_scale = 10.0; lcd_move_menu_axis(); @@ -1793,76 +1791,78 @@ char *ftostr52(const float &x) { } #ifdef MANUAL_BED_LEVELING -static int _lcd_level_bed_position; -static void _lcd_level_bed() -{ - if (encoderPosition != 0) { - refresh_cmd_timeout(); - current_position[Z_AXIS] += float((int)encoderPosition) * MBL_Z_STEP; - if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS; - if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; - encoderPosition = 0; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[Z_AXIS]/60, active_extruder); - lcdDrawUpdate = 1; - } - if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS])); - static bool debounce_click = false; - if (LCD_CLICKED) { - if (!debounce_click) { - debounce_click = true; - int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; - int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; - if (iy&1) { // Zig zag - ix = (MESH_NUM_X_POINTS - 1) - ix; - } - mbl.set_z(ix, iy, current_position[Z_AXIS]); - _lcd_level_bed_position++; - if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) { - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); - mbl.active = 1; - enquecommands_P(PSTR("G28")); - lcd_return_to_status(); - } else { - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); - ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; - iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; + + static int _lcd_level_bed_position; + static void _lcd_level_bed() { + if (encoderPosition != 0) { + refresh_cmd_timeout(); + current_position[Z_AXIS] += float((int)encoderPosition) * MBL_Z_STEP; + if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS; + if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; + encoderPosition = 0; + line_to_current(); + lcdDrawUpdate = 1; + } + if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS])); + static bool debounce_click = false; + if (LCD_CLICKED) { + if (!debounce_click) { + debounce_click = true; + int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; + int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; if (iy&1) { // Zig zag ix = (MESH_NUM_X_POINTS - 1) - ix; } - current_position[X_AXIS] = mbl.get_x(ix); - current_position[Y_AXIS] = mbl.get_y(iy); - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); - lcdDrawUpdate = 1; + mbl.set_z(ix, iy, current_position[Z_AXIS]); + _lcd_level_bed_position++; + if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) { + current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; + line_to_current(); + mbl.active = 1; + enquecommands_P(PSTR("G28")); + lcd_return_to_status(); + } else { + current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; + line_to_current(); + ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; + iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; + if (iy&1) { // Zig zag + ix = (MESH_NUM_X_POINTS - 1) - ix; + } + current_position[X_AXIS] = mbl.get_x(ix); + current_position[Y_AXIS] = mbl.get_y(iy); + line_to_current(); + lcdDrawUpdate = 1; + } } + } else { + debounce_click = false; } - } else { - debounce_click = false; } -} -static void _lcd_level_bed_homing() -{ - if (axis_known_position[X_AXIS] && - axis_known_position[Y_AXIS] && - axis_known_position[Z_AXIS]) { - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - current_position[X_AXIS] = MESH_MIN_X; - current_position[Y_AXIS] = MESH_MIN_Y; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); - _lcd_level_bed_position = 0; - lcd_goto_menu(_lcd_level_bed); + + static void _lcd_level_bed_homing() { + if (axis_known_position[X_AXIS] && + axis_known_position[Y_AXIS] && + axis_known_position[Z_AXIS]) { + current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + current_position[X_AXIS] = MESH_MIN_X; + current_position[Y_AXIS] = MESH_MIN_Y; + line_to_current(); + _lcd_level_bed_position = 0; + lcd_goto_menu(_lcd_level_bed); + } } -} -static void lcd_level_bed() { - axis_known_position[X_AXIS] = false; - axis_known_position[Y_AXIS] = false; - axis_known_position[Z_AXIS] = false; - mbl.reset(); - enquecommands_P(PSTR("G28")); - lcd_goto_menu(_lcd_level_bed_homing); -} + + static void lcd_level_bed() { + axis_known_position[X_AXIS] = false; + axis_known_position[Y_AXIS] = false; + axis_known_position[Z_AXIS] = false; + mbl.reset(); + enquecommands_P(PSTR("G28")); + lcd_goto_menu(_lcd_level_bed_homing); + } + #endif // MANUAL_BED_LEVELING -#endif //ULTRA_LCD +#endif // ULTRA_LCD From fb4cefc91da021e57ad7058a1674bd050af2e179 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 19:33:16 -0700 Subject: [PATCH 014/118] Define lcd_move_[xyz] ahead of lcd_move_menu_axis --- Marlin/ultralcd.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 4a41b6bf02..0d65ba2df5 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -666,19 +666,6 @@ inline void line_to_current() { #endif } -float move_menu_scale; -static void lcd_move_menu_axis() { - START_MENU(); - MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); - MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); - MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); - if (move_menu_scale < 10.0) { - MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); - MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); - } - END_MENU(); -} - static void _lcd_move(const char *name, int axis, int min, int max) { if (encoderPosition != 0) { refresh_cmd_timeout(); @@ -696,6 +683,19 @@ static void lcd_move_x() { _lcd_move(PSTR("X"), X_AXIS, X_MIN_POS, X_MAX_POS); } static void lcd_move_y() { _lcd_move(PSTR("Y"), Y_AXIS, Y_MIN_POS, Y_MAX_POS); } static void lcd_move_z() { _lcd_move(PSTR("Z"), Z_AXIS, Z_MIN_POS, Z_MAX_POS); } +float move_menu_scale; +static void lcd_move_menu_axis() { + START_MENU(); + MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); + MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); + MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); + if (move_menu_scale < 10.0) { + MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); + MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); + } + END_MENU(); +} + static void lcd_move_e() { if (encoderPosition != 0) { current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; From b328c6e6b6934d178d5927763067d369ebdb5411 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 20:05:10 -0700 Subject: [PATCH 015/118] Shuffling declarations. --- Marlin/ultralcd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 0d65ba2df5..e3b7d2ef8f 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -666,6 +666,9 @@ inline void line_to_current() { #endif } +float move_menu_scale; +static void lcd_move_menu_axis(); + static void _lcd_move(const char *name, int axis, int min, int max) { if (encoderPosition != 0) { refresh_cmd_timeout(); @@ -683,7 +686,6 @@ static void lcd_move_x() { _lcd_move(PSTR("X"), X_AXIS, X_MIN_POS, X_MAX_POS); } static void lcd_move_y() { _lcd_move(PSTR("Y"), Y_AXIS, Y_MIN_POS, Y_MAX_POS); } static void lcd_move_z() { _lcd_move(PSTR("Z"), Z_AXIS, Z_MIN_POS, Z_MAX_POS); } -float move_menu_scale; static void lcd_move_menu_axis() { START_MENU(); MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); From 5914d9d7def75080f97542b7e5fef8e4be05c4ce Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 20:21:30 -0700 Subject: [PATCH 016/118] Shuffling declarations.. --- Marlin/ultralcd.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index e3b7d2ef8f..62440a3cdf 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -685,6 +685,16 @@ static void _lcd_move(const char *name, int axis, int min, int max) { static void lcd_move_x() { _lcd_move(PSTR("X"), X_AXIS, X_MIN_POS, X_MAX_POS); } static void lcd_move_y() { _lcd_move(PSTR("Y"), Y_AXIS, Y_MIN_POS, Y_MAX_POS); } static void lcd_move_z() { _lcd_move(PSTR("Z"), Z_AXIS, Z_MIN_POS, Z_MAX_POS); } +static void lcd_move_e() { + if (encoderPosition != 0) { + current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; + encoderPosition = 0; + line_to_current(); + lcdDrawUpdate = 1; + } + if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS])); + if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); +} static void lcd_move_menu_axis() { START_MENU(); @@ -698,17 +708,6 @@ static void lcd_move_menu_axis() { END_MENU(); } -static void lcd_move_e() { - if (encoderPosition != 0) { - current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; - encoderPosition = 0; - line_to_current(); - lcdDrawUpdate = 1; - } - if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS])); - if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); -} - static void lcd_move_menu_10mm() { move_menu_scale = 10.0; lcd_move_menu_axis(); From 8b16ebe705e510dbad7534e55c54b1a7e8d49f22 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 9 Apr 2015 22:40:37 -0700 Subject: [PATCH 017/118] Break out prevent_dangerous_extrude feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - It’s inline here, but could be a macro and duplicated for `planner.cpp` --- Marlin/Marlin_main.cpp | 97 +++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index f4f77ef634..10958e3fa4 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -547,9 +547,7 @@ void servo_init() #endif } - -void setup() -{ +void setup() { setup_killpin(); setup_filrunoutpin(); setup_powerhold(); @@ -559,15 +557,16 @@ void setup() // Check startup - does nothing if bootloader sets MCUSR to 0 byte mcu = MCUSR; - if(mcu & 1) SERIAL_ECHOLNPGM(MSG_POWERUP); - if(mcu & 2) SERIAL_ECHOLNPGM(MSG_EXTERNAL_RESET); - if(mcu & 4) SERIAL_ECHOLNPGM(MSG_BROWNOUT_RESET); - if(mcu & 8) SERIAL_ECHOLNPGM(MSG_WATCHDOG_RESET); - if(mcu & 32) SERIAL_ECHOLNPGM(MSG_SOFTWARE_RESET); - MCUSR=0; + if (mcu & 1) SERIAL_ECHOLNPGM(MSG_POWERUP); + if (mcu & 2) SERIAL_ECHOLNPGM(MSG_EXTERNAL_RESET); + if (mcu & 4) SERIAL_ECHOLNPGM(MSG_BROWNOUT_RESET); + if (mcu & 8) SERIAL_ECHOLNPGM(MSG_WATCHDOG_RESET); + if (mcu & 32) SERIAL_ECHOLNPGM(MSG_SOFTWARE_RESET); + MCUSR = 0; SERIAL_ECHOPGM(MSG_MARLIN); - SERIAL_ECHOLNPGM(STRING_VERSION); + SERIAL_ECHOLNPGM(" " STRING_VERSION); + #ifdef STRING_VERSION_CONFIG_H #ifdef STRING_CONFIG_H_AUTHOR SERIAL_ECHO_START; @@ -579,17 +578,16 @@ void setup() SERIAL_ECHOLNPGM(__DATE__); #endif // STRING_CONFIG_H_AUTHOR #endif // STRING_VERSION_CONFIG_H + SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_FREE_MEMORY); SERIAL_ECHO(freeMemory()); SERIAL_ECHOPGM(MSG_PLANNER_BUFFER_BYTES); SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); + #ifdef SDSUPPORT - for(int8_t i = 0; i < BUFSIZE; i++) - { - fromsd[i] = false; - } - #endif //!SDSUPPORT + for (int8_t i = 0; i < BUFSIZE; i++) fromsd[i] = false; + #endif // !SDSUPPORT // loads data from EEPROM if available else uses defaults (and resets step acceleration rate) Config_RetrieveSettings(); @@ -600,7 +598,6 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -612,20 +609,23 @@ void setup() #ifdef DIGIPOT_I2C digipot_i2c_init(); #endif -#ifdef Z_PROBE_SLED - pinMode(SERVO0_PIN, OUTPUT); - digitalWrite(SERVO0_PIN, LOW); // turn it off -#endif // Z_PROBE_SLED + + #ifdef Z_PROBE_SLED + pinMode(SERVO0_PIN, OUTPUT); + digitalWrite(SERVO0_PIN, LOW); // turn it off + #endif // Z_PROBE_SLED + setup_homepin(); -#ifdef STAT_LED_RED - pinMode(STAT_LED_RED, OUTPUT); - digitalWrite(STAT_LED_RED, LOW); // turn it off -#endif -#ifdef STAT_LED_BLUE - pinMode(STAT_LED_BLUE, OUTPUT); - digitalWrite(STAT_LED_BLUE, LOW); // turn it off -#endif + #ifdef STAT_LED_RED + pinMode(STAT_LED_RED, OUTPUT); + digitalWrite(STAT_LED_RED, LOW); // turn it off + #endif + + #ifdef STAT_LED_BLUE + pinMode(STAT_LED_BLUE, OUTPUT); + digitalWrite(STAT_LED_BLUE, LOW); // turn it off + #endif } @@ -5447,26 +5447,37 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_ } #endif // MESH_BED_LEVELING +#ifdef PREVENT_DANGEROUS_EXTRUDE + + inline float prevent_dangerous_extrude(float &curr_e, float &dest_e) { + float de = dest_e - curr_e; + if (de) { + if (degHotend(active_extruder) < extrude_min_temp) { + curr_e = dest_e; // Behave as if the move really took place, but ignore E part + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); + return 0; + } + #ifdef PREVENT_LENGTHY_EXTRUDE + if (labs(de) > EXTRUDE_MAXLENGTH) { + curr_e = dest_e; // Behave as if the move really took place, but ignore E part + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); + return 0; + } + #endif + } + return de; + } + +#endif // PREVENT_DANGEROUS_EXTRUDE + void prepare_move() { clamp_to_software_endstops(destination); refresh_cmd_timeout(); #ifdef PREVENT_DANGEROUS_EXTRUDE - float de = destination[E_AXIS] - current_position[E_AXIS]; - if (de) { - if (degHotend(active_extruder) < extrude_min_temp) { - current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); - } - #ifdef PREVENT_LENGTHY_EXTRUDE - if (labs(de) > EXTRUDE_MAXLENGTH) { - current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); - } - #endif - } + (void)prevent_dangerous_extrude(current_position[E_AXIS], destination[E_AXIS]); #endif #ifdef SCARA //for now same as delta-code From 907e8e98e5d547ddcb67b8447c857394eac4b10f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 14:55:21 -0700 Subject: [PATCH 018/118] Add GCodes from Marlin 1.0.3 dev, format as pre --- Documentation/GCodes.md | 227 ++++++++++++++++++++++------------------ 1 file changed, 128 insertions(+), 99 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index 57b95cdeea..94756f8d9b 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -2,105 +2,134 @@ ## G Codes -* G0 -> G1 -* G1 - Coordinated Movement X Y Z E -* G2 - CW ARC -* G3 - CCW ARC -* G4 - Dwell S[seconds] or P[milliseconds] -* G10 - retract filament according to settings of M207 -* G11 - retract recover filament according to settings of M208 -* G28 - Home all Axis -* G29 - Detailed Z-Probe, probes the bed at 3 points. You must be at the home position for this to work correctly. -* G30 - Single Z Probe, probes bed at current XY location. -* G31 - Dock Z Probe sled (if enabled) -* G32 - Undock Z Probe sled (if enabled) -* G90 - Use Absolute Coordinates -* G91 - Use Relative Coordinates -* G92 - Set current position to cordinates given - +``` +G0 -> G1 +G1 - Coordinated Movement X Y Z E +G2 - CW ARC +G3 - CCW ARC +G4 - Dwell S[seconds] or P[milliseconds] +G10 - retract filament according to settings of M207 +G11 - retract recover filament according to settings of M208 +G28 - Home all Axis +G29 - Detailed Z-Probe, probes the bed at 3 points. You must be at the home position for this to work correctly. +G30 - Single Z Probe, probes bed at current XY location. +G31 - Dock Z Probe sled (if enabled) +G32 - Undock Z Probe sled (if enabled) +G90 - Use Absolute Coordinates +G91 - Use Relative Coordinates +G92 - Set current position to cordinates given +``` ## M Codes -* M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) -* M1 - Same as M0 -* M17 - Enable/Power all stepper motors -* M18 - Disable all stepper motors; same as M84 -* M20 - List SD card -* M21 - Init SD card -* M22 - Release SD card -* M23 - Select SD file (M23 filename.g) -* M24 - Start/resume SD print -* M25 - Pause SD print -* M26 - Set SD position in bytes (M26 S12345) -* M27 - Report SD print status -* M28 - Start SD write (M28 filename.g) -* M29 - Stop SD write -* M30 - Delete file from SD (M30 filename.g) -* M31 - Output time since last M109 or SD card start to serial -* M32 - Select file and start SD print (Can be used when printing from SD card) -* M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. -* M80 - Turn on Power Supply -* M81 - Turn off Power Supply -* M82 - Set E codes absolute (default) -* M83 - Set E codes relative while in Absolute Coordinates (G90) mode -* M84 - Disable steppers until next move, or use S[seconds] to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. -* M85 - Set inactivity shutdown timer with parameter S[seconds]. To disable set zero (default) -* M92 - Set axis_steps_per_unit - same syntax as G92 -* M104 - Set extruder target temp -* M105 - Read current temp -* M106 - Fan on -* M107 - Fan off -* M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating -* Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling -* M112 - Emergency stop -* M114 - Output current position to serial port -* M115 - Capabilities string -* M117 - display message -* M119 - Output Endstop status to serial port -* M126 - Solenoid Air Valve Open (BariCUDA support by jmil) -* M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) -* M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) -* M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) -* M140 - Set bed target temp -* M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating -* Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling -* M200 - D[millimeters]- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). -* M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) -* M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! -* M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec -* M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 -* M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk -* M206 - set additional homing offset -* M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting -* M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/min] -* 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. -* M218 - set hotend offset (in mm): T[extruder_number] X[offset_on_X] Y[offset_on_Y] -* M220 - S[factor in percent] - set speed factor override percentage -* M221 - S[factor in percent] - set extrude factor override percentage -* M240 - Trigger a camera to take a photograph -* M280 - Position an RC Servo P[index] S[angle/microseconds], ommit S to report back current angle -* M300 - Play beep sound S[frequency Hz] P[duration ms] -* M301 - Set PID parameters P I and D -* M302 - Allow cold extrudes -* M303 - PID relay autotune S[temperature] sets the target temperature. (default target temperature = 150C) -* M304 - Set bed PID parameters P I and D -* M350 - Set microstepping mode. -* M351 - Toggle MS1 MS2 pins directly. -* M400 - Finish all moves -* M401 - Lower z-probe if present -* M402 - Raise z-probe if present -* M404 - N[dia in mm] Enter the nominal filament width (3mm, 1.75mm) or will display nominal filament width without parameters -* M405 - Turn on Filament Sensor extrusion control. Optional D[delay in cm] to set delay in centimeters between sensor and extruder -* M406 - Turn off Filament Sensor extrusion control -* M407 - Displays measured filament diameter -* M500 - stores paramters in EEPROM -* M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). -* M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. -* M503 - print the current settings (from memory not from EEPROM) -* M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) -* M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] -* M907 - Set digital trimpot motor current using axis codes. -* M908 - Control digital trimpot directly. -* M928 - Start SD logging (M928 filename.g) - ended by M29 -* M999 - Restart after being stopped by error +``` +M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) +M1 - Same as M0 +M17 - Enable/Power all stepper motors +M18 - Disable all stepper motors; same as M84 +M20 - List SD card +M21 - Init SD card +M22 - Release SD card +M23 - Select SD file (M23 filename.g) +M24 - Start/resume SD print +M25 - Pause SD print +M26 - Set SD position in bytes (M26 S12345) +M27 - Report SD print status +M28 - Start SD write (M28 filename.g) +M29 - Stop SD write +M30 - Delete file from SD (M30 filename.g) +M31 - Output time since last M109 or SD card start to serial +M32 - Select file and start SD print (Can be used _while_ printing from SD card files): + syntax "M32 /path/filename#", or "M32 S !filename#" + Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). + The '#' is necessary when calling from within sd files, as it stops buffer prereading +M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. +M48 - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] +M80 - Turn on Power Supply +M81 - Turn off Power Supply +M82 - Set E codes absolute (default) +M83 - Set E codes relative while in Absolute Coordinates (G90) mode +M84 - Disable steppers until next move, + or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. +M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) +M92 - Set axis_steps_per_unit - same syntax as G92 +M104 - Set extruder target temp +M105 - Read current temp +M106 - Fan on +M107 - Fan off +M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating + Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling + IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F +M112 - Emergency stop +M114 - Output current position to serial port +M115 - Capabilities string +M117 - display message +M119 - Output Endstop status to serial port +M120 - Enable endstop detection +M121 - Disable endstop detection +M126 - Solenoid Air Valve Open (BariCUDA support by jmil) +M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) +M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) +M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) +M140 - Set bed target temp +M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. +M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating + Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling +M200 D- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). +M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) +M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! +M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec +M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 +M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk +M206 - Set additional homing offset +M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting +M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] +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. +M218 - Set hotend offset (in mm): T X Y +M220 S- set speed factor override percentage +M221 S- set extrude factor override percentage +M226 P S- Wait until the specified pin reaches the state required +M240 - Trigger a camera to take a photograph +M250 - Set LCD contrast C (value 0..63) +M280 - Set servo position absolute. P: servo index, S: angle or microseconds +M300 - Play beep sound S P +M301 - Set PID parameters P I and D +M302 - Allow cold extrudes, or set the minimum extrude S. +M303 - PID relay autotune S sets the target temperature. (default target temperature = 150C) +M304 - Set bed PID parameters P I and D +M380 - Activate solenoid on active extruder +M381 - Disable all solenoids +M400 - Finish all moves +M401 - Lower z-probe if present +M402 - Raise z-probe if present +M404 - N Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters +M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +M406 - Turn off Filament Sensor extrusion control +M407 - Display measured filament diameter +M500 - Store parameters in EEPROM +M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). +M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. +M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. +M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) +M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] +M665 - Set delta configurations +M666 - Set delta endstop adjustment +M605 - Set dual x-carriage movement mode: S [ X R ] +M907 - Set digital trimpot motor current using axis codes. +M908 - Control digital trimpot directly. +M350 - Set microstepping mode. +M351 - Toggle MS1 MS2 pins directly. + +M928 - Start SD logging (M928 filename.g) - ended by M29 +M999 - Restart after being stopped by error +``` +## SCARA-specific M-Codes - May change to suit future G-code standards +``` +M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) +M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) +M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) +M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) +M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) +M365 - SCARA calibration: Scaling factor, X, Y, Z axis +``` # Comments @@ -122,4 +151,4 @@ If you need to use a literal `;` somewhere (for example within `M117`), you can M117 backslash: \\;and a comment -Please note that hosts should strip any comments before sending GCODE to the printer in order to save bandwidth. \ No newline at end of file +Please note that hosts should strip any comments before sending GCODE to the printer in order to save bandwidth. From 01654bdec1f37a36be00b44c149aca2862eca60b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 15:03:41 -0700 Subject: [PATCH 019/118] Cleanup formatting of some M codes --- Documentation/GCodes.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index 94756f8d9b..f7813830db 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -73,7 +73,7 @@ M140 - Set bed target temp M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling -M200 D- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). +M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).: D- M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec @@ -84,9 +84,9 @@ M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/h M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] 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. M218 - Set hotend offset (in mm): T X Y -M220 S- set speed factor override percentage -M221 S- set extrude factor override percentage -M226 P S- Wait until the specified pin reaches the state required +M220 - Set speed factor override percentage: S +M221 - Set extrude factor override percentage: S +M226 - Wait until the specified pin reaches the state required: P S M240 - Trigger a camera to take a photograph M250 - Set LCD contrast C (value 0..63) M280 - Set servo position absolute. P: servo index, S: angle or microseconds @@ -117,9 +117,6 @@ M907 - Set digital trimpot motor current using axis codes. M908 - Control digital trimpot directly. M350 - Set microstepping mode. M351 - Toggle MS1 MS2 pins directly. - -M928 - Start SD logging (M928 filename.g) - ended by M29 -M999 - Restart after being stopped by error ``` ## SCARA-specific M-Codes - May change to suit future G-code standards ``` From 3105ebc562040c8aecf8f510a455272bde97fc12 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 15:05:00 -0700 Subject: [PATCH 020/118] Restore M928, M999 --- Documentation/GCodes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index f7813830db..e7b21b7603 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -126,6 +126,8 @@ M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) M365 - SCARA calibration: Scaling factor, X, Y, Z axis +M928 - Start SD logging (M928 filename.g) - ended by M29 +M999 - Restart after being stopped by error ``` # Comments From a3b13eb5ac1ab97c8504279fe94749a9c511614e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 15:54:36 -0700 Subject: [PATCH 021/118] Organize M Codes by Category - In GCodes.md --- Documentation/GCodes.md | 156 +++++++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 56 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index e7b21b7603..81d7cc390d 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -8,10 +8,10 @@ G1 - Coordinated Movement X Y Z E G2 - CW ARC G3 - CCW ARC G4 - Dwell S[seconds] or P[milliseconds] -G10 - retract filament according to settings of M207 -G11 - retract recover filament according to settings of M208 +G10 - Retract filament according to settings of M207 +G11 - Retract recover filament according to settings of M208 G28 - Home all Axis -G29 - Detailed Z-Probe, probes the bed at 3 points. You must be at the home position for this to work correctly. +G29 - Detailed Z-Probe, probes the bed at 3 or more points. The printer must be homed with G28 before G29. G30 - Single Z Probe, probes bed at current XY location. G31 - Dock Z Probe sled (if enabled) G32 - Undock Z Probe sled (if enabled) @@ -19,12 +19,16 @@ G90 - Use Absolute Coordinates G91 - Use Relative Coordinates G92 - Set current position to cordinates given ``` -## M Codes +## Movement M Codes ``` -M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) +M0 - Wait for user, with optional prompt message (to press the LCD button, requires ULTRA_LCD) + M0 Click When Ready ; show "Click When Ready" until the button is pressed. M1 - Same as M0 -M17 - Enable/Power all stepper motors -M18 - Disable all stepper motors; same as M84 +M400 - Finish all moves +M999 - Restart after being stopped by error +``` +### SD Card M Codes +``` M20 - List SD card M21 - Init SD card M22 - Release SD card @@ -41,16 +45,24 @@ M32 - Select file and start SD print (Can be used _while_ printing from SD card syntax "M32 /path/filename#", or "M32 S !filename#" Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). The '#' is necessary when calling from within sd files, as it stops buffer prereading -M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. -M48 - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] +M540 - Enable/Disable "Stop SD Print on Endstop Hit" (req. ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) + M540 S<0|1> +M928 - Start SD logging (M928 filename.g) - ended by M29 +``` +### Hardware Control +``` +M42 - Change pin status via gcode: P S. If P is omitted the onboard LED pin will be used. + M42 P9 S1 ; set PIN 9 to 1. M80 - Turn on Power Supply M81 - Turn off Power Supply -M82 - Set E codes absolute (default) -M83 - Set E codes relative while in Absolute Coordinates (G90) mode M84 - Disable steppers until next move, or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) -M92 - Set axis_steps_per_unit - same syntax as G92 +M112 - Emergency stop. Requires hardware reset!! +M226 - Wait for a pin to be in some state: P S +``` +### Temperature M Codes +``` M104 - Set extruder target temp M105 - Read current temp M106 - Fan on @@ -58,67 +70,101 @@ M107 - Fan off M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F -M112 - Emergency stop -M114 - Output current position to serial port -M115 - Capabilities string -M117 - display message -M119 - Output Endstop status to serial port -M120 - Enable endstop detection -M121 - Disable endstop detection -M126 - Solenoid Air Valve Open (BariCUDA support by jmil) -M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) -M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) -M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) M140 - Set bed target temp -M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling -M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).: D- -M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) -M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! -M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec -M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 -M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk -M206 - Set additional homing offset -M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting -M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] -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. -M218 - Set hotend offset (in mm): T X Y -M220 - Set speed factor override percentage: S -M221 - Set extrude factor override percentage: S -M226 - Wait until the specified pin reaches the state required: P S -M240 - Trigger a camera to take a photograph -M250 - Set LCD contrast C (value 0..63) -M280 - Set servo position absolute. P: servo index, S: angle or microseconds -M300 - Play beep sound S P M301 - Set PID parameters P I and D M302 - Allow cold extrudes, or set the minimum extrude S. M303 - PID relay autotune S sets the target temperature. (default target temperature = 150C) M304 - Set bed PID parameters P I and D +``` +### Message M Codes +``` +M114 - Output current position to serial port +M115 - Capabilities string +M117 - Display message text on the LCD +M119 - Output Endstop status to serial port +``` +### Endstops M Codes +``` +M120 - Enable endstop detection +M121 - Disable endstop detection +``` +### Special Features M Codes +``` +M126 - Solenoid Air Valve Open (BariCUDA support by jmil) +M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) +M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) +M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) +M150 - Set BlinkM Color: R U B via I2C. Range: 0-255 +M240 - Trigger a camera to take a photograph. (Add to your per-layer GCode.) +M250 - Set LCD contrast: C<0-63> +M280 - Set servo position absolute. P S +M300 - Play beep sound S P M380 - Activate solenoid on active extruder M381 - Disable all solenoids -M400 - Finish all moves -M401 - Lower z-probe if present -M402 - Raise z-probe if present -M404 - N Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +M600 - Pause for filament change X Y Z E L +``` +### Units and Measures M Codes +``` +M82 - Set E codes absolute (default) +M83 - Set E codes relative while in Absolute Coordinates (G90) mode +M92 - Set axis_steps_per_unit - same syntax as G92 +M200 - Set filament diameter and set E axis units to mm^3 (use S0 to set back to mm).: D +M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) +M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! +M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec +M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 +M205 - Advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X=maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk +M206 - Set additional homing offset +M218 - Set hotend offset (in mm): T X Y +M220 - Set speed factor override percentage: S +M221 - Set extrude factor override percentage: S +``` +### Firmware Retraction M Codes +``` +M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting +M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/s] +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 +``` +### Z Probe M Codes +``` +M48 - Measure Z_Probe repeatability: P X Y V E=engage L + As with G29, the E flag causes the probe to stow after each probe. +M401 - Lower Z-probe (if present) +M402 - Raise Z-probe (if present) +``` +### Filament Diameter M Codes +``` +M404 - Set (or display) Nominal Filament Diameter in mm: [N] (e.g., 3mm or 1.75mm) +M405 - Turn on Filament Sensor extrusion control: [D] to set distance (in cm) from sensor to extruder M406 - Turn off Filament Sensor extrusion control -M407 - Display measured filament diameter +M407 - Display measured Filament Diameter +``` +### EEPROM Settings M Codes +``` M500 - Store parameters in EEPROM M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. -M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) -M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] -M665 - Set delta configurations -M666 - Set delta endstop adjustment +``` +### Delta M Codes +``` +M665 - Set Delta configurations: L R S +M666 - Set Delta endstop adjustment: X Y Z M605 - Set dual x-carriage movement mode: S [ X R ] +``` +### Stepper Driver M Codes +``` +M17 - Enable/Power all stepper motors +M18 - Disable all stepper motors. (same as M84) M907 - Set digital trimpot motor current using axis codes. M908 - Control digital trimpot directly. M350 - Set microstepping mode. M351 - Toggle MS1 MS2 pins directly. ``` -## SCARA-specific M-Codes - May change to suit future G-code standards +### SCARA M-Codes +__May change to suit future G-code standards__ ``` M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) @@ -126,11 +172,9 @@ M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) M365 - SCARA calibration: Scaling factor, X, Y, Z axis -M928 - Start SD logging (M928 filename.g) - ended by M29 -M999 - Restart after being stopped by error ``` -# Comments +## Comments Comments start at a `;` (semicolon) and end with the end of the line: From 93eb63238f39085ffa74ea999f7c124cda3f483e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 15:57:54 -0700 Subject: [PATCH 022/118] Move G Codes into categories with M Codes --- Documentation/GCodes.md | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index 81d7cc390d..fbf38ed682 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -1,26 +1,13 @@ # Implemented G Codes -## G Codes - +## Movement G and M Codes ``` G0 -> G1 G1 - Coordinated Movement X Y Z E G2 - CW ARC G3 - CCW ARC G4 - Dwell S[seconds] or P[milliseconds] -G10 - Retract filament according to settings of M207 -G11 - Retract recover filament according to settings of M208 -G28 - Home all Axis -G29 - Detailed Z-Probe, probes the bed at 3 or more points. The printer must be homed with G28 before G29. -G30 - Single Z Probe, probes bed at current XY location. -G31 - Dock Z Probe sled (if enabled) -G32 - Undock Z Probe sled (if enabled) -G90 - Use Absolute Coordinates -G91 - Use Relative Coordinates G92 - Set current position to cordinates given -``` -## Movement M Codes -``` M0 - Wait for user, with optional prompt message (to press the LCD button, requires ULTRA_LCD) M0 Click When Ready ; show "Click When Ready" until the button is pressed. M1 - Same as M0 @@ -105,8 +92,10 @@ M380 - Activate solenoid on active extruder M381 - Disable all solenoids M600 - Pause for filament change X Y Z E L ``` -### Units and Measures M Codes +### Units and Measures G and M Codes ``` +G90 - Use Absolute Coordinates +G91 - Use Relative Coordinates M82 - Set E codes absolute (default) M83 - Set E codes relative while in Absolute Coordinates (G90) mode M92 - Set axis_steps_per_unit - same syntax as G92 @@ -121,14 +110,21 @@ M218 - Set hotend offset (in mm): T X Y M221 - Set extrude factor override percentage: S ``` -### Firmware Retraction M Codes +### Firmware Retraction G and M Codes ``` +G10 - Retract filament according to settings of M207 +G11 - Retract recover filament according to settings of M208 M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/s] 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 ``` -### Z Probe M Codes +### Z Probe G and M Codes ``` +G28 - Home all Axis +G29 - Detailed Z-Probe, probes the bed at 3 or more points. The printer must be homed with G28 before G29. +G30 - Single Z Probe, probes bed at current XY location. +G31 - Dock Z Probe sled (if enabled) +G32 - Undock Z Probe sled (if enabled) M48 - Measure Z_Probe repeatability: P X Y V E=engage L As with G29, the E flag causes the probe to stow after each probe. M401 - Lower Z-probe (if present) From fe912f44dce6118a31fda95d148380ae496d1bba Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 15:58:32 -0700 Subject: [PATCH 023/118] Smaller headings --- Documentation/GCodes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index fbf38ed682..ed16648c9b 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -1,6 +1,6 @@ -# Implemented G Codes +## Implemented G Codes -## Movement G and M Codes +### Movement G and M Codes ``` G0 -> G1 G1 - Coordinated Movement X Y Z E From 652d59cd807b62082ca0a07bd52fdd88c93a2b4b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 15:59:55 -0700 Subject: [PATCH 024/118] Spacing of g-codes in GCodes.md --- Documentation/GCodes.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index ed16648c9b..e2461d45d9 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -2,12 +2,12 @@ ### Movement G and M Codes ``` -G0 -> G1 -G1 - Coordinated Movement X Y Z E -G2 - CW ARC -G3 - CCW ARC -G4 - Dwell S[seconds] or P[milliseconds] -G92 - Set current position to cordinates given +G0 -> G1 +G1 - Coordinated Movement X Y Z E +G2 - CW ARC +G3 - CCW ARC +G4 - Dwell S[seconds] or P[milliseconds] +G92 - Set current position to cordinates given M0 - Wait for user, with optional prompt message (to press the LCD button, requires ULTRA_LCD) M0 Click When Ready ; show "Click When Ready" until the button is pressed. M1 - Same as M0 @@ -94,8 +94,8 @@ M600 - Pause for filament change X Y Z E L ``` ### Firmware Retraction G and M Codes ``` -G10 - Retract filament according to settings of M207 -G11 - Retract recover filament according to settings of M208 +G10 - Retract filament according to settings of M207 +G11 - Retract recover filament according to settings of M208 M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/s] 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 ``` ### Z Probe G and M Codes ``` -G28 - Home all Axis -G29 - Detailed Z-Probe, probes the bed at 3 or more points. The printer must be homed with G28 before G29. -G30 - Single Z Probe, probes bed at current XY location. -G31 - Dock Z Probe sled (if enabled) -G32 - Undock Z Probe sled (if enabled) +G28 - Home all Axis +G29 - Detailed Z-Probe, probes the bed at 3 or more points. The printer must be homed with G28 before G29. +G30 - Single Z Probe, probes bed at current XY location. +G31 - Dock Z Probe sled (if enabled) +G32 - Undock Z Probe sled (if enabled) M48 - Measure Z_Probe repeatability: P X Y V E=engage L As with G29, the E flag causes the probe to stow after each probe. M401 - Lower Z-probe (if present) From a327d876fe0a8a934ab045324a51d7aff6fb3bf2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 16:02:00 -0700 Subject: [PATCH 025/118] Document G92 arguments in GCodes.md --- Documentation/GCodes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index e2461d45d9..311e89f29a 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -7,8 +7,8 @@ G1 - Coordinated Movement X Y Z E G2 - CW ARC G3 - CCW ARC G4 - Dwell S[seconds] or P[milliseconds] -G92 - Set current position to cordinates given -M0 - Wait for user, with optional prompt message (to press the LCD button, requires ULTRA_LCD) +G92 - Set the "current position" to coordinates: X Y Z E +M0 - Wait for user, with optional prompt message (requires LCD controller) M0 Click When Ready ; show "Click When Ready" until the button is pressed. M1 - Same as M0 M400 - Finish all moves From 8f164f4c8318385d278fcf99cd09bb1f621c194c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 16:04:32 -0700 Subject: [PATCH 026/118] Clean up M85 in GCodes.md --- Documentation/GCodes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/GCodes.md b/Documentation/GCodes.md index 311e89f29a..c05be6198b 100644 --- a/Documentation/GCodes.md +++ b/Documentation/GCodes.md @@ -44,7 +44,7 @@ M80 - Turn on Power Supply M81 - Turn off Power Supply M84 - Disable steppers until next move, or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. -M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) +M85 - Set inactivity shutdown timer with parameter S. Disable with "M85" or "M85 S0". M112 - Emergency stop. Requires hardware reset!! M226 - Wait for a pin to be in some state: P S ``` From 5fe382949bdc91d48312547b73d7e79e7ec02b8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 16:16:13 -0700 Subject: [PATCH 027/118] Some G-Codes comment cleanup --- Marlin/Marlin_main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 10958e3fa4..37dc7af234 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -141,7 +141,7 @@ // M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. // M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating // Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling -// M200 D- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters). +// M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D- // M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) // M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! // M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec @@ -152,9 +152,9 @@ // M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] // 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. // M218 - Set hotend offset (in mm): T X Y -// M220 S- set speed factor override percentage -// M221 S- set extrude factor override percentage -// M226 P S- Wait until the specified pin reaches the state required +// M220 - Set speed factor override percentage: S +// M221 - Set extrude factor override percentage: S +// M226 - Wait until the specified pin reaches the state required: P S // M240 - Trigger a camera to take a photograph // M250 - Set LCD contrast C (value 0..63) // M280 - Set servo position absolute. P: servo index, S: angle or microseconds @@ -178,7 +178,7 @@ // M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] -// M665 - Set delta configurations +// M665 - Set delta configurations: L R S // M666 - Set delta endstop adjustment // M605 - Set dual x-carriage movement mode: S [ X R ] // M907 - Set digital trimpot motor current using axis codes. From ccbe2c4ea3a36195dce61caf097420cb64e2d653 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 10 Apr 2015 21:29:42 -0700 Subject: [PATCH 028/118] Apply CUSTOM_MACHINE_NAME to configurations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace “Mendel” with “RepRap” --- Marlin/Configuration.h | 5 +++-- Marlin/configurator/config/Configuration.h | 5 +++-- Marlin/configurator/config/language.h | 2 +- Marlin/configurator/index.html | 2 +- Marlin/example_configurations/Felix/Configuration.h | 5 +++-- Marlin/example_configurations/Felix/Configuration_DUAL.h | 5 +++-- Marlin/example_configurations/Hephestos/Configuration.h | 4 ++-- Marlin/example_configurations/K8200/Configuration.h | 5 +++-- Marlin/example_configurations/SCARA/Configuration.h | 5 +++-- Marlin/example_configurations/WITBOX/Configuration.h | 5 +++-- Marlin/example_configurations/delta/generic/Configuration.h | 5 +++-- .../example_configurations/delta/kossel_mini/Configuration.h | 5 +++-- Marlin/example_configurations/makibox/Configuration.h | 5 +++-- Marlin/example_configurations/tvrrug/Round2/Configuration.h | 5 +++-- Marlin/language.h | 2 +- 15 files changed, 38 insertions(+), 27 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index b99d4f426f..646dc60aef 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -68,8 +68,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_RAMPS_13_EFB #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 3fad145275..57f37756b3 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -68,8 +68,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_RAMPS_13_EFB #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index 3fe7afd2ed..5d1fd6c2fb 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -75,7 +75,7 @@ #endif #ifdef CUSTOM_MENDEL_NAME - #warning CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME + #error CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME #define CUSTOM_MACHINE_NAME CUSTOM_MENDEL_NAME #endif diff --git a/Marlin/configurator/index.html b/Marlin/configurator/index.html index 9fa40a105d..54353913d2 100644 --- a/Marlin/configurator/index.html +++ b/Marlin/configurator/index.html @@ -46,7 +46,7 @@ - + diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 1efcad88c7..269b8b794e 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_FELIX2 #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +#define CUSTOM_MACHINE_NAME "Felix" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index dd5c371c08..49b9f5b0b7 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_FELIX2 #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +#define CUSTOM_MACHINE_NAME "Felix Dual" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 2a331c9ece..e399ed8996 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -62,8 +62,8 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_HEPHESTOS #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 5adab57f5b..60e2db873c 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_K8200 #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index c0032d4bbc..65fccb063d 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -80,8 +80,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_RAMPS_13_EFB #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 757c1628ef..293aa77169 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_WITBOX #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index f1760f59e7..2562010ea7 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_RAMPS_13_EFB #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +#define CUSTOM_MACHINE_NAME "Deltabot" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 990c4e7628..1c6313e938 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_RAMPS_13_EFB #endif -// Define this to set a custom name for your generic Mendel, -#define CUSTOM_MENDEL_NAME "Mini Kossel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +#define CUSTOM_MACHINE_NAME "Mini Kossel" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 1eea3186cf..e355a41ea5 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_5DPRINT #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 8a3c3a8546..06cd2ae475 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -62,8 +62,9 @@ Here are some standard links for getting your machine calibrated: #define MOTHERBOARD BOARD_OMCA #endif -// Define this to set a custom name for your generic Mendel, -// #define CUSTOM_MENDEL_NAME "This Mendel" +// Optional custom name for your RepStrap or other custom machine +// Displayed in the LCD "Ready" message +// #define CUSTOM_MACHINE_NAME "This RepRap" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/language.h b/Marlin/language.h index 3fe7afd2ed..5d1fd6c2fb 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -75,7 +75,7 @@ #endif #ifdef CUSTOM_MENDEL_NAME - #warning CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME + #error CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME #define CUSTOM_MACHINE_NAME CUSTOM_MENDEL_NAME #endif From c6bb98abade7db4abe1e2dbf3d4ecc651b493039 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 11 Apr 2015 01:36:24 -0700 Subject: [PATCH 029/118] machine name for hephestos too --- Marlin/example_configurations/Hephestos/Configuration.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index e399ed8996..9dbbc82085 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -64,7 +64,8 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message - +// #define CUSTOM_MACHINE_NAME "This RepRap" + // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) // #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" From 388dd0cfa50b1bffab06cc2ef288e560828d7123 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 11 Apr 2015 04:45:04 -0700 Subject: [PATCH 030/118] Fix doubled lcd_quick_feedback - MENU_ITEM causes lcd_quick_feedback to be called, so only those calls to `lcd_goto_menu` outside of the `MENU_ITEM` macro need to set the `feedback` flag when calling `lcd_goto_menu`. --- Marlin/ultralcd.cpp | 88 +++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 67801a04dd..daf4a30b8b 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -248,10 +248,10 @@ menuFunc_t callbackFunc; // place-holders for Ki and Kd edits float raw_Ki, raw_Kd; -static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool feedback=true) { +static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint32_t encoder=0) { if (currentMenu != menu) { currentMenu = menu; - #if defined(NEWPANEL) + #ifdef NEWPANEL encoderPosition = encoder; if (feedback) lcd_quick_feedback(); #endif @@ -296,77 +296,69 @@ static void lcd_status_screen() { #endif #endif //LCD_PROGRESS_BAR - lcd_implementation_status_screen(); + lcd_implementation_status_screen(); -#ifdef ULTIPANEL + #ifdef ULTIPANEL bool current_click = LCD_CLICKED; if (ignore_click) { - if (wait_for_unclick) { - if (!current_click) { - ignore_click = wait_for_unclick = false; - } - else { - current_click = false; - } + if (wait_for_unclick) { + if (!current_click) { + ignore_click = wait_for_unclick = false; } - else if (current_click) { - lcd_quick_feedback(); - wait_for_unclick = true; - current_click = false; + else { + current_click = false; } + } + else if (current_click) { + lcd_quick_feedback(); + wait_for_unclick = true; + current_click = false; + } } - if (current_click) - { - lcd_goto_menu(lcd_main_menu); - lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. - #ifdef LCD_PROGRESS_BAR - currentMenu == lcd_status_screen - #endif - ); - #ifdef FILAMENT_LCD_DISPLAY - message_millis = millis(); // get status message to show up for a while + if (current_click) { + lcd_goto_menu(lcd_main_menu, true); + lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. + #ifdef LCD_PROGRESS_BAR + currentMenu == lcd_status_screen #endif + ); + #ifdef FILAMENT_LCD_DISPLAY + message_millis = millis(); // get status message to show up for a while + #endif } -#ifdef ULTIPANEL_FEEDMULTIPLY - // Dead zone at 100% feedrate - if ((feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100) || - (feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)) - { + #ifdef ULTIPANEL_FEEDMULTIPLY + // Dead zone at 100% feedrate + if ((feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100) || + (feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)) { encoderPosition = 0; feedmultiply = 100; - } - - if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) - { + } + if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) { feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE; encoderPosition = 0; - } - else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) - { + } + else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) { feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE; encoderPosition = 0; - } - else if (feedmultiply != 100) - { + } + else if (feedmultiply != 100) { feedmultiply += int(encoderPosition); encoderPosition = 0; - } -#endif //ULTIPANEL_FEEDMULTIPLY + } + #endif // ULTIPANEL_FEEDMULTIPLY - if (feedmultiply < 10) - feedmultiply = 10; - else if (feedmultiply > 999) - feedmultiply = 999; -#endif //ULTIPANEL + feedmultiply = constrain(feedmultiply, 10, 999); + + #endif //ULTIPANEL } #ifdef ULTIPANEL -static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen, 0, false); } +static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); } static void lcd_sdcard_pause() { card.pauseSDPrint(); } From 055b11814acc887ca7bfc9430c850695131c74ee Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 11 Apr 2015 04:56:08 -0700 Subject: [PATCH 031/118] Additional cleanup of ultralcd.cpp --- Marlin/ultralcd.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index daf4a30b8b..9fef9c12dd 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -304,12 +304,10 @@ static void lcd_status_screen() { if (ignore_click) { if (wait_for_unclick) { - if (!current_click) { + if (!current_click) ignore_click = wait_for_unclick = false; - } - else { + else current_click = false; - } } else if (current_click) { lcd_quick_feedback(); @@ -337,15 +335,17 @@ static void lcd_status_screen() { encoderPosition = 0; feedmultiply = 100; } - if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) { - feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE; - encoderPosition = 0; + if (feedmultiply == 100) { + if (int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) { + feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE; + encoderPosition = 0; + } + else if (int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) { + feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE; + encoderPosition = 0; + } } - else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) { - feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE; - encoderPosition = 0; - } - else if (feedmultiply != 100) { + else { feedmultiply += int(encoderPosition); encoderPosition = 0; } From ac2b23f5743a822e04296b2e7fbbb6d8fd855128 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 11 Apr 2015 20:06:48 -0700 Subject: [PATCH 032/118] Homing fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Prevent `Z_SAFE_HOMING` from homing Z twice in some cases - Allow `G28` with XYZ values of 0 to explicitly set the position - Don’t add `home_offset` when setting XYZ explicitly in `G28` - Add `code_has_value` function to check for the presence of a numeric value (could just test for space or nul to allow other types of values) --- Marlin/Marlin_main.cpp | 159 ++++++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 72 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 37dc7af234..ddf8036de7 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -850,6 +850,11 @@ void get_command() } +float code_has_value() { + char c = *(strchr_pointer + 1); + return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'; +} + float code_value() { float ret; char *e = strchr(strchr_pointer, 'E'); @@ -1814,21 +1819,24 @@ inline void gcode_G28() { home_all_axis = !(homeX || homeY || homeZ) || (homeX && homeY && homeZ); - #if Z_HOME_DIR > 0 // If homing away from BED do Z first + if (home_all_axis || homeZ) { - if (home_all_axis || homeZ) HOMEAXIS(Z); + #if Z_HOME_DIR > 0 // If homing away from BED do Z first - #elif !defined(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0 + HOMEAXIS(Z); - // Raise Z before homing any other axes - if (home_all_axis || homeZ) { - destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed + #elif !defined(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0 + + // Raise Z before homing any other axes + // (Does this need to be "negative home direction?" Why not just use Z_RAISE_BEFORE_HOMING?) + destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); feedrate = max_feedrate[Z_AXIS] * 60; line_to_destination(); st_synchronize(); - } - #endif + #endif + + } // home_all_axis || homeZ #ifdef QUICK_HOME @@ -1897,97 +1905,104 @@ inline void gcode_G28() { if (home_all_axis || homeY) HOMEAXIS(Y); // Set the X position, if included - // Adds the home_offset as well, which may be wrong - if (code_seen(axis_codes[X_AXIS])) { - float v = code_value(); - if (v) current_position[X_AXIS] = v - #ifndef SCARA - + home_offset[X_AXIS] - #endif - ; - } + if (code_seen(axis_codes[X_AXIS]) && code_has_value()) + current_position[X_AXIS] = code_value(); // Set the Y position, if included - // Adds the home_offset as well, which may be wrong - if (code_seen(axis_codes[Y_AXIS])) { - float v = code_value(); - if (v) current_position[Y_AXIS] = v - #ifndef SCARA - + home_offset[Y_AXIS] - #endif - ; - } + if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) + current_position[Y_AXIS] = code_value(); // Home Z last if homing towards the bed #if Z_HOME_DIR < 0 - #ifndef Z_SAFE_HOMING + if (home_all_axis || homeZ) { - if (home_all_axis || homeZ) HOMEAXIS(Z); + #ifdef Z_SAFE_HOMING - #else // Z_SAFE_HOMING + if (home_all_axis) { - 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); - destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed - feedrate = XY_TRAVEL_SPEED; - current_position[Z_AXIS] = 0; + current_position[Z_AXIS] = 0; + sync_plan_position(); - sync_plan_position(); - line_to_destination(); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; + // + // Set the probe (or just the nozzle) destination to the safe homing point + // + // NOTE: If current_position[X_AXIS] or current_position[Y_AXIS] were set above + // then this may not work as expected. + 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); + destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed + feedrate = XY_TRAVEL_SPEED; + // This could potentially move X, Y, Z all together + line_to_destination(); + st_synchronize(); - HOMEAXIS(Z); - } + // Set current X, Y is the Z_SAFE_HOMING_POINT minus PROBE_OFFSET_FROM_EXTRUDER + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; - // Let's see if X and Y are homed and probe is inside bed area. - if (homeZ) { + // Home the Z axis + HOMEAXIS(Z); + } - if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) { + else if (homeZ) { // Don't need to Home Z twice - float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS]; - if ( cpx >= X_MIN_POS - X_PROBE_OFFSET_FROM_EXTRUDER - && cpx <= X_MAX_POS - X_PROBE_OFFSET_FROM_EXTRUDER - && cpy >= Y_MIN_POS - Y_PROBE_OFFSET_FROM_EXTRUDER - && cpy <= Y_MAX_POS - Y_PROBE_OFFSET_FROM_EXTRUDER) { - current_position[Z_AXIS] = 0; - plan_set_position(cpx, cpy, 0, current_position[E_AXIS]); - destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS] * 60; // max_feedrate is in mm/s. line_to_destination is feedrate/60. - line_to_destination(); - st_synchronize(); - HOMEAXIS(Z); - } - else { + // Let's see if X and Y are homed + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) { + + // Make sure the probe is within the physical limits + // NOTE: This doesn't necessarily ensure the probe is also within the bed! + float cpx = current_position[X_AXIS], cpy = current_position[Y_AXIS]; + if ( cpx >= X_MIN_POS - X_PROBE_OFFSET_FROM_EXTRUDER + && cpx <= X_MAX_POS - X_PROBE_OFFSET_FROM_EXTRUDER + && cpy >= Y_MIN_POS - Y_PROBE_OFFSET_FROM_EXTRUDER + && cpy <= Y_MAX_POS - Y_PROBE_OFFSET_FROM_EXTRUDER) { + // Set the plan current position to X, Y, 0 + current_position[Z_AXIS] = 0; + plan_set_position(cpx, cpy, 0, current_position[E_AXIS]); // = sync_plan_position + + // Set Z destination away from bed and raise the axis + // NOTE: This should always just be Z_RAISE_BEFORE_HOMING unless...??? + destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); + feedrate = max_feedrate[Z_AXIS] * 60; // feedrate (mm/m) = max_feedrate (mm/s) + line_to_destination(); + st_synchronize(); + + // Home the Z axis + HOMEAXIS(Z); + } + else { LCD_MESSAGEPGM(MSG_ZPROBE_OUT); SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ZPROBE_OUT); + } + } + else { + LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); } - } - else { - LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); - } - } - #endif // Z_SAFE_HOMING + } // !home_all_axes && homeZ + + #else // !Z_SAFE_HOMING + + HOMEAXIS(Z); + + #endif // !Z_SAFE_HOMING + + } // home_all_axis || homeZ #endif // Z_HOME_DIR < 0 // Set the Z position, if included - // Adds the home_offset as well, which may be wrong - if (code_seen(axis_codes[Z_AXIS])) { - float v = code_value(); - if (v) current_position[Z_AXIS] = v + home_offset[Z_AXIS]; - } + if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) + current_position[Z_AXIS] = code_value(); #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) #endif + sync_plan_position(); #endif // else DELTA From a37c7ff16d239794e6e53cc30f79f98d4b3cab41 Mon Sep 17 00:00:00 2001 From: Edward Patel Date: Sun, 12 Apr 2015 16:56:17 +0200 Subject: [PATCH 033/118] Manual bed leveling menu fixes. lcdDrawUpdate = 2 helped a lot! --- Marlin/ultralcd.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 9fef9c12dd..bdd15776d1 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1797,7 +1797,7 @@ char *ftostr52(const float &x) { if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; encoderPosition = 0; line_to_current(); - lcdDrawUpdate = 1; + lcdDrawUpdate = 2; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS])); static bool debounce_click = false; @@ -1828,7 +1828,7 @@ char *ftostr52(const float &x) { current_position[X_AXIS] = mbl.get_x(ix); current_position[Y_AXIS] = mbl.get_y(iy); line_to_current(); - lcdDrawUpdate = 1; + lcdDrawUpdate = 2; } } } else { @@ -1837,6 +1837,7 @@ char *ftostr52(const float &x) { } static void _lcd_level_bed_homing() { + if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing"); if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) { @@ -1848,6 +1849,7 @@ char *ftostr52(const float &x) { _lcd_level_bed_position = 0; lcd_goto_menu(_lcd_level_bed); } + lcdDrawUpdate = 2; } static void lcd_level_bed() { @@ -1856,6 +1858,7 @@ char *ftostr52(const float &x) { axis_known_position[Z_AXIS] = false; mbl.reset(); enquecommands_P(PSTR("G28")); + lcdDrawUpdate = 2; lcd_goto_menu(_lcd_level_bed_homing); } From 8857b9e921d88e9d8c8bdef3bf9d59e8622b0070 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Apr 2015 16:57:00 -0700 Subject: [PATCH 034/118] Use the extruder argument in plan_buffer_line --- Marlin/planner.cpp | 8 ++++---- Marlin/stepper.cpp | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 77af203252..49c090881c 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -504,7 +504,7 @@ float junction_deviation = 0.1; #ifdef PREVENT_DANGEROUS_EXTRUDE if (de) { - if (degHotend(active_extruder) < extrude_min_temp) { + if (degHotend(extruder) < extrude_min_temp) { position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part de = 0; // no difference SERIAL_ECHO_START; @@ -541,8 +541,8 @@ float junction_deviation = 0.1; block->steps[Z_AXIS] = labs(dz); block->steps[E_AXIS] = labs(de); - block->steps[E_AXIS] *= volumetric_multiplier[active_extruder]; - block->steps[E_AXIS] *= extruder_multiply[active_extruder]; + block->steps[E_AXIS] *= volumetric_multiplier[extruder]; + block->steps[E_AXIS] *= extruder_multiply[extruder]; block->steps[E_AXIS] /= 100; block->step_event_count = max(block->steps[X_AXIS], max(block->steps[Y_AXIS], max(block->steps[Z_AXIS], block->steps[E_AXIS]))); @@ -676,7 +676,7 @@ float junction_deviation = 0.1; delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS]; #endif delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS]; - delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[active_extruder] * extruder_multiply[active_extruder] / 100.0; + delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiply[extruder] / 100.0; if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) { block->millimeters = fabs(delta_mm[E_AXIS]); diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index c53d7c0c92..1f28b3af95 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1072,10 +1072,7 @@ void st_init() { TCCR0A &= ~BIT(WGM01); TCCR0A &= ~BIT(WGM00); #endif - e_steps[0] = 0; - e_steps[1] = 0; - e_steps[2] = 0; - e_steps[3] = 0; + e_steps[0] = e_steps[1] = e_steps[2] = e_steps[3] = 0; TIMSK0 |= BIT(OCIE0A); #endif //ADVANCE From 74e4b42f7ece308f4f5ec1313d79b18bfaecc59c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Apr 2015 17:17:41 -0700 Subject: [PATCH 035/118] Default MACHINE_NAME to "3D Printer" --- Marlin/Configuration.h | 2 +- Marlin/configurator/config/Configuration.h | 2 +- Marlin/example_configurations/Hephestos/Configuration.h | 2 +- Marlin/example_configurations/K8200/Configuration.h | 2 +- Marlin/example_configurations/SCARA/Configuration.h | 2 +- Marlin/example_configurations/WITBOX/Configuration.h | 2 +- Marlin/example_configurations/makibox/Configuration.h | 2 +- Marlin/example_configurations/tvrrug/Round2/Configuration.h | 2 +- Marlin/language.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 646dc60aef..f48646ac7f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -70,7 +70,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 57f37756b3..2b2175cc46 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -70,7 +70,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 9dbbc82085..02504e2839 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -64,7 +64,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 60e2db873c..df0614b507 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -64,7 +64,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 65fccb063d..1f180a53d2 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -82,7 +82,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 293aa77169..eaa1a8b9e5 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -64,7 +64,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index e355a41ea5..a01bcb6684 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -64,7 +64,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 06cd2ae475..423822a866 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -64,7 +64,7 @@ Here are some standard links for getting your machine calibrated: // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message -// #define CUSTOM_MACHINE_NAME "This RepRap" +// #define CUSTOM_MACHINE_NAME "3D Printer" // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines) // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4) diff --git a/Marlin/language.h b/Marlin/language.h index 5d1fd6c2fb..179a1b9563 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -70,7 +70,7 @@ #endif #else #ifndef MACHINE_NAME - #define MACHINE_NAME "Mendel" + #define MACHINE_NAME "3D Printer" #endif #endif From ccddc280be7d51618ba64dee9e05a4dc782e4463 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Apr 2015 18:07:08 -0700 Subject: [PATCH 036/118] Apply three more commits --- Marlin/Marlin.h | 16 +- Marlin/Marlin_main.cpp | 439 ++++++++---------- Marlin/cardreader.cpp | 10 +- Marlin/cardreader.h | 2 +- Marlin/dogm_lcd_implementation.h | 2 +- .../Hephestos/Configuration.h | 4 +- .../WITBOX/Configuration.h | 4 +- Marlin/planner.cpp | 26 +- Marlin/planner.h | 2 +- Marlin/stepper.cpp | 6 +- Marlin/temperature.cpp | 48 +- Marlin/ultralcd.cpp | 73 +-- Marlin/ultralcd.h | 3 +- .../ultralcd_implementation_hitachi_HD44780.h | 73 ++- 14 files changed, 337 insertions(+), 371 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 40128de997..ad4f82bd14 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -31,6 +31,10 @@ #define TEST(n,b) (((n)&BIT(b))!=0) #define RADIANS(d) ((d)*M_PI/180.0) #define DEGREES(r) ((d)*180.0/M_PI) +#define NOLESS(v,n) do{ if (v < n) v = n; }while(0) +#define NOMORE(v,n) do{ if (v > n) v = n; }while(0) + +typedef unsigned long millis_t; // Arduino < 1.0.0 does not define this, so we need to do it ourselves #ifndef analogInputToDigitalPin @@ -223,14 +227,14 @@ extern bool Running; inline bool IsRunning() { return Running; } inline bool IsStopped() { return !Running; } -bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full -void enquecommands_P(const char *cmd); //put one or many ASCII commands at the end of the current buffer, read from flash +bool enqueuecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full +void enqueuecommands_P(const char *cmd); //put one or many ASCII commands at the end of the current buffer, read from flash void prepare_arc_move(char isclockwise); void clamp_to_software_endstops(float target[3]); -extern unsigned long previous_millis_cmd; -inline void refresh_cmd_timeout() { previous_millis_cmd = millis(); } +extern millis_t previous_cmd_ms; +inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); } #ifdef FAST_PWM_FAN void setPwmFrequency(uint8_t pin, int val); @@ -305,8 +309,8 @@ extern int fanSpeed; extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate; #endif -extern unsigned long starttime; -extern unsigned long stoptime; +extern millis_t starttime; +extern millis_t stoptime; // Handling multiple extruders pins extern uint8_t active_extruder; diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ddf8036de7..94c4c7bd84 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -244,11 +244,11 @@ static char *strchr_pointer; ///< A pointer to find chars in the command string const char* queued_commands_P= NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */ const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42 // Inactivity shutdown -unsigned long previous_millis_cmd = 0; -static unsigned long max_inactive_time = 0; -static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l; -unsigned long starttime = 0; ///< Print job start time -unsigned long stoptime = 0; ///< Print job stop time +millis_t previous_cmd_ms = 0; +static millis_t max_inactive_time = 0; +static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L; +millis_t starttime = 0; ///< Print job start time +millis_t stoptime = 0; ///< Print job stop time static uint8_t target_extruder; bool CooldownNoWait = true; bool target_direction; @@ -425,7 +425,7 @@ static bool drain_queued_commands_P() { char c; while((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command cmd[i] = '\0'; - if (enquecommand(cmd)) { // buffer was not full (else we will retry later) + if (enqueuecommand(cmd)) { // buffer was not full (else we will retry later) if (c) queued_commands_P += i + 1; // move to next command else @@ -437,7 +437,7 @@ static bool drain_queued_commands_P() { //Record one or many commands to run from program memory. //Aborts the current queue, if any. //Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards -void enquecommands_P(const char* pgcode) { +void enqueuecommands_P(const char* pgcode) { queued_commands_P = pgcode; drain_queued_commands_P(); // first command executed asap (when possible) } @@ -446,7 +446,7 @@ void enquecommands_P(const char* pgcode) { //that is really done in a non-safe way. //needs overworking someday //Returns false if it failed to do so -bool enquecommand(const char *cmd) +bool enqueuecommand(const char *cmd) { if(*cmd==';') return false; @@ -666,33 +666,30 @@ void loop() { lcd_update(); } -void get_command() -{ - if (drain_queued_commands_P()) // priority is given to non-serial commands - return; +void get_command() { + + if (drain_queued_commands_P()) return; // priority is given to non-serial commands - while( MYSERIAL.available() > 0 && buflen < BUFSIZE) { + while (MYSERIAL.available() > 0 && buflen < BUFSIZE) { serial_char = MYSERIAL.read(); - if(serial_char == '\n' || - serial_char == '\r' || - serial_count >= (MAX_CMD_SIZE - 1) ) - { + if (serial_char == '\n' || serial_char == '\r' || + serial_count >= (MAX_CMD_SIZE - 1) + ) { // end of line == end of comment comment_mode = false; - if(!serial_count) { - // short cut for empty lines - return; - } - cmdbuffer[bufindw][serial_count] = 0; //terminate string + if (!serial_count) return; // shortcut for empty lines + + cmdbuffer[bufindw][serial_count] = 0; // terminate string + #ifdef SDSUPPORT - fromsd[bufindw] = false; - #endif //!SDSUPPORT - if(strchr(cmdbuffer[bufindw], 'N') != NULL) - { + fromsd[bufindw] = false; + #endif + + if (strchr(cmdbuffer[bufindw], 'N') != NULL) { strchr_pointer = strchr(cmdbuffer[bufindw], 'N'); gcode_N = (strtol(strchr_pointer + 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); @@ -702,14 +699,13 @@ 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++]; + while (cmdbuffer[bufindw][count] != '*') checksum ^= cmdbuffer[bufindw][count++]; strchr_pointer = strchr(cmdbuffer[bufindw], '*'); - if(strtol(strchr_pointer + 1, NULL, 10) != checksum) { + if (strtol(strchr_pointer + 1, NULL, 10) != checksum) { SERIAL_ERROR_START; SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH); SERIAL_ERRORLN(gcode_LastN); @@ -719,8 +715,7 @@ void get_command() } //if no errors, continue parsing } - else - { + else { SERIAL_ERROR_START; SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM); SERIAL_ERRORLN(gcode_LastN); @@ -732,10 +727,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); @@ -743,111 +736,99 @@ void get_command() return; } } - if((strchr(cmdbuffer[bufindw], 'G') != NULL)){ - strchr_pointer = strchr(cmdbuffer[bufindw], 'G'); - switch(strtol(strchr_pointer + 1, NULL, 10)){ - case 0: - case 1: - case 2: - case 3: - if (IsStopped()) { - SERIAL_ERRORLNPGM(MSG_ERR_STOPPED); - LCD_MESSAGEPGM(MSG_STOPPED); - } - break; - default: - break; - } + if (strchr(cmdbuffer[bufindw], 'G') != NULL) { + strchr_pointer = strchr(cmdbuffer[bufindw], 'G'); + switch (strtol(strchr_pointer + 1, NULL, 10)) { + case 0: + case 1: + case 2: + case 3: + if (IsStopped()) { + SERIAL_ERRORLNPGM(MSG_ERR_STOPPED); + LCD_MESSAGEPGM(MSG_STOPPED); + } + break; + default: + break; + } } - //If command was e-stop process now - if(strcmp(cmdbuffer[bufindw], "M112") == 0) - kill(); + // If command was e-stop process now + if (strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - bufindw = (bufindw + 1)%BUFSIZE; + bufindw = (bufindw + 1) % BUFSIZE; buflen += 1; serial_count = 0; //clear buffer } - else if(serial_char == '\\') { //Handle escapes - - if(MYSERIAL.available() > 0 && buflen < BUFSIZE) { - // if we have one more character, copy it over - serial_char = MYSERIAL.read(); - cmdbuffer[bufindw][serial_count++] = serial_char; - } - - //otherwise do nothing + else if (serial_char == '\\') { // Handle escapes + if (MYSERIAL.available() > 0 && buflen < BUFSIZE) { + // if we have one more character, copy it over + serial_char = MYSERIAL.read(); + cmdbuffer[bufindw][serial_count++] = serial_char; + } + // otherwise do nothing } else { // its not a newline, carriage return or escape char - if(serial_char == ';') comment_mode = true; - if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; + if (serial_char == ';') comment_mode = true; + if (!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; } } + #ifdef SDSUPPORT - if(!card.sdprinting || serial_count!=0){ - return; - } - //'#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible - // if it occurs, stop_buffering is triggered and the buffer is ran dry. - // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing + if (!card.sdprinting || serial_count) return; - static bool stop_buffering=false; - if(buflen==0) stop_buffering=false; + // '#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible + // if it occurs, stop_buffering is triggered and the buffer is ran dry. + // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing - while( !card.eof() && buflen < BUFSIZE && !stop_buffering) { - int16_t n=card.get(); - serial_char = (char)n; - if(serial_char == '\n' || - serial_char == '\r' || - (serial_char == '#' && comment_mode == false) || - (serial_char == ':' && comment_mode == false) || - serial_count >= (MAX_CMD_SIZE - 1)||n==-1) - { - if(card.eof()){ - SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED); - stoptime=millis(); - char time[30]; - unsigned long t=(stoptime-starttime)/1000; - int hours, minutes; - minutes=(t/60)%60; - hours=t/60/60; - sprintf_P(time, PSTR("%i "MSG_END_HOUR" %i "MSG_END_MINUTE),hours, minutes); - SERIAL_ECHO_START; - SERIAL_ECHOLN(time); - lcd_setstatus(time, true); - card.printingHasFinished(); - card.checkautostart(true); + static bool stop_buffering = false; + if (buflen == 0) stop_buffering = false; - } - if(serial_char=='#') - stop_buffering=true; + while (!card.eof() && buflen < BUFSIZE && !stop_buffering) { + int16_t n = card.get(); + serial_char = (char)n; + if (serial_char == '\n' || serial_char == '\r' || + ((serial_char == '#' || serial_char == ':') && !comment_mode) || + serial_count >= (MAX_CMD_SIZE - 1) || n == -1 + ) { + if (card.eof()) { + SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED); + stoptime = millis(); + char time[30]; + millis_t t = (stoptime - starttime) / 1000; + int hours = t / 60 / 60, minutes = (t / 60) % 60; + sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes); + SERIAL_ECHO_START; + SERIAL_ECHOLN(time); + lcd_setstatus(time, true); + card.printingHasFinished(); + card.checkautostart(true); + } + if (serial_char == '#') stop_buffering = true; - if(!serial_count) - { - comment_mode = false; //for new command - return; //if empty line - } - cmdbuffer[bufindw][serial_count] = 0; //terminate string -// if(!comment_mode){ + if (!serial_count) { + comment_mode = false; //for new command + return; //if empty line + } + cmdbuffer[bufindw][serial_count] = 0; //terminate string + // if (!comment_mode) { fromsd[bufindw] = true; buflen += 1; bufindw = (bufindw + 1)%BUFSIZE; -// } - comment_mode = false; //for new command - serial_count = 0; //clear buffer + // } + comment_mode = false; //for new command + serial_count = 0; //clear buffer + } + else { + if (serial_char == ';') comment_mode = true; + if (!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; + } } - else - { - if(serial_char == ';') comment_mode = true; - if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; - } - } - - #endif //SDSUPPORT + #endif // SDSUPPORT } float code_has_value() { @@ -923,7 +904,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1 static bool active_extruder_parked = false; // used in mode 1 & 2 static float raised_parked_position[NUM_AXIS]; // used in mode 1 - static unsigned long delayed_move_time = 0; // used in mode 1 + static millis_t delayed_move_time = 0; // used in mode 1 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2 static float duplicate_extruder_temp_offset = 0; // used in mode 2 bool extruder_duplication_enabled = false; // used in mode 2 @@ -1111,7 +1092,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, // move down slowly until you find the bed feedrate = homing_feedrate[Z_AXIS] / 4; destination[Z_AXIS] = -10; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination st_synchronize(); endstops_hit_on_purpose(); // clear endstop hit flags @@ -1157,7 +1138,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position, } /** - * + * Plan a move to (X, Y, Z) and set the current_position + * The final current_position may not be the one that was requested */ static void do_blocking_move_to(float x, float y, float z) { float oldFeedRate = feedrate; @@ -1169,7 +1151,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, destination[X_AXIS] = x; destination[Y_AXIS] = y; destination[Z_AXIS] = z; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination st_synchronize(); #else @@ -1233,17 +1215,17 @@ inline void set_destination_to_current() { memcpy(destination, current_position, destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_X; destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_Y; destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_Z; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination // Home X to touch the belt feedrate = homing_feedrate[X_AXIS]/10; destination[X_AXIS] = 0; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination // Home Y for safety feedrate = homing_feedrate[X_AXIS]/2; destination[Y_AXIS] = 0; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination st_synchronize(); @@ -1275,7 +1257,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, if (servo_endstops[Z_AXIS] >= 0) { #if Z_RAISE_AFTER_PROBING > 0 - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position st_synchronize(); #endif @@ -1296,29 +1278,29 @@ inline void set_destination_to_current() { memcpy(destination, current_position, // Move up for safety feedrate = homing_feedrate[X_AXIS]; destination[Z_AXIS] = current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination // Move to the start position to initiate retraction destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_X; destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_Y; destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_Z; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination // Move the nozzle down to push the probe into retracted position feedrate = homing_feedrate[Z_AXIS]/10; destination[Z_AXIS] = current_position[Z_AXIS] - Z_PROBE_ALLEN_KEY_STOW_DEPTH; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination // Move up for safety feedrate = homing_feedrate[Z_AXIS]/2; destination[Z_AXIS] = current_position[Z_AXIS] + Z_PROBE_ALLEN_KEY_STOW_DEPTH * 2; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination // Home XY for safety feedrate = homing_feedrate[X_AXIS]/2; destination[X_AXIS] = 0; destination[Y_AXIS] = 0; - prepare_move_raw(); + prepare_move_raw(); // this will also set_current_to_destination st_synchronize(); @@ -1352,8 +1334,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position, // Probe bed height at position (x,y), returns the measured z value static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeDeployAndStow, int verbose_level=1) { // move to right place - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); - do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); // this also updates current_position + do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); // this also updates current_position #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY) if (retract_action & ProbeDeploy) deploy_z_probe(); @@ -1364,7 +1346,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, #if Z_RAISE_BETWEEN_PROBINGS > 0 if (retract_action == ProbeStay) { - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); // this also updates current_position st_synchronize(); } #endif @@ -1643,12 +1625,12 @@ static void homeaxis(AxisEnum axis) { } if (dock) { - do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]); + do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]); // this also updates current_position digitalWrite(SERVO0_PIN, LOW); // turn off magnet } else { float z_loc = current_position[Z_AXIS]; if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING; - do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc); + do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc); // this also updates current_position digitalWrite(SERVO0_PIN, HIGH); // turn on magnet } } @@ -1700,7 +1682,7 @@ inline void gcode_G2_G3(bool clockwise) { * G4: Dwell S or P */ inline void gcode_G4() { - unsigned long codenum = 0; + millis_t codenum = 0; LCD_MESSAGEPGM(MSG_DWELL); @@ -1709,7 +1691,7 @@ inline void gcode_G4() { st_synchronize(); refresh_cmd_timeout(); - codenum += previous_millis_cmd; // keep track of when we started waiting + codenum += previous_cmd_ms; // keep track of when we started waiting while (millis() < codenum) { manage_heater(); manage_inactivity(); @@ -2096,7 +2078,7 @@ inline void gcode_G28() { case MeshStart: mbl.reset(); probe_point = 0; - enquecommands_P(PSTR("G28\nG29 S2")); + enqueuecommands_P(PSTR("G28\nG29 S2")); break; case MeshNext: @@ -2135,7 +2117,7 @@ inline void gcode_G28() { SERIAL_PROTOCOLLNPGM("Mesh probing done."); probe_point = -1; mbl.active = 1; - enquecommands_P(PSTR("G28")); + enqueuecommands_P(PSTR("G28")); } break; @@ -2517,7 +2499,7 @@ inline void gcode_G28() { #endif #ifdef Z_PROBE_END_SCRIPT - enquecommands_P(PSTR(Z_PROBE_END_SCRIPT)); + enqueuecommands_P(PSTR(Z_PROBE_END_SCRIPT)); st_synchronize(); #endif } @@ -2579,7 +2561,7 @@ inline void gcode_G92() { inline void gcode_M0_M1() { char *src = strchr_pointer + 2; - unsigned long codenum = 0; + millis_t codenum = 0; bool hasP = false, hasS = false; if (code_seen('P')) { codenum = code_value_short(); // milliseconds to wait @@ -2605,7 +2587,7 @@ inline void gcode_G92() { st_synchronize(); refresh_cmd_timeout(); if (codenum > 0) { - codenum += previous_millis_cmd; // keep track of when we started waiting + codenum += previous_cmd_ms; // keep track of when we started waiting while(millis() < codenum && !lcd_clicked()) { manage_heater(); manage_inactivity(); @@ -2747,7 +2729,7 @@ inline void gcode_M17() { */ inline void gcode_M31() { stoptime = millis(); - unsigned long t = (stoptime - starttime) / 1000; + millis_t t = (stoptime - starttime) / 1000; int min = t / 60, sec = t % 60; char time[30]; sprintf_P(time, PSTR("%i min, %i sec"), min, sec); @@ -2980,11 +2962,11 @@ inline void gcode_M42() { if (deploy_probe_for_each_reading) stow_z_probe(); for (uint8_t n=0; n < n_samples; n++) { - - do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location + // Make sure we are at the probe location + do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // this also updates current_position if (n_legs) { - unsigned long ms = millis(); + millis_t ms = millis(); double radius = ms % (X_MAX_LENGTH / 4), // limit how far out to go theta = RADIANS(ms % 360L); float dir = (ms & 0x0001) ? 1 : -1; // clockwise or counter clockwise @@ -3011,11 +2993,12 @@ inline void gcode_M42() { SERIAL_EOL; } - do_blocking_move_to(X_current, Y_current, Z_current); + do_blocking_move_to(X_current, Y_current, Z_current); // this also updates current_position } // n_legs loop - do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // Go back to the probe location + // Go back to the probe location + do_blocking_move_to(X_probe_location, Y_probe_location, Z_start_location); // this also updates current_position } // n_legs @@ -3221,7 +3204,7 @@ inline void gcode_M109() { setWatch(); - unsigned long timetemp = millis(); + millis_t temp_ms = millis(); /* See if we are heating up or cooling down */ target_direction = isHeatingHotend(target_extruder); // true if heating, false if cooling @@ -3229,26 +3212,26 @@ inline void gcode_M109() { cancel_heatup = false; #ifdef TEMP_RESIDENCY_TIME - long residencyStart = -1; + long residency_start_ms = -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)))) ) + while((!cancel_heatup)&&((residency_start_ms == -1) || + (residency_start_ms >= 0 && (((unsigned int) (millis() - residency_start_ms)) < (TEMP_RESIDENCY_TIME * 1000UL)))) ) #else while ( target_direction ? (isHeatingHotend(target_extruder)) : (isCoolingHotend(target_extruder)&&(CooldownNoWait==false)) ) #endif //TEMP_RESIDENCY_TIME { // while loop - if (millis() > timetemp + 1000UL) { //Print temp & remaining time every 1s while waiting + if (millis() > temp_ms + 1000UL) { //Print temp & remaining time every 1s while waiting SERIAL_PROTOCOLPGM("T:"); SERIAL_PROTOCOL_F(degHotend(target_extruder),1); SERIAL_PROTOCOLPGM(" E:"); SERIAL_PROTOCOL((int)target_extruder); #ifdef TEMP_RESIDENCY_TIME SERIAL_PROTOCOLPGM(" W:"); - if (residencyStart > -1) { - timetemp = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residencyStart)) / 1000UL; - SERIAL_PROTOCOLLN( timetemp ); + if (residency_start_ms > -1) { + temp_ms = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residency_start_ms)) / 1000UL; + SERIAL_PROTOCOLLN(temp_ms); } else { SERIAL_PROTOCOLLNPGM("?"); @@ -3256,7 +3239,7 @@ inline void gcode_M109() { #else SERIAL_EOL; #endif - timetemp = millis(); + temp_ms = millis(); } manage_heater(); manage_inactivity(); @@ -3264,18 +3247,18 @@ inline void gcode_M109() { #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(target_extruder) >= (degTargetHotend(target_extruder)-TEMP_WINDOW))) || - (residencyStart == -1 && !target_direction && (degHotend(target_extruder) <= (degTargetHotend(target_extruder)+TEMP_WINDOW))) || - (residencyStart > -1 && labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > TEMP_HYSTERESIS) ) + if ((residency_start_ms == -1 && target_direction && (degHotend(target_extruder) >= (degTargetHotend(target_extruder)-TEMP_WINDOW))) || + (residency_start_ms == -1 && !target_direction && (degHotend(target_extruder) <= (degTargetHotend(target_extruder)+TEMP_WINDOW))) || + (residency_start_ms > -1 && labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > TEMP_HYSTERESIS) ) { - residencyStart = millis(); + residency_start_ms = millis(); } #endif //TEMP_RESIDENCY_TIME } LCD_MESSAGEPGM(MSG_HEATING_COMPLETE); refresh_cmd_timeout(); - starttime = previous_millis_cmd; + starttime = previous_cmd_ms; } #if HAS_TEMP_BED @@ -3290,15 +3273,15 @@ inline void gcode_M109() { if (CooldownNoWait || code_seen('R')) setTargetBed(code_value()); - unsigned long timetemp = millis(); + millis_t temp_ms = millis(); cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) ) { - unsigned long ms = millis(); - if (ms > timetemp + 1000UL) { //Print Temp Reading every 1 second while heating up. - timetemp = ms; + millis_t ms = millis(); + if (ms > temp_ms + 1000UL) { //Print Temp Reading every 1 second while heating up. + temp_ms = ms; float tt = degHotend(active_extruder); SERIAL_PROTOCOLPGM("T:"); SERIAL_PROTOCOL(tt); @@ -3974,14 +3957,14 @@ inline void gcode_M226() { #endif // NUM_SERVOS > 0 -#if defined(LARGE_FLASH) && (BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)) +#if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER) /** * M300: Play beep sound S P */ inline void gcode_M300() { - int beepS = code_seen('S') ? code_value() : 110; - int beepP = code_seen('P') ? code_value() : 1000; + uint16_t beepS = code_seen('S') ? code_value_short() : 110; + uint32_t beepP = code_seen('P') ? code_value_long() : 1000; if (beepS > 0) { #if BEEPER > 0 tone(BEEPER, beepS); @@ -3998,7 +3981,7 @@ inline void gcode_M226() { } } -#endif // LARGE_FLASH && (BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER) +#endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER #ifdef PIDTEMP @@ -4472,24 +4455,10 @@ inline void gcode_M503() { LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE); uint8_t cnt = 0; while (!lcd_clicked()) { - cnt++; + if (++cnt == 0) lcd_quick_feedback(); // every 256th frame till the lcd is clicked manage_heater(); manage_inactivity(true); lcd_update(); - if (cnt == 0) { - #if BEEPER > 0 - OUT_WRITE(BEEPER,HIGH); - delay(3); - WRITE(BEEPER,LOW); - delay(3); - #else - #if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) - lcd_buzz(1000/6, 100); - #else - lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); - #endif - #endif - } } // while(!lcd_clicked) //return to normal @@ -5078,11 +5047,11 @@ void process_commands() { break; #endif // NUM_SERVOS > 0 - #if defined(LARGE_FLASH) && (BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER)) + #if BEEPER > 0 || defined(ULTRALCD) || defined(LCD_USE_I2C_BUZZER) case 300: // M300 - Play beep tone gcode_M300(); break; - #endif // LARGE_FLASH && (BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER) + #endif // BEEPER > 0 || ULTRALCD || LCD_USE_I2C_BUZZER #ifdef PIDTEMP case 301: // M301 @@ -5289,25 +5258,23 @@ void get_arc_coordinates() { offset[1] = code_seen('J') ? code_value() : 0; } -void clamp_to_software_endstops(float target[3]) -{ +void clamp_to_software_endstops(float target[3]) { if (min_software_endstops) { - if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; - if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; + NOLESS(target[X_AXIS], min_pos[X_AXIS]); + NOLESS(target[Y_AXIS], min_pos[Y_AXIS]); float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING - if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; - if (home_offset[Z_AXIS] < 0) negative_z_offset = negative_z_offset + home_offset[Z_AXIS]; + if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset += Z_PROBE_OFFSET_FROM_EXTRUDER; + if (home_offset[Z_AXIS] < 0) negative_z_offset += home_offset[Z_AXIS]; #endif - - if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; + NOLESS(target[Z_AXIS], min_pos[Z_AXIS] + negative_z_offset); } if (max_software_endstops) { - if (target[X_AXIS] > max_pos[X_AXIS]) target[X_AXIS] = max_pos[X_AXIS]; - if (target[Y_AXIS] > max_pos[Y_AXIS]) target[Y_AXIS] = max_pos[Y_AXIS]; - if (target[Z_AXIS] > max_pos[Z_AXIS]) target[Z_AXIS] = max_pos[Z_AXIS]; + NOMORE(target[X_AXIS], max_pos[X_AXIS]); + NOMORE(target[Y_AXIS], max_pos[Y_AXIS]); + NOMORE(target[Z_AXIS], max_pos[Z_AXIS]); } } @@ -5522,7 +5489,7 @@ void prepare_move() { //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedmultiply/100.0, active_extruder); } #endif // SCARA @@ -5549,7 +5516,7 @@ void prepare_move() { #ifdef ENABLE_AUTO_BED_LEVELING adjust_delta(destination); #endif - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedmultiply/100.0, active_extruder); } #endif // DELTA @@ -5573,7 +5540,7 @@ void prepare_move() { // (so it can be used as the start of the next non-travel move) if (delayed_move_time != 0xFFFFFFFFUL) { set_current_to_destination(); - if (destination[Z_AXIS] > raised_parked_position[Z_AXIS]) raised_parked_position[Z_AXIS] = destination[Z_AXIS]; + NOLESS(raised_parked_position[Z_AXIS], destination[Z_AXIS]); delayed_move_time = millis(); return; } @@ -5621,11 +5588,11 @@ void prepare_arc_move(char isclockwise) { #if HAS_CONTROLLERFAN -unsigned long lastMotor = 0; // Last time a motor was turned on -unsigned long lastMotorCheck = 0; // Last time the state was checked +millis_t lastMotor = 0; // Last time a motor was turned on +millis_t lastMotorCheck = 0; // Last time the state was checked void controllerFan() { - uint32_t ms = millis(); + millis_t ms = millis(); if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms lastMotorCheck = ms; if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0 @@ -5732,36 +5699,28 @@ void calculate_delta(float cartesian[3]){ #endif #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) { - float max_temp = 0.0; - if(millis() > stat_update) { - stat_update += 500; // Update every 0.5s - for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { - max_temp = max(max_temp, degHotend(cur_extruder)); - max_temp = max(max_temp, degTargetHotend(cur_extruder)); - } - #if HAS_TEMP_BED - max_temp = max(max_temp, degTargetBed()); - max_temp = max(max_temp, degBed()); - #endif - if((max_temp > 55.0) && (red_led == false)) { - digitalWrite(STAT_LED_RED, 1); - digitalWrite(STAT_LED_BLUE, 0); - red_led = true; - blue_led = false; - } - if((max_temp < 54.0) && (blue_led == false)) { - digitalWrite(STAT_LED_RED, 0); - digitalWrite(STAT_LED_BLUE, 1); - red_led = false; - blue_led = true; + static bool red_led = false; + static millis_t next_status_led_update_ms = 0; + + void handle_status_leds(void) { + float max_temp = 0.0; + if (millis() > next_status_led_update_ms) { + next_status_led_update_ms += 500; // Update every 0.5s + for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) + max_temp = max(max(max_temp, degHotend(cur_extruder)), degTargetHotend(cur_extruder)); + #if HAS_TEMP_BED + max_temp = max(max(max_temp, degTargetBed()), degBed()); + #endif + bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led; + if (new_led != red_led) { + red_led = new_led; + digitalWrite(STAT_LED_RED, new_led ? HIGH : LOW); + digitalWrite(STAT_LED_BLUE, new_led ? LOW : HIGH); + } } } -} + #endif void enable_all_steppers() { @@ -5805,11 +5764,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { if (buflen < BUFSIZE - 1) get_command(); - unsigned long ms = millis(); + millis_t ms = millis(); - if (max_inactive_time && ms > previous_millis_cmd + max_inactive_time) kill(); + if (max_inactive_time && ms > previous_cmd_ms + max_inactive_time) kill(); - if (stepper_inactive_time && ms > previous_millis_cmd + stepper_inactive_time + if (stepper_inactive_time && ms > previous_cmd_ms + stepper_inactive_time && !ignore_stepper_queue && !blocks_queued()) disable_all_steppers(); @@ -5845,7 +5804,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { const int HOME_DEBOUNCE_DELAY = 750; if (!READ(HOME_PIN)) { if (!homeDebounceCount) { - enquecommands_P(PSTR("G28")); + enqueuecommands_P(PSTR("G28")); LCD_ALERTMESSAGEPGM(MSG_AUTO_HOME); } if (homeDebounceCount < HOME_DEBOUNCE_DELAY) @@ -5860,7 +5819,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #endif #ifdef EXTRUDER_RUNOUT_PREVENT - if (ms > previous_millis_cmd + EXTRUDER_RUNOUT_SECONDS * 1000) + if (ms > previous_cmd_ms + EXTRUDER_RUNOUT_SECONDS * 1000) if (degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) { bool oldstatus; switch(active_extruder) { @@ -5894,7 +5853,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { current_position[E_AXIS] = oldepos; destination[E_AXIS] = oldedes; plan_set_e_position(oldepos); - previous_millis_cmd = ms; // refresh_cmd_timeout() + previous_cmd_ms = ms; // refresh_cmd_timeout() st_synchronize(); switch(active_extruder) { case 0: @@ -5964,7 +5923,7 @@ void kill() { if filrunoutEnqued == false { filrunoutEnqued = true; - enquecommand("M600"); + enqueuecommand("M600"); } } #endif diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 877b72b927..639b4f244a 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -25,7 +25,7 @@ CardReader::CardReader() { OUT_WRITE(SDPOWER, HIGH); #endif //SDPOWER - autostart_atmillis = millis() + 5000; + next_autostart_ms = millis() + 5000; } char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters @@ -397,7 +397,7 @@ void CardReader::write_command(char *buf) { } void CardReader::checkautostart(bool force) { - if (!force && (!autostart_stilltocheck || autostart_atmillis < millis())) + if (!force && (!autostart_stilltocheck || next_autostart_ms < millis())) return; autostart_stilltocheck = false; @@ -421,8 +421,8 @@ void CardReader::checkautostart(bool force) { if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) { char cmd[30]; sprintf_P(cmd, PSTR("M23 %s"), autoname); - enquecommand(cmd); - enquecommands_P(PSTR("M24")); + enqueuecommand(cmd); + enqueuecommands_P(PSTR("M24")); found = true; } } @@ -508,7 +508,7 @@ void CardReader::printingHasFinished() { sdprinting = false; if (SD_FINISHED_STEPPERRELEASE) { //finishAndDisableSteppers(); - enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); + enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); } autotempShutdown(); } diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index b55d09a65a..03d4303e30 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -62,7 +62,7 @@ private: uint32_t filespos[SD_PROCEDURE_DEPTH]; char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH]; uint32_t filesize; - unsigned long autostart_atmillis; + millis_t next_autostart_ms; uint32_t sdpos; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index fd52d645ed..546703bfb0 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -350,7 +350,7 @@ static void lcd_implementation_status_screen() { #ifndef FILAMENT_LCD_DISPLAY lcd_print(lcd_status_message); #else - if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line + if (millis() < previous_lcd_status_ms + 5000) { //Display both Status message line and Filament display on the last line lcd_print(lcd_status_message); } else { diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 02504e2839..a83c6e911d 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -58,9 +58,7 @@ Here are some standard links for getting your machine calibrated: // The following define selects which electronics board you have. // Please choose the name from boards.h that matches your setup -#ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_HEPHESTOS -#endif +#define MOTHERBOARD BOARD_HEPHESTOS // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index eaa1a8b9e5..dda21b7759 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -58,9 +58,7 @@ Here are some standard links for getting your machine calibrated: // The following define selects which electronics board you have. // Please choose the name from boards.h that matches your setup -#ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_WITBOX -#endif +#define MOTHERBOARD BOARD_WITBOX // Optional custom name for your RepStrap or other custom machine // Displayed in the LCD "Ready" message diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 49c090881c..a452428d78 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -60,13 +60,13 @@ #ifdef MESH_BED_LEVELING #include "mesh_bed_leveling.h" -#endif // MESH_BED_LEVELING +#endif //=========================================================================== //============================= public variables ============================ //=========================================================================== -unsigned long minsegmenttime; +millis_t minsegmenttime; float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute float axis_steps_per_unit[NUM_AXIS]; unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software @@ -159,8 +159,8 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi unsigned long final_rate = ceil(block->nominal_rate * exit_factor); // (step/min) // Limit minimal step rate (Otherwise the timer will overflow.) - if (initial_rate < 120) initial_rate = 120; - if (final_rate < 120) final_rate = 120; + NOLESS(initial_rate, 120); + NOLESS(final_rate, 120); long acceleration = block->acceleration_st; int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration)); @@ -382,9 +382,11 @@ void plan_init() { } float t = autotemp_min + high * autotemp_factor; - if (t < autotemp_min) t = autotemp_min; - if (t > autotemp_max) t = autotemp_max; - if (oldt > t) t = AUTOTEMP_OLDWEIGHT * oldt + (1 - AUTOTEMP_OLDWEIGHT) * t; + t = constrain(t, autotemp_min, autotemp_max); + if (oldt > t) { + t *= (1 - AUTOTEMP_OLDWEIGHT); + t += AUTOTEMP_OLDWEIGHT * oldt; + } oldt = t; setTargetHotend0(t); } @@ -426,7 +428,7 @@ void check_axes_activity() { #if HAS_FAN #ifdef FAN_KICKSTART_TIME - static unsigned long fan_kick_end; + static millis_t fan_kick_end; if (tail_fan_speed) { if (fan_kick_end == 0) { // Just starting up fan - run at full power. @@ -651,10 +653,10 @@ float junction_deviation = 0.1; } } - if (block->steps[E_AXIS]) { - if (feed_rate < minimumfeedrate) feed_rate = minimumfeedrate; - } - else if (feed_rate < mintravelfeedrate) feed_rate = mintravelfeedrate; + if (block->steps[E_AXIS]) + NOLESS(feed_rate, minimumfeedrate); + else + NOLESS(feed_rate, mintravelfeedrate); /** * This part of the code calculates the total length of the movement. diff --git a/Marlin/planner.h b/Marlin/planner.h index c617d6d481..d96aa8c112 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -115,7 +115,7 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block void plan_set_e_position(const float &e); -extern unsigned long minsegmenttime; +extern millis_t minsegmenttime; extern float max_feedrate[NUM_AXIS]; // set the max speeds extern float axis_steps_per_unit[NUM_AXIS]; extern unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 1f28b3af95..2ad555327d 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -400,7 +400,7 @@ ISR(TIMER1_COMPA_vect) { current_block = NULL; plan_discard_current_block(); #ifdef SD_FINISHED_RELEASECOMMAND - if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); + if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); #endif cleaning_buffer_counter--; OCR1A = 200; @@ -718,7 +718,7 @@ ISR(TIMER1_COMPA_vect) { // Calculate new timer value unsigned short timer; unsigned short step_rate; - if (step_events_completed <= (unsigned long int)current_block->accelerate_until) { + if (step_events_completed <= (unsigned long)current_block->accelerate_until) { MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate); acc_step_rate += current_block->initial_rate; @@ -742,7 +742,7 @@ ISR(TIMER1_COMPA_vect) { #endif } - else if (step_events_completed > (unsigned long int)current_block->decelerate_after) { + else if (step_events_completed > (unsigned long)current_block->decelerate_after) { MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate); if (step_rate > acc_step_rate) { // Check step_rate stays positive diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index b4dffbfe16..f494edecf0 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -77,14 +77,14 @@ unsigned char soft_pwm_bed; #define HAS_BED_THERMAL_PROTECTION (defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 && TEMP_SENSOR_BED != 0) #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway }; - void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc); + void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc); #if HAS_HEATER_THERMAL_PROTECTION static TRState thermal_runaway_state_machine[4] = { TRReset, TRReset, TRReset, TRReset }; - static unsigned long thermal_runaway_timer[4]; // = {0,0,0,0}; + static millis_t thermal_runaway_timer[4]; // = {0,0,0,0}; #endif #if HAS_BED_THERMAL_PROTECTION static TRState thermal_runaway_bed_state_machine = TRReset; - static unsigned long thermal_runaway_bed_timer; + static millis_t thermal_runaway_bed_timer; #endif #endif @@ -118,7 +118,7 @@ static volatile bool temp_meas_ready = false; static float temp_iState_min_bed; static float temp_iState_max_bed; #else //PIDTEMPBED - static unsigned long previous_millis_bed_heater; + static millis_t previous_bed_check_ms; #endif //PIDTEMPBED static unsigned char soft_pwm[EXTRUDERS]; @@ -126,7 +126,7 @@ static volatile bool temp_meas_ready = false; static unsigned char soft_pwm_fan; #endif #if HAS_AUTO_FAN - static unsigned long extruder_autofan_last_check; + static millis_t previous_auto_fan_check_ms; #endif #ifdef PIDTEMP @@ -171,7 +171,7 @@ static void updateTemperaturesFromRawValues(); #ifdef WATCH_TEMP_PERIOD int watch_start_temp[EXTRUDERS] = { 0 }; - unsigned long watchmillis[EXTRUDERS] = { 0 }; + millis_t watchmillis[EXTRUDERS] = { 0 }; #endif //WATCH_TEMP_PERIOD #ifndef SOFT_PWM_SCALE @@ -196,7 +196,7 @@ void PID_autotune(float temp, int extruder, int ncycles) int cycles = 0; bool heating = true; - unsigned long temp_millis = millis(), t1 = temp_millis, t2 = temp_millis; + millis_t temp_ms = millis(), t1 = temp_ms, t2 = temp_ms; long t_high = 0, t_low = 0; long bias, d; @@ -205,7 +205,7 @@ void PID_autotune(float temp, int extruder, int ncycles) float max = 0, min = 10000; #if HAS_AUTO_FAN - unsigned long extruder_autofan_last_check = temp_millis; + millis_t previous_auto_fan_check_ms = temp_ms; #endif if (extruder >= EXTRUDERS @@ -229,7 +229,7 @@ void PID_autotune(float temp, int extruder, int ncycles) // PID Tuning loop for (;;) { - unsigned long ms = millis(); + millis_t ms = millis(); if (temp_meas_ready) { // temp sample ready updateTemperaturesFromRawValues(); @@ -240,9 +240,9 @@ void PID_autotune(float temp, int extruder, int ncycles) min = min(min, input); #if HAS_AUTO_FAN - if (ms > extruder_autofan_last_check + 2500) { + if (ms > previous_auto_fan_check_ms + 2500) { checkExtruderAutoFans(); - extruder_autofan_last_check = ms; + previous_auto_fan_check_ms = ms; } #endif @@ -317,7 +317,7 @@ void PID_autotune(float temp, int extruder, int ncycles) return; } // Every 2 seconds... - if (ms > temp_millis + 2000) { + if (ms > temp_ms + 2000) { int p; if (extruder < 0) { p = soft_pwm_bed; @@ -332,7 +332,7 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_PROTOCOLPGM(MSG_AT); SERIAL_PROTOCOLLN(p); - temp_millis = ms; + temp_ms = ms; } // every 2 seconds // Over 2 minutes? if (((ms - t1) + (ms - t2)) > (10L*60L*1000L*2L)) { @@ -592,7 +592,7 @@ void manage_heater() { #endif //HEATER_0_USES_MAX6675 #if defined(WATCH_TEMP_PERIOD) || !defined(PIDTEMPBED) || HAS_AUTO_FAN - unsigned long ms = millis(); + millis_t ms = millis(); #endif // Loop through all extruders @@ -631,15 +631,15 @@ void manage_heater() { } // Extruders Loop #if HAS_AUTO_FAN - if (ms > extruder_autofan_last_check + 2500) { // only need to check fan state very infrequently + if (ms > previous_auto_fan_check_ms + 2500) { // only need to check fan state very infrequently checkExtruderAutoFans(); - extruder_autofan_last_check = ms; + previous_auto_fan_check_ms = ms; } #endif #ifndef PIDTEMPBED - if (ms < previous_millis_bed_heater + BED_CHECK_INTERVAL) return; - previous_millis_bed_heater = ms; + if (ms < previous_bed_check_ms + BED_CHECK_INTERVAL) return; + previous_bed_check_ms = ms; #endif //PIDTEMPBED #if TEMP_SENSOR_BED != 0 @@ -992,7 +992,7 @@ void tp_init() void setWatch() { #ifdef WATCH_TEMP_PERIOD - unsigned long ms = millis(); + millis_t ms = millis(); for (int e = 0; e < EXTRUDERS; e++) { if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) { watch_start_temp[e] = degHotend(e); @@ -1004,7 +1004,7 @@ void setWatch() { #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION - void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { + void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { static float tr_target_temperature[EXTRUDERS+1] = { 0.0 }; @@ -1109,16 +1109,16 @@ void disable_heater() { #ifdef HEATER_0_USES_MAX6675 #define MAX6675_HEAT_INTERVAL 250u - unsigned long max6675_previous_millis = MAX6675_HEAT_INTERVAL; + millis_t previous_max6675_ms = MAX6675_HEAT_INTERVAL; int max6675_temp = 2000; static int read_max6675() { - unsigned long ms = millis(); - if (ms < max6675_previous_millis + MAX6675_HEAT_INTERVAL) + millis_t ms = millis(); + if (ms < previous_max6675_ms + MAX6675_HEAT_INTERVAL) return max6675_temp; - max6675_previous_millis = ms; + previous_max6675_ms = ms; max6675_temp = 0; #ifdef PRR diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 9fef9c12dd..293f819c92 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -22,7 +22,7 @@ int absPreheatHPBTemp; int absPreheatFanSpeed; #ifdef FILAMENT_LCD_DISPLAY - unsigned long message_millis = 0; + millis_t previous_lcd_status_ms = 0; #endif /* !Configuration settings */ @@ -77,8 +77,6 @@ static void lcd_status_screen(); static void lcd_level_bed(); #endif - static void lcd_quick_feedback();//Cause an LCD refresh, and give the user visual or audible feedback that something has happened - /* Different types of actions that can be used in menu items. */ static void menu_action_back(menuFunc_t data); static void menu_action_submenu(menuFunc_t data); @@ -220,7 +218,7 @@ static void lcd_status_screen(); volatile uint8_t slow_buttons; // Bits of the pressed buttons. #endif uint8_t currentMenuViewOffset; /* scroll offset in the current menu */ - uint32_t blocking_enc; + millis_t next_button_update_ms; uint8_t lastEncoderBits; uint32_t encoderPosition; #if (SDCARDDETECT > 0) @@ -230,7 +228,7 @@ static void lcd_status_screen(); #endif // ULTIPANEL menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ -uint32_t lcd_next_update_millis; +millis_t next_lcd_update_ms; uint8_t lcd_status_update_delay; bool ignore_click = false; bool wait_for_unclick; @@ -267,7 +265,7 @@ static void lcd_status_screen() { encoderRateMultiplierEnabled = false; #ifdef LCD_PROGRESS_BAR - unsigned long ms = millis(); + millis_t ms = millis(); #ifndef PROGRESS_MSG_ONCE if (ms > progressBarTick + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) { progressBarTick = ms; @@ -324,7 +322,7 @@ static void lcd_status_screen() { #endif ); #ifdef FILAMENT_LCD_DISPLAY - message_millis = millis(); // get status message to show up for a while + previous_lcd_status_ms = millis(); // get status message to show up for a while #endif } @@ -433,7 +431,7 @@ void lcd_set_home_offsets() { plan_set_position(0.0, 0.0, 0.0, current_position[E_AXIS]); // Audio feedback - enquecommands_P(PSTR("M300 S659 P200\nM300 S698 P200")); + enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200")); lcd_return_to_status(); } @@ -1114,15 +1112,15 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) lcd_move_y(); } static void reprapworld_keypad_move_home() { - enquecommands_P((PSTR("G28"))); // move all axis home + enqueuecommands_P((PSTR("G28"))); // move all axis home } #endif //REPRAPWORLD_KEYPAD /** End of menus **/ -static void lcd_quick_feedback() { +void lcd_quick_feedback() { lcdDrawUpdate = 2; - blocking_enc = millis() + 500; + next_button_update_ms = millis() + 500; #ifdef LCD_USE_I2C_BUZZER #ifndef LCD_FEEDBACK_FREQUENCY_HZ @@ -1140,15 +1138,15 @@ static void lcd_quick_feedback() { #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2 #endif - const unsigned int delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2; - int i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000; + const uint16_t delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2; + uint16_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000; while (i--) { WRITE(BEEPER,HIGH); delayMicroseconds(delay); WRITE(BEEPER,LOW); delayMicroseconds(delay); } - const int j = max(10000 - LCD_FEEDBACK_FREQUENCY_DURATION_MS * 1000, 0); + const uint16_t j = max(10000 - LCD_FEEDBACK_FREQUENCY_DURATION_MS * 1000, 0); if (j) delayMicroseconds(j); #endif } @@ -1156,15 +1154,15 @@ static void lcd_quick_feedback() { /** Menu action functions **/ static void menu_action_back(menuFunc_t data) { lcd_goto_menu(data); } static void menu_action_submenu(menuFunc_t data) { lcd_goto_menu(data); } -static void menu_action_gcode(const char* pgcode) { enquecommands_P(pgcode); } +static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); } static void menu_action_function(menuFunc_t data) { (*data)(); } static void menu_action_sdfile(const char* filename, char* longFilename) { char cmd[30]; char* c; sprintf_P(cmd, PSTR("M23 %s"), filename); for(c = &cmd[4]; *c; c++) *c = tolower(*c); - enquecommand(cmd); - enquecommands_P(PSTR("M24")); + enqueuecommand(cmd); + enqueuecommands_P(PSTR("M24")); lcd_return_to_status(); } static void menu_action_sddirectory(const char* filename, char* longFilename) { @@ -1252,7 +1250,7 @@ int lcd_strlen_P(const char *s) { void lcd_update() { #ifdef ULTIPANEL - static unsigned long timeoutToStatus = 0; + static millis_t return_to_status_ms = 0; #endif #ifdef LCD_HAS_SLOW_BUTTONS @@ -1282,8 +1280,8 @@ void lcd_update() { } #endif//CARDINSERTED - uint32_t ms = millis(); - if (ms > lcd_next_update_millis) { + millis_t ms = millis(); + if (ms > next_lcd_update_ms) { #ifdef ULTIPANEL @@ -1335,7 +1333,7 @@ void lcd_update() { encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP; encoderDiff = 0; } - timeoutToStatus = ms + LCD_TIMEOUT_TO_STATUS; + return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; lcdDrawUpdate = 1; } #endif //ULTIPANEL @@ -1371,20 +1369,24 @@ void lcd_update() { #endif #ifdef ULTIPANEL + + // Return to Status Screen after a timeout if (currentMenu != lcd_status_screen && - #if defined(MANUAL_BED_LEVELING) - currentMenu != _lcd_level_bed && - currentMenu != _lcd_level_bed_homing && - #endif // MANUAL_BED_LEVELING - millis() > timeoutToStatus) { + #ifdef MANUAL_BED_LEVELING + currentMenu != _lcd_level_bed && + currentMenu != _lcd_level_bed_homing && + #endif + millis() > return_to_status_ms + ) { lcd_return_to_status(); lcdDrawUpdate = 2; } - #endif //ULTIPANEL + + #endif // ULTIPANEL if (lcdDrawUpdate == 2) lcd_implementation_clear(); if (lcdDrawUpdate) lcdDrawUpdate--; - lcd_next_update_millis = millis() + LCD_UPDATE_INTERVAL; + next_lcd_update_ms = millis() + LCD_UPDATE_INTERVAL; } } @@ -1403,7 +1405,7 @@ void lcd_finishstatus(bool persist=false) { lcdDrawUpdate = 2; #ifdef FILAMENT_LCD_DISPLAY - message_millis = millis(); //get status message to show up for a while + previous_lcd_status_ms = millis(); //get status message to show up for a while #endif } @@ -1473,7 +1475,7 @@ void lcd_buttons_update() { if (READ(BTN_EN1) == 0) newbutton |= EN_A; if (READ(BTN_EN2) == 0) newbutton |= EN_B; #if BTN_ENC > 0 - if (millis() > blocking_enc && READ(BTN_ENC) == 0) newbutton |= EN_C; + if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C; #endif buttons = newbutton; #ifdef LCD_HAS_SLOW_BUTTONS @@ -1797,7 +1799,7 @@ char *ftostr52(const float &x) { if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; encoderPosition = 0; line_to_current(); - lcdDrawUpdate = 1; + lcdDrawUpdate = 2; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS])); static bool debounce_click = false; @@ -1815,7 +1817,7 @@ char *ftostr52(const float &x) { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; line_to_current(); mbl.active = 1; - enquecommands_P(PSTR("G28")); + enqueuecommands_P(PSTR("G28")); lcd_return_to_status(); } else { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; @@ -1828,7 +1830,7 @@ char *ftostr52(const float &x) { current_position[X_AXIS] = mbl.get_x(ix); current_position[Y_AXIS] = mbl.get_y(iy); line_to_current(); - lcdDrawUpdate = 1; + lcdDrawUpdate = 2; } } } else { @@ -1837,6 +1839,7 @@ char *ftostr52(const float &x) { } static void _lcd_level_bed_homing() { + if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing"); if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) { @@ -1848,6 +1851,7 @@ char *ftostr52(const float &x) { _lcd_level_bed_position = 0; lcd_goto_menu(_lcd_level_bed); } + lcdDrawUpdate = 2; } static void lcd_level_bed() { @@ -1855,7 +1859,8 @@ char *ftostr52(const float &x) { axis_known_position[Y_AXIS] = false; axis_known_position[Z_AXIS] = false; mbl.reset(); - enquecommands_P(PSTR("G28")); + enqueuecommands_P(PSTR("G28")); + lcdDrawUpdate = 2; lcd_goto_menu(_lcd_level_bed_homing); } diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index fe4f597680..b8d5cba8ad 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -49,10 +49,11 @@ extern bool cancel_heatup; #ifdef FILAMENT_LCD_DISPLAY - extern unsigned long message_millis; + extern millis_t previous_lcd_status_ms; #endif void lcd_buzz(long duration,uint16_t freq); + void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual bool lcd_clicked(); void lcd_ignore_click(bool b=true); diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index aa348018ef..2601575e3b 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -610,7 +610,7 @@ static void lcd_implementation_status_screen() { // Show Filament Diameter and Volumetric Multiplier % // After allowing lcd_status_message to show for 5 seconds - if (millis() >= message_millis + 5000) { + if (millis() >= previous_lcd_status_ms + 5000) { lcd_printPGM(PSTR("Dia ")); lcd.print(ftostr12ns(filament_width_meas)); lcd_printPGM(PSTR(" V")); @@ -724,46 +724,45 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #ifdef LCD_HAS_STATUS_INDICATORS -static void lcd_implementation_update_indicators() -{ - #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library - static uint8_t ledsprev = 0; - uint8_t leds = 0; - if (target_temperature_bed > 0) leds |= LED_A; - if (target_temperature[0] > 0) leds |= LED_B; - if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 - if (target_temperature[1] > 0) leds |= LED_C; + + static void lcd_implementation_update_indicators() { + #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) + //set the LEDS - referred to as backlights by the LiquidTWI2 library + static uint8_t ledsprev = 0; + uint8_t leds = 0; + if (target_temperature_bed > 0) leds |= LED_A; + if (target_temperature[0] > 0) leds |= LED_B; + if (fanSpeed) leds |= LED_C; + #if EXTRUDERS > 1 + if (target_temperature[1] > 0) leds |= LED_C; + #endif + if (leds != ledsprev) { + lcd.setBacklight(leds); + ledsprev = leds; + } #endif - if (leds != ledsprev) { - lcd.setBacklight(leds); - ledsprev = leds; - } - #endif -} -#endif + } + +#endif // LCD_HAS_STATUS_INDICATORS #ifdef LCD_HAS_SLOW_BUTTONS -extern uint32_t blocking_enc; -static uint8_t lcd_implementation_read_slow_buttons() -{ - #ifdef LCD_I2C_TYPE_MCP23017 - uint8_t slow_buttons; - // Reading these buttons this is likely to be too slow to call inside interrupt context - // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; - #if defined(LCD_I2C_VIKI) - if(slow_buttons & (B_MI|B_RI)) { //LCD clicked - if(blocking_enc > millis()) { - slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated - } - } + extern millis_t next_button_update_ms; + + static uint8_t lcd_implementation_read_slow_buttons() { + #ifdef LCD_I2C_TYPE_MCP23017 + uint8_t slow_buttons; + // Reading these buttons this is likely to be too slow to call inside interrupt context + // so they are called during normal lcd_update + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + #ifdef LCD_I2C_VIKI + if ((slow_buttons & (B_MI|B_RI)) && millis() < next_button_update_ms) // LCD clicked + slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated + #endif + return slow_buttons; #endif - return slow_buttons; - #endif -} -#endif + } + +#endif // LCD_HAS_SLOW_BUTTONS #endif //__ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H From e4b1e8651bdc0f96603e6a18d525df7f452d6432 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Apr 2015 23:06:50 -0700 Subject: [PATCH 037/118] next_ vars faster than previous_ - Change some `previous_` time vars to `next_` so an add only happens at intervals - Fix `HEATER_0_USES_MAX6675` polling too frequently, or not at all --- Marlin/temperature.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index f494edecf0..179023de6c 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -118,7 +118,7 @@ static volatile bool temp_meas_ready = false; static float temp_iState_min_bed; static float temp_iState_max_bed; #else //PIDTEMPBED - static millis_t previous_bed_check_ms; + static millis_t next_bed_check_ms; #endif //PIDTEMPBED static unsigned char soft_pwm[EXTRUDERS]; @@ -126,7 +126,7 @@ static volatile bool temp_meas_ready = false; static unsigned char soft_pwm_fan; #endif #if HAS_AUTO_FAN - static millis_t previous_auto_fan_check_ms; + static millis_t next_auto_fan_check_ms; #endif #ifdef PIDTEMP @@ -205,7 +205,7 @@ void PID_autotune(float temp, int extruder, int ncycles) float max = 0, min = 10000; #if HAS_AUTO_FAN - millis_t previous_auto_fan_check_ms = temp_ms; + millis_t next_auto_fan_check_ms = temp_ms + 2500; #endif if (extruder >= EXTRUDERS @@ -240,9 +240,9 @@ void PID_autotune(float temp, int extruder, int ncycles) min = min(min, input); #if HAS_AUTO_FAN - if (ms > previous_auto_fan_check_ms + 2500) { + if (ms > next_auto_fan_check_ms) { checkExtruderAutoFans(); - previous_auto_fan_check_ms = ms; + next_auto_fan_check_ms = ms + 2500; } #endif @@ -631,16 +631,16 @@ void manage_heater() { } // Extruders Loop #if HAS_AUTO_FAN - if (ms > previous_auto_fan_check_ms + 2500) { // only need to check fan state very infrequently + if (ms > next_auto_fan_check_ms) { // only need to check fan state very infrequently checkExtruderAutoFans(); - previous_auto_fan_check_ms = ms; + next_auto_fan_check_ms = ms + 2500; } #endif #ifndef PIDTEMPBED - if (ms < previous_bed_check_ms + BED_CHECK_INTERVAL) return; - previous_bed_check_ms = ms; - #endif //PIDTEMPBED + if (ms < previous_bed_check_ms) return; + next_bed_check_ms = ms + BED_CHECK_INTERVAL; + #endif #if TEMP_SENSOR_BED != 0 @@ -1109,16 +1109,18 @@ void disable_heater() { #ifdef HEATER_0_USES_MAX6675 #define MAX6675_HEAT_INTERVAL 250u - millis_t previous_max6675_ms = MAX6675_HEAT_INTERVAL; + static millis_t next_max6675_ms = 0; int max6675_temp = 2000; static int read_max6675() { millis_t ms = millis(); - if (ms < previous_max6675_ms + MAX6675_HEAT_INTERVAL) + + if (ms < next_max6675_ms) return max6675_temp; - previous_max6675_ms = ms; + next_max6675_ms = ms + MAX6675_HEAT_INTERVAL; + max6675_temp = 0; #ifdef PRR From 257a907456071e67f5b4d7aa3e85fbc6f6746d75 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 12 Apr 2015 23:17:28 -0700 Subject: [PATCH 038/118] Fix typo in next_bed_check_ms --- Marlin/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 179023de6c..9c9d6c5e08 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -638,7 +638,7 @@ void manage_heater() { #endif #ifndef PIDTEMPBED - if (ms < previous_bed_check_ms) return; + if (ms < next_bed_check_ms) return; next_bed_check_ms = ms + BED_CHECK_INTERVAL; #endif From 5a9e45cc4a5db0242a82843f10434582ef32485f Mon Sep 17 00:00:00 2001 From: Mehmet Sutas Date: Mon, 13 Apr 2015 22:37:18 +0300 Subject: [PATCH 039/118] Fix Syntax Error Filament Runout Statement --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 94c4c7bd84..1f02695284 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5921,7 +5921,7 @@ void kill() #ifdef FILAMENT_RUNOUT_SENSOR void filrunout() { - if filrunoutEnqued == false { + if (filrunoutEnqued == false) { filrunoutEnqued = true; enqueuecommand("M600"); } From 09d60e01280f622b75a098182fe3bb41d212fba8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2015 17:17:36 -0700 Subject: [PATCH 040/118] Naming and code comments --- Marlin/Marlin.h | 6 +- Marlin/Marlin_main.cpp | 613 ++++++++++-------- Marlin/configurator/config/language.h | 2 +- Marlin/dogm_lcd_implementation.h | 6 +- Marlin/language.h | 2 +- Marlin/temperature.cpp | 140 ++-- Marlin/temperature.h | 2 +- Marlin/ultralcd.cpp | 26 +- .../ultralcd_implementation_hitachi_HD44780.h | 6 +- 9 files changed, 436 insertions(+), 367 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index ad4f82bd14..0158a1d714 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -247,7 +247,7 @@ inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); } extern float homing_feedrate[]; extern bool axis_relative_modes[]; -extern int feedmultiply; +extern int feedrate_multiplier; extern bool volumetric_enabled; extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder. @@ -309,8 +309,8 @@ extern int fanSpeed; extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate; #endif -extern millis_t starttime; -extern millis_t stoptime; +extern millis_t print_job_start_ms; +extern millis_t print_job_stop_ms; // Handling multiple extruders pins extern uint8_t active_extruder; diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1f02695284..236b2be32b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -67,136 +67,149 @@ #include #endif -// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html -// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes +/** + * Look here for descriptions of G-codes: + * - http://linuxcnc.org/handbook/gcode/g-code.html + * - http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes + * + * Help us document these G-codes online: + * - http://reprap.org/wiki/G-code + * - https://github.com/MarlinFirmware/Marlin/wiki/Marlin-G-Code + */ -//Implemented Codes -//------------------- -// G0 -> G1 -// G1 - Coordinated Movement X Y Z E -// G2 - CW ARC -// G3 - CCW ARC -// G4 - Dwell S or P -// G10 - retract filament according to settings of M207 -// G11 - retract recover filament according to settings of M208 -// G28 - Home one or more axes -// G29 - Detailed Z-Probe, probes the bed at 3 or more points. Will fail if you haven't homed yet. -// G30 - Single Z Probe, probes bed at current XY location. -// G31 - Dock sled (Z_PROBE_SLED only) -// G32 - Undock sled (Z_PROBE_SLED only) -// G90 - Use Absolute Coordinates -// G91 - Use Relative Coordinates -// G92 - Set current position to coordinates given - -// M Codes -// M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) -// M1 - Same as M0 -// M17 - Enable/Power all stepper motors -// M18 - Disable all stepper motors; same as M84 -// M20 - List SD card -// M21 - Init SD card -// M22 - Release SD card -// M23 - Select SD file (M23 filename.g) -// M24 - Start/resume SD print -// M25 - Pause SD print -// M26 - Set SD position in bytes (M26 S12345) -// M27 - Report SD print status -// M28 - Start SD write (M28 filename.g) -// M29 - Stop SD write -// M30 - Delete file from SD (M30 filename.g) -// M31 - Output time since last M109 or SD card start to serial -// M32 - Select file and start SD print (Can be used _while_ printing from SD card files): -// syntax "M32 /path/filename#", or "M32 S !filename#" -// Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). -// The '#' is necessary when calling from within sd files, as it stops buffer prereading -// M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. -// M48 - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] -// M80 - Turn on Power Supply -// M81 - Turn off Power Supply -// M82 - Set E codes absolute (default) -// M83 - Set E codes relative while in Absolute Coordinates (G90) mode -// M84 - Disable steppers until next move, -// or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. -// M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) -// M92 - Set axis_steps_per_unit - same syntax as G92 -// M104 - Set extruder target temp -// M105 - Read current temp -// M106 - Fan on -// M107 - Fan off -// M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating -// Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling -// IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F -// M112 - Emergency stop -// M114 - Output current position to serial port -// M115 - Capabilities string -// M117 - display message -// M119 - Output Endstop status to serial port -// M120 - Enable endstop detection -// M121 - Disable endstop detection -// M126 - Solenoid Air Valve Open (BariCUDA support by jmil) -// M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) -// M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) -// M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) -// M140 - Set bed target temp -// M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. -// M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating -// Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling -// M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D- -// M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) -// M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! -// M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec -// M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 -// M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk -// M206 - Set additional homing offset -// M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting -// M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] -// 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. -// M218 - Set hotend offset (in mm): T X Y -// M220 - Set speed factor override percentage: S -// M221 - Set extrude factor override percentage: S -// M226 - Wait until the specified pin reaches the state required: P S -// M240 - Trigger a camera to take a photograph -// M250 - Set LCD contrast C (value 0..63) -// M280 - Set servo position absolute. P: servo index, S: angle or microseconds -// M300 - Play beep sound S P -// M301 - Set PID parameters P I and D -// M302 - Allow cold extrudes, or set the minimum extrude S. -// M303 - PID relay autotune S sets the target temperature. (default target temperature = 150C) -// M304 - Set bed PID parameters P I and D -// M380 - Activate solenoid on active extruder -// M381 - Disable all solenoids -// M400 - Finish all moves -// M401 - Lower z-probe if present -// M402 - Raise z-probe if present -// M404 - N Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Display measured filament diameter -// M500 - Store parameters in EEPROM -// M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). -// M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. -// M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. -// M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) -// M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] -// M665 - Set delta configurations: L R S -// M666 - Set delta endstop adjustment -// M605 - Set dual x-carriage movement mode: S [ X R ] -// M907 - Set digital trimpot motor current using axis codes. -// M908 - Control digital trimpot directly. -// M350 - Set microstepping mode. -// M351 - Toggle MS1 MS2 pins directly. - -// ************ SCARA Specific - This can change to suit future G-code regulations -// M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) -// M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) -// M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) -// M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) -// M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) -// M365 - SCARA calibration: Scaling factor, X, Y, Z axis -//************* SCARA End *************** - -// M928 - Start SD logging (M928 filename.g) - ended by M29 -// M999 - Restart after being stopped by error +/** + * Implemented Codes + * ------------------- + * + * "G" Codes + * + * G0 -> G1 + * G1 - Coordinated Movement X Y Z E + * G2 - CW ARC + * G3 - CCW ARC + * G4 - Dwell S or P + * G10 - retract filament according to settings of M207 + * G11 - retract recover filament according to settings of M208 + * G28 - Home one or more axes + * G29 - Detailed Z-Probe, probes the bed at 3 or more points. Will fail if you haven't homed yet. + * G30 - Single Z Probe, probes bed at current XY location. + * G31 - Dock sled (Z_PROBE_SLED only) + * G32 - Undock sled (Z_PROBE_SLED only) + * G90 - Use Absolute Coordinates + * G91 - Use Relative Coordinates + * G92 - Set current position to coordinates given + * + * "M" Codes + * + * M0 - Unconditional stop - Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled) + * M1 - Same as M0 + * M17 - Enable/Power all stepper motors + * M18 - Disable all stepper motors; same as M84 + * M20 - List SD card + * M21 - Init SD card + * M22 - Release SD card + * M23 - Select SD file (M23 filename.g) + * M24 - Start/resume SD print + * M25 - Pause SD print + * M26 - Set SD position in bytes (M26 S12345) + * M27 - Report SD print status + * M28 - Start SD write (M28 filename.g) + * M29 - Stop SD write + * M30 - Delete file from SD (M30 filename.g) + * M31 - Output time since last M109 or SD card start to serial + * M32 - Select file and start SD print (Can be used _while_ printing from SD card files): + * syntax "M32 /path/filename#", or "M32 S !filename#" + * Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). + * The '#' is necessary when calling from within sd files, as it stops buffer prereading + * M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. + * M48 - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] + * M80 - Turn on Power Supply + * M81 - Turn off Power Supply + * M82 - Set E codes absolute (default) + * M83 - Set E codes relative while in Absolute Coordinates (G90) mode + * M84 - Disable steppers until next move, + * or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout. + * M85 - Set inactivity shutdown timer with parameter S. To disable set zero (default) + * M92 - Set axis_steps_per_unit - same syntax as G92 + * M104 - Set extruder target temp + * M105 - Read current temp + * M106 - Fan on + * M107 - Fan off + * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating + * Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling + * IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F + * M112 - Emergency stop + * M114 - Output current position to serial port + * M115 - Capabilities string + * M117 - display message + * M119 - Output Endstop status to serial port + * M120 - Enable endstop detection + * M121 - Disable endstop detection + * M126 - Solenoid Air Valve Open (BariCUDA support by jmil) + * M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil) + * M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) + * M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) + * M140 - Set bed target temp + * M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. + * M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating + * Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling + * M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D- + * M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) + * M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! + * M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec + * M204 - Set default acceleration: P for Printing moves, R for Retract only (no X, Y, Z) moves and T for Travel (non printing) moves (ex. M204 P800 T3000 R9000) in mm/sec^2 + * M205 - advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk + * M206 - Set additional homing offset + * M207 - Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting + * M208 - Set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] + * 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. + * M218 - Set hotend offset (in mm): T X Y + * M220 - Set speed factor override percentage: S + * M221 - Set extrude factor override percentage: S + * M226 - Wait until the specified pin reaches the state required: P S + * M240 - Trigger a camera to take a photograph + * M250 - Set LCD contrast C (value 0..63) + * M280 - Set servo position absolute. P: servo index, S: angle or microseconds + * M300 - Play beep sound S P + * M301 - Set PID parameters P I and D + * M302 - Allow cold extrudes, or set the minimum extrude S. + * M303 - PID relay autotune S sets the target temperature. (default target temperature = 150C) + * M304 - Set bed PID parameters P I and D + * M380 - Activate solenoid on active extruder + * M381 - Disable all solenoids + * M400 - Finish all moves + * M401 - Lower z-probe if present + * M402 - Raise z-probe if present + * M404 - N Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters + * M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder + * M406 - Turn off Filament Sensor extrusion control + * M407 - Display measured filament diameter + * M500 - Store parameters in EEPROM + * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). + * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. + * M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings. + * M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) + * M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] + * M665 - Set delta configurations: L R S + * M666 - Set delta endstop adjustment + * M605 - Set dual x-carriage movement mode: S [ X R ] + * M907 - Set digital trimpot motor current using axis codes. + * M908 - Control digital trimpot directly. + * M350 - Set microstepping mode. + * M351 - Toggle MS1 MS2 pins directly. + * + * ************ SCARA Specific - This can change to suit future G-code regulations + * M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) + * M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) + * M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration) + * M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree) + * M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position) + * M365 - SCARA calibration: Scaling factor, X, Y, Z axis + * ************* SCARA End *************** + * + * M928 - Start SD logging (M928 filename.g) - ended by M29 + * M999 - Restart after being stopped by error + */ #ifdef SDSUPPORT CardReader card; @@ -210,12 +223,16 @@ static float destination[NUM_AXIS] = { 0.0 }; bool axis_known_position[3] = { false }; static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0; -static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE]; + +static int cmd_queue_index_r = 0; +static int cmd_queue_index_w = 0; +static int commands_in_queue = 0; +static char command_queue[BUFSIZE][MAX_CMD_SIZE]; float homing_feedrate[] = HOMING_FEEDRATE; bool axis_relative_modes[] = AXIS_RELATIVE_MODES; -int feedmultiply = 100; //100->1 200->2 -int saved_feedmultiply; +int feedrate_multiplier = 100; //100->1 200->2 +int saved_feedrate_multiplier; int extruder_multiply[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100, 100, 100, 100); bool volumetric_enabled = false; float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA); @@ -234,9 +251,6 @@ const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; static float offset[3] = { 0 }; static bool relative_mode = false; //Determines Absolute or Relative Coordinates -static int bufindr = 0; -static int bufindw = 0; -static int buflen = 0; static char serial_char; static int serial_count = 0; static boolean comment_mode = false; @@ -247,10 +261,10 @@ const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42 millis_t previous_cmd_ms = 0; static millis_t max_inactive_time = 0; static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L; -millis_t starttime = 0; ///< Print job start time -millis_t stoptime = 0; ///< Print job stop time +millis_t print_job_start_ms = 0; ///< Print job start time +millis_t print_job_stop_ms = 0; ///< Print job stop time static uint8_t target_extruder; -bool CooldownNoWait = true; +bool no_wait_for_cooling = true; bool target_direction; #ifdef ENABLE_AUTO_BED_LEVELING @@ -357,7 +371,7 @@ bool target_direction; #endif #ifdef FILAMENT_RUNOUT_SENSOR - static bool filrunoutEnqued = false; + static bool filrunoutEnqueued = false; #endif #ifdef SDSUPPORT @@ -410,8 +424,10 @@ void serial_echopair_P(const char *s_P, unsigned long v) { serialprintPGM(s_P); } #endif //!SDSUPPORT -//Injects the next command from the pending sequence of commands, when possible -//Return false if and only if no command was pending +/** + * Inject the next command from the command queue, when possible + * Return false only if no command was pending + */ static bool drain_queued_commands_P() { if (!queued_commands_P) return false; @@ -425,7 +441,7 @@ static bool drain_queued_commands_P() { char c; while((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command cmd[i] = '\0'; - if (enqueuecommand(cmd)) { // buffer was not full (else we will retry later) + if (enqueuecommand(cmd)) { // buffer was not full (else we will retry later) if (c) queued_commands_P += i + 1; // move to next command else @@ -434,45 +450,46 @@ static bool drain_queued_commands_P() { return true; } -//Record one or many commands to run from program memory. -//Aborts the current queue, if any. -//Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards +/** + * Record one or many commands to run from program memory. + * Aborts the current queue, if any. + * Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards + */ void enqueuecommands_P(const char* pgcode) { - queued_commands_P = pgcode; - drain_queued_commands_P(); // first command executed asap (when possible) + queued_commands_P = pgcode; + drain_queued_commands_P(); // first command executed asap (when possible) } -//adds a single command to the main command buffer, from RAM -//that is really done in a non-safe way. -//needs overworking someday -//Returns false if it failed to do so -bool enqueuecommand(const char *cmd) -{ - if(*cmd==';') - return false; - if(buflen >= BUFSIZE) - return false; - //this is dangerous if a mixing of serial and this happens - strcpy(&(cmdbuffer[bufindw][0]),cmd); +/** + * Copy a command directly into the main command buffer, from RAM. + * + * This is done in a non-safe way and needs a rework someday. + * Returns false if it doesn't add any command + */ +bool enqueuecommand(const char *cmd) { + + if (*cmd == ';' || commands_in_queue >= BUFSIZE) return false; + + // This is dangerous if a mixing of serial and this happens + char *command = command_queue[cmd_queue_index_w]; + strcpy(command, cmd); SERIAL_ECHO_START; - SERIAL_ECHOPGM(MSG_Enqueing); - SERIAL_ECHO(cmdbuffer[bufindw]); + SERIAL_ECHOPGM(MSG_Enqueueing); + SERIAL_ECHO(command); SERIAL_ECHOLNPGM("\""); - bufindw= (bufindw + 1)%BUFSIZE; - buflen += 1; + cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE; + commands_in_queue++; return true; } -void setup_killpin() -{ +void setup_killpin() { #if HAS_KILL SET_INPUT(KILL_PIN); WRITE(KILL_PIN, HIGH); #endif } -void setup_filrunoutpin() -{ +void setup_filrunoutpin() { #if HAS_FILRUNOUT pinMode(FILRUNOUT_PIN, INPUT); #ifdef ENDSTOPPULLUP_FIL_RUNOUT @@ -482,8 +499,7 @@ void setup_filrunoutpin() } // Set home pin -void setup_homepin(void) -{ +void setup_homepin(void) { #if HAS_HOME SET_INPUT(HOME_PIN); WRITE(HOME_PIN, HIGH); @@ -491,15 +507,13 @@ void setup_homepin(void) } -void setup_photpin() -{ +void setup_photpin() { #if HAS_PHOTOGRAPH OUT_WRITE(PHOTOGRAPH_PIN, LOW); #endif } -void setup_powerhold() -{ +void setup_powerhold() { #if HAS_SUICIDE OUT_WRITE(SUICIDE_PIN, HIGH); #endif @@ -512,15 +526,13 @@ void setup_powerhold() #endif } -void suicide() -{ +void suicide() { #if HAS_SUICIDE OUT_WRITE(SUICIDE_PIN, LOW); #endif } -void servo_init() -{ +void servo_init() { #if NUM_SERVOS >= 1 && HAS_SERVO_0 servos[0].attach(SERVO0_PIN); #endif @@ -547,6 +559,24 @@ void servo_init() #endif } +/** + * Marlin entry-point: Set up before the program loop + * - Set up the kill pin, filament runout, power hold + * - Start the serial port + * - Print startup messages and diagnostics + * - Get EEPROM or default settings + * - Initialize managers for: + * • temperature + * • planner + * • watchdog + * • stepper + * • photo pin + * • servos + * • LCD controller + * • Digipot I2C + * • Z probe sled + * • status LEDs + */ void setup() { setup_killpin(); setup_filrunoutpin(); @@ -587,7 +617,7 @@ void setup() { #ifdef SDSUPPORT for (int8_t i = 0; i < BUFSIZE; i++) fromsd[i] = false; - #endif // !SDSUPPORT + #endif // loads data from EEPROM if available else uses defaults (and resets step acceleration rate) Config_RetrieveSettings(); @@ -628,36 +658,54 @@ void setup() { #endif } - +/** + * The main Marlin program loop + * + * - Save or log commands to SD + * - Process available commands (if not saving) + * - Call heater manager + * - Call inactivity manager + * - Call endstop manager + * - Call LCD update + */ void loop() { - if (buflen < BUFSIZE - 1) get_command(); + if (commands_in_queue < BUFSIZE - 1) get_command(); #ifdef SDSUPPORT card.checkautostart(false); #endif - if (buflen) { + if (commands_in_queue) { + #ifdef SDSUPPORT + if (card.saving) { - if (strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL) { - card.write_command(cmdbuffer[bufindr]); - if (card.logging) - process_commands(); - else - SERIAL_PROTOCOLLNPGM(MSG_OK); - } - else { + char *command = command_queue[cmd_queue_index_r]; + if (strstr_P(command, PSTR("M29"))) { + // M29 closes the file card.closefile(); SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED); } + else { + // Write the string from the read buffer to SD + card.write_command(command); + if (card.logging) + process_commands(); // The card is saving because it's logging + else + SERIAL_PROTOCOLLNPGM(MSG_OK); + } } else process_commands(); + #else + process_commands(); + #endif // SDSUPPORT - buflen--; - bufindr = (bufindr + 1) % BUFSIZE; + + commands_in_queue--; + cmd_queue_index_r = (cmd_queue_index_r + 1) % BUFSIZE; } // Check heater every n milliseconds manage_heater(); @@ -666,12 +714,20 @@ void loop() { lcd_update(); } +/** + * Add to the circular command queue the next command from: + * - The command-injection queue (queued_commands_P) + * - The active serial input (usually USB) + * - The SD card file being actively printed + */ void get_command() { if (drain_queued_commands_P()) return; // priority is given to non-serial commands - while (MYSERIAL.available() > 0 && buflen < BUFSIZE) { + while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { + serial_char = MYSERIAL.read(); + if (serial_char == '\n' || serial_char == '\r' || serial_count >= (MAX_CMD_SIZE - 1) ) { @@ -680,16 +736,17 @@ void get_command() { if (!serial_count) return; // shortcut for empty lines - cmdbuffer[bufindw][serial_count] = 0; // terminate string + char *command = command_queue[cmd_queue_index_w]; + command[serial_count] = 0; // terminate string #ifdef SDSUPPORT - fromsd[bufindw] = false; + fromsd[cmd_queue_index_w] = false; #endif - if (strchr(cmdbuffer[bufindw], 'N') != NULL) { - strchr_pointer = strchr(cmdbuffer[bufindw], 'N'); + if (strchr(command, 'N') != NULL) { + strchr_pointer = strchr(command, 'N'); gcode_N = (strtol(strchr_pointer + 1, NULL, 10)); - if (gcode_N != gcode_LastN + 1 && strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) { + if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) { SERIAL_ERROR_START; SERIAL_ERRORPGM(MSG_ERR_LINE_NO); SERIAL_ERRORLN(gcode_LastN); @@ -699,11 +756,11 @@ void get_command() { return; } - if (strchr(cmdbuffer[bufindw], '*') != NULL) { + if (strchr(command, '*') != NULL) { byte checksum = 0; byte count = 0; - while (cmdbuffer[bufindw][count] != '*') checksum ^= cmdbuffer[bufindw][count++]; - strchr_pointer = strchr(cmdbuffer[bufindw], '*'); + while (command[count] != '*') checksum ^= command[count++]; + strchr_pointer = strchr(command, '*'); if (strtol(strchr_pointer + 1, NULL, 10) != checksum) { SERIAL_ERROR_START; @@ -728,7 +785,7 @@ void get_command() { //if no errors, continue parsing } else { // if we don't receive 'N' but still see '*' - if ((strchr(cmdbuffer[bufindw], '*') != NULL)) { + if ((strchr(command, '*') != NULL)) { SERIAL_ERROR_START; SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM); SERIAL_ERRORLN(gcode_LastN); @@ -737,8 +794,8 @@ void get_command() { } } - if (strchr(cmdbuffer[bufindw], 'G') != NULL) { - strchr_pointer = strchr(cmdbuffer[bufindw], 'G'); + if (strchr(command, 'G') != NULL) { + strchr_pointer = strchr(command, 'G'); switch (strtol(strchr_pointer + 1, NULL, 10)) { case 0: case 1: @@ -755,24 +812,24 @@ void get_command() { } // If command was e-stop process now - if (strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); + if (strcmp(command, "M112") == 0) kill(); - bufindw = (bufindw + 1) % BUFSIZE; - buflen += 1; + cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE; + commands_in_queue += 1; serial_count = 0; //clear buffer } else if (serial_char == '\\') { // Handle escapes - if (MYSERIAL.available() > 0 && buflen < BUFSIZE) { + if (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { // if we have one more character, copy it over serial_char = MYSERIAL.read(); - cmdbuffer[bufindw][serial_count++] = serial_char; + command_queue[cmd_queue_index_w][serial_count++] = serial_char; } // otherwise do nothing } else { // its not a newline, carriage return or escape char if (serial_char == ';') comment_mode = true; - if (!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; + if (!comment_mode) command_queue[cmd_queue_index_w][serial_count++] = serial_char; } } @@ -785,9 +842,9 @@ void get_command() { // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing static bool stop_buffering = false; - if (buflen == 0) stop_buffering = false; + if (commands_in_queue == 0) stop_buffering = false; - while (!card.eof() && buflen < BUFSIZE && !stop_buffering) { + while (!card.eof() && commands_in_queue < BUFSIZE && !stop_buffering) { int16_t n = card.get(); serial_char = (char)n; if (serial_char == '\n' || serial_char == '\r' || @@ -796,9 +853,9 @@ void get_command() { ) { if (card.eof()) { SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED); - stoptime = millis(); + print_job_stop_ms = millis(); char time[30]; - millis_t t = (stoptime - starttime) / 1000; + millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000; int hours = t / 60 / 60, minutes = (t / 60) % 60; sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes); SERIAL_ECHO_START; @@ -813,18 +870,18 @@ void get_command() { comment_mode = false; //for new command return; //if empty line } - cmdbuffer[bufindw][serial_count] = 0; //terminate string + command_queue[cmd_queue_index_w][serial_count] = 0; //terminate string // if (!comment_mode) { - fromsd[bufindw] = true; - buflen += 1; - bufindw = (bufindw + 1)%BUFSIZE; + fromsd[cmd_queue_index_w] = true; + commands_in_queue += 1; + cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE; // } comment_mode = false; //for new command serial_count = 0; //clear buffer } else { if (serial_char == ';') comment_mode = true; - if (!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; + if (!comment_mode) command_queue[cmd_queue_index_w][serial_count++] = serial_char; } } @@ -854,7 +911,7 @@ long code_value_long() { return strtol(strchr_pointer + 1, NULL, 10); } int16_t code_value_short() { return (int16_t)strtol(strchr_pointer + 1, NULL, 10); } bool code_seen(char code) { - strchr_pointer = strchr(cmdbuffer[bufindr], code); + strchr_pointer = strchr(command_queue[cmd_queue_index_r], code); return (strchr_pointer != NULL); //Return True if a character was found } @@ -1023,7 +1080,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, void prepare_move_raw() { refresh_cmd_timeout(); calculate_delta(destination); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedrate_multiplier/100.0), active_extruder); set_current_to_destination(); } #endif @@ -1176,8 +1233,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position, static void setup_for_endstop_move() { saved_feedrate = feedrate; - saved_feedmultiply = feedmultiply; - feedmultiply = 100; + saved_feedrate_multiplier = feedrate_multiplier; + feedrate_multiplier = 100; refresh_cmd_timeout(); enable_endstops(true); } @@ -1187,7 +1244,7 @@ inline void set_destination_to_current() { memcpy(destination, current_position, enable_endstops(false); #endif feedrate = saved_feedrate; - feedmultiply = saved_feedmultiply; + feedrate_multiplier = saved_feedrate_multiplier; refresh_cmd_timeout(); } @@ -1610,12 +1667,12 @@ static void homeaxis(AxisEnum axis) { #define SLED_DOCKING_OFFSET 0 #endif - // - // Method to dock/undock a sled designed by Charles Bell. - // - // dock[in] If true, move to MAX_X and engage the electromagnet - // offset[in] The additional distance to move to adjust docking location - // + /** + * Method to dock/undock a sled designed by Charles Bell. + * + * 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) { if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); @@ -1649,9 +1706,10 @@ static void homeaxis(AxisEnum axis) { inline void gcode_G0_G1() { if (IsRunning()) { get_coordinates(); // For X Y Z E F + #ifdef FWRETRACT - if (autoretract_enabled) - if (!(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) { + + if (autoretract_enabled && !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) { float echange = destination[E_AXIS] - current_position[E_AXIS]; // Is this move an attempt to retract or recover? if ((echange < -MIN_RETRACT && !retracted[active_extruder]) || (echange > MIN_RETRACT && retracted[active_extruder])) { @@ -1661,7 +1719,9 @@ inline void gcode_G0_G1() { return; } } + #endif //FWRETRACT + prepare_move(); //ClearToSend(); } @@ -1758,8 +1818,8 @@ inline void gcode_G28() { #endif saved_feedrate = feedrate; - saved_feedmultiply = feedmultiply; - feedmultiply = 100; + saved_feedrate_multiplier = feedrate_multiplier; + feedrate_multiplier = 100; refresh_cmd_timeout(); enable_endstops(true); @@ -2013,7 +2073,7 @@ inline void gcode_G28() { #endif feedrate = saved_feedrate; - feedmultiply = saved_feedmultiply; + feedrate_multiplier = saved_feedrate_multiplier; refresh_cmd_timeout(); endstops_hit_on_purpose(); // clear endstop hit flags } @@ -2659,7 +2719,7 @@ inline void gcode_M17() { */ inline void gcode_M24() { card.startFileprint(); - starttime = millis(); + print_job_start_ms = millis(); } /** @@ -2691,7 +2751,7 @@ inline void gcode_M17() { char* codepos = strchr_pointer + 4; char* starpos = strchr(codepos, '*'); if (starpos) { - char* npos = strchr(cmdbuffer[bufindr], 'N'); + char* npos = strchr(command_queue[cmd_queue_index_r], 'N'); strchr_pointer = strchr(npos, ' ') + 1; *(starpos) = '\0'; } @@ -2714,7 +2774,7 @@ inline void gcode_M17() { card.closefile(); char* starpos = strchr(strchr_pointer + 4, '*'); if (starpos) { - char* npos = strchr(cmdbuffer[bufindr], 'N'); + char* npos = strchr(command_queue[cmd_queue_index_r], 'N'); strchr_pointer = strchr(npos, ' ') + 1; *(starpos) = '\0'; } @@ -2728,8 +2788,8 @@ inline void gcode_M17() { * M31: Get the time since the start of SD Print (or last M109) */ inline void gcode_M31() { - stoptime = millis(); - millis_t t = (stoptime - starttime) / 1000; + print_job_stop_ms = millis(); + millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000; int min = t / 60, sec = t % 60; char time[30]; sprintf_P(time, PSTR("%i min, %i sec"), min, sec); @@ -2769,7 +2829,7 @@ inline void gcode_M31() { card.startFileprint(); if (!call_procedure) - starttime = millis(); //procedure calls count as normal print time. + print_job_start_ms = millis(); //procedure calls count as normal print time. } } @@ -2779,7 +2839,7 @@ inline void gcode_M31() { inline void gcode_M928() { char* starpos = strchr(strchr_pointer + 5, '*'); if (starpos) { - char* npos = strchr(cmdbuffer[bufindr], 'N'); + char* npos = strchr(command_queue[cmd_queue_index_r], 'N'); strchr_pointer = strchr(npos, ' ') + 1; *(starpos) = '\0'; } @@ -3185,8 +3245,8 @@ inline void gcode_M109() { LCD_MESSAGEPGM(MSG_HEATING); - CooldownNoWait = code_seen('S'); - if (CooldownNoWait || code_seen('R')) { + no_wait_for_cooling = code_seen('S'); + if (no_wait_for_cooling || code_seen('R')) { float temp = code_value(); setTargetHotend(temp, target_extruder); #ifdef DUAL_X_CARRIAGE @@ -3218,7 +3278,7 @@ inline void gcode_M109() { while((!cancel_heatup)&&((residency_start_ms == -1) || (residency_start_ms >= 0 && (((unsigned int) (millis() - residency_start_ms)) < (TEMP_RESIDENCY_TIME * 1000UL)))) ) #else - while ( target_direction ? (isHeatingHotend(target_extruder)) : (isCoolingHotend(target_extruder)&&(CooldownNoWait==false)) ) + while ( target_direction ? (isHeatingHotend(target_extruder)) : (isCoolingHotend(target_extruder)&&(no_wait_for_cooling==false)) ) #endif //TEMP_RESIDENCY_TIME { // while loop @@ -3258,7 +3318,7 @@ inline void gcode_M109() { LCD_MESSAGEPGM(MSG_HEATING_COMPLETE); refresh_cmd_timeout(); - starttime = previous_cmd_ms; + print_job_start_ms = previous_cmd_ms; } #if HAS_TEMP_BED @@ -3269,8 +3329,8 @@ inline void gcode_M109() { */ inline void gcode_M190() { LCD_MESSAGEPGM(MSG_BED_HEATING); - CooldownNoWait = code_seen('S'); - if (CooldownNoWait || code_seen('R')) + no_wait_for_cooling = code_seen('S'); + if (no_wait_for_cooling || code_seen('R')) setTargetBed(code_value()); millis_t temp_ms = millis(); @@ -3278,7 +3338,7 @@ inline void gcode_M109() { cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling - while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) ) { + while ((target_direction && !cancel_heatup) ? isHeatingBed() : isCoolingBed() && !no_wait_for_cooling) { millis_t ms = millis(); if (ms > temp_ms + 1000UL) { //Print Temp Reading every 1 second while heating up. temp_ms = ms; @@ -3371,7 +3431,7 @@ inline void gcode_M140() { * This code should ALWAYS be available for EMERGENCY SHUTDOWN! */ inline void gcode_M81() { - disable_heater(); + disable_all_heaters(); st_synchronize(); disable_e0(); disable_e1(); @@ -3803,7 +3863,7 @@ inline void gcode_M206() { default: SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND); - SERIAL_ECHO(cmdbuffer[bufindr]); + SERIAL_ECHO(command_queue[cmd_queue_index_r]); SERIAL_ECHOLNPGM("\""); return; } @@ -3849,7 +3909,7 @@ inline void gcode_M206() { * M220: Set speed percentage factor, aka "Feed Rate" (M220 S95) */ inline void gcode_M220() { - if (code_seen('S')) feedmultiply = code_value(); + if (code_seen('S')) feedrate_multiplier = code_value(); } /** @@ -4485,7 +4545,7 @@ inline void gcode_M503() { #endif #ifdef FILAMENT_RUNOUT_SENSOR - filrunoutEnqued = false; + filrunoutEnqueued = false; #endif } @@ -4619,6 +4679,9 @@ inline void gcode_M999() { FlushSerialRequestResend(); } +/** + * T0-T3: Switch tool, usually switching extruders + */ inline void gcode_T() { int tmp_extruder = code_value(); if (tmp_extruder >= EXTRUDERS) { @@ -5208,7 +5271,7 @@ void process_commands() { else { SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND); - SERIAL_ECHO(cmdbuffer[bufindr]); + SERIAL_ECHO(command_queue[cmd_queue_index_r]); SERIAL_ECHOLNPGM("\""); } @@ -5216,7 +5279,7 @@ void process_commands() { } void FlushSerialRequestResend() { - //char cmdbuffer[bufindr][100]="Resend:"; + //char command_queue[cmd_queue_index_r][100]="Resend:"; MYSERIAL.flush(); SERIAL_PROTOCOLPGM(MSG_RESEND); SERIAL_PROTOCOLLN(gcode_LastN + 1); @@ -5226,7 +5289,7 @@ void FlushSerialRequestResend() { void ClearToSend() { refresh_cmd_timeout(); #ifdef SDSUPPORT - if (fromsd[bufindr]) return; + if (fromsd[cmd_queue_index_r]) return; #endif SERIAL_PROTOCOLLNPGM(MSG_OK); } @@ -5470,7 +5533,7 @@ void prepare_move() { 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; + float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier; int steps = max(1, int(scara_segments_per_second * seconds)); //SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm); @@ -5489,7 +5552,7 @@ void prepare_move() { //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedmultiply/100.0, active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder); } #endif // SCARA @@ -5502,7 +5565,7 @@ void prepare_move() { 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; + float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier; int steps = max(1, int(delta_segments_per_second * seconds)); // SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm); @@ -5516,7 +5579,7 @@ void prepare_move() { #ifdef ENABLE_AUTO_BED_LEVELING adjust_delta(destination); #endif - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedmultiply/100.0, active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate/60*feedrate_multiplier/100.0, active_extruder); } #endif // DELTA @@ -5556,16 +5619,16 @@ void prepare_move() { #endif // DUAL_X_CARRIAGE #if !defined(DELTA) && !defined(SCARA) - // Do not use feedmultiply for E or Z only moves + // Do not use feedrate_multiplier for E or Z only moves if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) { line_to_destination(); } else { #ifdef MESH_BED_LEVELING - mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder); + mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedrate_multiplier/100.0), active_extruder); return; #else - line_to_destination(feedrate * feedmultiply / 100.0); + line_to_destination(feedrate * feedrate_multiplier / 100.0); #endif // MESH_BED_LEVELING } #endif // !(DELTA || SCARA) @@ -5577,7 +5640,7 @@ void prepare_arc_move(char isclockwise) { float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc // Trace the arc - mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedmultiply/60/100.0, r, isclockwise, active_extruder); + mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate*feedrate_multiplier/60/100.0, r, isclockwise, active_extruder); // As far as the parser is concerned, the position is now == target. In reality the // motion control system might still be processing the action and the real tool position @@ -5762,7 +5825,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { filrunout(); #endif - if (buflen < BUFSIZE - 1) get_command(); + if (commands_in_queue < BUFSIZE - 1) get_command(); millis_t ms = millis(); @@ -5898,7 +5961,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { void kill() { cli(); // Stop interrupts - disable_heater(); + disable_all_heaters(); disable_all_steppers(); @@ -5919,18 +5982,18 @@ void kill() } #ifdef FILAMENT_RUNOUT_SENSOR - void filrunout() - { - if (filrunoutEnqued == false) { - filrunoutEnqued = true; - enqueuecommand("M600"); - } - } + + void filrunout() { + if (!filrunoutEnqueued) { + filrunoutEnqueued = true; + enqueuecommand("M600"); + } + } + #endif -void Stop() -{ - disable_heater(); +void Stop() { + disable_all_heaters(); if (IsRunning()) { Running = false; Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index 5d1fd6c2fb..eb0ef8c0a1 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -110,7 +110,7 @@ // Serial Console Messages (do not translate those!) -#define MSG_Enqueing "enqueing \"" +#define MSG_Enqueueing "enqueueing \"" #define MSG_POWERUP "PowerUp" #define MSG_EXTERNAL_RESET " External Reset" #define MSG_BROWNOUT_RESET " Brown out Reset" diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 546703bfb0..3ab18af75c 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -269,8 +269,8 @@ static void lcd_implementation_status_screen() { } u8g.setPrintPos(80,48); - if (starttime != 0) { - uint16_t time = (millis() - starttime) / 60000; + if (print_job_start_ms != 0) { + uint16_t time = (millis() - print_job_start_ms) / 60000; lcd_print(itostr2(time/60)); lcd_print(':'); lcd_print(itostr2(time%60)); @@ -337,7 +337,7 @@ static void lcd_implementation_status_screen() { lcd_print(LCD_STR_FEEDRATE[0]); lcd_setFont(FONT_STATUSMENU); u8g.setPrintPos(12,49); - lcd_print(itostr3(feedmultiply)); + lcd_print(itostr3(feedrate_multiplier)); lcd_print('%'); // Status line diff --git a/Marlin/language.h b/Marlin/language.h index 179a1b9563..ba5f3f700e 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -110,7 +110,7 @@ // Serial Console Messages (do not translate those!) -#define MSG_Enqueing "enqueing \"" +#define MSG_Enqueueing "enqueueing \"" #define MSG_POWERUP "PowerUp" #define MSG_EXTERNAL_RESET " External Reset" #define MSG_BROWNOUT_RESET " Brown out Reset" diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 9c9d6c5e08..69a2877e70 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -219,7 +219,7 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN(MSG_PID_AUTOTUNE_START); - disable_heater(); // switch off all heaters. + disable_all_heaters(); // switch off all heaters. if (extruder < 0) soft_pwm_bed = bias = d = MAX_BED_POWER / 2; @@ -458,11 +458,11 @@ inline void _temp_error(int e, const char *msg1, const char *msg2) { } void max_temp_error(uint8_t e) { - disable_heater(); + disable_all_heaters(); _temp_error(e, PSTR(MSG_MAXTEMP_EXTRUDER_OFF), PSTR(MSG_ERR_MAXTEMP)); } void min_temp_error(uint8_t e) { - disable_heater(); + disable_all_heaters(); _temp_error(e, PSTR(MSG_MINTEMP_EXTRUDER_OFF), PSTR(MSG_ERR_MINTEMP)); } void bed_max_temp_error(void) { @@ -579,6 +579,14 @@ float get_pid_output(int e) { } #endif +/** + * Manage heating activities for extruder hot-ends and a heated bed + * - Acquire updated temperature readings + * - Invoke thermal runaway protection + * - Manage extruder auto-fan + * - Apply filament width to the extrusion rate (may move) + * - Update the heated bed PID output value + */ void manage_heater() { if (!temp_meas_ready) return; @@ -623,7 +631,7 @@ void manage_heater() { #ifdef TEMP_SENSOR_1_AS_REDUNDANT if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { - disable_heater(); + disable_all_heaters(); _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP)); } #endif // TEMP_SENSOR_1_AS_REDUNDANT @@ -636,7 +644,22 @@ void manage_heater() { next_auto_fan_check_ms = ms + 2500; } #endif - + + // Control the extruder rate based on the width sensor + #ifdef FILAMENT_SENSOR + if (filament_sensor) { + meas_shift_index = delay_index1 - meas_delay_cm; + if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed + + // Get the delayed info and add 100 to reconstitute to a percent of + // the nominal filament diameter then square it to get an area + meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); + float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2); + if (vm < 0.01) vm = 0.01; + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm; + } + #endif //FILAMENT_SENSOR + #ifndef PIDTEMPBED if (ms < next_bed_check_ms) return; next_bed_check_ms = ms + BED_CHECK_INTERVAL; @@ -653,16 +676,7 @@ void manage_heater() { soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0; - #elif !defined(BED_LIMIT_SWITCHING) - // Check if temperature is within the correct range - if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) { - soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0; - } - else { - soft_pwm_bed = 0; - WRITE_HEATER_BED(LOW); - } - #else //#ifdef BED_LIMIT_SWITCHING + #elif defined(BED_LIMIT_SWITCHING) // Check if temperature is within the correct band if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) { if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS) @@ -674,58 +688,47 @@ void manage_heater() { soft_pwm_bed = 0; WRITE_HEATER_BED(LOW); } + #else // BED_LIMIT_SWITCHING + // Check if temperature is within the correct range + if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) { + soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0; + } + else { + soft_pwm_bed = 0; + WRITE_HEATER_BED(LOW); + } #endif #endif //TEMP_SENSOR_BED != 0 - - // Control the extruder rate based on the width sensor - #ifdef FILAMENT_SENSOR - if (filament_sensor) { - meas_shift_index = delay_index1 - meas_delay_cm; - if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed - - // Get the delayed info and add 100 to reconstitute to a percent of - // the nominal filament diameter then square it to get an area - meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); - float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2); - if (vm < 0.01) vm = 0.01; - volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm; - } - #endif //FILAMENT_SENSOR } #define PGM_RD_W(x) (short)pgm_read_word(&x) // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. static float analog2temp(int raw, uint8_t e) { -#ifdef TEMP_SENSOR_1_AS_REDUNDANT - if (e > EXTRUDERS) -#else - if (e >= EXTRUDERS) -#endif - { + #ifdef TEMP_SENSOR_1_AS_REDUNDANT + if (e > EXTRUDERS) + #else + if (e >= EXTRUDERS) + #endif + { SERIAL_ERROR_START; SERIAL_ERROR((int)e); SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER_NUM); kill(); return 0.0; - } + } + #ifdef HEATER_0_USES_MAX6675 - if (e == 0) - { - return 0.25 * raw; - } + if (e == 0) return 0.25 * raw; #endif - if(heater_ttbl_map[e] != NULL) - { + if (heater_ttbl_map[e] != NULL) { float celsius = 0; uint8_t i; short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]); - for (i=1; i raw) - { + for (i = 1; i < heater_ttbllen_map[e]; i++) { + if (PGM_RD_W((*tt)[i][0]) > raw) { celsius = PGM_RD_W((*tt)[i-1][1]) + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / @@ -749,10 +752,8 @@ static float analog2tempBed(int raw) { float celsius = 0; byte i; - for (i=1; i raw) - { + for (i = 1; i < BEDTEMPTABLE_LEN; i++) { + if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / @@ -816,11 +817,11 @@ static void updateTemperaturesFromRawValues() { #endif - - - -void tp_init() -{ +/** + * Initialize the temperature manager + * The manager is implemented by periodic calls to manage_heater() + */ +void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector MCUCR=BIT(JTD); @@ -1059,7 +1060,7 @@ void setWatch() { SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP); if (heater_id < 0) SERIAL_ERRORLNPGM("bed"); else SERIAL_ERRORLN(heater_id); LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY); - disable_heater(); + disable_all_heaters(); disable_all_steppers(); for (;;) { manage_heater(); @@ -1070,7 +1071,7 @@ void setWatch() { #endif // HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION -void disable_heater() { +void disable_all_heaters() { for (int i=0; i= OVERSAMPLENR #ifdef BABYSTEPPING - for (uint8_t axis=X_AXIS; axis<=Z_AXIS; axis++) { - int curTodo=babystepsTodo[axis]; //get rid of volatile for performance + for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) { + int curTodo = babystepsTodo[axis]; //get rid of volatile for performance if (curTodo > 0) { babystep(axis,/*fwd*/true); - babystepsTodo[axis]--; //less to do next time + babystepsTodo[axis]--; //fewer to do next time } - else if(curTodo < 0) { + else if (curTodo < 0) { babystep(axis,/*fwd*/false); - babystepsTodo[axis]++; //less to do next time + babystepsTodo[axis]++; //fewer to do next time } } #endif //BABYSTEPPING diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 847c41b009..f9effaa9ed 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -129,7 +129,7 @@ HOTEND_ROUTINES(0); #endif int getHeaterPower(int heater); -void disable_heater(); +void disable_all_heaters(); void setWatch(); void updatePID(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 293f819c92..d0fe358ac9 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -152,10 +152,10 @@ static void lcd_status_screen(); * lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause) * menu_action_function(lcd_sdcard_pause) * - * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999) - * MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedmultiply, 10, 999) - * lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedmultiply, 10, 999) - * menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedmultiply, 10, 999) + * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999) + * MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999) + * lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999) + * menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999) * */ #define MENU_ITEM(type, label, args...) do { \ @@ -328,28 +328,28 @@ static void lcd_status_screen() { #ifdef ULTIPANEL_FEEDMULTIPLY // Dead zone at 100% feedrate - if ((feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100) || - (feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)) { + if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) || + (feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) { encoderPosition = 0; - feedmultiply = 100; + feedrate_multiplier = 100; } - if (feedmultiply == 100) { + if (feedrate_multiplier == 100) { if (int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) { - feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE; + feedrate_multiplier += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE; encoderPosition = 0; } else if (int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) { - feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE; + feedrate_multiplier += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE; encoderPosition = 0; } } else { - feedmultiply += int(encoderPosition); + feedrate_multiplier += int(encoderPosition); encoderPosition = 0; } #endif // ULTIPANEL_FEEDMULTIPLY - feedmultiply = constrain(feedmultiply, 10, 999); + feedrate_multiplier = constrain(feedrate_multiplier, 10, 999); #endif //ULTIPANEL } @@ -456,7 +456,7 @@ void lcd_set_home_offsets() { static void lcd_tune_menu() { START_MENU(); MENU_ITEM(back, MSG_MAIN, lcd_main_menu); - MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999); + MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999); #if TEMP_SENSOR_0 != 0 MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); #endif diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 2601575e3b..f9ed56a7dc 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -550,7 +550,7 @@ static void lcd_implementation_status_screen() { lcd.setCursor(0, 2); lcd.print(LCD_STR_FEEDRATE[0]); - lcd.print(itostr3(feedmultiply)); + lcd.print(itostr3(feedrate_multiplier)); lcd.print('%'); #if LCD_WIDTH > 19 && defined(SDSUPPORT) @@ -567,8 +567,8 @@ static void lcd_implementation_status_screen() { lcd.setCursor(LCD_WIDTH - 6, 2); lcd.print(LCD_STR_CLOCK[0]); - if (starttime != 0) { - uint16_t time = millis()/60000 - starttime/60000; + if (print_job_start_ms != 0) { + uint16_t time = millis()/60000 - print_job_start_ms/60000; lcd.print(itostr2(time/60)); lcd.print(':'); lcd.print(itostr2(time%60)); From 17ad80c1e10254434323cb983862108bce33ca08 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2015 17:58:47 -0700 Subject: [PATCH 041/118] Spacing in XYZ_CONSTS --- Marlin/Marlin_main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 236b2be32b..1f6a0a163e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -928,12 +928,12 @@ static const PROGMEM type array##_P[3] = \ static inline type array(int axis) \ { return pgm_read_any(&array##_P[axis]); } -XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS); -XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS); -XYZ_CONSTS_FROM_CONFIG(float, base_home_pos, HOME_POS); -XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH); -XYZ_CONSTS_FROM_CONFIG(float, home_bump_mm, HOME_BUMP_MM); -XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); +XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS); +XYZ_CONSTS_FROM_CONFIG(float, base_max_pos, MAX_POS); +XYZ_CONSTS_FROM_CONFIG(float, base_home_pos, HOME_POS); +XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH); +XYZ_CONSTS_FROM_CONFIG(float, home_bump_mm, HOME_BUMP_MM); +XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); #ifdef DUAL_X_CARRIAGE From 642f6a92bc9f1a2a80c5cff581ef6923ba8f2891 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Apr 2015 18:02:17 -0700 Subject: [PATCH 042/118] fix type of code_has_value --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1f6a0a163e..c65d88395a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -888,7 +888,7 @@ void get_command() { #endif // SDSUPPORT } -float code_has_value() { +bool code_has_value() { char c = *(strchr_pointer + 1); return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'; } From ffaf1b4f2219894c4b2caf70b24c7d3f8b6633d8 Mon Sep 17 00:00:00 2001 From: Chris Petersen Date: Thu, 9 Apr 2015 22:11:50 -0700 Subject: [PATCH 043/118] Add pin configuration for Brainwave Pro Copied from jcrocholl's contributions to the OpenBeamUSA Marlin fork --- Marlin/pins.h | 2 ++ Marlin/pins_BRAINWAVE_PRO.h | 63 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Marlin/pins_BRAINWAVE_PRO.h diff --git a/Marlin/pins.h b/Marlin/pins.h index e5af0af179..e45ba09dff 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -76,6 +76,8 @@ #include "pins_PRINTRBOARD.h" #elif MB(BRAINWAVE) #include "pins_BRAINWAVE.h" +#elif MB(BRAINWAVE_PRO) + #include "pins_BRAINWAVE_PRO.h" #elif MB(SAV_MKI) #include "pins_SAV_MKI.h" #elif MB(TEENSY2) diff --git a/Marlin/pins_BRAINWAVE_PRO.h b/Marlin/pins_BRAINWAVE_PRO.h new file mode 100644 index 0000000000..3744870467 --- /dev/null +++ b/Marlin/pins_BRAINWAVE_PRO.h @@ -0,0 +1,63 @@ +/** + * Brainwave Pro pin assignments (AT90USB186) + * + * Requires hardware bundle for Arduino: + * https://github.com/unrepentantgeek/brainwave-arduino + */ + +#ifndef __AVR_AT90USB1286__ + #error Oops! Make sure you have 'Brainwave Pro' selected from the 'Tools -> Boards' menu. +#endif + +#ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // use Teensyduino Teensy++2.0 pin assignments instead of Marlin alphabetical. + #error Uncomment #define AT90USBxx_TEENSYPP_ASSIGNMENTS in fastio.h for this config +#endif + +#define AT90USB 1286 // Disable MarlinSerial etc. + +#define X_STEP_PIN 33 +#define X_DIR_PIN 32 +#define X_ENABLE_PIN 11 +#define X_STOP_PIN 47 + +#define Y_STEP_PIN 31 +#define Y_DIR_PIN 30 +#define Y_ENABLE_PIN 8 +#define Y_STOP_PIN 18 + +#define Z_STEP_PIN 29 +#define Z_DIR_PIN 28 +#define Z_ENABLE_PIN 37 +#define Z_MAX_PIN 36 +#define Z_MIN_PIN 17 // Bed probe + +#define E0_STEP_PIN 35 +#define E0_DIR_PIN 34 +#define E0_ENABLE_PIN 13 + +#define HEATER_0_PIN 15 +#define HEATER_1_PIN -1 +#define HEATER_2_PIN -1 +#define HEATER_BED_PIN 14 // Bed +#define FAN_PIN 16 // Fan, PWM + +#define TEMP_0_PIN 2 // Extruder / Analog pin numbering +#define TEMP_1_PIN 1 // Spare / Analog pin numbering +#define TEMP_2_PIN -1 +#define TEMP_BED_PIN 0 // Bed / Analog pin numbering + +#define SDPOWER -1 +#define SDSS 20 +#define LED_PIN 19 +#define PS_ON_PIN -1 +#define KILL_PIN -1 +#define ALARM_PIN -1 +#define SDCARDDETECT 12 + +#ifndef SDSUPPORT +// these pins are defined in the SD library if building with SD support + #define SCK_PIN 21 + #define MISO_PIN 23 + #define MOSI_PIN 22 +#endif + From e0e68c5cbc9f92d48f3c1f6e46f7151f2ea9f179 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2015 03:13:25 -0700 Subject: [PATCH 044/118] Rename servos[] array in Marlin to servo[] --- Marlin/Marlin_main.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c65d88395a..475362f2c9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -379,7 +379,7 @@ bool target_direction; #endif #if NUM_SERVOS > 0 - Servo servos[NUM_SERVOS]; + Servo servo[NUM_SERVOS]; #endif #ifdef CHDK @@ -534,28 +534,28 @@ void suicide() { void servo_init() { #if NUM_SERVOS >= 1 && HAS_SERVO_0 - servos[0].attach(SERVO0_PIN); + servo[0].attach(SERVO0_PIN); #endif #if NUM_SERVOS >= 2 && HAS_SERVO_1 - servos[1].attach(SERVO1_PIN); + servo[1].attach(SERVO1_PIN); #endif #if NUM_SERVOS >= 3 && HAS_SERVO_2 - servos[2].attach(SERVO2_PIN); + servo[2].attach(SERVO2_PIN); #endif #if NUM_SERVOS >= 4 && HAS_SERVO_3 - servos[3].attach(SERVO3_PIN); + servo[3].attach(SERVO3_PIN); #endif // Set position of Servo Endstops that are defined #ifdef SERVO_ENDSTOPS for (int i = 0; i < 3; i++) if (servo_endstops[i] >= 0) - servos[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]); + servo[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]); #endif #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servos[servo_endstops[Z_AXIS]].detach(); + servo[servo_endstops[Z_AXIS]].detach(); #endif } @@ -889,7 +889,7 @@ void get_command() { } bool code_has_value() { - char c = *(strchr_pointer + 1); + char c = strchr_pointer[1]; return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'; } @@ -1255,12 +1255,12 @@ inline void set_destination_to_current() { memcpy(destination, current_position, // Engage Z Servo endstop if enabled if (servo_endstops[Z_AXIS] >= 0) { #if SERVO_LEVELING - servos[servo_endstops[Z_AXIS]].attach(0); + servo[servo_endstops[Z_AXIS]].attach(0); #endif - servos[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2]); + servo[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2]); #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servos[servo_endstops[Z_AXIS]].detach(); + servo[servo_endstops[Z_AXIS]].detach(); #endif } @@ -1319,14 +1319,14 @@ inline void set_destination_to_current() { memcpy(destination, current_position, #endif #if SERVO_LEVELING - servos[servo_endstops[Z_AXIS]].attach(0); + servo[servo_endstops[Z_AXIS]].attach(0); #endif - servos[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2 + 1]); + servo[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2 + 1]); #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servos[servo_endstops[Z_AXIS]].detach(); + servo[servo_endstops[Z_AXIS]].detach(); #endif } @@ -1520,7 +1520,7 @@ static void homeaxis(AxisEnum axis) { #endif { if (servo_endstops[axis] > -1) - servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]); + servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]); } #endif // SERVO_ENDSTOPS && !Z_PROBE_SLED @@ -1598,7 +1598,7 @@ static void homeaxis(AxisEnum axis) { // Retract Servo endstop if enabled #ifdef SERVO_ENDSTOPS if (servo_endstops[axis] > -1) - servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2 + 1]); + servo[servo_endstops[axis]].write(servo_endstop_angles[axis * 2 + 1]); #endif #if SERVO_LEVELING && !defined(Z_PROBE_SLED) @@ -3990,12 +3990,12 @@ inline void gcode_M226() { servo_position = code_value(); if ((servo_index >= 0) && (servo_index < NUM_SERVOS)) { #if SERVO_LEVELING - servos[servo_index].attach(0); + servo[servo_index].attach(0); #endif - servos[servo_index].write(servo_position); + servo[servo_index].write(servo_position); #if SERVO_LEVELING delay(PROBE_SERVO_DEACTIVATION_DELAY); - servos[servo_index].detach(); + servo[servo_index].detach(); #endif } else { @@ -4010,7 +4010,7 @@ inline void gcode_M226() { SERIAL_PROTOCOL(" Servo "); SERIAL_PROTOCOL(servo_index); SERIAL_PROTOCOL(": "); - SERIAL_PROTOCOL(servos[servo_index].read()); + SERIAL_PROTOCOL(servo[servo_index].read()); SERIAL_EOL; } } From 3f02da646c88ec0a8a332f59cede0d1901e1e251 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2015 03:41:37 -0700 Subject: [PATCH 045/118] Make sure axis_active is cleared for #1908 --- Marlin/planner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index a452428d78..060be3007e 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -393,7 +393,7 @@ void plan_init() { #endif void check_axes_activity() { - unsigned char axis_active[NUM_AXIS], + unsigned char axis_active[NUM_AXIS] = { 0 }, tail_fan_speed = fanSpeed; #ifdef BARICUDA unsigned char tail_valve_pressure = ValvePressure, From 5dd87d2e740b2f7096e6869ae67e250adfdd92f9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2015 04:05:51 -0700 Subject: [PATCH 046/118] Enable all old_z_*_endstop vars for Z_DUAL_ENDSTOPS - Potentially addressing #1911 --- Marlin/stepper.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 2ad555327d..9a243caabe 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -98,19 +98,12 @@ static volatile bool endstop_z_probe_hit = false; // Leaving this in even if Z_P #if HAS_Y_MAX static bool old_y_max_endstop = false; #endif -#if HAS_Z_MIN - static bool old_z_min_endstop = false; -#endif -#if HAS_Z_MAX - static bool old_z_max_endstop = false; -#endif + #ifdef Z_DUAL_ENDSTOPS - // #if HAS_Z2_MIN - static bool old_z2_min_endstop = false; - // #endif - // #if HAS_Z2_MAX - static bool old_z2_max_endstop = false; - // #endif + static bool old_z_min_endstop = false; + static bool old_z_max_endstop = false; + static bool old_z2_min_endstop = false; + static bool old_z2_max_endstop = false; #endif #ifdef Z_PROBE_ENDSTOP // No need to check for valid pin, SanityCheck.h already does this. From 7336e6df070a2f20e5f2cb9b3ac2d40c9da0c8c4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 14 Apr 2015 04:55:20 -0700 Subject: [PATCH 047/118] Always define old_z, not always z2 --- Marlin/stepper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 9a243caabe..f11cc04301 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -99,9 +99,10 @@ static volatile bool endstop_z_probe_hit = false; // Leaving this in even if Z_P static bool old_y_max_endstop = false; #endif +static bool old_z_min_endstop = false; +static bool old_z_max_endstop = false; + #ifdef Z_DUAL_ENDSTOPS - static bool old_z_min_endstop = false; - static bool old_z_max_endstop = false; static bool old_z2_min_endstop = false; static bool old_z2_max_endstop = false; #endif From 3851ac62264bfc1e1e462e6ab0300956c5aa6ef9 Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Tue, 14 Apr 2015 17:12:42 +0200 Subject: [PATCH 048/118] Example Configuration for K8200 back in sync example_configurations\K8200\Configuration.h: * merge upstream changes from default Configuration.h manually * add some machine specific comments --- .../K8200/Configuration.h | 90 +++++++++++++++---- 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index df0614b507..1cde25fca3 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -31,10 +31,12 @@ Here are some standard links for getting your machine calibrated: //=========================================================================== //============================= SCARA Printer =============================== //=========================================================================== -// For a Delta printer replace the configuration files with the files in the +// For a Scara printer replace the configuration files with the files in the // example_configurations/SCARA directory. // +// @section info + // User-specified version info of this build to display in [Pronterface, etc] terminal window during // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. @@ -45,12 +47,16 @@ Here are some standard links for getting your machine calibrated: #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 //#define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H // will be shown during bootup in line2 +// @section machine + // SERIAL_PORT selects which serial port should be used for communication with the host. // This allows the connection of wireless adapters (for instance) to non-default port pins. // Serial port 0 is still used by the Arduino bootloader regardless of this setting. +// :[0,1,2,3,4,5,6,7] #define SERIAL_PORT 0 // This determines the communication speed of the printer +// :[2400,9600,19200,38400,57600,115200,250000] #define BAUDRATE 250000 // This enables the serial port associated to the Bluetooth interface @@ -71,17 +77,27 @@ Here are some standard links for getting your machine calibrated: // #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" // This defines the number of extruders +// :[1,2,3,4] #define EXTRUDERS 1 +// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). +// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). +// For the other hotends it is their distance from the extruder 0 hotend. +//#define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis +//#define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis + //// The following define selects which power supply you have. Please choose the one that matches your setup // 1 = ATX // 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC) +// :{1:'ATX',2:'X-Box 360'} #define POWER_SUPPLY 1 // Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it. // #define PS_DEFAULT_OFF +// @section temperature + //=========================================================================== //============================= Thermal Settings ============================ //=========================================================================== @@ -245,7 +261,7 @@ Here are some standard links for getting your machine calibrated: // #define DEFAULT_bedKi 1.41 // #define DEFAULT_bedKd 1675.16 -//Vellemann K8200 PCB heatbed with standard PCU - calculated with PID Autotune and tested +//Vellemann K8200 PCB heatbed with standard PCU at 60 degreesC - calculated with PID Autotune and tested //from pidautotune #define DEFAULT_bedKp 341.88 #define DEFAULT_bedKi 25.32 @@ -254,6 +270,7 @@ Here are some standard links for getting your machine calibrated: // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED +// @section extruder //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit //can be software-disabled for whatever purposes by @@ -308,12 +325,16 @@ your extruder heater takes 2 minutes to hit the target on heating. //============================= Mechanical Settings ========================= //=========================================================================== +// @section machine + // Uncomment this option to enable CoreXY kinematics // #define COREXY // Enable this option for Toshiba steppers // #define CONFIG_STEPPERS_TOSHIBA +// @section homing + // coarse Endstop Settings #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors @@ -325,6 +346,7 @@ your extruder heater takes 2 minutes to hit the target on heating. #define ENDSTOPPULLUP_XMIN #define ENDSTOPPULLUP_YMIN #define ENDSTOPPULLUP_ZMIN + // #define ENDSTOPPULLUP_ZPROBE #endif // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). @@ -338,7 +360,15 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS +// @section machine +// If you want to enable the Z Probe pin, but disable its use, uncomment the line below. +// This only affects a Z Probe Endstop if you have separate Z min endstop as well and have +// activated Z_PROBE_ENDSTOP below. If you are using the Z Min endstop on your Z Probe, +// this has no effect. +//#define DISABLE_Z_PROBE_ENDSTOP + // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 +// :{0:'Low',1:'High'} #define X_ENABLE_ON 0 #define Y_ENABLE_ON 0 #define Z_ENABLE_ON 0 @@ -348,20 +378,32 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z true + +// @section extruder + #define DISABLE_E false // For all extruders #define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled +// @section machine + // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false #define INVERT_Y_DIR false #define INVERT_Z_DIR false -#define INVERT_E0_DIR true + +// @section extruder + +// For direct drive extruder v9 set to true, for geared extruder set to false. +#define INVERT_E0_DIR true // K8200: true for geared default extruder! #define INVERT_E1_DIR true #define INVERT_E2_DIR true #define INVERT_E3_DIR true +// @section homing + // ENDSTOP SETTINGS: // Sets direction of endstops when homing; 1=MAX, -1=MIN +// :[-1,1] #define X_HOME_DIR -1 #define Y_HOME_DIR -1 #define Z_HOME_DIR -1 @@ -369,6 +411,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS. #define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below. +// @section machine + // Travel limits after homing (units are in mm) #define X_MIN_POS 0 #define Y_MIN_POS 0 @@ -388,14 +432,14 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. //=========================================================================== -//============================ Manual Bed Leveling ========================== +//============================ Mesh Bed Leveling ============================ //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling // #define MESH_BED_LEVELING // Enable mesh bed leveling #ifdef MANUAL_BED_LEVELING - #define MBL_Z_STEP 0.025 + #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis #endif // MANUAL_BED_LEVELING #ifdef MESH_BED_LEVELING @@ -412,6 +456,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //============================= Bed Auto Leveling =========================== //=========================================================================== +// @section bedlevel + //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) #define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled. @@ -520,6 +566,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // ENABLE_AUTO_BED_LEVELING +// @section homing + // The position of the homing switches //#define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used //#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0) @@ -533,6 +581,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing. #endif +// @section movement + /** * MOVEMENT SETTINGS */ @@ -549,13 +599,6 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define DEFAULT_RETRACT_ACCELERATION 1000 // E acceleration in mm/s^2 for retracts #define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves - -// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). -// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). -// For the other hotends it is their distance from the extruder 0 hotend. -// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis -// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis - // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) #define DEFAULT_XYJERK 20.0 // (mm/sec) #define DEFAULT_ZJERK 0.4 // (mm/sec) @@ -566,6 +609,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //============================= Additional Features =========================== //============================================================================= +// @section more + // Custom M code points #define CUSTOM_M_CODES #ifdef CUSTOM_M_CODES @@ -576,6 +621,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif #endif +// @section extras // EEPROM // The microcontroller can store settings in the EEPROM, e.g. max velocity... @@ -590,26 +636,30 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define EEPROM_CHITCHAT // please keep turned on if you can. #endif + +// @section temperature + // Preheat Constants #define PLA_PREHEAT_HOTEND_TEMP 190 -#define PLA_PREHEAT_HPB_TEMP 50 +#define PLA_PREHEAT_HPB_TEMP 50 // K8200: set back to 70 if you have an upgraded heatbed power supply #define PLA_PREHEAT_FAN_SPEED 0 // Insert Value between 0 and 255 #define ABS_PREHEAT_HOTEND_TEMP 240 -#define ABS_PREHEAT_HPB_TEMP 60 +#define ABS_PREHEAT_HPB_TEMP 60 // K8200: set back to 110 if you have an upgraded heatbed power supply #define ABS_PREHEAT_FAN_SPEED 0 // Insert Value between 0 and 255 //==============================LCD and SD support============================= +// @section lcd // Define your display language below. Replace (en) with your language code and uncomment. // en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test // See also language.h -//#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) +#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) // Choose ONE of these 3 charsets. This has to match your hardware. Ignored for full graphic display. // To find out what type you have - compile with (test) - upload - click to get the menu. You'll see two typical lines from the upper half of the charset. // See also documentation/LCDLanguageFont.md - #define DISPLAY_CHARSET_HD44780_JAPAN // this is the most common hardware + #define DISPLAY_CHARSET_HD44780_JAPAN // K8200: for Display VM8201 // this is the most common hardware //#define DISPLAY_CHARSET_HD44780_WESTERN //#define DISPLAY_CHARSET_HD44780_CYRILLIC @@ -620,7 +670,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking -#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. +#define ULTIMAKERCONTROLLER // K8200: for Display VM8201 // as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click @@ -683,6 +733,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define SAV_3DLCD +// @section extras + // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino //#define FAST_PWM_FAN @@ -706,7 +758,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // Data from: http://www.doc-diy.net/photo/rc-1_hacked/ // #define PHOTOGRAPH_PIN 23 -// SF send wrong arc g-codes when using Arc Point as fillet procedure +// SkeinForge sends the wrong arc g-codes when using Arc Point as fillet procedure //#define SF_ARC_FIX // Support for the BariCUDA Paste Extruder. @@ -760,7 +812,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY From cb9ac490d4043356f64a3ef9d67b438c2fd6bfd8 Mon Sep 17 00:00:00 2001 From: elgambitero Date: Tue, 14 Apr 2015 23:14:52 +0200 Subject: [PATCH 049/118] Some minor translations to spanish --- Marlin/language_es.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/language_es.h b/Marlin/language_es.h index 92f903cebc..168dd0a658 100644 --- a/Marlin/language_es.h +++ b/Marlin/language_es.h @@ -17,7 +17,7 @@ #define MSG_SD_INSERTED "Tarjeta colocada" #define MSG_SD_REMOVED "Tarjeta retirada" #define MSG_MAIN "Menu principal" -#define MSG_AUTOSTART " Autostart" +#define MSG_AUTOSTART "Autostart" #define MSG_DISABLE_STEPPERS "Apagar motores" #define MSG_AUTO_HOME "Llevar al origen" #define MSG_SET_HOME_OFFSETS "Ajustar offsets" @@ -46,7 +46,7 @@ #define MSG_MOVE_1MM "Mover 1mm" #define MSG_MOVE_10MM "Mover 10mm" #define MSG_SPEED "Velocidad" -#define MSG_NOZZLE "Nozzle" +#define MSG_NOZZLE "Fusor" #define MSG_BED "Base" #define MSG_FAN_SPEED "Ventilador" #define MSG_FLOW "Flujo" @@ -80,7 +80,7 @@ #define MSG_ESTEPS "E pasos/mm" #define MSG_TEMPERATURE "Temperatura" #define MSG_MOTION "Movimiento" -#define MSG_VOLUMETRIC "Filament" +#define MSG_VOLUMETRIC "Filamento" #define MSG_VOLUMETRIC_ENABLED "E in mm3" #define MSG_FILAMENT_SIZE_EXTRUDER_0 "Fil. Dia. 1" #define MSG_FILAMENT_SIZE_EXTRUDER_1 "Fil. Dia. 2" @@ -116,22 +116,22 @@ #define MSG_FILAMENTCHANGE "Cambiar filamento" #define MSG_INIT_SDCARD "Iniciando tarjeta" #define MSG_CNG_SDCARD "Cambiar tarjeta" -#define MSG_ZPROBE_OUT "sonda Z fuera" +#define MSG_ZPROBE_OUT "Sonda Z fuera" #define MSG_POSITION_UNKNOWN "Reiniciar X/Y y Z" #define MSG_ZPROBE_ZOFFSET "Offset Z" -#define MSG_BABYSTEP_X "Babystep X" -#define MSG_BABYSTEP_Y "Babystep Y" -#define MSG_BABYSTEP_Z "Babystep Z" +#define MSG_BABYSTEP_X "Micropaso X" +#define MSG_BABYSTEP_Y "Micropaso Y" +#define MSG_BABYSTEP_Z "Micropaso Z" #define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_END_HOUR "horas" #define MSG_END_MINUTE "minutos" #ifdef DELTA_CALIBRATION_MENU - #define MSG_DELTA_CALIBRATE "Delta Calibration" - #define MSG_DELTA_CALIBRATE_X "Calibrate X" - #define MSG_DELTA_CALIBRATE_Y "Calibrate Y" - #define MSG_DELTA_CALIBRATE_Z "Calibrate Z" - #define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center" + #define MSG_DELTA_CALIBRATE "Calibracion Delta" + #define MSG_DELTA_CALIBRATE_X "Calibrar X" + #define MSG_DELTA_CALIBRATE_Y "Calibrar Y" + #define MSG_DELTA_CALIBRATE_Z "Calibrar Z" + #define MSG_DELTA_CALIBRATE_CENTER "Calibrar Centro" #endif // DELTA_CALIBRATION_MENU #endif // LANGUAGE_ES_H From 0af5e3a04f48abe9c0972d3f7d95ce67d01f2d82 Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Wed, 15 Apr 2015 10:00:41 +0200 Subject: [PATCH 050/118] Example Configuration for K8200: comments/URL/readme Example Configuration for K8200 : comments/URL/readme example_configurations\K8200\Configuration.h: * add machine specific header * change STRING_URL to K8200 fork (@thinkyhead: What do you think?) example_configurations\K8200\readme.md: * updated documentation * added URLs and links --- Marlin/example_configurations/K8200/Configuration.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 1cde25fca3..6f47b972ff 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -1,4 +1,9 @@ -#ifndef CONFIGURATION_H +// Example configuration file for Vellemann K8200 +// tested on K8200 with VM8201 (Display) +// and Arduino 1.6.1 (Win) by @CONSULitAS, 2015-04-14 +// https://github.com/CONSULitAS/Marlin-K8200/archive/K8200_stable_2015-04-14.zip + +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" @@ -41,7 +46,7 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" +#define STRING_URL "https://github.com/CONSULitAS/Marlin-K8200/" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(K8200, CONSULitAS)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 From 1de9b568dbb8f489ce2d8afd76db4bad850d1434 Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Wed, 15 Apr 2015 10:02:13 +0200 Subject: [PATCH 051/118] Example Configuration for K8200: comments/URL/readme Example Configuration for K8200 : comments/URL/readme example_configurations\K8200\Configuration.h: * add machine specific header * change STRING_URL to K8200 fork (@thinkyhead: What do you think?) example_configurations\K8200\readme.md: * updated documentation * added URLs and links --- Marlin/example_configurations/K8200/readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/example_configurations/K8200/readme.md b/Marlin/example_configurations/K8200/readme.md index 7f0761360a..bb29f51c1d 100644 --- a/Marlin/example_configurations/K8200/readme.md +++ b/Marlin/example_configurations/K8200/readme.md @@ -1,5 +1,5 @@ -# Example Configuration for Vellemann K8200 -* Configuration files for **Vellemann K8200** (with VM8201 - LCD Option for K8200) +# Example Configuration for Vellemann [K8200](http://www.k8200.eu/) +* Configuration files for **Vellemann K8200** (with [VM8201](http://www.vellemanprojects.eu/products/view/?id=416158) - LCD Option for K8200) * K8200 is a 3Drag clone - configuration should work with 3Drag http://reprap.org/wiki/3drag, too. Please report. * updated manually with parameters from genuine Vellemann Firmware "firmware_k8200_marlinv2" based on the recent development branch @@ -7,14 +7,14 @@ * VM8201 uses "DISPLAY_CHARSET_HD44870_JAPAN" and "ULTIMAKERCONTROLLER" * german (de) translation with umlaut is supported now - thanks to @AnHardt for the great hardware based umlaut support -I (@CONSULitAS) tested the changes on my K8200 with 20x4-LCD and Arduino 1.0.5 for Windows (SD library added to IDE manually) - everything works well. +I [@CONSULitAS](https://github.com/CONSULitAS) tested the changes on my K8200 with 20x4-LCD and Arduino 1.6.1 for Windows (SD library added to IDE manually) - everything works well. -**Source for genuine Vellemann Firmware V2 (with LCD/SD-Support):** -* [firmware_k8200_v2.1.1.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_v2.1.1.zip) +**Source for genuine [Vellemann Firmware](http://www.k8200.eu/support/downloads/)** +* V2.1.1 (for z axis upgrade, date branched: 2013-06-05): [firmware_k8200_v2.1.1.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_v2.1.1.zip) * see also https://github.com/CONSULitAS/Marlin-K8200/tree/Vellemann_firmware_k8200_v2.1.1.zip -* [firmware_k8200_marlinv2.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv2.zip) +* V2 (with LCD/SD-Support, date branched: 2013-06-05): [firmware_k8200_marlinv2.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv2.zip) * see also https://github.com/CONSULitAS/Marlin-K8200/tree/Vellemann_firmware_k8200_marlinv2.zip -* [firmware_k8200_marlinv1.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv1.zip) +* V1 (without LCD/SD-Support, date branched: 2012-10-02): [firmware_k8200_marlinv1.zip](http://www.k8200.eu/downloads/files/downloads/firmware_k8200_marlinv1.zip) * see also https://github.com/CONSULitAS/Marlin-K8200/tree/Vellemann_firmware_k8200_marlinv1.zip From a40c274310ca716a95da66a20e817efb790e6315 Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Tue, 14 Apr 2015 17:12:42 +0200 Subject: [PATCH 052/118] Example Configuration for K8200 back in sync example_configurations\K8200\Configuration.h: * merge upstream changes from default Configuration.h manually * add some machine specific comments --- .../K8200/Configuration.h | 90 +++++++++++++++---- 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index df0614b507..1cde25fca3 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -31,10 +31,12 @@ Here are some standard links for getting your machine calibrated: //=========================================================================== //============================= SCARA Printer =============================== //=========================================================================== -// For a Delta printer replace the configuration files with the files in the +// For a Scara printer replace the configuration files with the files in the // example_configurations/SCARA directory. // +// @section info + // User-specified version info of this build to display in [Pronterface, etc] terminal window during // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. @@ -45,12 +47,16 @@ Here are some standard links for getting your machine calibrated: #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 //#define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H // will be shown during bootup in line2 +// @section machine + // SERIAL_PORT selects which serial port should be used for communication with the host. // This allows the connection of wireless adapters (for instance) to non-default port pins. // Serial port 0 is still used by the Arduino bootloader regardless of this setting. +// :[0,1,2,3,4,5,6,7] #define SERIAL_PORT 0 // This determines the communication speed of the printer +// :[2400,9600,19200,38400,57600,115200,250000] #define BAUDRATE 250000 // This enables the serial port associated to the Bluetooth interface @@ -71,17 +77,27 @@ Here are some standard links for getting your machine calibrated: // #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" // This defines the number of extruders +// :[1,2,3,4] #define EXTRUDERS 1 +// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). +// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). +// For the other hotends it is their distance from the extruder 0 hotend. +//#define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis +//#define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis + //// The following define selects which power supply you have. Please choose the one that matches your setup // 1 = ATX // 2 = X-Box 360 203Watts (the blue wire connected to PS_ON and the red wire to VCC) +// :{1:'ATX',2:'X-Box 360'} #define POWER_SUPPLY 1 // Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it. // #define PS_DEFAULT_OFF +// @section temperature + //=========================================================================== //============================= Thermal Settings ============================ //=========================================================================== @@ -245,7 +261,7 @@ Here are some standard links for getting your machine calibrated: // #define DEFAULT_bedKi 1.41 // #define DEFAULT_bedKd 1675.16 -//Vellemann K8200 PCB heatbed with standard PCU - calculated with PID Autotune and tested +//Vellemann K8200 PCB heatbed with standard PCU at 60 degreesC - calculated with PID Autotune and tested //from pidautotune #define DEFAULT_bedKp 341.88 #define DEFAULT_bedKi 25.32 @@ -254,6 +270,7 @@ Here are some standard links for getting your machine calibrated: // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED +// @section extruder //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit //can be software-disabled for whatever purposes by @@ -308,12 +325,16 @@ your extruder heater takes 2 minutes to hit the target on heating. //============================= Mechanical Settings ========================= //=========================================================================== +// @section machine + // Uncomment this option to enable CoreXY kinematics // #define COREXY // Enable this option for Toshiba steppers // #define CONFIG_STEPPERS_TOSHIBA +// @section homing + // coarse Endstop Settings #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors @@ -325,6 +346,7 @@ your extruder heater takes 2 minutes to hit the target on heating. #define ENDSTOPPULLUP_XMIN #define ENDSTOPPULLUP_YMIN #define ENDSTOPPULLUP_ZMIN + // #define ENDSTOPPULLUP_ZPROBE #endif // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup). @@ -338,7 +360,15 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS +// @section machine +// If you want to enable the Z Probe pin, but disable its use, uncomment the line below. +// This only affects a Z Probe Endstop if you have separate Z min endstop as well and have +// activated Z_PROBE_ENDSTOP below. If you are using the Z Min endstop on your Z Probe, +// this has no effect. +//#define DISABLE_Z_PROBE_ENDSTOP + // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 +// :{0:'Low',1:'High'} #define X_ENABLE_ON 0 #define Y_ENABLE_ON 0 #define Z_ENABLE_ON 0 @@ -348,20 +378,32 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z true + +// @section extruder + #define DISABLE_E false // For all extruders #define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled +// @section machine + // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false #define INVERT_Y_DIR false #define INVERT_Z_DIR false -#define INVERT_E0_DIR true + +// @section extruder + +// For direct drive extruder v9 set to true, for geared extruder set to false. +#define INVERT_E0_DIR true // K8200: true for geared default extruder! #define INVERT_E1_DIR true #define INVERT_E2_DIR true #define INVERT_E3_DIR true +// @section homing + // ENDSTOP SETTINGS: // Sets direction of endstops when homing; 1=MAX, -1=MIN +// :[-1,1] #define X_HOME_DIR -1 #define Y_HOME_DIR -1 #define Z_HOME_DIR -1 @@ -369,6 +411,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS. #define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below. +// @section machine + // Travel limits after homing (units are in mm) #define X_MIN_POS 0 #define Y_MIN_POS 0 @@ -388,14 +432,14 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. //=========================================================================== -//============================ Manual Bed Leveling ========================== +//============================ Mesh Bed Leveling ============================ //=========================================================================== // #define MANUAL_BED_LEVELING // Add display menu option for bed leveling // #define MESH_BED_LEVELING // Enable mesh bed leveling #ifdef MANUAL_BED_LEVELING - #define MBL_Z_STEP 0.025 + #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis #endif // MANUAL_BED_LEVELING #ifdef MESH_BED_LEVELING @@ -412,6 +456,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //============================= Bed Auto Leveling =========================== //=========================================================================== +// @section bedlevel + //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line) #define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled. @@ -520,6 +566,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif // ENABLE_AUTO_BED_LEVELING +// @section homing + // The position of the homing switches //#define MANUAL_HOME_POSITIONS // If defined, MANUAL_*_HOME_POS below will be used //#define BED_CENTER_AT_0_0 // If defined, the center of the bed is at (X=0, Y=0) @@ -533,6 +581,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing. #endif +// @section movement + /** * MOVEMENT SETTINGS */ @@ -549,13 +599,6 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define DEFAULT_RETRACT_ACCELERATION 1000 // E acceleration in mm/s^2 for retracts #define DEFAULT_TRAVEL_ACCELERATION 1000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves - -// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). -// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). -// For the other hotends it is their distance from the extruder 0 hotend. -// #define EXTRUDER_OFFSET_X {0.0, 20.00} // (in mm) for each extruder, offset of the hotend on the X axis -// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis - // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) #define DEFAULT_XYJERK 20.0 // (mm/sec) #define DEFAULT_ZJERK 0.4 // (mm/sec) @@ -566,6 +609,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //============================= Additional Features =========================== //============================================================================= +// @section more + // Custom M code points #define CUSTOM_M_CODES #ifdef CUSTOM_M_CODES @@ -576,6 +621,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #endif #endif +// @section extras // EEPROM // The microcontroller can store settings in the EEPROM, e.g. max velocity... @@ -590,26 +636,30 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define EEPROM_CHITCHAT // please keep turned on if you can. #endif + +// @section temperature + // Preheat Constants #define PLA_PREHEAT_HOTEND_TEMP 190 -#define PLA_PREHEAT_HPB_TEMP 50 +#define PLA_PREHEAT_HPB_TEMP 50 // K8200: set back to 70 if you have an upgraded heatbed power supply #define PLA_PREHEAT_FAN_SPEED 0 // Insert Value between 0 and 255 #define ABS_PREHEAT_HOTEND_TEMP 240 -#define ABS_PREHEAT_HPB_TEMP 60 +#define ABS_PREHEAT_HPB_TEMP 60 // K8200: set back to 110 if you have an upgraded heatbed power supply #define ABS_PREHEAT_FAN_SPEED 0 // Insert Value between 0 and 255 //==============================LCD and SD support============================= +// @section lcd // Define your display language below. Replace (en) with your language code and uncomment. // en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test // See also language.h -//#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) +#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) // Choose ONE of these 3 charsets. This has to match your hardware. Ignored for full graphic display. // To find out what type you have - compile with (test) - upload - click to get the menu. You'll see two typical lines from the upper half of the charset. // See also documentation/LCDLanguageFont.md - #define DISPLAY_CHARSET_HD44780_JAPAN // this is the most common hardware + #define DISPLAY_CHARSET_HD44780_JAPAN // K8200: for Display VM8201 // this is the most common hardware //#define DISPLAY_CHARSET_HD44780_WESTERN //#define DISPLAY_CHARSET_HD44780_CYRILLIC @@ -620,7 +670,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking -#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. +#define ULTIMAKERCONTROLLER // K8200: for Display VM8201 // as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click @@ -683,6 +733,8 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define SAV_3DLCD +// @section extras + // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino //#define FAST_PWM_FAN @@ -706,7 +758,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // Data from: http://www.doc-diy.net/photo/rc-1_hacked/ // #define PHOTOGRAPH_PIN 23 -// SF send wrong arc g-codes when using Arc Point as fillet procedure +// SkeinForge sends the wrong arc g-codes when using Arc Point as fillet procedure //#define SF_ARC_FIX // Support for the BariCUDA Paste Extruder. @@ -760,7 +812,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY From 60f46276bf0b6d8cff3834326000caf5e117331e Mon Sep 17 00:00:00 2001 From: elgambitero Date: Tue, 14 Apr 2015 23:14:52 +0200 Subject: [PATCH 053/118] Some minor translations to spanish --- Marlin/language_es.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/language_es.h b/Marlin/language_es.h index 92f903cebc..168dd0a658 100644 --- a/Marlin/language_es.h +++ b/Marlin/language_es.h @@ -17,7 +17,7 @@ #define MSG_SD_INSERTED "Tarjeta colocada" #define MSG_SD_REMOVED "Tarjeta retirada" #define MSG_MAIN "Menu principal" -#define MSG_AUTOSTART " Autostart" +#define MSG_AUTOSTART "Autostart" #define MSG_DISABLE_STEPPERS "Apagar motores" #define MSG_AUTO_HOME "Llevar al origen" #define MSG_SET_HOME_OFFSETS "Ajustar offsets" @@ -46,7 +46,7 @@ #define MSG_MOVE_1MM "Mover 1mm" #define MSG_MOVE_10MM "Mover 10mm" #define MSG_SPEED "Velocidad" -#define MSG_NOZZLE "Nozzle" +#define MSG_NOZZLE "Fusor" #define MSG_BED "Base" #define MSG_FAN_SPEED "Ventilador" #define MSG_FLOW "Flujo" @@ -80,7 +80,7 @@ #define MSG_ESTEPS "E pasos/mm" #define MSG_TEMPERATURE "Temperatura" #define MSG_MOTION "Movimiento" -#define MSG_VOLUMETRIC "Filament" +#define MSG_VOLUMETRIC "Filamento" #define MSG_VOLUMETRIC_ENABLED "E in mm3" #define MSG_FILAMENT_SIZE_EXTRUDER_0 "Fil. Dia. 1" #define MSG_FILAMENT_SIZE_EXTRUDER_1 "Fil. Dia. 2" @@ -116,22 +116,22 @@ #define MSG_FILAMENTCHANGE "Cambiar filamento" #define MSG_INIT_SDCARD "Iniciando tarjeta" #define MSG_CNG_SDCARD "Cambiar tarjeta" -#define MSG_ZPROBE_OUT "sonda Z fuera" +#define MSG_ZPROBE_OUT "Sonda Z fuera" #define MSG_POSITION_UNKNOWN "Reiniciar X/Y y Z" #define MSG_ZPROBE_ZOFFSET "Offset Z" -#define MSG_BABYSTEP_X "Babystep X" -#define MSG_BABYSTEP_Y "Babystep Y" -#define MSG_BABYSTEP_Z "Babystep Z" +#define MSG_BABYSTEP_X "Micropaso X" +#define MSG_BABYSTEP_Y "Micropaso Y" +#define MSG_BABYSTEP_Z "Micropaso Z" #define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_END_HOUR "horas" #define MSG_END_MINUTE "minutos" #ifdef DELTA_CALIBRATION_MENU - #define MSG_DELTA_CALIBRATE "Delta Calibration" - #define MSG_DELTA_CALIBRATE_X "Calibrate X" - #define MSG_DELTA_CALIBRATE_Y "Calibrate Y" - #define MSG_DELTA_CALIBRATE_Z "Calibrate Z" - #define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center" + #define MSG_DELTA_CALIBRATE "Calibracion Delta" + #define MSG_DELTA_CALIBRATE_X "Calibrar X" + #define MSG_DELTA_CALIBRATE_Y "Calibrar Y" + #define MSG_DELTA_CALIBRATE_Z "Calibrar Z" + #define MSG_DELTA_CALIBRATE_CENTER "Calibrar Centro" #endif // DELTA_CALIBRATION_MENU #endif // LANGUAGE_ES_H From f8389b10768fcf0d04633a70fdeafa96742cb384 Mon Sep 17 00:00:00 2001 From: Bo Herrmannsen Date: Wed, 15 Apr 2015 15:25:18 +0200 Subject: [PATCH 054/118] Update README.md --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7cb93c7e26..eeb9091301 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ This firmware is a mashup between [Sprinter](https://github.com/kliment/Sprinter ## Current Status: Bug Fixing The Marlin development is currently revived. There's a long list of reported issues and pull requests, which we are working on currently. -We are actively looking for testers. So please try the current development version and report new issues and feedback. [![Coverity Scan Build Status](https://scan.coverity.com/projects/2224/badge.svg)](https://scan.coverity.com/projects/2224) [![Travis Build Status](https://travis-ci.org/MarlinFirmware/Marlin.svg)](https://travis-ci.org/MarlinFirmware/Marlin) @@ -40,10 +39,9 @@ The current Marlin dev team consists of: - Scott Lahteine [@thinkyhead] - -Sprinters lead developers are Kliment and caru. -Grbl's lead developer is Simen Svale Skogsrud. -Sonney Jeon (Chamnit) improved some parts of grbl. -A fork by bkubicek for the Ultimaker was merged. +## Donation + +If you find our work usefull please consider donating. Donations will be used to pay for our website http://www.marlinfirmware.org/ and to pay some food or rent money for the very active Collaborators More features have been added by: - Lampmaker, @@ -52,7 +50,7 @@ More features have been added by: ## License -Marlin is published under the [GPL license](/Documentation/COPYING.md) because I believe in open development. -Please do not use this code in products (3D printers, CNC etc) that are closed source or are crippled by a patent. +Marlin is published under the [GPL license](/Documentation/COPYING.md) because We believe in open development. +Do not use this code in products (3D printers, CNC etc) that are closed source or are crippled by a patent. [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) From d0b1f70118104b3bf45bba4ba7edce1ec803c1dd Mon Sep 17 00:00:00 2001 From: Bo Herrmannsen Date: Wed, 15 Apr 2015 16:35:02 +0200 Subject: [PATCH 055/118] Update Compilation.md --- Documentation/Compilation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/Compilation.md b/Documentation/Compilation.md index 56b4f356ca..93c23a627d 100644 --- a/Documentation/Compilation.md +++ b/Documentation/Compilation.md @@ -3,14 +3,14 @@ 1. Install the latest non-beta arduino software IDE/toolset: http://www.arduino.cc/en/Main/Software 2. Download the Marlin firmware - [Latest developement version](https://github.com/MarlinFirmware/Marlin/tree/Development) - - [Stable version](https://github.com/MarlinFirmware/Marlin/tree/Development) + - [Stable version]() 3. In both cases use the "Download Zip" button on the right. 4. Some boards require special files and/or libraries from the ArduinoAddons directory. Take a look at the dedicated [README](/ArduinoAddons/README.md) for details. 5. Start the arduino IDE. - 6. Select Tools -> Board -> Arduino Mega 2560 or your microcontroller + 6. Select Tools -> Board -> Arduino Mega 2560 or your microcontroller 7. Select the correct serial port in Tools ->Serial Port 8. Open Marlin.pde or .ino 9. Click the Verify/Compile button 10. Click the Upload button. If all goes well the firmware is uploading -That's ok. Enjoy Silky Smooth Printing. \ No newline at end of file +That's ok. Enjoy Silky Smooth Printing. From e1b69db6d18ab3f4ea42c6e6711c2077eca79303 Mon Sep 17 00:00:00 2001 From: paclema Date: Wed, 15 Apr 2015 18:17:58 +0200 Subject: [PATCH 056/118] Fixed M48 mismatch between n and P parameter on documentation --- Marlin/Marlin_main.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 475362f2c9..bfde32aa3e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -122,7 +122,7 @@ * Call gcode file : "M32 P !filename#" and return to caller file after finishing (similar to #include). * The '#' is necessary when calling from within sd files, as it stops buffer prereading * M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. - * M48 - Measure Z_Probe repeatability. M48 [n # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] + * M48 - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] * M80 - Turn on Power Supply * M81 - Turn off Power Supply * M82 - Set E codes absolute (default) @@ -2893,7 +2893,7 @@ inline void gcode_M42() { * M48: Z-Probe repeatability measurement function. * * Usage: - * M48 + * M48 * P = Number of sampled points (4-50, default 10) * X = Sample X position * Y = Sample Y position @@ -2905,10 +2905,6 @@ inline void gcode_M42() { * as been issued prior to invoking the M48 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. */ inline void gcode_M48() { @@ -2926,7 +2922,7 @@ inline void gcode_M42() { if (verbose_level > 0) SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n"); - if (code_seen('P') || code_seen('p') || code_seen('n')) { // `n` for legacy support only - please use `P`! + if (code_seen('P') || code_seen('p')) { // `n` for legacy support only - please use `P`! n_samples = code_value_short(); if (n_samples < 4 || n_samples > 50) { SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n"); From cde5eee2a560b957d0d975c950389f88fe7253dd Mon Sep 17 00:00:00 2001 From: paclema Date: Wed, 15 Apr 2015 19:01:09 +0200 Subject: [PATCH 057/118] Removed unnecessary comments --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index bfde32aa3e..64d3d1f350 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2922,7 +2922,7 @@ inline void gcode_M42() { if (verbose_level > 0) SERIAL_PROTOCOLPGM("M48 Z-Probe Repeatability test\n"); - if (code_seen('P') || code_seen('p')) { // `n` for legacy support only - please use `P`! + if (code_seen('P') || code_seen('p')) { n_samples = code_value_short(); if (n_samples < 4 || n_samples > 50) { SERIAL_PROTOCOLPGM("?Sample size not plausible (4-50).\n"); From 53be0f3399e9d11c91ec35628f6a736b172dfb1c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2015 04:16:36 -0700 Subject: [PATCH 058/118] Babystep delay 2us --- Marlin/stepper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index f11cc04301..a44ddbdab8 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1140,7 +1140,7 @@ void quickStop() { uint8_t old_pin = AXIS ##_DIR_READ; \ AXIS ##_APPLY_DIR(INVERT_## AXIS ##_DIR^direction^INVERT, true); \ AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN, true); \ - _delay_us(1U); \ + delayMicroseconds(2); \ AXIS ##_APPLY_STEP(INVERT_## AXIS ##_STEP_PIN, true); \ AXIS ##_APPLY_DIR(old_pin, true); \ } @@ -1179,7 +1179,7 @@ void quickStop() { X_STEP_WRITE(!INVERT_X_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN); Z_STEP_WRITE(!INVERT_Z_STEP_PIN); - _delay_us(1U); + delayMicroseconds(2); X_STEP_WRITE(INVERT_X_STEP_PIN); Y_STEP_WRITE(INVERT_Y_STEP_PIN); Z_STEP_WRITE(INVERT_Z_STEP_PIN); From 63b98b828021796583691fade58de09d73b35f9a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2015 07:24:33 -0700 Subject: [PATCH 059/118] Raise Z for M401 and M402 --- Marlin/Marlin_main.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f350..81ba32ab19 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -4309,14 +4309,34 @@ inline void gcode_M400() { st_synchronize(); } #if defined(ENABLE_AUTO_BED_LEVELING) && (defined(SERVO_ENDSTOPS) || defined(Z_PROBE_ALLEN_KEY)) && not defined(Z_PROBE_SLED) + #ifdef SERVO_ENDSTOPS + void raise_z_for_servo() { + float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING; + if (!axis_known_position[Z_AXIS]) z_dest += zpos; + if (zpos < z_dest) + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_dest); // also updates current_position + } + #endif + /** * M401: Engage Z Servo endstop if available */ - inline void gcode_M401() { deploy_z_probe(); } + inline void gcode_M401() { + #ifdef SERVO_ENDSTOPS + raise_z_for_servo(); + #endif + deploy_z_probe(); + } + /** * M402: Retract Z Servo endstop if enabled */ - inline void gcode_M402() { stow_z_probe(); } + inline void gcode_M402() { + #ifdef SERVO_ENDSTOPS + raise_z_for_servo(); + #endif + stow_z_probe(); + } #endif From 58d128b7a9178490252f76045e7d5282430549e4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2015 07:41:19 -0700 Subject: [PATCH 060/118] Apply zprobe_zoffset in axis_is_at_home Ensure the probe offset will always be included when homing Z. --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f350..5a396bb932 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1033,6 +1033,10 @@ static void axis_is_at_home(int axis) { min_pos[axis] = base_min_pos(axis) + home_offset[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis]; #endif + + #if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0 + if (axis == Z_AXIS) current_position[Z_AXIS] += zprobe_zoffset; + #endif } /** @@ -2041,10 +2045,6 @@ inline void gcode_G28() { if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) current_position[Z_AXIS] = code_value(); - #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) - if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) - #endif - sync_plan_position(); #endif // else DELTA From e4595fa24a2051e95df8a4ed044d2c94cca18e63 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Thu, 16 Apr 2015 23:04:38 +0100 Subject: [PATCH 061/118] Fixed jump in speed when using high accelerations on axes with lots of steps. I.e., when acceleration * steps per mm > 2,000,000. This was done by changing MultiU24X24toH16 to take a 32b bit operand. Removed the claim that stepper.cpp uses the Leib algorithm. --- Marlin/stepper.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index a44ddbdab8..552d529476 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -206,7 +206,17 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; // uses: // r26 to store 0 // r27 to store the byte 1 of the 48bit result -#define MultiU24X24toH16(intRes, longIn1, longIn2) \ +// intRes = longIn1 * longIn2 >> 24 +// uses: +// r26 to store 0 +// r27 to store bits 16-23 of the 48bit result. The top bit is used to round the two byte result. +// note that the lower two bytes and the upper byte of the 48bit result are not calculated. +// this can cause the result to be out by one as the lower bytes may cause carries into the upper ones. +// B0 A0 are bits 24-39 and are the returned value +// C1 B1 A1 is longIn1 +// D2 C2 B2 A2 is longIn2 +// +#define MultiU24X32toH16(intRes, longIn1, longIn2) \ asm volatile ( \ "clr r26 \n\t" \ "mul %A1, %B2 \n\t" \ @@ -237,6 +247,11 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; "lsr r27 \n\t" \ "adc %A0, r26 \n\t" \ "adc %B0, r26 \n\t" \ + "mul %D2, %A1 \n\t" \ + "add %A0, r0 \n\t" \ + "adc %B0, r1 \n\t" \ + "mul %D2, %B1 \n\t" \ + "add %B0, r0 \n\t" \ "clr r1 \n\t" \ : \ "=&r" (intRes) \ @@ -313,7 +328,7 @@ void enable_endstops(bool check) { check_endstops = check; } // The trapezoid is the shape the speed curve over time. It starts at block->initial_rate, accelerates // first block->accelerate_until step_events_completed, then keeps going at constant speed until // step_events_completed reaches block->decelerate_after after which it decelerates until the trapezoid generator is reset. -// The slope of acceleration is calculated with the leib ramp alghorithm. +// The slope of acceleration is calculated using v = u + at where t is the accumulated timer values of the steps so far. void st_wake_up() { // TCNT1 = 0; @@ -714,7 +729,7 @@ ISR(TIMER1_COMPA_vect) { unsigned short step_rate; if (step_events_completed <= (unsigned long)current_block->accelerate_until) { - MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate); + MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate); acc_step_rate += current_block->initial_rate; // upper limit @@ -737,7 +752,7 @@ ISR(TIMER1_COMPA_vect) { #endif } else if (step_events_completed > (unsigned long)current_block->decelerate_after) { - MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate); + MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate); if (step_rate > acc_step_rate) { // Check step_rate stays positive step_rate = current_block->final_rate; From cc6b7cf3ce66e832506ee782c5e7af3cdf41211e Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Fri, 17 Apr 2015 09:28:08 +0100 Subject: [PATCH 062/118] Fixed some comment spellings. --- Marlin/stepper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 552d529476..7fe96f2687 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -54,7 +54,7 @@ static unsigned int cleaning_buffer_counter; locked_z2_motor = false; #endif -// Counter variables for the bresenham line tracer +// Counter variables for the Bresenham line tracer static long counter_x, counter_y, counter_z, counter_e; volatile static unsigned long step_events_completed; // The number of step events executed in the current block @@ -66,7 +66,7 @@ volatile static unsigned long step_events_completed; // The number of step event static long acceleration_time, deceleration_time; //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate; -static unsigned short acc_step_rate; // needed for deccelaration start point +static unsigned short acc_step_rate; // needed for deceleration start point static char step_loops; static unsigned short OCR1A_nominal; static unsigned short step_loops_nominal; @@ -484,7 +484,7 @@ ISR(TIMER1_COMPA_vect) { if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) { if (TEST(out_bits, X_HEAD)) #else - if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular cartesians bot) + if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot) #endif { // -direction #ifdef DUAL_X_CARRIAGE From 483384aaa48a204780f6a4b3c6786fbde81a345d Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Fri, 17 Apr 2015 09:31:53 +0100 Subject: [PATCH 063/118] Fixed faulty comment merge --- Marlin/stepper.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 7fe96f2687..c8bcbbbf2b 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -202,10 +202,6 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; "r26" \ ) -// intRes = longIn1 * longIn2 >> 24 -// uses: -// r26 to store 0 -// r27 to store the byte 1 of the 48bit result // intRes = longIn1 * longIn2 >> 24 // uses: // r26 to store 0 From 581685a231064decaa721804bfad8dd7d76d94e9 Mon Sep 17 00:00:00 2001 From: paclema Date: Fri, 17 Apr 2015 11:15:09 +0200 Subject: [PATCH 064/118] Added new PID autotune info, to make easy copy & paste results to marlin --- Marlin/configurator/config/language.h | 2 +- Marlin/language.h | 2 +- Marlin/temperature.cpp | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index eb0ef8c0a1..718fe9499c 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -209,7 +209,7 @@ #define MSG_OK_B "ok B:" #define MSG_OK_T "ok T:" #define MSG_AT " @:" -#define MSG_PID_AUTOTUNE_FINISHED MSG_PID_AUTOTUNE " finished! Put the last Kp, Ki and Kd constants from above into Configuration.h" +#define MSG_PID_AUTOTUNE_FINISHED MSG_PID_AUTOTUNE " finished! Put the last Kp, Ki and Kd constants from below into Configuration.h" #define MSG_PID_DEBUG " PID_DEBUG " #define MSG_PID_DEBUG_INPUT ": Input " #define MSG_PID_DEBUG_OUTPUT " Output " diff --git a/Marlin/language.h b/Marlin/language.h index ba5f3f700e..3bc7ce0161 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -209,7 +209,7 @@ #define MSG_OK_B "ok B:" #define MSG_OK_T "ok T:" #define MSG_AT " @:" -#define MSG_PID_AUTOTUNE_FINISHED MSG_PID_AUTOTUNE " finished! Put the last Kp, Ki and Kd constants from above into Configuration.h" +#define MSG_PID_AUTOTUNE_FINISHED MSG_PID_AUTOTUNE " finished! Put the last Kp, Ki and Kd constants from below into Configuration.h" #define MSG_PID_DEBUG " PID_DEBUG " #define MSG_PID_DEBUG_INPUT ": Input " #define MSG_PID_DEBUG_OUTPUT " Output " diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 69a2877e70..fa17b6c4c2 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -341,6 +341,9 @@ void PID_autotune(float temp, int extruder, int ncycles) } if (cycles > ncycles) { SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED); + SERIAL_PROTOCOLPGM("#define DEFAULT_Kp "); SERIAL_PROTOCOLLN(Kp); + SERIAL_PROTOCOLPGM("#define DEFAULT_Ki "); SERIAL_PROTOCOLLN(Ki); + SERIAL_PROTOCOLPGM("#define DEFAULT_Kd "); SERIAL_PROTOCOLLN(Kd); return; } lcd_update(); From 2d1e73021605ffd7d01a08f60d83ed0048a100eb Mon Sep 17 00:00:00 2001 From: Bo Herrmannsen Date: Fri, 17 Apr 2015 15:00:21 +0200 Subject: [PATCH 065/118] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eeb9091301..9b40193d25 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The Marlin development is currently revived. There's a long list of reported iss ## Contact -__Google Hangout:__ Hangout +__Google Hangout:__ Hangout ## Credits From b99e63a7bf9820984e67ebcecaeacf515cc9823e Mon Sep 17 00:00:00 2001 From: Ivan Galvez Junquera Date: Fri, 17 Apr 2015 16:10:58 +0200 Subject: [PATCH 066/118] =?UTF-8?q?Fixed=20compilation=20error=20"error:?= =?UTF-8?q?=20stray=20=E2=80=98\357=E2=80=99=20in=20program"=20in=20severa?= =?UTF-8?q?l=20configuration=20files.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced in commit 697ee2dc and later spread to other files. --- Marlin/example_configurations/Felix/Configuration.h | 2 +- Marlin/example_configurations/Hephestos/Configuration.h | 2 +- Marlin/example_configurations/K8200/Configuration.h | 2 +- Marlin/example_configurations/SCARA/Configuration.h | 2 +- Marlin/example_configurations/WITBOX/Configuration.h | 2 +- Marlin/example_configurations/delta/generic/Configuration.h | 2 +- Marlin/example_configurations/delta/kossel_mini/Configuration.h | 2 +- Marlin/example_configurations/makibox/Configuration.h | 2 +- Marlin/example_configurations/tvrrug/Round2/Configuration.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 269b8b794e..d5f400bae0 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index a83c6e911d..ce295054c6 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 1cde25fca3..4832e8cc7a 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 1f180a53d2..02637f3e55 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index dda21b7759..434a529cde 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 2562010ea7..4d479047a4 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 1c6313e938..c7c24a16c7 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index a01bcb6684..83947b65f7 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 423822a866..8b365019e8 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -1,4 +1,4 @@ -#ifndef CONFIGURATION_H +#ifndef CONFIGURATION_H #define CONFIGURATION_H #include "boards.h" From 47847765e217a6d37d7b3a1853d2941768fdab03 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Apr 2015 23:07:48 -0700 Subject: [PATCH 067/118] Add M410 QuickStop command --- Marlin/Marlin_main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f350..0b6fa211f3 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -184,6 +184,7 @@ * M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder * M406 - Turn off Filament Sensor extrusion control * M407 - Display measured filament diameter + * M410 - Quickstop - Abort all the planned moves * M500 - Store parameters in EEPROM * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -4376,6 +4377,14 @@ inline void gcode_M400() { st_synchronize(); } #endif // FILAMENT_SENSOR +/** + * M410: quickstop - Abort all planned moves + * + * This will stop the carriages mid-move, so most likely they + * will be out of sync with the stepper position after this. + */ +inline void gcode_M410() { quickStop(); } + /** * M500: Store settings in EEPROM */ @@ -5195,6 +5204,10 @@ void process_commands() { break; #endif // FILAMENT_SENSOR + case 410: // M410 quickstop - Abort all the planned moves. + gcode_M410(); + break; + case 500: // M500 Store settings in EEPROM gcode_M500(); break; From d931220a6594704c7392a9bc98ce6bc070fe3ba0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Apr 2015 23:12:29 -0700 Subject: [PATCH 068/118] Tweak comments --- Marlin/Marlin_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 0b6fa211f3..8863b3db36 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -184,7 +184,7 @@ * M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder * M406 - Turn off Filament Sensor extrusion control * M407 - Display measured filament diameter - * M410 - Quickstop - Abort all the planned moves + * M410 - Quickstop. Abort all the planned moves * M500 - Store parameters in EEPROM * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -4378,7 +4378,7 @@ inline void gcode_M400() { st_synchronize(); } #endif // FILAMENT_SENSOR /** - * M410: quickstop - Abort all planned moves + * M410: Quickstop - Abort all planned moves * * This will stop the carriages mid-move, so most likely they * will be out of sync with the stepper position after this. From 671aaf2dc9ec19ba774371129acbb0fb2775f402 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Sun, 19 Apr 2015 13:25:20 +0200 Subject: [PATCH 069/118] Minor fix for M300 Corrected wrong order of parameters. --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 94c4c7bd84..4e3bb05be5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3971,7 +3971,7 @@ inline void gcode_M226() { delay(beepP); noTone(BEEPER); #elif defined(ULTRALCD) - lcd_buzz(beepS, beepP); + lcd_buzz(beepP, beepS); #elif defined(LCD_USE_I2C_BUZZER) lcd_buzz(beepP, beepS); #endif From 064f2b37d03827440364c2dabcdb2468fbc57415 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 20 Apr 2015 11:11:13 +0200 Subject: [PATCH 070/118] More Beeper clean up. Centralised beep code to lcd_buzz(). From gcode_M300() and lcd_quick_feedback(). Enforced max. duration for M300 to 5 seconds. Corrected description in 'Configuration.h' LCD_FEEDBACK_FREQUENCY_HZ 0 gives now a silent delay of LCD_FEEDBACK_FREQUENCY_DURATION_MS. --- Marlin/Configuration.h | 7 ++-- Marlin/Marlin_main.cpp | 16 ++------- Marlin/configurator/config/Configuration.h | 4 +-- .../Felix/Configuration.h | 4 +-- .../Felix/Configuration_DUAL.h | 4 +-- .../Hephestos/Configuration.h | 4 +-- .../K8200/Configuration.h | 4 +-- .../SCARA/Configuration.h | 4 +-- .../WITBOX/Configuration.h | 4 +-- .../delta/generic/Configuration.h | 4 +-- .../delta/kossel_mini/Configuration.h | 4 +-- .../makibox/Configuration.h | 4 +-- .../tvrrug/Round2/Configuration.h | 4 +-- Marlin/ultralcd.cpp | 35 +++++++++++-------- 14 files changed, 48 insertions(+), 54 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f48646ac7f..81392d96bb 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -661,10 +661,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback - +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne //#define PANEL_ONE @@ -681,7 +680,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // The RepRapDiscount Smart Controller (white PCB) // http://reprap.org/wiki/RepRapDiscount_Smart_Controller -//#define REPRAP_DISCOUNT_SMART_CONTROLLER +#define REPRAP_DISCOUNT_SMART_CONTROLLER // The GADGETS3D G3D LCD/SD Controller (blue PCB) // http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 4e3bb05be5..b74cf66abe 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3965,20 +3965,8 @@ inline void gcode_M226() { inline void gcode_M300() { uint16_t beepS = code_seen('S') ? code_value_short() : 110; uint32_t beepP = code_seen('P') ? code_value_long() : 1000; - if (beepS > 0) { - #if BEEPER > 0 - tone(BEEPER, beepS); - delay(beepP); - noTone(BEEPER); - #elif defined(ULTRALCD) - lcd_buzz(beepP, beepS); - #elif defined(LCD_USE_I2C_BUZZER) - lcd_buzz(beepP, beepS); - #endif - } - else { - delay(beepP); - } + if (beepP > 5000) beepP = 5000; // limit to 5 seconds + lcd_buzz(beepP, beepS); } #endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 2b2175cc46..7210894182 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -660,9 +660,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 269b8b794e..8536f4b2cb 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -594,9 +594,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index 49b9f5b0b7..edc1588101 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -590,9 +590,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index a83c6e911d..b6bafe8f74 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -614,9 +614,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index df0614b507..9790eabaeb 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -622,9 +622,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 1f180a53d2..b1ffea4563 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -645,9 +645,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index dda21b7759..d9265da9bf 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -613,9 +613,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 2562010ea7..926469e32d 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -662,9 +662,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 1c6313e938..090811249a 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -666,9 +666,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index a01bcb6684..16516deb27 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -613,9 +613,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 423822a866..b4af63b959 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -619,9 +619,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse -//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click - // 0 to disable buzzer feedback +//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click + // 0 to disable buzzer feedback. Test with M300 S P // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3) // http://reprap.org/wiki/PanelOne diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 293f819c92..2673f0f853 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1131,23 +1131,18 @@ void lcd_quick_feedback() { #endif lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); #elif defined(BEEPER) && BEEPER > -1 - SET_OUTPUT(BEEPER); #ifndef LCD_FEEDBACK_FREQUENCY_HZ #define LCD_FEEDBACK_FREQUENCY_HZ 5000 #endif #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2 #endif - const uint16_t delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2; - uint16_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000; - while (i--) { - WRITE(BEEPER,HIGH); - delayMicroseconds(delay); - WRITE(BEEPER,LOW); - delayMicroseconds(delay); - } - const uint16_t j = max(10000 - LCD_FEEDBACK_FREQUENCY_DURATION_MS * 1000, 0); - if (j) delayMicroseconds(j); + lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); + #else + #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS + #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2 + #endif + delay(LCD_FEEDBACK_FREQUENCY_DURATION_MS); #endif } @@ -1544,9 +1539,21 @@ bool lcd_detected(void) { } void lcd_buzz(long duration, uint16_t freq) { - #ifdef LCD_USE_I2C_BUZZER - lcd.buzz(duration,freq); - #endif + if (freq > 0) { + #if BEEPER > 0 + SET_OUTPUT(BEEPER); + tone(BEEPER, freq); + delay(duration); + noTone(BEEPER); + #elif defined(LCD_USE_I2C_BUZZER) + lcd.buzz(duration,freq); + #else + delay(duration); + #endif + } + else { + delay(duration); + } } bool lcd_clicked() { return LCD_CLICKED; } From 3a27a78f9ed5c89735ace99d8c4173991f3405a4 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 20 Apr 2015 15:01:43 +0200 Subject: [PATCH 071/118] Commented REPRAP_DISCOUNT_SMART_CONTROLLER again and removed some tabs. --- Marlin/Configuration.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 81392d96bb..4e39703ad4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -680,7 +680,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // The RepRapDiscount Smart Controller (white PCB) // http://reprap.org/wiki/RepRapDiscount_Smart_Controller -#define REPRAP_DISCOUNT_SMART_CONTROLLER +//#define REPRAP_DISCOUNT_SMART_CONTROLLER // The GADGETS3D G3D LCD/SD Controller (blue PCB) // http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel @@ -791,13 +791,13 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // Uncomment below to enable //#define FILAMENT_SENSOR -#define FILAMENT_SENSOR_EXTRUDER_NUM 0 //The number of the extruder that has the filament sensor (0,1,2) -#define MEASUREMENT_DELAY_CM 14 //measurement delay in cm. This is the distance from filament sensor to middle of barrel +#define FILAMENT_SENSOR_EXTRUDER_NUM 0 //The number of the extruder that has the filament sensor (0,1,2) +#define MEASUREMENT_DELAY_CM 14 //measurement delay in cm. This is the distance from filament sensor to middle of barrel -#define DEFAULT_NOMINAL_FILAMENT_DIA 3.0 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation -#define MEASURED_UPPER_LIMIT 3.30 //upper limit factor used for sensor reading validation in mm -#define MEASURED_LOWER_LIMIT 1.90 //lower limit factor for sensor reading validation in mm -#define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) +#define DEFAULT_NOMINAL_FILAMENT_DIA 3.0 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation +#define MEASURED_UPPER_LIMIT 3.3 //upper limit factor used for sensor reading validation in mm +#define MEASURED_LOWER_LIMIT 1.9 //lower limit factor for sensor reading validation in mm +#define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code #define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially From da0d91a79b1bf0fd1c4d4a568415073b70d17573 Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Mon, 20 Apr 2015 23:28:46 +0200 Subject: [PATCH 072/118] max endstopp no user will home to 0 with a max endstopp --- Marlin/Marlin_main.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f350..22f037075d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1947,12 +1947,18 @@ inline void gcode_G28() { if (home_all_axis || homeY) HOMEAXIS(Y); // Set the X position, if included - if (code_seen(axis_codes[X_AXIS]) && code_has_value()) - current_position[X_AXIS] = code_value(); + if (code_seen(axis_codes[X_AXIS]) && code_has_value()) { + float v = code_value(); + if (X_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps + current_position[X_AXIS] = v; + } // Set the Y position, if included - if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) - current_position[Y_AXIS] = code_value(); + if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) { + float v = code_value(); + if (Y_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps + current_position[Y_AXIS] = code_value(); + } // Home Z last if homing towards the bed #if Z_HOME_DIR < 0 @@ -2038,8 +2044,11 @@ inline void gcode_G28() { #endif // Z_HOME_DIR < 0 // Set the Z position, if included - if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) + if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) { + float v = code_value(); + if (Z_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps current_position[Z_AXIS] = code_value(); + } #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) From 61ae43f35e8523ab9785a0d79a3c6f7e73407e4a Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Mon, 20 Apr 2015 23:31:10 +0200 Subject: [PATCH 073/118] v <-> code_value --- Marlin/Marlin_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 22f037075d..4987aaf1e2 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1957,7 +1957,7 @@ inline void gcode_G28() { if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) { float v = code_value(); if (Y_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps - current_position[Y_AXIS] = code_value(); + current_position[Y_AXIS] = v; } // Home Z last if homing towards the bed @@ -2047,7 +2047,7 @@ inline void gcode_G28() { if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) { float v = code_value(); if (Z_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps - current_position[Z_AXIS] = code_value(); + current_position[Z_AXIS] = v; } #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) From b59e92ab99c64c280a1afc0b240b9217c2329eda Mon Sep 17 00:00:00 2001 From: AnHardt Date: Tue, 21 Apr 2015 13:50:28 +0200 Subject: [PATCH 074/118] Fix for #1946 Syntax error. --- Marlin/pins_AZTEEG_X3.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/pins_AZTEEG_X3.h b/Marlin/pins_AZTEEG_X3.h index ea98f95c59..7c5dca3397 100644 --- a/Marlin/pins_AZTEEG_X3.h +++ b/Marlin/pins_AZTEEG_X3.h @@ -28,9 +28,7 @@ #define STAT_LED_RED 64 #define STAT_LED_BLUE 63 #endif -#endif - -#elif define TEMP_STAT_LEDS +#elif defined(TEMP_STAT_LEDS) #define STAT_LED_RED 6 #define STAT_LED_BLUE 11 #endif From c5e0e29d23bebea6b9d900f2b9886f612e7e8901 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Tue, 21 Apr 2015 21:42:00 +0200 Subject: [PATCH 075/118] Add DISPLAY_CHARSET_HD44780_CYRILLIC as alternative in SanityCheck.h and add some documentation - how to integrate a new font. --- Marlin/SanityCheck.h | 4 ++-- Marlin/fonts/README.fonts | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 857976bc30..3bba4584cd 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -87,8 +87,8 @@ /** * Required LCD language */ - #if !defined(DOGLCD) && defined(ULTRA_LCD) && !defined(DISPLAY_CHARSET_HD44780_JAPAN) && !defined(DISPLAY_CHARSET_HD44780_WESTERN) - #error You must enable either DISPLAY_CHARSET_HD44780_JAPAN or DISPLAY_CHARSET_HD44780_WESTERN for your LCD controller. + #if !defined(DOGLCD) && defined(ULTRA_LCD) && !defined(DISPLAY_CHARSET_HD44780_JAPAN) && !defined(DISPLAY_CHARSET_HD44780_WESTERN)&& !defined(DISPLAY_CHARSET_HD44780_CYRILLIC) + #error You must enable either DISPLAY_CHARSET_HD44780_JAPAN or DISPLAY_CHARSET_HD44780_WESTERN or DISPLAY_CHARSET_HD44780_CYRILLIC for your LCD controller. #endif /** diff --git a/Marlin/fonts/README.fonts b/Marlin/fonts/README.fonts index f227c079ae..a33e6afcd0 100644 --- a/Marlin/fonts/README.fonts +++ b/Marlin/fonts/README.fonts @@ -3,4 +3,23 @@ In Fony export the fonts to bdf-format. Maybe another one can edit them with Fon Then run make_fonts.bat what calls bdf2u8g.exe with the needed parameters to produce the .h files. The .h files must be edited to replace '#include "u8g.h"' with '#include ', replace 'U8G_FONT_SECTION' with 'U8G_SECTION', insert '.progmem.' right behind the first '"' and moved to the main directory. -Especially the Kana and Cyrillic fonts should be revised by someone who knows what he/she does. I am only a west-European with very little knowledge about this scripts. +How to integrate a new font: +Currently we are limited to 256 symbols per font. We use a menu system with 5 lines, on a display with 64 pixel height. That means we have 12 pixel for a line. To have some space in between the lines we can't use more then 10 pixel height for the symbols. +We use fixed width fonts. To fit 22 Symbols on the 128 pixel wide screen, the symbols can't be wider than 5 pixel. Maybe you can work with half symbols - two places in the charset will than build one wide symbol. + + * Get 'Fony.exe' + * Copy one of the existing *.fon files and work with this. + * Change the pixels. Don't change width or height. + * Export as *.bdf + * Use 'bdf2u8g.exe' to produce the *.h file. Examples for the existing fonts are in 'make_fonts.bat' + * Edit the produced .h file to match our needs. See hints in 'README.fonts' or the other 'dogm_font_data_.h' files. + * Make a new entry in the font list in 'dogm_lcd_implementation.h' before the '#else // fall back' + #elif defined( DISPLAY_CHARSET_NEWNAME ) + #include "dogm_font_data_yourfont.h" + #define FONT_MENU_NAME YOURFONTNAME + #else // fall-back + * Add your font to the list of permitted fonts in 'language_en.h' + ... || defined(DISPLAY_CHARSET_YOUR_NEW_FONT) ... ) + + +Especially the Kana font should be revised by someone who knows what he/she does. I am only a west-European with very little knowledge about this script. From f2c94b3298302dad7a8c24432fef08faf60b1987 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 22 Apr 2015 01:49:55 +0200 Subject: [PATCH 076/118] tone will end automaticly --- Marlin/ultralcd.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 2673f0f853..90ab351c88 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1542,9 +1542,7 @@ void lcd_buzz(long duration, uint16_t freq) { if (freq > 0) { #if BEEPER > 0 SET_OUTPUT(BEEPER); - tone(BEEPER, freq); - delay(duration); - noTone(BEEPER); + tone(BEEPER, freq, duration); #elif defined(LCD_USE_I2C_BUZZER) lcd.buzz(duration,freq); #else From c26d816839e556876522595e85c6aadd43c05844 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Apr 2015 12:09:57 +0200 Subject: [PATCH 077/118] filter any 0 --- Marlin/Marlin_main.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 4987aaf1e2..952aa2fb3e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1948,16 +1948,14 @@ inline void gcode_G28() { // Set the X position, if included if (code_seen(axis_codes[X_AXIS]) && code_has_value()) { - float v = code_value(); - if (X_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps - current_position[X_AXIS] = v; + if (code_value_long() != 0) // filter 0 + current_position[X_AXIS] = code_value(); } // Set the Y position, if included if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) { - float v = code_value(); - if (Y_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps - current_position[Y_AXIS] = v; + if (code_value_long() != 0) // filter 0 + current_position[X_AXIS] = code_value(); } // Home Z last if homing towards the bed @@ -2045,9 +2043,8 @@ inline void gcode_G28() { // Set the Z position, if included if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) { - float v = code_value(); - if (Z_HOME_DIR == -1 || v != 0) // filter 0 with max-endstopps - current_position[Z_AXIS] = v; + if (code_value_long() != 0) // filter 0 + current_position[X_AXIS] = code_value(); } #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) From be9e4ceddcf02741c7042753d8c1276f9443bc67 Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Thu, 23 Apr 2015 10:35:14 +0200 Subject: [PATCH 078/118] fix typo c'n'p ftw :/ --- Marlin/Marlin_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 952aa2fb3e..d99b63b0b6 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1955,7 +1955,7 @@ inline void gcode_G28() { // Set the Y position, if included if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) { if (code_value_long() != 0) // filter 0 - current_position[X_AXIS] = code_value(); + current_position[Y_AXIS] = code_value(); } // Home Z last if homing towards the bed @@ -2044,7 +2044,7 @@ inline void gcode_G28() { // Set the Z position, if included if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) { if (code_value_long() != 0) // filter 0 - current_position[X_AXIS] = code_value(); + current_position[Z_AXIS] = code_value(); } #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) From 8534bc376c55740e93ca21ac626d56c47da10b91 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 17:56:37 -0700 Subject: [PATCH 079/118] Fix homing of YZ with DUAL_X_CARRIAGE --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a51d483e8f..f3b83294ce 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1504,7 +1504,7 @@ static void homeaxis(AxisEnum axis) { int axis_home_dir; #ifdef DUAL_X_CARRIAGE - if (axis == X_AXIS) axis_home_dir = x_home_dir(active_extruder); + axis_home_dir = (axis == X_AXIS) ? x_home_dir(active_extruder) : home_dir(axis); #else axis_home_dir = home_dir(axis); #endif From 996d0a9185f12806d51e77b5d163086f21f144d8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 18:06:36 -0700 Subject: [PATCH 080/118] Squish the code down a little --- Marlin/Marlin_main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index f3b83294ce..fb9739aade 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1501,13 +1501,11 @@ static void homeaxis(AxisEnum axis) { if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) { - int axis_home_dir; - - #ifdef DUAL_X_CARRIAGE - axis_home_dir = (axis == X_AXIS) ? x_home_dir(active_extruder) : home_dir(axis); - #else - axis_home_dir = home_dir(axis); - #endif + int axis_home_dir = + #ifdef DUAL_X_CARRIAGE + (axis == X_AXIS) ? x_home_dir(active_extruder) : + #endif + home_dir(axis); // Set the axis position as setup for the move current_position[axis] = 0; From 64268f331263b0ff064274c3ee293f44b1bd144d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 18:16:44 -0700 Subject: [PATCH 081/118] Fixup axis_is_at_home a little --- Marlin/Marlin_main.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index fb9739aade..cc76792428 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -990,10 +990,10 @@ static void axis_is_at_home(int axis) { #endif #ifdef SCARA - float homeposition[3]; - if (axis < 2) { + if (axis == X_AXIS || axis == Y_AXIS) { + float homeposition[3]; for (int i = 0; i < 3; i++) homeposition[i] = base_home_pos(i); // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); @@ -1023,17 +1023,14 @@ static void axis_is_at_home(int axis) { // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } - else { - current_position[axis] = base_home_pos(axis) + home_offset[axis]; - min_pos[axis] = base_min_pos(axis) + home_offset[axis]; - max_pos[axis] = base_max_pos(axis) + home_offset[axis]; } - #else + else + #endif + { current_position[axis] = base_home_pos(axis) + home_offset[axis]; min_pos[axis] = base_min_pos(axis) + home_offset[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis]; - #endif + } } /** From c3560e0288cc4c4ee9caeb70abb4f17cbed5d8d5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 19:10:09 -0700 Subject: [PATCH 082/118] Include axis parameter to ultralcd's line_to_current --- Marlin/ultralcd.cpp | 46 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 341eb3c0d0..7ed146cb83 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -648,12 +648,12 @@ static void lcd_prepare_menu() { #endif // DELTA_CALIBRATION_MENU -inline void line_to_current() { +inline void line_to_current(AxisEnum axis) { #ifdef DELTA calculate_delta(current_position); - plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder); #else - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[X_AXIS]/60, active_extruder); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder); #endif } @@ -667,7 +667,7 @@ static void _lcd_move(const char *name, int axis, int min, int max) { if (min_software_endstops && current_position[axis] < min) current_position[axis] = min; if (max_software_endstops && current_position[axis] > max) current_position[axis] = max; encoderPosition = 0; - line_to_current(); + line_to_current(axis); lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis])); @@ -680,7 +680,7 @@ static void lcd_move_e() { if (encoderPosition != 0) { current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; encoderPosition = 0; - line_to_current(); + line_to_current(E_AXIS); lcdDrawUpdate = 1; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Extruder"), ftostr31(current_position[E_AXIS])); @@ -1803,7 +1803,7 @@ char *ftostr52(const float &x) { if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS; if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; encoderPosition = 0; - line_to_current(); + line_to_current(Z_AXIS); lcdDrawUpdate = 2; } if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS])); @@ -1811,48 +1811,44 @@ char *ftostr52(const float &x) { if (LCD_CLICKED) { if (!debounce_click) { debounce_click = true; - int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; - int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; - if (iy&1) { // Zig zag - ix = (MESH_NUM_X_POINTS - 1) - ix; - } + int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS, + iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; + if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag mbl.set_z(ix, iy, current_position[Z_AXIS]); _lcd_level_bed_position++; if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - line_to_current(); + line_to_current(Z_AXIS); mbl.active = 1; enqueuecommands_P(PSTR("G28")); lcd_return_to_status(); - } else { + } + else { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; - line_to_current(); + line_to_current(Z_AXIS); ix = _lcd_level_bed_position % MESH_NUM_X_POINTS; iy = _lcd_level_bed_position / MESH_NUM_X_POINTS; - if (iy&1) { // Zig zag - ix = (MESH_NUM_X_POINTS - 1) - ix; - } + if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag current_position[X_AXIS] = mbl.get_x(ix); current_position[Y_AXIS] = mbl.get_y(iy); - line_to_current(); + line_to_current(X_AXIS); lcdDrawUpdate = 2; } } - } else { + } + else { debounce_click = false; } } static void _lcd_level_bed_homing() { if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing"); - if (axis_known_position[X_AXIS] && - axis_known_position[Y_AXIS] && - axis_known_position[Z_AXIS]) { + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) { current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); current_position[X_AXIS] = MESH_MIN_X; current_position[Y_AXIS] = MESH_MIN_Y; - line_to_current(); + line_to_current(X_AXIS); _lcd_level_bed_position = 0; lcd_goto_menu(_lcd_level_bed); } @@ -1860,9 +1856,7 @@ char *ftostr52(const float &x) { } static void lcd_level_bed() { - axis_known_position[X_AXIS] = false; - axis_known_position[Y_AXIS] = false; - axis_known_position[Z_AXIS] = false; + axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false; mbl.reset(); enqueuecommands_P(PSTR("G28")); lcdDrawUpdate = 2; From 31932912dd82178ac7010b52ab1694d903b5ee1e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 19:32:37 -0700 Subject: [PATCH 083/118] Use AxisEnum instead of int for _lcd_move --- Marlin/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 7ed146cb83..aa24a7a8f5 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -660,7 +660,7 @@ inline void line_to_current(AxisEnum axis) { float move_menu_scale; static void lcd_move_menu_axis(); -static void _lcd_move(const char *name, int axis, int min, int max) { +static void _lcd_move(const char *name, AxisEnum axis, int min, int max) { if (encoderPosition != 0) { refresh_cmd_timeout(); current_position[axis] += float((int)encoderPosition) * move_menu_scale; From 2558c10c6c25bdcf524c118dac45a94a7c09ac8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Apr 2015 20:06:17 -0700 Subject: [PATCH 084/118] Use the slower feedrate for XY axes --- Marlin/Marlin_main.cpp | 12 ++++++------ Marlin/ultralcd.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a51d483e8f..a27795eb5c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3806,23 +3806,23 @@ inline void gcode_M206() { * M666: Set delta endstop adjustment */ inline void gcode_M666() { - for (int8_t i = 0; i < 3; i++) { + for (int8_t i = X_AXIS; i <= Z_AXIS; i++) { if (code_seen(axis_codes[i])) { endstop_adj[i] = code_value(); } } } -#elif defined(Z_DUAL_ENDSTOPS) +#elif defined(Z_DUAL_ENDSTOPS) // !DELTA && defined(Z_DUAL_ENDSTOPS) /** * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis. */ inline void gcode_M666() { - if (code_seen('Z')) z_endstop_adj = code_value(); - SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj ); - SERIAL_EOL; + if (code_seen('Z')) z_endstop_adj = code_value(); + SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj); + SERIAL_EOL; } -#endif // DELTA +#endif // !DELTA && defined(Z_DUAL_ENDSTOPS) #ifdef FWRETRACT diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index aa24a7a8f5..c96f098994 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1831,7 +1831,7 @@ char *ftostr52(const float &x) { if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag current_position[X_AXIS] = mbl.get_x(ix); current_position[Y_AXIS] = mbl.get_y(iy); - line_to_current(X_AXIS); + line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS); lcdDrawUpdate = 2; } } @@ -1848,7 +1848,7 @@ char *ftostr52(const float &x) { plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); current_position[X_AXIS] = MESH_MIN_X; current_position[Y_AXIS] = MESH_MIN_Y; - line_to_current(X_AXIS); + line_to_current(manual_feedrate[X_AXIS] <= manual_feedrate[Y_AXIS] ? X_AXIS : Y_AXIS); _lcd_level_bed_position = 0; lcd_goto_menu(_lcd_level_bed); } From 01655603330b67319fa5dc4be27819099857a006 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2015 07:41:19 -0700 Subject: [PATCH 085/118] Apply zprobe_zoffset in axis_is_at_home Ensure the probe offset will always be included when homing Z. --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a51d483e8f..5849fdd685 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1034,6 +1034,10 @@ static void axis_is_at_home(int axis) { min_pos[axis] = base_min_pos(axis) + home_offset[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis]; #endif + + #if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0 + if (axis == Z_AXIS) current_position[Z_AXIS] += zprobe_zoffset; + #endif } /** @@ -2042,10 +2046,6 @@ inline void gcode_G28() { if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) current_position[Z_AXIS] = code_value(); - #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) - if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) - #endif - sync_plan_position(); #endif // else DELTA From 79a44a9de37859b58a8de288341a54df42e26061 Mon Sep 17 00:00:00 2001 From: Wurstnase Date: Fri, 24 Apr 2015 08:03:17 +0200 Subject: [PATCH 086/118] stepper.cpp macros rework delete some tabs --- Marlin/stepper.cpp | 121 ++++++++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 50 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index c8bcbbbf2b..ca17b3f9f2 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -46,7 +46,7 @@ block_t *current_block; // A pointer to the block currently being traced // Variables used by The Stepper Driver Interrupt static unsigned char out_bits; // The next stepping-bits to be output -static unsigned int cleaning_buffer_counter; +static unsigned int cleaning_buffer_counter; #ifdef Z_DUAL_ENDSTOPS static bool performing_homing = false, @@ -285,8 +285,8 @@ void checkHitEndstops() { } #ifdef Z_PROBE_ENDSTOP if (endstop_z_probe_hit) { - SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); - LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP"); + SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); + LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP"); } #endif SERIAL_EOL; @@ -411,7 +411,7 @@ ISR(TIMER1_COMPA_vect) { OCR1A = 200; return; } - + // If there is no current block, attempt to pop one from the buffer if (!current_block) { // Anything in the buffer? @@ -463,14 +463,22 @@ ISR(TIMER1_COMPA_vect) { count_direction[Y_AXIS] = 1; } + #define _ENDSTOP(axis, minmax) axis ##_## minmax ##_endstop + #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN + #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING + #define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop + #define _AXIS(AXIS) AXIS ##_AXIS + #define _ENDSTOP_HIT(axis) endstop_## axis ##_hit + #define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \ - bool axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_## MINMAX ##_ENDSTOP_INVERTING); \ - if (axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop && (current_block->steps[AXIS ##_AXIS] > 0)) { \ - endstops_trigsteps[AXIS ##_AXIS] = count_position[AXIS ##_AXIS]; \ - endstop_## axis ##_hit = true; \ + bool _ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)); \ + if (_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax) && (current_block->steps[_AXIS(AXIS)] > 0)) { \ + endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \ + _ENDSTOP_HIT(axis) = true; \ step_events_completed = current_block->step_event_count; \ } \ - old_## axis ##_## minmax ##_endstop = axis ##_## minmax ##_endstop; + _OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax); + // Check X and Y endstops if (check_endstops) { @@ -486,7 +494,7 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if HAS_X_MIN UPDATE_ENDSTOP(x, X, min, MIN); @@ -572,14 +580,14 @@ ISR(TIMER1_COMPA_vect) { z_probe_endstop=(READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); if(z_probe_endstop && old_z_probe_endstop) { - endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_probe_hit=true; + endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; + endstop_z_probe_hit=true; -// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); +// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); } old_z_probe_endstop = z_probe_endstop; #endif - + } // check_endstops } @@ -625,15 +633,15 @@ ISR(TIMER1_COMPA_vect) { #endif // !Z_DUAL_ENDSTOPS #endif // Z_MAX_PIN - + #ifdef Z_PROBE_ENDSTOP UPDATE_ENDSTOP(z, Z, probe, PROBE); z_probe_endstop=(READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING); if(z_probe_endstop && old_z_probe_endstop) { - endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_probe_hit=true; -// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); + endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; + endstop_z_probe_hit=true; +// if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true"); } old_z_probe_endstop = z_probe_endstop; #endif @@ -667,6 +675,11 @@ ISR(TIMER1_COMPA_vect) { } #endif //ADVANCE + #define _COUNTER(axis) counter_## axis + #define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW) + #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP + #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN + #ifdef CONFIG_STEPPERS_TOSHIBA /** * The Toshiba stepper controller require much longer pulses. @@ -675,8 +688,8 @@ ISR(TIMER1_COMPA_vect) { * lag to allow it work with without needing NOPs */ #define STEP_ADD(axis, AXIS) \ - counter_## axis += current_block->steps[AXIS ##_AXIS]; \ - if (counter_## axis > 0) { AXIS ##_STEP_WRITE(HIGH); } + _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ + if (_COUNTER(axis) > 0) { _WRITE_STEP(AXIS, HIGH); } STEP_ADD(x,X); STEP_ADD(y,Y); STEP_ADD(z,Z); @@ -685,10 +698,10 @@ ISR(TIMER1_COMPA_vect) { #endif #define STEP_IF_COUNTER(axis, AXIS) \ - if (counter_## axis > 0) { \ - counter_## axis -= current_block->step_event_count; \ - count_position[AXIS ##_AXIS] += count_direction[AXIS ##_AXIS]; \ - AXIS ##_STEP_WRITE(LOW); \ + if (_COUNTER(axis) > 0) { \ + _COUNTER(axis) -= current_block->step_event_count; \ + count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ + _WRITE_STEP(AXIS, LOW); \ } STEP_IF_COUNTER(x, X); @@ -701,12 +714,12 @@ ISR(TIMER1_COMPA_vect) { #else // !CONFIG_STEPPERS_TOSHIBA #define APPLY_MOVEMENT(axis, AXIS) \ - counter_## axis += current_block->steps[AXIS ##_AXIS]; \ - if (counter_## axis > 0) { \ - AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN,0); \ - counter_## axis -= current_block->step_event_count; \ - count_position[AXIS ##_AXIS] += count_direction[AXIS ##_AXIS]; \ - AXIS ##_APPLY_STEP(INVERT_## AXIS ##_STEP_PIN,0); \ + _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \ + if (_COUNTER(axis) > 0) { \ + _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); \ + _COUNTER(axis) -= current_block->step_event_count; \ + count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ + _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \ } APPLY_MOVEMENT(x, X); @@ -874,7 +887,7 @@ void st_init() { #ifdef HAVE_L6470DRIVER L6470_init(); #endif - + // Initialize Dir Pins #if HAS_X_DIR X_DIR_INIT; @@ -920,11 +933,11 @@ void st_init() { #if HAS_Y_ENABLE Y_ENABLE_INIT; if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH); - - #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE - Y2_ENABLE_INIT; - if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH); - #endif + + #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE + Y2_ENABLE_INIT; + if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH); + #endif #endif #if HAS_Z_ENABLE Z_ENABLE_INIT; @@ -1001,8 +1014,8 @@ void st_init() { #ifdef ENDSTOPPULLUP_ZMAX WRITE(Z2_MAX_PIN,HIGH); #endif - #endif - + #endif + #if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used. SET_INPUT(Z_PROBE_PIN); #ifdef ENDSTOPPULLUP_ZPROBE @@ -1010,10 +1023,13 @@ void st_init() { #endif #endif + #define _STEP_INIT(AXIS) AXIS ##_STEP_INIT + #define _DISABLE(axis) disable_## axis() + #define AXIS_INIT(axis, AXIS, PIN) \ - AXIS ##_STEP_INIT; \ - AXIS ##_STEP_WRITE(INVERT_## PIN ##_STEP_PIN); \ - disable_## axis() + _STEP_INIT(AXIS); \ + _WRITE_STEP(AXIS, _INVERT_STEP_PIN(PIN)); \ + _DISABLE(axis) #define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E) @@ -1146,14 +1162,19 @@ void quickStop() { // No other ISR should ever interrupt this! void babystep(const uint8_t axis, const bool direction) { + #define _ENABLE(axis) enable_## axis() + #define _READ_DIR(AXIS) AXIS ##_DIR_READ + #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR + #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) + #define BABYSTEP_AXIS(axis, AXIS, INVERT) { \ - enable_## axis(); \ - uint8_t old_pin = AXIS ##_DIR_READ; \ - AXIS ##_APPLY_DIR(INVERT_## AXIS ##_DIR^direction^INVERT, true); \ - AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN, true); \ + _ENABLE(axis); \ + uint8_t old_pin = _READ_DIR(AXIS); \ + _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \ + _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \ delayMicroseconds(2); \ - AXIS ##_APPLY_STEP(INVERT_## AXIS ##_STEP_PIN, true); \ - AXIS ##_APPLY_DIR(old_pin, true); \ + _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \ + _APPLY_DIR(AXIS, old_pin); \ } switch(axis) { @@ -1165,7 +1186,7 @@ void quickStop() { case Y_AXIS: BABYSTEP_AXIS(y, Y, false); break; - + case Z_AXIS: { #ifndef DELTA @@ -1202,7 +1223,7 @@ void quickStop() { #endif } break; - + default: break; } } @@ -1266,7 +1287,7 @@ void microstep_init() { #if HAS_MICROSTEPS pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); From 0fed46360c7b43ecb49f0fc404a46fa48ad3a4cc Mon Sep 17 00:00:00 2001 From: AnHardt Date: Fri, 24 Apr 2015 16:43:19 +0200 Subject: [PATCH 087/118] Add variant for MAX6675 in M104 Else will throw error: @:0 B@:0 Error:No thermistors - no temperature [ERROR] Error:No thermistors - no temperature when no bed is defined --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a06bf78d0c..52b79c7dee 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -3152,7 +3152,7 @@ inline void gcode_M104() { inline void gcode_M105() { if (setTargetedHotend(105)) return; - #if HAS_TEMP_0 || HAS_TEMP_BED + #if HAS_TEMP_0 || HAS_TEMP_BED || defined(HEATER_0_USES_MAX6675) SERIAL_PROTOCOLPGM("ok"); #if HAS_TEMP_0 SERIAL_PROTOCOLPGM(" T:"); From 35e79d56a5e5af903f310f28d92298bfc5bb5548 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 19:23:12 -0700 Subject: [PATCH 088/118] Remove set-coordinate extension of G28 --- Marlin/Marlin_main.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 7d417bd228..a09ef49070 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1790,12 +1790,6 @@ inline void gcode_G4() { * Y Home to the Y endstop * Z Home to the Z endstop * - * If numbers are included with XYZ set the position as with G92 - * Currently adds the home_offset, which may be wrong and removed soon. - * - * Xn Home X, setting X to n + home_offset[X_AXIS] - * Yn Home Y, setting Y to n + home_offset[Y_AXIS] - * Zn Home Z, setting Z to n + home_offset[Z_AXIS] */ inline void gcode_G28() { @@ -1855,7 +1849,7 @@ inline void gcode_G28() { homeY = code_seen(axis_codes[Y_AXIS]), homeZ = code_seen(axis_codes[Z_AXIS]); - home_all_axis = !(homeX || homeY || homeZ) || (homeX && homeY && homeZ); + home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ); if (home_all_axis || homeZ) { @@ -1942,18 +1936,6 @@ inline void gcode_G28() { // Home Y if (home_all_axis || homeY) HOMEAXIS(Y); - // Set the X position, if included - if (code_seen(axis_codes[X_AXIS]) && code_has_value()) { - if (code_value_long() != 0) // filter 0 - current_position[X_AXIS] = code_value(); - } - - // Set the Y position, if included - if (code_seen(axis_codes[Y_AXIS]) && code_has_value()) { - if (code_value_long() != 0) // filter 0 - current_position[Y_AXIS] = code_value(); - } - // Home Z last if homing towards the bed #if Z_HOME_DIR < 0 @@ -2037,12 +2019,6 @@ inline void gcode_G28() { #endif // Z_HOME_DIR < 0 - // Set the Z position, if included - if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) { - if (code_value_long() != 0) // filter 0 - current_position[Z_AXIS] = code_value(); - } - #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) #endif From ce142afddae60aad7ce6f7fb2d223613607b700d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 20:13:01 -0700 Subject: [PATCH 089/118] G4 shows status message only if no message is set already - Address issue raised in #1961 --- Marlin/Marlin_main.cpp | 5 +++-- Marlin/ultralcd.cpp | 2 ++ Marlin/ultralcd.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a09ef49070..e1a9cd6e01 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1740,14 +1740,15 @@ inline void gcode_G2_G3(bool clockwise) { inline void gcode_G4() { millis_t codenum = 0; - LCD_MESSAGEPGM(MSG_DWELL); - if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait st_synchronize(); refresh_cmd_timeout(); codenum += previous_cmd_ms; // keep track of when we started waiting + + if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL); + while (millis() < codenum) { manage_heater(); manage_inactivity(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index c96f098994..03da2366b3 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1418,6 +1418,8 @@ void set_utf_strlen(char *s, uint8_t n) { s[i] = 0; } +bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); } + void lcd_setstatus(const char* message, bool persist) { if (lcd_status_message_level > 0) return; strncpy(lcd_status_message, message, 3*LCD_WIDTH); diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index b8d5cba8ad..97d939fa34 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -8,6 +8,7 @@ int lcd_strlen_P(const char *s); void lcd_update(); void lcd_init(); + bool lcd_hasstatus(); void lcd_setstatus(const char* message, const bool persist=false); void lcd_setstatuspgm(const char* message, const uint8_t level=0); void lcd_setalertstatuspgm(const char* message); From 56ff46eb8b34d3fa8db9ea6ddac22dab6f79878c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 20:43:16 -0700 Subject: [PATCH 090/118] Improve code_has_value test --- Marlin/Marlin_main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index e1a9cd6e01..27027c8332 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -890,8 +890,11 @@ void get_command() { } bool code_has_value() { - char c = strchr_pointer[1]; - return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'; + int i = 1; + char c = strchr_pointer[i]; + if (c == '-' || c == '+') c = strchr_pointer[++i]; + if (c == '.') c = strchr_pointer[++i]; + return (c >= '0' && c <= '9'); } float code_value() { From 182f2cda350b284db5d71cc194ed7f3ea7872d4c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 21:26:36 -0700 Subject: [PATCH 091/118] Minor cleanup of M48 --- Marlin/Marlin_main.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 05a864e6a6..65290b3cb8 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1189,8 +1189,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position, st_synchronize(); endstops_hit_on_purpose(); // clear endstop hit flags + // Get the current stepper position after bumping an endstop current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); - // make sure the planner knows where we are as it may be a bit different than we last said to move to sync_plan_position(); #endif // !DELTA @@ -2908,12 +2908,12 @@ inline void gcode_M42() { } } - double X_probe_location, Y_probe_location, - X_current = X_probe_location = st_get_position_mm(X_AXIS), - Y_current = Y_probe_location = st_get_position_mm(Y_AXIS), + double X_current = st_get_position_mm(X_AXIS), + Y_current = st_get_position_mm(Y_AXIS), Z_current = st_get_position_mm(Z_AXIS), - Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING, - ext_position = st_get_position_mm(E_AXIS); + E_current = st_get_position_mm(E_AXIS), + X_probe_location = X_current, Y_probe_location = Y_current, + Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING; bool deploy_probe_for_each_reading = code_seen('E') || code_seen('e'); @@ -2948,10 +2948,7 @@ inline void gcode_M42() { st_synchronize(); plan_bed_level_matrix.set_to_identity(); - plan_buffer_line(X_current, Y_current, Z_start_location, - ext_position, - homing_feedrate[Z_AXIS] / 60, - active_extruder); + plan_buffer_line(X_current, Y_current, Z_start_location, E_current, homing_feedrate[Z_AXIS] / 60, active_extruder); st_synchronize(); // @@ -2963,7 +2960,7 @@ inline void gcode_M42() { SERIAL_PROTOCOLPGM("Positioning the probe...\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, - ext_position, + E_current, homing_feedrate[X_AXIS]/60, active_extruder); st_synchronize(); @@ -2971,7 +2968,7 @@ inline void gcode_M42() { current_position[X_AXIS] = X_current = st_get_position_mm(X_AXIS); current_position[Y_AXIS] = Y_current = st_get_position_mm(Y_AXIS); current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); - current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); + current_position[E_AXIS] = E_current = st_get_position_mm(E_AXIS); // // OK, do the inital probe to get us close to the bed. @@ -2987,7 +2984,7 @@ inline void gcode_M42() { Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, - ext_position, + E_current, homing_feedrate[X_AXIS]/60, active_extruder); st_synchronize(); @@ -3017,8 +3014,8 @@ inline void gcode_M42() { if (radius < 0.0) radius = -radius; X_current = X_probe_location + cos(theta) * radius; - Y_current = Y_probe_location + sin(theta) * radius; X_current = constrain(X_current, X_MIN_POS, X_MAX_POS); + Y_current = Y_probe_location + sin(theta) * radius; Y_current = constrain(Y_current, Y_MIN_POS, Y_MAX_POS); if (verbose_level > 3) { From 0d8c00d3f644e569489b61ba5bdb0ec22ba6fcf3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 21:36:04 -0700 Subject: [PATCH 092/118] Define lcd_hasstatus for no lcd also --- Marlin/ultralcd.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 97d939fa34..94ec168778 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -101,6 +101,7 @@ #else //no LCD FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_init() {} + FORCE_INLINE bool lcd_hasstatus() { return false; }; FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {} FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {} FORCE_INLINE void lcd_buttons_update() {} @@ -108,8 +109,8 @@ FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {} FORCE_INLINE bool lcd_detected(void) { return true; } - #define LCD_MESSAGEPGM(x) - #define LCD_ALERTMESSAGEPGM(x) + #define LCD_MESSAGEPGM(x) do{}while(0) + #define LCD_ALERTMESSAGEPGM(x) do{}while(0) #endif //ULTRA_LCD From 7295640f44636e779c1d8dec142c0b987c65fb59 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 21:37:27 -0700 Subject: [PATCH 093/118] Remove extraneous ; --- Marlin/ultralcd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 94ec168778..8f96f008ba 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -101,7 +101,7 @@ #else //no LCD FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_init() {} - FORCE_INLINE bool lcd_hasstatus() { return false; }; + FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {} FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {} FORCE_INLINE void lcd_buttons_update() {} From 97dfa0365d7d83303bbc2bea547d1815005c02f6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 21:51:10 -0700 Subject: [PATCH 094/118] Rename expireStatusMillis to expire_status_ms --- Marlin/ultralcd.cpp | 14 +++++++------- Marlin/ultralcd_implementation_hitachi_HD44780.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 03da2366b3..a310db6143 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -273,22 +273,22 @@ static void lcd_status_screen() { #endif #if PROGRESS_MSG_EXPIRE > 0 // Handle message expire - if (expireStatusMillis > 0) { + if (expire_status_ms > 0) { if (card.isFileOpen()) { // Expire the message when printing is active if (IS_SD_PRINTING) { // Expire the message when printing is active - if (ms >= expireStatusMillis) { + if (ms >= expire_status_ms) { lcd_status_message[0] = '\0'; - expireStatusMillis = 0; + expire_status_ms = 0; } } else { - expireStatusMillis += LCD_UPDATE_INTERVAL; + expire_status_ms += LCD_UPDATE_INTERVAL; } } else { - expireStatusMillis = 0; + expire_status_ms = 0; } } #endif @@ -1394,7 +1394,7 @@ void lcd_finishstatus(bool persist=false) { #ifdef LCD_PROGRESS_BAR progressBarTick = millis(); #if PROGRESS_MSG_EXPIRE > 0 - expireStatusMillis = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE; + expire_status_ms = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE; #endif #endif lcdDrawUpdate = 2; @@ -1405,7 +1405,7 @@ void lcd_finishstatus(bool persist=false) { } #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 - void dontExpireStatus() { expireStatusMillis = 0; } + void dontExpireStatus() { expire_status_ms = 0; } #endif void set_utf_strlen(char *s, uint8_t n) { diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index f9ed56a7dc..50c6deb5e4 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -196,7 +196,7 @@ #ifdef LCD_PROGRESS_BAR static uint16_t progressBarTick = 0; #if PROGRESS_MSG_EXPIRE > 0 - static uint16_t expireStatusMillis = 0; + static uint16_t expire_status_ms = 0; #endif #define LCD_STR_PROGRESS "\x03\x04\x05" #endif From c92b59952a9eb517d92df58f428df8dbb03a1f05 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 22:16:09 -0700 Subject: [PATCH 095/118] Use millis_t for progress_bar_ms and expire_status_ms --- Marlin/ultralcd.cpp | 8 ++++---- Marlin/ultralcd_implementation_hitachi_HD44780.h | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index a310db6143..1d4e167287 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -267,8 +267,8 @@ static void lcd_status_screen() { #ifdef LCD_PROGRESS_BAR millis_t ms = millis(); #ifndef PROGRESS_MSG_ONCE - if (ms > progressBarTick + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) { - progressBarTick = ms; + if (ms > progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) { + progress_bar_ms = ms; } #endif #if PROGRESS_MSG_EXPIRE > 0 @@ -1392,9 +1392,9 @@ void lcd_ignore_click(bool b) { void lcd_finishstatus(bool persist=false) { #ifdef LCD_PROGRESS_BAR - progressBarTick = millis(); + progress_bar_ms = millis(); #if PROGRESS_MSG_EXPIRE > 0 - expire_status_ms = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE; + expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE; #endif #endif lcdDrawUpdate = 2; diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 50c6deb5e4..eb1f525cc2 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -194,9 +194,9 @@ #include "utf_mapper.h" #ifdef LCD_PROGRESS_BAR - static uint16_t progressBarTick = 0; + static millis_t progress_bar_ms = 0; #if PROGRESS_MSG_EXPIRE > 0 - static uint16_t expire_status_ms = 0; + static millis_t expire_status_ms = 0; #endif #define LCD_STR_PROGRESS "\x03\x04\x05" #endif @@ -588,8 +588,9 @@ static void lcd_implementation_status_screen() { #ifdef LCD_PROGRESS_BAR if (card.isFileOpen()) { - if (millis() >= progressBarTick + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) { - // draw the progress bar + // Draw the progress bar if the message has shown long enough + // or if there is no message set. + if (millis() >= progress_bar_ms + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) { int tix = (int)(card.percentDone() * LCD_WIDTH * 3) / 100, cel = tix / 3, rem = tix % 3, i = LCD_WIDTH; char msg[LCD_WIDTH+1], b = ' '; From 5c29fda16756d28b231444b1e54ed656650bc8ab Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Apr 2015 00:46:33 -0700 Subject: [PATCH 096/118] Add a warning for DISABLE_[XYZ] options --- Marlin/Configuration.h | 1 + Marlin/configurator/config/Configuration.h | 1 + Marlin/example_configurations/Felix/Configuration.h | 1 + Marlin/example_configurations/Felix/Configuration_DUAL.h | 1 + Marlin/example_configurations/Hephestos/Configuration.h | 1 + Marlin/example_configurations/K8200/Configuration.h | 1 + Marlin/example_configurations/SCARA/Configuration.h | 1 + Marlin/example_configurations/WITBOX/Configuration.h | 1 + Marlin/example_configurations/delta/generic/Configuration.h | 1 + Marlin/example_configurations/delta/kossel_mini/Configuration.h | 1 + Marlin/example_configurations/makibox/Configuration.h | 1 + Marlin/example_configurations/tvrrug/Round2/Configuration.h | 1 + 12 files changed, 12 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 4e39703ad4..e3d0c339a2 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -364,6 +364,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 7210894182..59d13ab64e 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -364,6 +364,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 5b1bca2256..558ee3bb03 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -317,6 +317,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index edc1588101..2e5633b8c1 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -317,6 +317,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 0ebea087c6..69841816fd 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -338,6 +338,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 68634b552a..2987552f6d 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -375,6 +375,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z true diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 3718edbe7b..6d70fa244f 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -369,6 +369,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index d4ff5b2aca..7022f78887 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -337,6 +337,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z true diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 1fa08d0cb4..ae094ccac5 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -367,6 +367,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 5557932838..f6b6a1e036 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -367,6 +367,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index bc6cbb949f..500f47fe86 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -337,6 +337,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic #define E_ENABLE_ON 0 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index a785543ca7..314faf2d6a 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -339,6 +339,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic #define E_ENABLE_ON 1 // For all extruders // Disables axis when it's not being used. +// WARNING: When motors turn off there is a chance of losing position accuracy! #define DISABLE_X false #define DISABLE_Y false #define DISABLE_Z false From 9c5d14ea683099cbc70597894488281ab380c4f1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Apr 2015 03:12:49 -0700 Subject: [PATCH 097/118] Fix BEEPER duration --- Marlin/ultralcd.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 1d4e167287..433d0087b1 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1544,7 +1544,9 @@ void lcd_buzz(long duration, uint16_t freq) { if (freq > 0) { #if BEEPER > 0 SET_OUTPUT(BEEPER); - tone(BEEPER, freq, duration); + tone(BEEPER, freq); + delay(duration); + noTone(BEEPER); #elif defined(LCD_USE_I2C_BUZZER) lcd.buzz(duration,freq); #else From a932e7490fcfa01eb64c3675a0ce83d29c16045c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Apr 2015 03:25:30 -0700 Subject: [PATCH 098/118] No noTone needed, but delay is --- Marlin/ultralcd.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 433d0087b1..d2fb575ce0 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1544,11 +1544,10 @@ void lcd_buzz(long duration, uint16_t freq) { if (freq > 0) { #if BEEPER > 0 SET_OUTPUT(BEEPER); - tone(BEEPER, freq); + tone(BEEPER, freq, duration); delay(duration); - noTone(BEEPER); #elif defined(LCD_USE_I2C_BUZZER) - lcd.buzz(duration,freq); + lcd.buzz(duration, freq); #else delay(duration); #endif From a22a228bcc65e30c9c500dc17fbed51cc9718ef4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Apr 2015 21:04:54 -0700 Subject: [PATCH 099/118] Rename files to move them in the IDE --- Marlin/BlinkM.cpp | 4 ++-- Marlin/BlinkM.h | 2 +- Marlin/Makefile | 4 ++-- Marlin/Marlin_main.cpp | 8 ++++---- Marlin/Servo.cpp | 4 ++-- Marlin/Servo.h | 6 +++--- .../{ConfigurationStore.cpp => configuration_store.cpp} | 4 ++-- Marlin/{ConfigurationStore.h => configuration_store.h} | 6 +++--- Marlin/{DOGMbitmaps.h => dogm_bitmaps.h} | 0 Marlin/dogm_lcd_implementation.h | 2 +- Marlin/pins_SAV_MKI.h | 2 +- Marlin/ultralcd.cpp | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) rename Marlin/{ConfigurationStore.cpp => configuration_store.cpp} (99%) rename Marlin/{ConfigurationStore.h => configuration_store.h} (83%) rename Marlin/{DOGMbitmaps.h => dogm_bitmaps.h} (100%) diff --git a/Marlin/BlinkM.cpp b/Marlin/BlinkM.cpp index b340f968c0..1ec5b656cc 100644 --- a/Marlin/BlinkM.cpp +++ b/Marlin/BlinkM.cpp @@ -1,11 +1,11 @@ /* - BlinkM.cpp - Library for controlling a BlinkM over i2c + blinkm.cpp - Library for controlling a BlinkM over i2c Created by Tim Koster, August 21 2013. */ #include "Marlin.h" #ifdef BLINKM -#include "BlinkM.h" +#include "blinkm.h" void SendColors(byte red, byte grn, byte blu) { Wire.begin(); diff --git a/Marlin/BlinkM.h b/Marlin/BlinkM.h index 5b802b718b..08169e589c 100644 --- a/Marlin/BlinkM.h +++ b/Marlin/BlinkM.h @@ -1,5 +1,5 @@ /* - BlinkM.h + blinkm.h Library header file for BlinkM library */ #if ARDUINO >= 100 diff --git a/Marlin/Makefile b/Marlin/Makefile index 56e5dda734..e23c2a19b4 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -267,8 +267,8 @@ endif CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \ MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \ SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \ - stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \ - watchdog.cpp SPI.cpp Servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \ + stepper.cpp temperature.cpp cardreader.cpp configuration_store.cpp \ + watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \ vector_3.cpp qr_solve.cpp ifeq ($(LIQUID_TWI2), 0) CXXSRC += LiquidCrystal.cpp diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index e22fddb271..33432ac366 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -49,18 +49,18 @@ #include "motion_control.h" #include "cardreader.h" #include "watchdog.h" -#include "ConfigurationStore.h" +#include "configuration_store.h" #include "language.h" #include "pins_arduino.h" #include "math.h" #ifdef BLINKM - #include "BlinkM.h" + #include "blinkm.h" #include "Wire.h" #endif #if NUM_SERVOS > 0 - #include "Servo.h" + #include "servo.h" #endif #if HAS_DIGIPOTSS @@ -4417,7 +4417,7 @@ inline void gcode_M503() { if (code_seen('Z')) { value = code_value(); if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) { - zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp + zprobe_zoffset = -value; // compare w/ line 278 of configuration_store.cpp SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK); SERIAL_EOL; diff --git a/Marlin/Servo.cpp b/Marlin/Servo.cpp index 27a7d3cf3e..81d73ae870 100644 --- a/Marlin/Servo.cpp +++ b/Marlin/Servo.cpp @@ -1,5 +1,5 @@ /* - Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. This library is free software; you can redistribute it and/or @@ -48,7 +48,7 @@ #include #include -#include "Servo.h" +#include "servo.h" #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds diff --git a/Marlin/Servo.h b/Marlin/Servo.h index 682a3b3798..4647561754 100644 --- a/Marlin/Servo.h +++ b/Marlin/Servo.h @@ -1,5 +1,5 @@ /* - Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 Copyright (c) 2009 Michael Margolis. All right reserved. This library is free software; you can redistribute it and/or @@ -42,8 +42,8 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#ifndef Servo_h -#define Servo_h +#ifndef servo_h +#define servo_h #include diff --git a/Marlin/ConfigurationStore.cpp b/Marlin/configuration_store.cpp similarity index 99% rename from Marlin/ConfigurationStore.cpp rename to Marlin/configuration_store.cpp index 0154691de0..9f91db0985 100644 --- a/Marlin/ConfigurationStore.cpp +++ b/Marlin/configuration_store.cpp @@ -1,5 +1,5 @@ /** - * ConfigurationStore.cpp + * configuration_store.cpp * * Configuration and EEPROM storage * @@ -93,7 +93,7 @@ #include "planner.h" #include "temperature.h" #include "ultralcd.h" -#include "ConfigurationStore.h" +#include "configuration_store.h" #ifdef MESH_BED_LEVELING #include "mesh_bed_leveling.h" diff --git a/Marlin/ConfigurationStore.h b/Marlin/configuration_store.h similarity index 83% rename from Marlin/ConfigurationStore.h rename to Marlin/configuration_store.h index 3dc4a92cfd..6f1a8fcbdc 100644 --- a/Marlin/ConfigurationStore.h +++ b/Marlin/configuration_store.h @@ -1,5 +1,5 @@ -#ifndef CONFIGURATIONSTORE_H -#define CONFIGURATIONSTORE_H +#ifndef CONFIGURATION_STORE_H +#define CONFIGURATION_STORE_H #include "Configuration.h" @@ -19,4 +19,4 @@ void Config_ResetDefault(); FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } #endif -#endif //CONFIGURATIONSTORE_H +#endif //CONFIGURATION_STORE_H diff --git a/Marlin/DOGMbitmaps.h b/Marlin/dogm_bitmaps.h similarity index 100% rename from Marlin/DOGMbitmaps.h rename to Marlin/dogm_bitmaps.h diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 3ab18af75c..0965b90972 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -29,7 +29,7 @@ #endif #include -#include "DOGMbitmaps.h" +#include "dogm_bitmaps.h" #include "ultralcd.h" #include "ultralcd_st7920_u8glib_rrd.h" diff --git a/Marlin/pins_SAV_MKI.h b/Marlin/pins_SAV_MKI.h index e898c9f285..e853b63b95 100644 --- a/Marlin/pins_SAV_MKI.h +++ b/Marlin/pins_SAV_MKI.h @@ -82,7 +82,7 @@ #define HOME_PIN -1 // A4 = marlin 44 - teensy = 42 #ifdef NUM_SERVOS - #define SERVO0_PIN 41 // In teensy's pin definition for pinMode (in Servo.cpp) + #define SERVO0_PIN 41 // In teensy's pin definition for pinMode (in servo.cpp) #endif #endif // SAV_3DLCD diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index d2fb575ce0..81844573ea 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -5,7 +5,7 @@ #include "cardreader.h" #include "temperature.h" #include "stepper.h" -#include "ConfigurationStore.h" +#include "configuration_store.h" int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */ From 0ec444720f32a25175b6aa6846d31e457d751bdf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Apr 2015 21:06:19 -0700 Subject: [PATCH 100/118] Rename blinkm files --- Marlin/{BlinkM.cpp => blinkm.cpp} | 0 Marlin/{BlinkM.h => blinkm.h} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Marlin/{BlinkM.cpp => blinkm.cpp} (100%) rename Marlin/{BlinkM.h => blinkm.h} (100%) diff --git a/Marlin/BlinkM.cpp b/Marlin/blinkm.cpp similarity index 100% rename from Marlin/BlinkM.cpp rename to Marlin/blinkm.cpp diff --git a/Marlin/BlinkM.h b/Marlin/blinkm.h similarity index 100% rename from Marlin/BlinkM.h rename to Marlin/blinkm.h From d43cc2dd5f52c9b71b486e7778d7fb44ea67fad6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 26 Apr 2015 20:08:45 -0700 Subject: [PATCH 101/118] M111 - Debug Level - Add `M111` as a standard option to set the debug level - Implement `DEBUG_ECHO` in `process_commands` - Other debug levels (e.g., `DEBUG_DRYRUN`) need more work --- Marlin/Marlin.h | 12 ++++++ Marlin/Marlin_main.cpp | 59 ++++++++++++++++++--------- Marlin/configurator/config/language.h | 3 +- Marlin/language.h | 3 +- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 0158a1d714..97978c45f7 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -223,6 +223,18 @@ void Stop(); void filrunout(); #endif +/** + * Debug flags - not yet widely applied + */ +enum DebugFlags { + DEBUG_ECHO = BIT(0), + DEBUG_INFO = BIT(1), + DEBUG_ERRORS = BIT(2), + DEBUG_DRYRUN = BIT(3), + DEBUG_COMMUNICATION = BIT(4) +}; +extern uint8_t marlin_debug_flags; + extern bool Running; inline bool IsRunning() { return Running; } inline bool IsStopped() { return !Running; } diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 33432ac366..ac86cb05b7 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -138,6 +138,7 @@ * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating * Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling * IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F + * M111 - Set debug flags with S. See flag bits defined in Marlin.h. * M112 - Emergency stop * M114 - Output current position to serial port * M115 - Capabilities string @@ -218,6 +219,8 @@ bool Running = true; +uint8_t marlin_debug_flags = DEBUG_INFO|DEBUG_ERRORS; + static float feedrate = 1500.0, next_feedrate, saved_feedrate; float current_position[NUM_AXIS] = { 0.0 }; static float destination[NUM_AXIS] = { 0.0 }; @@ -749,9 +752,10 @@ void get_command() { gcode_N = (strtol(strchr_pointer + 1, NULL, 10)); if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) { SERIAL_ERROR_START; - SERIAL_ERRORPGM(MSG_ERR_LINE_NO); - SERIAL_ERRORLN(gcode_LastN); - //Serial.println(gcode_N); + SERIAL_ERRORPGM(MSG_ERR_LINE_NO1); + SERIAL_ERROR(gcode_LastN + 1); + SERIAL_ERRORPGM(MSG_ERR_LINE_NO2); + SERIAL_ERRORLN(gcode_N); FlushSerialRequestResend(); serial_count = 0; return; @@ -3336,12 +3340,17 @@ inline void gcode_M109() { #endif // HAS_TEMP_BED +/** + * M111: Set the debug level + */ +inline void gcode_M111() { + marlin_debug_flags = code_seen('S') ? code_value_short() : DEBUG_INFO|DEBUG_ERRORS; +} + /** * M112: Emergency Stop */ -inline void gcode_M112() { - kill(); -} +inline void gcode_M112() { kill(); } #ifdef BARICUDA @@ -4781,6 +4790,12 @@ inline void gcode_T() { * This is called from the main loop() */ void process_commands() { + + if ((marlin_debug_flags & DEBUG_ECHO)) { + SERIAL_ECHO_START; + SERIAL_ECHOLN(command_queue[cmd_queue_index_r]); + } + if (code_seen('G')) { int gCode = code_value_short(); @@ -4919,34 +4934,38 @@ void process_commands() { gcode_M104(); break; - case 112: // M112 Emergency Stop + case 111: // M111: Set debug level + gcode_M111(); + break; + + case 112: // M112: Emergency Stop gcode_M112(); break; - case 140: // M140 Set bed temp + case 140: // M140: Set bed temp gcode_M140(); break; - case 105: // M105 Read current temperature + case 105: // M105: Read current temperature gcode_M105(); return; break; - case 109: // M109 Wait for temperature + case 109: // M109: Wait for temperature gcode_M109(); break; #if HAS_TEMP_BED - case 190: // M190 - Wait for bed heater to reach target. + case 190: // M190: Wait for bed heater to reach target gcode_M190(); break; #endif // HAS_TEMP_BED #if HAS_FAN - case 106: //M106 Fan On + case 106: // M106: Fan On gcode_M106(); break; - case 107: //M107 Fan Off + case 107: // M107: Fan Off gcode_M107(); break; #endif // HAS_FAN @@ -4954,20 +4973,20 @@ void process_commands() { #ifdef BARICUDA // PWM for HEATER_1_PIN #if HAS_HEATER_1 - case 126: // M126 valve open + case 126: // M126: valve open gcode_M126(); break; - case 127: // M127 valve closed + case 127: // M127: valve closed gcode_M127(); break; #endif // HAS_HEATER_1 // PWM for HEATER_2_PIN #if HAS_HEATER_2 - case 128: // M128 valve open + case 128: // M128: valve open gcode_M128(); break; - case 129: // M129 valve closed + case 129: // M129: valve closed gcode_M129(); break; #endif // HAS_HEATER_2 @@ -4975,13 +4994,13 @@ void process_commands() { #if HAS_POWER_SWITCH - case 80: // M80 - Turn on Power Supply + case 80: // M80: Turn on Power Supply gcode_M80(); break; #endif // HAS_POWER_SWITCH - case 81: // M81 - Turn off Power, including Power Supply, if possible + case 81: // M81: Turn off Power, including Power Supply, if possible gcode_M81(); break; @@ -4991,7 +5010,7 @@ void process_commands() { case 83: gcode_M83(); break; - case 18: //compatibility + case 18: // (for compatibility) case 84: // M84 gcode_M18_M84(); break; diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index 718fe9499c..2576bec42b 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -122,7 +122,8 @@ #define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " #define MSG_OK "ok" #define MSG_FILE_SAVED "Done saving file." -#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: " +#define MSG_ERR_LINE_NO1 "Line Number out of sequence. Expected: " +#define MSG_ERR_LINE_NO2 " Got: " #define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: " #define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line: " #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: " diff --git a/Marlin/language.h b/Marlin/language.h index 3bc7ce0161..c9ddfeee41 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -122,7 +122,8 @@ #define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " #define MSG_OK "ok" #define MSG_FILE_SAVED "Done saving file." -#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: " +#define MSG_ERR_LINE_NO1 "Line Number out of sequence. Expected: " +#define MSG_ERR_LINE_NO2 " Got: " #define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: " #define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line: " #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: " From 0fca084ea688aed41b892f9cea7e069510c73c94 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 26 Apr 2015 18:44:01 -0700 Subject: [PATCH 102/118] Make EEPROM reproducible in GCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With these changes the output of `M503 S0` is all you need to restore the EEPROM. Building on this it is straightforward to save and restore the EEPROM state using the SD card or external GCode file. - Added `M145` to set “heatup states” for the LCD menu - Added `M420` to toggle Mesh Bed Leveling - Added `M421` to set a single Mesh coordinate - Extended `Config_PrintSettings` with added M codes - Cleaned up some comments here and there --- Marlin/Configuration_adv.h | 2 +- Marlin/Marlin_main.cpp | 153 +++++++- Marlin/configuration_store.cpp | 334 +++++++++++------- .../configurator/config/Configuration_adv.h | 2 +- Marlin/configurator/config/language.h | 5 +- .../Felix/Configuration_adv.h | 2 +- .../Hephestos/Configuration_adv.h | 2 +- .../K8200/Configuration_adv.h | 2 +- .../SCARA/Configuration_adv.h | 2 +- .../WITBOX/Configuration_adv.h | 2 +- .../delta/generic/Configuration_adv.h | 2 +- .../delta/kossel_mini/Configuration_adv.h | 2 +- .../makibox/Configuration_adv.h | 2 +- .../tvrrug/Round2/Configuration_adv.h | 2 +- Marlin/language.h | 3 + Marlin/planner.cpp | 139 ++++---- Marlin/planner.h | 14 +- Marlin/temperature.cpp | 5 +- Marlin/ultralcd.cpp | 8 +- Marlin/watchdog.cpp | 6 +- 20 files changed, 454 insertions(+), 235 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6478eb923e..059f0c5c16 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ac86cb05b7..cbeb9a0912 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -151,6 +151,7 @@ * M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil) * M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil) * M140 - Set bed target temp + * M145 - Set the heatup state H B F for S (0=PLA, 1=ABS) * M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. * M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating * Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling @@ -186,6 +187,8 @@ * M406 - Turn off Filament Sensor extrusion control * M407 - Display measured filament diameter * M410 - Quickstop. Abort all the planned moves + * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable + * M421 - Set a single Z coordinate in the Mesh Leveling grid. X Y Z * M500 - Store parameters in EEPROM * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -3385,6 +3388,62 @@ inline void gcode_M140() { if (code_seen('S')) setTargetBed(code_value()); } +#ifdef ULTIPANEL + + /** + * M145: Set the heatup state for a material in the LCD menu + * S (0=PLA, 1=ABS) + * H + * B + * F + */ + inline void gcode_M145() { + uint8_t material = code_seen('S') ? code_value_short() : 0; + if (material < 0 || material > 1) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX); + } + else { + int v; + switch (material) { + case 0: + if (code_seen('H')) { + v = code_value_short(); + plaPreheatHotendTemp = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15); + } + if (code_seen('F')) { + v = code_value_short(); + plaPreheatFanSpeed = constrain(v, 0, 255); + } + #if TEMP_SENSOR_BED != 0 + if (code_seen('B')) { + v = code_value_short(); + plaPreheatHPBTemp = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15); + } + #endif + break; + case 1: + if (code_seen('H')) { + v = code_value_short(); + absPreheatHotendTemp = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15); + } + if (code_seen('F')) { + v = code_value_short(); + absPreheatFanSpeed = constrain(v, 0, 255); + } + #if TEMP_SENSOR_BED != 0 + if (code_seen('B')) { + v = code_value_short(); + absPreheatHPBTemp = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15); + } + #endif + break; + } + } + } + +#endif + #if HAS_POWER_SWITCH /** @@ -3492,7 +3551,8 @@ inline void gcode_M85() { } /** - * M92: Set inactivity shutdown timer with parameter S. To disable set zero (default) + * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E. + * (Follows the same syntax as G92) */ inline void gcode_M92() { for(int8_t i=0; i < NUM_AXIS; i++) { @@ -3814,20 +3874,35 @@ inline void gcode_M206() { #ifdef FWRETRACT /** - * M207: Set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop] + * M207: Set firmware retraction values + * + * S[+mm] retract_length + * W[+mm] retract_length_swap (multi-extruder) + * F[mm/min] retract_feedrate + * Z[mm] retract_zlift */ inline void gcode_M207() { if (code_seen('S')) retract_length = code_value(); if (code_seen('F')) retract_feedrate = code_value() / 60; if (code_seen('Z')) retract_zlift = code_value(); + #if EXTRUDERS > 1 + if (code_seen('W')) retract_length_swap = code_value(); + #endif } /** - * M208: Set retract recover length S[positive mm surplus to the M207 S*] F[feedrate mm/min] + * M208: Set firmware un-retraction values + * + * S[+mm] retract_recover_length (in addition to M207 S*) + * W[+mm] retract_recover_length_swap (multi-extruder) + * F[mm/min] retract_recover_feedrate */ inline void gcode_M208() { if (code_seen('S')) retract_recover_length = code_value(); if (code_seen('F')) retract_recover_feedrate = code_value() / 60; + #if EXTRUDERS > 1 + if (code_seen('W')) retract_recover_length_swap = code_value(); + #endif } /** @@ -4380,6 +4455,42 @@ inline void gcode_M400() { st_synchronize(); } */ inline void gcode_M410() { quickStop(); } + +#ifdef MESH_BED_LEVELING + + /** + * M420: Enable/Disable Mesh Bed Leveling + */ + inline void gcode_M420() { if (code_seen('S') && code_has_value()) mbl.active = !!code_value_short(); } + + /** + * M421: Set a single Mesh Bed Leveling Z coordinate + */ + inline void gcode_M421() { + int x, y; + float z; + bool err = false, hasX, hasY, hasZ; + if ((hasX = code_seen('X'))) x = code_value_short(); + if ((hasY = code_seen('Y'))) y = code_value_short(); + if ((hasZ = code_seen('Z'))) z = code_value(); + + if (!hasX || !hasY || !hasZ) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_XYZ_REQUIRED_FOR_M421); + err = true; + } + + if (x >= MESH_NUM_X_POINTS || y >= MESH_NUM_Y_POINTS) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM(MSG_ERR_MESH_INDEX_OOB); + err = true; + } + + if (!err) mbl.z_values[y][x] = z; + } + +#endif + /** * M500: Store settings in EEPROM */ @@ -4934,11 +5045,11 @@ void process_commands() { gcode_M104(); break; - case 111: // M111: Set debug level + case 111: // M111: Set debug level gcode_M111(); break; - case 112: // M112: Emergency Stop + case 112: // M112: Emergency Stop gcode_M112(); break; @@ -5017,28 +5128,35 @@ void process_commands() { case 85: // M85 gcode_M85(); break; - case 92: // M92 + case 92: // M92: Set the steps-per-unit for one or more axes gcode_M92(); break; - case 115: // M115 + case 115: // M115: Report capabilities gcode_M115(); break; - case 117: // M117 display message + case 117: // M117: Set LCD message text gcode_M117(); break; - case 114: // M114 + case 114: // M114: Report current position gcode_M114(); break; - case 120: // M120 + case 120: // M120: Enable endstops gcode_M120(); break; - case 121: // M121 + case 121: // M121: Disable endstops gcode_M121(); break; - case 119: // M119 + case 119: // M119: Report endstop states gcode_M119(); break; - //TODO: update for all axis, use for loop + + #ifdef ULTIPANEL + + case 145: // M145: Set material heatup parameters + gcode_M145(); + break; + + #endif #ifdef BLINKM @@ -5213,6 +5331,15 @@ void process_commands() { gcode_M410(); break; + #ifdef MESH_BED_LEVELING + case 420: // M420 Enable/Disable Mesh Bed Leveling + gcode_M420(); + break; + case 421: // M421 Set a Mesh Bed Leveling Z coordinate + gcode_M421(); + break; + #endif + case 500: // M500 Store settings in EEPROM gcode_M500(); break; diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 9f91db0985..318501db62 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -20,72 +20,72 @@ * V19 EEPROM Layout: * * ver - * axis_steps_per_unit (x4) - * max_feedrate (x4) - * max_acceleration_units_per_sq_second (x4) - * acceleration - * retract_acceleration - * travel_acceleration - * minimumfeedrate - * mintravelfeedrate - * minsegmenttime - * max_xy_jerk - * max_z_jerk - * max_e_jerk - * home_offset (x3) + * M92 XYZE axis_steps_per_unit (x4) + * M203 XYZE max_feedrate (x4) + * M201 XYZE max_acceleration_units_per_sq_second (x4) + * M204 P acceleration + * M204 R retract_acceleration + * M204 T travel_acceleration + * M205 S minimumfeedrate + * M205 T mintravelfeedrate + * M205 B minsegmenttime + * M205 X max_xy_jerk + * M205 Z max_z_jerk + * M205 E max_e_jerk + * M206 XYZ home_offset (x3) * * Mesh bed leveling: - * active - * mesh_num_x - * mesh_num_y - * z_values[][] - * zprobe_zoffset + * M420 S active + * mesh_num_x (set in firmware) + * mesh_num_y (set in firmware) + * M421 XYZ z_values[][] + * M851 zprobe_zoffset * * DELTA: - * endstop_adj (x3) - * delta_radius - * delta_diagonal_rod - * delta_segments_per_second + * M666 XYZ endstop_adj (x3) + * M665 R delta_radius + * M665 L delta_diagonal_rod + * M665 S delta_segments_per_second * * ULTIPANEL: - * plaPreheatHotendTemp - * plaPreheatHPBTemp - * plaPreheatFanSpeed - * absPreheatHotendTemp - * absPreheatHPBTemp - * absPreheatFanSpeed + * M145 S0 H plaPreheatHotendTemp + * M145 S0 B plaPreheatHPBTemp + * M145 S0 F plaPreheatFanSpeed + * M145 S1 H absPreheatHotendTemp + * M145 S1 B absPreheatHPBTemp + * M145 S1 F absPreheatFanSpeed * * PIDTEMP: - * Kp[0], Ki[0], Kd[0], Kc[0] - * Kp[1], Ki[1], Kd[1], Kc[1] - * Kp[2], Ki[2], Kd[2], Kc[2] - * Kp[3], Ki[3], Kd[3], Kc[3] + * M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] + * M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] + * M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] + * M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] * * PIDTEMPBED: - * bedKp, bedKi, bedKd + * M304 PID bedKp, bedKi, bedKd * * DOGLCD: - * lcd_contrast + * M250 C lcd_contrast * * SCARA: - * axis_scaling (x3) + * M365 XYZ axis_scaling (x3) * * FWRETRACT: - * autoretract_enabled - * retract_length - * retract_length_swap - * retract_feedrate - * retract_zlift - * retract_recover_length - * retract_recover_length_swap - * retract_recover_feedrate + * M209 S autoretract_enabled + * M207 S retract_length + * M207 W retract_length_swap + * M207 F retract_feedrate + * M207 Z retract_zlift + * M208 S retract_recover_length + * M208 W retract_recover_length_swap + * M208 F retract_recover_feedrate * - * volumetric_enabled + * M200 D volumetric_enabled (D>0 makes this enabled) * - * filament_size (x4) + * M200 T D filament_size (x4) (T0..3) * - * Z_DUAL_ENDSTOPS - * z_endstop_adj + * Z_DUAL_ENDSTOPS: + * M666 Z z_endstop_adj * */ #include "Marlin.h" @@ -122,7 +122,9 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { #define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value)) #define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value)) -//====================================================================================== +/** + * Store Configuration Settings - M500 + */ #define DUMMY_PID_VALUE 3000.0f @@ -235,7 +237,7 @@ void Config_StoreSettings() { EEPROM_WRITE_VAR(i, bedKi); EEPROM_WRITE_VAR(i, bedKd); - #ifndef DOGLCD + #ifndef HAS_LCD_CONTRAST int lcd_contrast = 32; #endif EEPROM_WRITE_VAR(i, lcd_contrast); @@ -286,6 +288,10 @@ void Config_StoreSettings() { SERIAL_ECHOLNPGM(" bytes)"); } +/** + * Retrieve Configuration Settings - M501 + */ + void Config_RetrieveSettings() { int i = EEPROM_OFFSET; @@ -412,7 +418,7 @@ void Config_RetrieveSettings() { for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd } - #ifndef DOGLCD + #ifndef HAS_LCD_CONTRAST int lcd_contrast; #endif EEPROM_READ_VAR(i, lcd_contrast); @@ -467,6 +473,10 @@ void Config_RetrieveSettings() { #endif // EEPROM_SETTINGS +/** + * Reset Configuration Settings - M502 + */ + void Config_ResetDefault() { float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[] = DEFAULT_MAX_FEEDRATE; @@ -522,7 +532,7 @@ void Config_ResetDefault() { absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED; #endif - #ifdef DOGLCD + #ifdef HAS_LCD_CONTRAST lcd_contrast = DEFAULT_LCD_CONTRAST; #endif @@ -584,14 +594,20 @@ void Config_ResetDefault() { #ifndef DISABLE_M503 +/** + * Print Configuration Settings - M503 + */ + +#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0) + void Config_PrintSettings(bool forReplay) { // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Steps per unit:"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M92 X", axis_steps_per_unit[X_AXIS]); SERIAL_ECHOPAIR(" Y", axis_steps_per_unit[Y_AXIS]); @@ -599,23 +615,23 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOPAIR(" E", axis_steps_per_unit[E_AXIS]); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; #ifdef SCARA if (!forReplay) { SERIAL_ECHOLNPGM("Scaling factors:"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M365 X", axis_scaling[X_AXIS]); SERIAL_ECHOPAIR(" Y", axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z", axis_scaling[Z_AXIS]); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; #endif // SCARA if (!forReplay) { SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); @@ -623,160 +639,224 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M201 X", max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS] ); - SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS] ); + SERIAL_ECHOPAIR(" M201 X", max_acceleration_units_per_sq_second[X_AXIS]); + SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M204 P", acceleration ); + SERIAL_ECHOPAIR(" M204 P", acceleration); SERIAL_ECHOPAIR(" R", retract_acceleration); SERIAL_ECHOPAIR(" T", travel_acceleration); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M205 S", minimumfeedrate ); - SERIAL_ECHOPAIR(" T", mintravelfeedrate ); - SERIAL_ECHOPAIR(" B", minsegmenttime ); - SERIAL_ECHOPAIR(" X", max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S", minimumfeedrate); + SERIAL_ECHOPAIR(" T", mintravelfeedrate); + SERIAL_ECHOPAIR(" B", minsegmenttime); + SERIAL_ECHOPAIR(" X", max_xy_jerk); SERIAL_ECHOPAIR(" Z", max_z_jerk); SERIAL_ECHOPAIR(" E", max_e_jerk); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Home offset (mm):"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS] ); - SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS] ); - SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS] ); + SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS]); + SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS]); SERIAL_EOL; + #ifdef MESH_BED_LEVELING + if (!forReplay) { + SERIAL_ECHOLNPGM("Mesh bed leveling:"); + CONFIG_ECHO_START; + } + SERIAL_ECHOPAIR(" M420 S", (int32_t)mbl.active); + SERIAL_ECHOPAIR(" X", MESH_NUM_X_POINTS); + SERIAL_ECHOPAIR(" Y", MESH_NUM_Y_POINTS); + SERIAL_EOL; + for (int y=0; y 1 + if (forReplay) { + for (uint8_t i = 0; i < EXTRUDERS; i++) { + CONFIG_ECHO_START; + SERIAL_ECHOPAIR(" M301 E", (unsigned long)i); + SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, i)); + SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, i))); + SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i))); + #ifdef PID_ADD_EXTRUSION_RATE + SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, i)); + #endif + SERIAL_EOL; + } + } + else + #endif // EXTRUDERS > 1 + // !forReplay || EXTRUDERS == 1 + { + CONFIG_ECHO_START; + SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0 + SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0))); + SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0))); + #ifdef PID_ADD_EXTRUSION_RATE + SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0)); + #endif + SERIAL_EOL; + } + #endif // PIDTEMP + #ifdef PIDTEMPBED - SERIAL_ECHOPAIR(" M304 P", bedKp); // for compatibility with hosts, only echos values for E0 + CONFIG_ECHO_START; + SERIAL_ECHOPAIR(" M304 P", bedKp); SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi)); SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd)); SERIAL_EOL; #endif + + #endif // PIDTEMP || PIDTEMPBED + + #ifdef HAS_LCD_CONTRAST + CONFIG_ECHO_START; + if (!forReplay) { + SERIAL_ECHOLNPGM("LCD Contrast:"); + CONFIG_ECHO_START; + } + SERIAL_ECHOPAIR(" M250 C", (unsigned long)lcd_contrast); + SERIAL_EOL; #endif #ifdef FWRETRACT - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M207 S", retract_length); + #if EXTRUDERS > 1 + SERIAL_ECHOPAIR(" W", retract_length_swap); + #endif SERIAL_ECHOPAIR(" F", retract_feedrate*60); SERIAL_ECHOPAIR(" Z", retract_zlift); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M208 S", retract_recover_length); + #if EXTRUDERS > 1 + SERIAL_ECHOPAIR(" W", retract_recover_length_swap); + #endif SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60); SERIAL_EOL; - SERIAL_ECHO_START; + CONFIG_ECHO_START; if (!forReplay) { SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries"); - SERIAL_ECHO_START; + CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0)); SERIAL_EOL; - #if EXTRUDERS > 1 - if (!forReplay) { - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM("Multi-extruder settings:"); - SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap); - SERIAL_EOL; - SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap); - SERIAL_EOL; - } - #endif // EXTRUDERS > 1 - #endif // FWRETRACT - SERIAL_ECHO_START; if (volumetric_enabled) { if (!forReplay) { + CONFIG_ECHO_START; SERIAL_ECHOLNPGM("Filament settings:"); - SERIAL_ECHO_START; } + + CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); SERIAL_EOL; #if EXTRUDERS > 1 - SERIAL_ECHO_START; + CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); SERIAL_EOL; #if EXTRUDERS > 2 - SERIAL_ECHO_START; + CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); SERIAL_EOL; #if EXTRUDERS > 3 - SERIAL_ECHO_START; + CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]); SERIAL_EOL; #endif @@ -785,21 +865,23 @@ void Config_PrintSettings(bool forReplay) { } else { if (!forReplay) { + CONFIG_ECHO_START; SERIAL_ECHOLNPGM("Filament settings: Disabled"); } } #ifdef ENABLE_AUTO_BED_LEVELING - SERIAL_ECHO_START; #ifdef CUSTOM_M_CODES if (!forReplay) { + CONFIG_ECHO_START; SERIAL_ECHOLNPGM("Z-Probe Offset (mm):"); - SERIAL_ECHO_START; } + CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET); SERIAL_ECHOPAIR(" Z", -zprobe_zoffset); #else if (!forReplay) { + CONFIG_ECHO_START; SERIAL_ECHOPAIR("Z-Probe Offset (mm):", -zprobe_zoffset); } #endif diff --git a/Marlin/configurator/config/Configuration_adv.h b/Marlin/configurator/config/Configuration_adv.h index 6478eb923e..059f0c5c16 100644 --- a/Marlin/configurator/config/Configuration_adv.h +++ b/Marlin/configurator/config/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h index 2576bec42b..b6beb47473 100644 --- a/Marlin/configurator/config/language.h +++ b/Marlin/configurator/config/language.h @@ -70,7 +70,7 @@ #endif #else #ifndef MACHINE_NAME - #define MACHINE_NAME "Mendel" + #define MACHINE_NAME "3D Printer" #endif #endif @@ -158,6 +158,9 @@ #define MSG_Z_MAX "z_max: " #define MSG_Z2_MAX "z2_max: " #define MSG_Z_PROBE "z_probe: " +#define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" +#define MSG_ERR_XYZ_REQUIRED_FOR_M421 "M421 requires XYZ parameters" +#define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" #define MSG_M119_REPORT "Reporting endstop status" #define MSG_ENDSTOP_HIT "TRIGGERED" #define MSG_ENDSTOP_OPEN "open" diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index a80790b957..bc27cd8dcf 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 84536d044e..39545c378b 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index a80790b957..bc27cd8dcf 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index edc2445af6..bdf2eab4b2 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 15c5232848..e9c0cd0f1a 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 88b76c66e1..aebfa59d5a 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -356,7 +356,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 9b52ede7b7..5e8337ce84 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 7b63732a69..2d97c626bc 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index d221f080b4..832fb83552 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -355,7 +355,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HEATERS_PARALLEL //=========================================================================== -//=============================Buffers ============================ +//================================= Buffers ================================= //=========================================================================== // @section hidden diff --git a/Marlin/language.h b/Marlin/language.h index c9ddfeee41..b6beb47473 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -158,6 +158,9 @@ #define MSG_Z_MAX "z_max: " #define MSG_Z2_MAX "z2_max: " #define MSG_Z_PROBE "z_probe: " +#define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" +#define MSG_ERR_XYZ_REQUIRED_FOR_M421 "M421 requires XYZ parameters" +#define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" #define MSG_M119_REPORT "Reporting endstop status" #define MSG_ENDSTOP_HIT "TRIGGERED" #define MSG_ENDSTOP_OPEN "open" diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 060be3007e..a8558d6c49 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -1,54 +1,51 @@ -/* - planner.c - buffers movement commands and manages the acceleration profile plan - Part of Grbl - - Copyright (c) 2009-2011 Simen Svale Skogsrud - - Grbl is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Grbl is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Grbl. If not, see . - */ - -/* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ - -/* - Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - - s == speed, a == acceleration, t == time, d == distance - - Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) - Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - - Distance to reach a specific speed with a constant acceleration: - - Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] - d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - - Speed after a given distance of travel with constant acceleration: - - Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - - DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - - When to start braking (di) to reach a specified destionation speed (s2) after accelerating - from initial speed s1 without ever stopping at a plateau: - - Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] - di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - - IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) +/** + * planner.cpp - Buffer movement commands and manage the acceleration profile plan + * Part of Grbl + * + * Copyright (c) 2009-2011 Simen Svale Skogsrud + * + * Grbl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Grbl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Grbl. If not, see . + * + * + * The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. + * + * + * Reasoning behind the mathematics in this module (in the key of 'Mathematica'): + * + * s == speed, a == acceleration, t == time, d == distance + * + * Basic definitions: + * Speed[s_, a_, t_] := s + (a*t) + * Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] + * + * Distance to reach a specific speed with a constant acceleration: + * Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] + * d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() + * + * Speed after a given distance of travel with constant acceleration: + * Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] + * m -> Sqrt[2 a d + s^2] + * + * DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] + * + * When to start braking (di) to reach a specified destination speed (s2) after accelerating + * from initial speed s1 without ever stopping at a plateau: + * Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] + * di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() + * + * IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) + * */ #include "Marlin.h" @@ -71,17 +68,17 @@ float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute float axis_steps_per_unit[NUM_AXIS]; unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software float minimumfeedrate; -float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all printing moves. M204 SXXXX -float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX -float travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX -float max_xy_jerk; //speed than can be stopped at once, if i understand correctly. +float acceleration; // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all printing moves. M204 SXXXX +float retract_acceleration; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX +float travel_acceleration; // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX +float max_xy_jerk; // The largest speed change requiring no acceleration float max_z_jerk; float max_e_jerk; float mintravelfeedrate; unsigned long axis_steps_per_sqr_second[NUM_AXIS]; #ifdef ENABLE_AUTO_BED_LEVELING - // this holds the required transform to compensate for bed level + // Transform required to compensate for bed level matrix_3x3 plan_bed_level_matrix = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -89,11 +86,6 @@ unsigned long axis_steps_per_sqr_second[NUM_AXIS]; }; #endif // ENABLE_AUTO_BED_LEVELING -// The current position of the tool in absolute steps -long position[NUM_AXIS]; //rescaled from extern when axis_steps_per_unit are changed by gcode -static float previous_speed[NUM_AXIS]; // Speed of previous path line segment -static float previous_nominal_speed; // Nominal speed of previous path line segment - #ifdef AUTOTEMP float autotemp_max = 250; float autotemp_min = 210; @@ -101,18 +93,25 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm bool autotemp_enabled = false; #endif -unsigned char g_uc_extruder_last_move[4] = {0,0,0,0}; +//=========================================================================== +//============ semi-private variables, used in inline functions ============= +//=========================================================================== -//=========================================================================== -//=================semi-private variables, used in inline functions ===== -//=========================================================================== block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions volatile unsigned char block_buffer_head; // Index of the next block to be pushed volatile unsigned char block_buffer_tail; // Index of the block to process now //=========================================================================== -//=============================private variables ============================ +//============================ private variables ============================ //=========================================================================== + +// The current position of the tool in absolute steps +long position[NUM_AXIS]; // Rescaled from extern when axis_steps_per_unit are changed by gcode +static float previous_speed[NUM_AXIS]; // Speed of previous path line segment +static float previous_nominal_speed; // Nominal speed of previous path line segment + +unsigned char g_uc_extruder_last_move[4] = {0,0,0,0}; + #ifdef XY_FREQUENCY_LIMIT // Used for the frequency limit #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT) @@ -126,15 +125,15 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro static char meas_sample; //temporary variable to hold filament measurement sample #endif +//=========================================================================== +//================================ functions ================================ +//=========================================================================== + // Get the next / previous index of the next block in the ring buffer // NOTE: Using & here (not %) because BLOCK_BUFFER_SIZE is always a power of 2 FORCE_INLINE int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); } FORCE_INLINE int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); } -//=========================================================================== -//================================ Functions ================================ -//=========================================================================== - // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { diff --git a/Marlin/planner.h b/Marlin/planner.h index d96aa8c112..c54ed4411a 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -115,15 +115,19 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block void plan_set_e_position(const float &e); +//=========================================================================== +//============================= public variables ============================ +//=========================================================================== + extern millis_t minsegmenttime; -extern float max_feedrate[NUM_AXIS]; // set the max speeds +extern float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute extern float axis_steps_per_unit[NUM_AXIS]; extern unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software extern float minimumfeedrate; -extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX -extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX -extern float travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX -extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly. +extern float acceleration; // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all printing moves. M204 SXXXX +extern float retract_acceleration; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX +extern float travel_acceleration; // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX +extern float max_xy_jerk; // The largest speed change requiring no acceleration extern float max_z_jerk; extern float max_e_jerk; extern float mintravelfeedrate; diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index fa17b6c4c2..a494e3a9d0 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -89,8 +89,9 @@ unsigned char soft_pwm_bed; #endif //=========================================================================== -//=============================private variables============================ +//============================ private variables ============================ //=========================================================================== + static volatile bool temp_meas_ready = false; #ifdef PIDTEMP @@ -187,7 +188,7 @@ static void updateTemperaturesFromRawValues(); #endif //=========================================================================== -//============================= functions ============================ +//================================ functions ================================ //=========================================================================== void PID_autotune(float temp, int extruder, int ncycles) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 81844573ea..3895dc5519 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -868,10 +868,10 @@ static void lcd_control_temperature_preheat_pla_settings_menu() { MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &plaPreheatFanSpeed, 0, 255); #if TEMP_SENSOR_0 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, 0, HEATER_0_MAXTEMP - 15); + MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15); #endif #if TEMP_SENSOR_BED != 0 - MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, 0, BED_MAXTEMP - 15); + MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15); #endif #ifdef EEPROM_SETTINGS MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); @@ -884,10 +884,10 @@ static void lcd_control_temperature_preheat_abs_settings_menu() { MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &absPreheatFanSpeed, 0, 255); #if TEMP_SENSOR_0 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, 0, HEATER_0_MAXTEMP - 15); + MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15); #endif #if TEMP_SENSOR_BED != 0 - MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, 0, BED_MAXTEMP - 15); + MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15); #endif #ifdef EEPROM_SETTINGS MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); diff --git a/Marlin/watchdog.cpp b/Marlin/watchdog.cpp index b378ca706a..8505f7efac 100644 --- a/Marlin/watchdog.cpp +++ b/Marlin/watchdog.cpp @@ -7,11 +7,11 @@ #include "ultralcd.h" //=========================================================================== -//=============================private variables ============================ +//============================ private variables ============================ //=========================================================================== //=========================================================================== -//=============================functinos ============================ +//================================ functions ================================ //=========================================================================== @@ -36,7 +36,7 @@ void watchdog_reset() } //=========================================================================== -//=============================ISR ============================ +//=================================== ISR =================================== //=========================================================================== //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. From fb379384ee79eabb42b8edad06e4588b84cb9544 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 26 Apr 2015 21:06:04 -0700 Subject: [PATCH 103/118] Reduce MBL eeprom read code --- Marlin/configuration_store.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 318501db62..0cd7faa7c1 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -325,30 +325,21 @@ void Config_RetrieveSettings() { EEPROM_READ_VAR(i, max_e_jerk); EEPROM_READ_VAR(i, home_offset); - uint8_t mesh_num_x = 0; - uint8_t mesh_num_y = 0; + uint8_t dummy_uint8 = 0, mesh_num_x = 0, mesh_num_y = 0; + EEPROM_READ_VAR(i, dummy_uint8); + EEPROM_READ_VAR(i, mesh_num_x); + EEPROM_READ_VAR(i, mesh_num_y); #ifdef MESH_BED_LEVELING - EEPROM_READ_VAR(i, mbl.active); - EEPROM_READ_VAR(i, mesh_num_x); - EEPROM_READ_VAR(i, mesh_num_y); - if (mesh_num_x != MESH_NUM_X_POINTS || - mesh_num_y != MESH_NUM_Y_POINTS) { - mbl.reset(); - for (int q=0; q Date: Mon, 27 Apr 2015 12:15:36 +0200 Subject: [PATCH 104/118] Intit. commit for Chinese Edited the European part of 'ISO10646_CN.fon' to match the existing fonts. Added Chinese font to make_fonts.bat Created 'dogm_font_data_ISO10646_CN.h' Added Chinese to 'language.h' Added 'language_cn.h' with some minor edits. Added Chinese font in 'language_en.h' to not fall back to European font. Added cn to 'Configuration.h' Changed WIDTH to LCD_PIXEL_WIDTH and HEIGHT to LCD_PIXEL_HEIGHT to have more descriptive names. In 'dogm_lcd_implementation.h' Added Chinese Font Made 1 pixel more room for the larger Chinese font on the status line. Changed geometry of the 'select bar' by one pixel. Changed the way the position for values and postcars are set. --- Marlin/Configuration.h | 2 +- Marlin/dogm_font_data_ISO10646_CN.h | 270 ++++++++++++++++++++++++++++ Marlin/dogm_lcd_implementation.h | 35 ++-- Marlin/fonts/ISO10646_CN.fon | Bin 0 -> 6192 bytes Marlin/fonts/make_fonts.bat | 1 + Marlin/language.h | 1 + Marlin/language_cn.h | 159 ++++++++++++++++ Marlin/language_en.h | 2 +- Marlin/ultralcd_st7920_u8glib_rrd.h | 14 +- 9 files changed, 465 insertions(+), 19 deletions(-) create mode 100644 Marlin/dogm_font_data_ISO10646_CN.h create mode 100644 Marlin/fonts/ISO10646_CN.fon create mode 100644 Marlin/language_cn.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e3d0c339a2..0ba1d0594b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -642,7 +642,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // @section lcd // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/dogm_font_data_ISO10646_CN.h b/Marlin/dogm_font_data_ISO10646_CN.h new file mode 100644 index 0000000000..f74e8a6054 --- /dev/null +++ b/Marlin/dogm_font_data_ISO10646_CN.h @@ -0,0 +1,270 @@ +/* + Fontname: ISO10646_CN + Copyright: A. Hardtung, public domain + Capital A Height: 7, '1' Height: 7 + Calculated Max Values w=11 h=11 x= 2 y=10 dx=12 dy= 0 ascent=10 len=22 + Font Bounding box w=12 h=11 x= 0 y=-2 + Calculated Min Values x= 0 y=-1 dx= 0 dy= 0 + Pure Font ascent = 7 descent=-1 + X Font ascent = 7 descent=-1 + Max Font ascent =10 descent=-1 +*/ +#include +const u8g_fntpgm_uint8_t ISO10646_CN[4105] U8G_SECTION(".progmem.ISO10646_CN") = { + 0,12,11,0,254,7,1,146,3,33,32,255,255,10,255,7, + 255,0,0,0,6,0,10,1,7,7,6,2,0,128,128,128, + 128,128,0,128,3,2,2,6,1,5,160,160,5,7,7,6, + 0,0,80,80,248,80,248,80,80,5,7,7,6,0,0,32, + 120,160,112,40,240,32,5,7,7,6,0,0,192,200,16,32, + 64,152,24,5,7,7,6,0,0,96,144,160,64,168,144,104, + 2,3,3,6,1,4,192,64,128,3,7,7,6,1,0,32, + 64,128,128,128,64,32,3,7,7,6,1,0,128,64,32,32, + 32,64,128,5,5,5,6,0,1,32,168,112,168,32,5,5, + 5,6,0,1,32,32,248,32,32,2,3,3,6,2,255,192, + 64,128,5,1,1,6,0,3,248,2,2,2,6,2,0,192, + 192,5,5,5,6,0,1,8,16,32,64,128,5,7,7,6, + 0,0,112,136,152,168,200,136,112,3,7,7,6,1,0,64, + 192,64,64,64,64,224,5,7,7,6,0,0,112,136,8,112, + 128,128,248,5,7,7,6,0,0,248,16,32,16,8,8,240, + 5,7,7,6,0,0,16,48,80,144,248,16,16,5,7,7, + 6,0,0,248,128,240,8,8,136,112,5,7,7,6,0,0, + 112,128,128,240,136,136,112,5,7,7,6,0,0,248,8,16, + 32,32,32,32,5,7,7,6,0,0,112,136,136,112,136,136, + 112,5,7,7,6,0,0,112,136,136,120,8,8,112,2,5, + 5,6,2,0,192,192,0,192,192,2,6,6,6,2,255,192, + 192,0,192,64,128,4,7,7,6,0,0,16,32,64,128,64, + 32,16,5,3,3,6,0,2,248,0,248,4,7,7,6,0, + 0,128,64,32,16,32,64,128,5,7,7,6,0,0,112,136, + 8,16,32,0,32,5,7,7,6,0,0,112,136,8,104,168, + 168,112,5,7,7,6,0,0,112,136,136,248,136,136,136,5, + 7,7,6,0,0,240,136,136,240,136,136,240,5,7,7,6, + 0,0,112,136,128,128,128,136,112,5,7,7,6,0,0,240, + 136,136,136,136,136,240,5,7,7,6,0,0,248,128,128,240, + 128,128,248,5,7,7,6,0,0,248,128,128,240,128,128,128, + 5,7,7,6,0,0,112,136,128,184,136,136,112,5,7,7, + 6,0,0,136,136,136,248,136,136,136,1,7,7,6,2,0, + 128,128,128,128,128,128,128,5,7,7,6,0,0,56,16,16, + 16,16,144,96,5,7,7,6,0,0,136,144,160,192,160,144, + 136,5,7,7,6,0,0,128,128,128,128,128,128,248,5,7, + 7,6,0,0,136,216,168,136,136,136,136,5,7,7,6,0, + 0,136,136,200,168,152,136,136,5,7,7,6,0,0,112,136, + 136,136,136,136,112,5,7,7,6,0,0,240,136,136,240,128, + 128,128,5,7,7,6,0,0,112,136,136,136,168,144,104,5, + 7,7,6,0,0,240,136,136,240,160,144,136,5,7,7,6, + 0,0,120,128,128,112,8,8,240,5,7,7,6,0,0,248, + 32,32,32,32,32,32,5,7,7,6,0,0,136,136,136,136, + 136,136,112,5,7,7,6,0,0,136,136,136,136,136,80,32, + 5,7,7,6,0,0,136,136,136,136,136,168,80,5,7,7, + 6,0,0,136,136,80,32,80,136,136,5,7,7,6,0,0, + 136,136,136,80,32,32,32,5,7,7,6,0,0,248,8,16, + 32,64,128,248,3,7,7,6,0,0,224,128,128,128,128,128, + 224,5,5,5,6,0,1,128,64,32,16,8,3,7,7,6, + 0,0,224,32,32,32,32,32,224,5,3,3,6,0,4,32, + 80,136,5,1,1,6,0,0,248,2,2,2,6,2,5,128, + 64,5,5,5,6,0,0,112,8,120,136,120,5,7,7,6, + 0,0,128,128,176,200,136,136,240,5,5,5,6,0,0,112, + 128,128,136,112,5,7,7,6,0,0,8,8,104,152,136,136, + 120,5,5,5,6,0,0,112,136,248,128,112,5,7,7,6, + 0,0,48,72,224,64,64,64,64,5,6,6,6,0,255,112, + 136,136,120,8,112,5,7,7,6,0,0,128,128,176,200,136, + 136,136,1,7,7,6,2,0,128,0,128,128,128,128,128,3, + 8,8,6,1,255,32,0,32,32,32,32,160,64,4,7,7, + 6,1,0,128,128,144,160,192,160,144,3,7,7,6,1,0, + 192,64,64,64,64,64,224,5,5,5,6,0,0,208,168,168, + 168,168,5,5,5,6,0,0,176,200,136,136,136,5,5,5, + 6,0,0,112,136,136,136,112,5,6,6,6,0,255,240,136, + 136,240,128,128,5,6,6,6,0,255,120,136,136,120,8,8, + 5,5,5,6,0,0,176,200,128,128,128,5,5,5,6,0, + 0,112,128,112,8,240,4,7,7,6,0,0,64,64,224,64, + 64,64,48,5,5,5,6,0,0,136,136,136,152,104,5,5, + 5,6,0,0,136,136,136,80,32,5,5,5,6,0,0,136, + 136,168,168,80,5,5,5,6,0,0,136,80,32,80,136,5, + 6,6,6,0,255,136,136,136,120,8,112,5,5,5,6,0, + 0,248,16,32,64,248,3,7,7,6,1,0,32,64,64,128, + 64,64,32,1,7,7,6,2,0,128,128,128,128,128,128,128, + 3,7,7,6,1,0,128,64,64,32,64,64,128,5,2,2, + 6,0,3,104,144,0,0,0,6,0,10,0,0,0,12,0, + 10,0,0,0,12,0,10,0,0,0,12,0,10,0,0,0, + 12,0,10,0,0,0,12,0,10,0,0,0,12,0,10,0, + 0,0,12,0,10,0,0,0,12,0,10,0,0,0,12,0, + 10,0,0,0,12,0,10,0,0,0,12,0,10,0,0,0, + 12,0,10,0,0,0,12,0,10,0,0,0,12,0,10,0, + 0,0,12,0,10,0,0,0,12,0,10,0,0,0,12,0, + 10,0,0,0,12,0,10,0,0,0,12,0,10,0,0,0, + 12,0,10,0,0,0,12,0,10,0,0,0,12,0,10,0, + 0,0,12,0,10,0,0,0,12,0,10,0,0,0,12,0, + 10,0,0,0,12,0,10,0,0,0,12,0,10,0,0,0, + 12,0,10,0,0,0,12,0,10,11,11,22,12,0,255,255, + 224,2,0,2,0,4,0,13,0,20,128,36,64,196,32,4, + 0,4,0,4,0,11,11,22,12,0,255,249,0,138,0,171, + 224,172,64,170,64,170,64,170,64,170,128,33,0,82,128,140, + 96,11,11,22,12,0,255,36,0,36,0,63,128,68,0,132, + 0,4,0,255,224,10,0,17,0,32,128,192,96,11,11,22, + 12,0,255,36,0,36,0,63,192,68,0,4,0,255,224,9, + 0,9,0,17,32,33,32,64,224,11,11,22,12,0,255,32, + 0,61,224,81,32,145,32,17,32,255,32,17,32,41,32,37, + 224,69,32,128,0,11,11,22,12,0,255,32,128,127,192,8, + 64,255,224,17,0,32,128,95,64,128,32,63,128,0,0,127, + 192,11,11,22,12,0,255,34,64,71,224,148,128,228,128,47, + 224,68,128,244,128,7,224,52,128,196,128,7,224,11,11,22, + 12,0,255,4,128,143,224,73,0,25,0,47,192,9,0,9, + 0,47,192,73,0,137,0,15,224,11,11,22,12,0,255,16, + 0,63,128,81,0,14,0,49,128,192,96,63,128,36,128,63, + 128,36,128,63,128,11,11,22,12,0,255,34,128,250,64,7, + 224,250,128,138,128,138,128,250,128,34,128,178,128,170,160,100, + 224,11,11,22,12,0,255,34,32,71,64,146,128,239,224,34, + 0,71,192,236,64,7,192,52,64,199,192,4,64,11,11,22, + 12,0,255,8,0,15,192,8,0,8,0,255,224,8,0,14, + 0,9,128,8,64,8,0,8,0,10,11,22,12,0,255,255, + 128,0,128,0,128,128,128,128,128,255,128,128,0,128,0,128, + 64,128,64,127,192,11,11,22,12,0,255,71,192,65,0,239, + 224,65,0,69,0,105,96,201,32,77,96,73,32,79,224,200, + 32,11,11,22,12,0,255,8,0,4,0,4,0,10,0,10, + 0,10,0,17,0,17,0,32,128,64,64,128,32,11,11,22, + 12,0,255,34,64,34,0,247,224,34,0,35,224,53,32,229, + 32,37,64,40,128,41,64,114,32,11,10,20,12,0,0,68, + 64,68,64,68,64,127,192,4,0,4,0,132,32,132,32,132, + 32,255,224,11,11,22,12,0,255,4,0,0,0,127,192,4, + 0,4,0,4,0,127,192,4,0,4,0,4,0,255,224,11, + 11,22,12,0,255,255,224,17,0,1,192,254,0,72,128,37, + 0,4,0,255,224,21,0,36,128,196,96,11,11,22,12,0, + 255,17,0,127,192,68,64,127,192,68,64,127,192,4,0,255, + 224,4,0,4,0,4,0,9,11,22,12,0,255,16,0,255, + 128,128,128,128,128,255,128,128,128,128,128,255,128,128,128,128, + 128,255,128,11,11,22,12,0,255,113,0,1,0,3,224,249, + 32,33,32,65,32,81,32,137,32,250,32,2,32,4,192,11, + 11,22,12,0,255,127,192,17,0,17,0,17,0,17,0,255, + 224,17,0,17,0,33,0,33,0,65,0,11,11,22,12,0, + 255,33,0,34,0,244,64,87,224,80,32,87,192,148,64,84, + 64,36,64,87,192,148,64,11,11,22,12,0,255,17,0,10, + 0,127,192,4,0,4,0,255,224,4,0,10,0,17,0,32, + 128,192,96,10,11,22,12,0,255,95,192,0,64,132,64,132, + 64,191,64,132,64,140,64,148,64,164,64,140,64,129,192,11, + 11,22,12,0,255,36,0,39,192,36,0,36,0,255,224,0, + 0,20,64,36,128,71,0,12,0,112,0,11,11,22,12,0, + 255,36,128,4,128,15,192,228,128,36,128,63,224,36,128,36, + 128,40,128,80,0,143,224,11,11,22,12,0,255,8,0,8, + 0,255,128,136,128,136,128,255,128,136,128,136,128,255,160,136, + 32,7,224,11,11,22,12,0,255,39,128,36,128,244,128,36, + 128,116,128,108,128,164,128,36,128,36,160,40,160,48,96,10, + 11,22,12,0,255,255,192,128,64,128,64,158,64,146,64,146, + 64,158,64,128,64,128,64,255,192,128,64,11,11,22,12,0, + 255,127,192,68,0,95,192,80,64,95,192,80,64,95,192,66, + 0,74,128,82,64,166,32,11,11,22,12,0,255,4,0,7, + 224,4,0,127,192,64,64,64,64,64,64,127,192,0,0,82, + 64,137,32,11,11,22,12,0,255,71,128,36,128,4,128,4, + 128,232,96,32,0,47,192,36,64,34,128,49,0,38,192,11, + 11,22,12,0,255,127,192,74,64,127,192,4,0,255,224,4, + 0,63,128,32,128,36,128,36,128,255,224,11,11,22,12,0, + 255,34,0,79,224,72,32,79,224,200,0,79,224,74,160,90, + 160,111,224,74,160,72,96,11,11,22,12,0,255,243,192,36, + 64,42,128,241,0,34,128,101,224,114,32,165,64,32,128,35, + 0,44,0,11,11,22,12,0,255,4,0,255,224,128,32,0, + 0,255,224,4,0,36,0,39,192,36,0,84,0,143,224,11, + 11,22,12,0,255,115,224,16,128,81,0,35,224,250,32,42, + 160,34,160,34,160,32,128,33,64,98,32,11,11,22,12,0, + 255,34,0,247,128,34,128,54,128,226,160,37,160,36,96,104, + 32,0,0,82,64,137,32,11,11,22,12,0,255,115,192,66, + 0,66,0,123,224,74,64,74,64,122,64,74,64,66,64,68, + 64,136,64,11,11,22,12,0,255,8,0,255,224,8,0,31, + 192,48,64,95,192,144,64,31,192,16,64,16,64,16,192,11, + 11,22,12,0,255,2,0,127,224,66,0,66,0,95,192,66, + 0,71,0,74,128,82,64,98,32,130,0,11,11,22,12,0, + 255,243,192,150,64,145,128,166,96,161,0,151,192,145,0,149, + 0,231,224,129,0,129,0,11,11,22,12,0,255,15,128,136, + 128,79,128,8,128,143,128,64,0,31,192,53,64,85,64,149, + 64,63,224,11,11,22,12,0,255,39,224,32,128,248,128,32, + 128,32,128,56,128,224,128,32,128,32,128,32,128,97,128,11, + 11,22,12,0,255,31,224,145,0,87,192,20,64,23,192,148, + 64,87,192,17,0,85,64,153,32,35,0,11,11,22,12,0, + 255,32,128,39,224,242,64,33,128,34,64,52,32,226,64,34, + 64,34,64,34,64,100,64,11,11,22,12,0,255,65,0,65, + 0,79,224,233,32,73,32,73,32,111,224,201,32,73,32,73, + 32,207,224,11,11,22,12,0,255,33,0,241,0,79,224,169, + 32,249,32,47,224,57,32,233,32,41,32,47,224,40,32,11, + 11,22,12,0,255,143,224,73,32,9,32,203,160,73,32,79, + 224,72,32,75,160,74,160,107,160,80,224,11,11,22,12,0, + 255,127,192,4,0,68,64,36,64,36,128,4,0,255,224,4, + 0,4,0,4,0,4,0,11,11,22,12,0,255,130,0,66, + 0,31,224,194,0,95,192,82,64,95,192,71,0,74,128,82, + 64,191,224,11,11,22,12,0,255,4,0,127,224,72,128,127, + 224,72,128,79,128,64,0,95,192,72,64,71,128,152,96,11, + 11,22,12,0,255,1,0,239,224,161,0,164,64,175,224,164, + 64,175,224,169,32,233,32,2,128,12,96,11,11,22,12,0, + 255,20,192,246,160,188,96,167,128,168,128,191,224,169,32,239, + 224,9,32,15,224,9,32,11,11,22,12,0,255,127,128,64, + 128,66,128,98,128,84,128,72,128,72,128,84,160,98,160,64, + 96,128,32,11,11,22,12,0,255,4,0,127,224,64,32,127, + 224,64,0,125,224,84,32,76,160,84,96,100,160,141,96,11, + 11,22,12,0,255,130,0,95,224,4,0,8,64,159,224,64, + 32,10,128,10,128,74,160,146,160,34,96,11,11,22,12,0, + 255,65,0,79,224,232,32,66,128,68,64,104,32,199,192,65, + 0,65,0,65,0,207,224,11,11,22,12,0,255,80,32,125, + 32,145,32,255,32,17,32,125,32,85,32,85,32,84,32,92, + 32,16,224,11,11,22,12,0,255,63,128,32,128,63,128,32, + 128,255,224,72,0,123,192,73,64,121,64,72,128,251,96,11, + 11,22,12,0,255,4,0,4,0,4,0,36,128,36,64,68, + 64,68,32,132,32,4,0,4,0,28,0,11,11,22,12,0, + 255,4,0,4,0,4,0,255,224,4,0,10,0,10,0,17, + 0,17,0,32,128,192,96,9,10,20,10,0,0,136,128,73, + 0,8,0,255,128,0,128,0,128,127,128,0,128,0,128,255, + 128,11,11,22,12,0,255,33,0,18,0,255,224,0,0,120, + 128,74,128,122,128,74,128,122,128,72,128,89,128,11,11,22, + 12,0,255,39,192,0,0,0,0,239,224,33,0,34,0,36, + 64,47,224,32,32,80,0,143,224,11,11,22,12,0,255,32, + 128,39,0,249,0,33,192,119,0,33,0,249,224,39,0,113, + 32,169,32,32,224,11,11,22,12,0,255,16,64,16,64,253, + 224,16,64,56,192,53,64,82,64,148,64,16,64,16,64,16, + 192,11,11,22,12,0,255,0,64,248,64,11,224,8,64,136, + 64,82,64,81,64,33,64,80,64,72,64,137,192,10,11,22, + 12,0,255,132,0,132,64,132,128,245,0,134,0,132,0,132, + 0,148,0,164,64,196,64,131,192,11,11,22,12,0,255,17, + 32,125,0,17,0,255,224,41,0,253,64,73,64,124,128,8, + 160,253,96,10,32,11,11,22,12,0,255,23,192,36,64,36, + 64,103,192,161,0,47,224,33,0,35,128,37,64,41,32,33, + 0,11,11,22,12,0,255,8,0,255,224,16,0,39,192,32, + 128,97,0,175,224,33,0,33,0,33,0,35,0,11,11,22, + 12,0,255,36,0,47,224,180,0,164,128,164,160,170,192,42, + 128,40,128,41,64,50,64,36,32,11,11,22,12,0,255,127, + 224,128,0,63,192,32,64,63,192,16,0,31,192,16,64,40, + 128,71,0,56,224,11,11,22,12,0,255,127,224,64,0,64, + 0,64,0,64,0,64,0,64,0,64,0,64,0,64,0,128, + 0,11,11,22,12,0,255,255,224,4,0,127,192,68,64,127, + 192,68,64,127,192,68,0,36,0,24,0,231,224,11,11,22, + 12,0,255,17,224,253,0,69,0,41,224,253,64,17,64,125, + 64,17,64,85,64,146,64,52,64,11,11,22,12,0,255,33, + 0,95,224,64,0,207,192,64,0,79,192,64,0,79,192,72, + 64,79,192,72,64,11,11,22,12,0,255,4,0,127,192,64, + 64,127,192,64,64,127,192,64,64,127,192,4,64,82,32,191, + 160,11,11,22,12,0,255,127,192,68,64,127,192,68,64,127, + 192,4,0,27,0,224,224,17,0,17,0,97,0,11,11,22, + 12,0,255,255,224,4,0,8,0,127,224,73,32,79,32,73, + 32,79,32,73,32,73,32,127,224,11,11,22,12,0,255,253, + 224,86,64,121,64,56,128,85,64,146,32,255,224,4,0,39, + 192,36,0,255,224,11,11,22,12,0,255,251,128,82,0,123, + 224,18,64,250,64,20,64,63,128,32,128,63,128,32,128,63, + 128,11,11,22,12,0,255,31,224,32,0,39,192,100,64,167, + 192,32,0,47,224,40,32,39,192,33,0,35,0,11,11,22, + 12,0,255,243,224,130,32,130,32,250,32,130,32,130,32,138, + 32,178,32,194,224,2,0,2,0,11,11,22,12,0,255,36, + 128,70,160,149,192,228,128,39,224,68,128,245,192,6,160,52, + 128,196,128,7,224,11,11,22,12,0,255,39,192,65,0,135, + 224,224,32,34,128,69,128,242,128,15,224,48,128,193,64,2, + 32,11,11,22,12,0,255,2,0,2,0,34,0,35,192,34, + 0,34,0,34,0,34,0,34,0,34,0,255,224,9,11,22, + 12,0,255,8,0,8,0,255,128,136,128,136,128,136,128,255, + 128,136,128,136,128,136,128,255,128,11,11,22,12,0,255,33, + 0,83,160,65,0,247,224,81,0,83,192,86,64,83,192,90, + 64,83,192,66,64,11,11,22,12,0,255,127,192,4,0,4, + 0,4,0,255,224,10,0,10,0,18,0,34,32,66,32,129, + 224,11,11,22,12,0,255,17,0,33,0,47,224,97,0,163, + 128,35,128,37,64,37,64,41,32,33,0,33,0,11,11,22, + 12,0,255,247,224,148,32,244,32,151,224,148,128,244,128,151, + 224,148,128,244,160,150,96,4,32,11,11,22,12,0,255,123, + 224,148,128,4,0,127,192,4,0,255,224,1,0,255,224,33, + 0,17,0,7,0,11,11,22,12,0,255,33,0,71,192,145, + 0,47,224,96,128,175,224,32,128,36,128,34,128,32,128,35, + 128,11,11,22,12,0,255,39,192,36,64,247,192,46,224,42, + 160,62,224,225,0,47,224,35,128,37,64,105,32,11,11,22, + 12,0,255,20,0,39,224,42,0,98,0,163,192,34,0,34, + 0,35,224,34,0,34,0,34,0}; diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 3ab18af75c..927904c7a7 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -64,6 +64,10 @@ #elif defined( DISPLAY_CHARSET_ISO10646_KANA ) #include "dogm_font_data_ISO10646_Kana.h" #define FONT_MENU_NAME ISO10646_Kana_5x7 + #elif defined( DISPLAY_CHARSET_ISO10646_CN ) + #include "dogm_font_data_ISO10646_CN.h" + #define FONT_MENU_NAME ISO10646_CN + #define TALL_FONT_CORRECTION 1 #else // fall-back #include "dogm_font_data_ISO10646_1.h" #define FONT_MENU_NAME ISO10646_1_5x7 @@ -123,6 +127,13 @@ U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0 #endif +#ifndef LCD_PIXEL_WIDTH + #define LCD_PIXEL_WIDTH 128 +#endif +#ifndef LCD_PIXEL_HEIGHT + #define LCD_PIXEL_HEIGHT 64 +#endif + #include "utf_mapper.h" int lcd_contrast; @@ -252,20 +263,21 @@ static void lcd_implementation_status_screen() { #ifdef SDSUPPORT // SD Card Symbol - u8g.drawBox(42,42,8,7); - u8g.drawBox(50,44,2,5); - u8g.drawFrame(42,49,10,4); - u8g.drawPixel(50,43); + u8g.drawBox(42, 42 - TALL_FONT_CORRECTION, 8, 7); + u8g.drawBox(50, 44 - TALL_FONT_CORRECTION, 2, 5); + u8g.drawFrame(42, 49 - TALL_FONT_CORRECTION, 10, 4); + u8g.drawPixel(50, 43 - TALL_FONT_CORRECTION); + // Progress bar frame - u8g.drawFrame(54,49,73,4); + u8g.drawFrame(54, 49, 73, 4 - TALL_FONT_CORRECTION); // SD Card Progress bar and clock lcd_setFont(FONT_STATUSMENU); if (IS_SD_PRINTING) { // Progress bar solid part - u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2); + u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - TALL_FONT_CORRECTION); } u8g.setPrintPos(80,48); @@ -306,9 +318,9 @@ static void lcd_implementation_status_screen() { lcd_setFont(FONT_STATUSMENU); #ifdef USE_SMALL_INFOFONT - u8g.drawBox(0,30,128,10); + u8g.drawBox(0,30,LCD_PIXEL_WIDTH,10); #else - u8g.drawBox(0,30,128,9); + u8g.drawBox(0,30,LCD_PIXEL_WIDTH,9); #endif u8g.setColorIndex(0); // white on black u8g.setPrintPos(2,XYZ_BASELINE); @@ -366,7 +378,7 @@ static void lcd_implementation_status_screen() { static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) { if (isSelected) { u8g.setColorIndex(1); // black on white - u8g.drawBox(0, row * DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); + u8g.drawBox(0, row * DOG_CHAR_HEIGHT + 3 - TALL_FONT_CORRECTION, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else { @@ -386,13 +398,15 @@ static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, co pstr++; } while (n--) lcd_print(' '); + u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); lcd_print(post_char); lcd_print(' '); } static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) { char c; - uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data))); + uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data))); + uint8_t n = LCD_WIDTH - 2 - vallen; lcd_implementation_mark_as_selected(row, isSelected); @@ -402,6 +416,7 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c } lcd_print(':'); while (n--) lcd_print(' '); + u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH * vallen, (row + 1) * DOG_CHAR_HEIGHT); if (pgm) { lcd_printPGM(data); } else { lcd_print((char *)data); } } diff --git a/Marlin/fonts/ISO10646_CN.fon b/Marlin/fonts/ISO10646_CN.fon new file mode 100644 index 0000000000000000000000000000000000000000..6c77eeccd8dea480f2759b0b987b777c34b48083 GIT binary patch literal 6192 zcmeH~e{7WX9mhXCAKRxV!d=B5W5#~(`qY+&&_a+P+3eF>v3ED6$59|_mi4G8EmNok z6=8UfrEy2YMrkTC{%|KUE!`r9n8lD~-U!jk;#|nGEc{`fHEt?d1QDgw;O+f=KhG7D zE&jP=iQnh$b>I6upYP}U{(ion=X>q_ou5dVh!}Vmiz2V%Q#YIZdN{Z}yZXdzd9CuD z$m?bIy%Xu^>D{XO`nPQCU;l{efAG=Adix*Ts_yT7pnuEOEe~x|>v}hD*z&~Ig*OH* zKlI8K*MDa>6^NL-|8u^2D6wUm?8aqip;Q_$eb4I*sc>kPo1{`wvlj4%>Dz9Xjb%-@ zmpPty#l7t-J6aRz8xpJA7d0(ivb5`aEA<^q+tVvnt3^#s3+`Tums+mA;-em4v~ZCZ z0!lI4b=|j!v@BHd_5B;RJ+^t{0@e3e_rtvps0~{lS>L@3Ms)B3!%k}>KuZSs)D1H8~wM=SFRi)Yg>u0%Wr*iq2oF>c5wWW%@gKQv|k}+~6 z*-1V`_LEPML*xPSF!>63f_#%aL%v6zBR?kt6?*pB2WYrw%Cu3wM*-s9UhshJ<8S)$%2vI+|m`sx0gT9>Y5R~rY7&Ji71ZO?aLh;o5=O?i^}K) zc>TVd+2=Uk@TrgrndSxhgql*rQ=t(1Q_cm`^vA;aLeB3`AwC*?`d}>C(b;aAUVMrv z>CwV`&01M$y&_Y%yrzvM(a?qkmg1W|V`C-Fxv5+(#{m$dU+nkg9LMps!HDMBr=WRe zjqE!m|JO^J;XD&lFA9x5%di!p;SBq^;d~)K?9Gdr&^*<-zm4h1JfGae*g?OKJfL}+ zwMY!0kG7X;K-)_(w>wT>DgW5$84V2M$6-IE{JC_Xl;2OO)QpB)s-$1i=aAuou=7?GIMP=t|)YFOD}i_FOmmghX$Ew_w|jr!uKH?HRgwF-877hUUlAdP-~1nJ)S0O#2%k z+gYLBfLAAw6n|_VHsAvLwykwG`F4ak*mJG#=U)Wr_w$dw-hgX9{<=`x*Z?nwcv@`b zCzA60HEJVn`D1&A{mwTZ-(=wbI|Ic)z_@X)b;>XdarIJg=;)6tL%;sbI9epV7vJ=Q zhMy@XBbL?NI%pJwVO4J>!pe%rz*sDaTIzlG4>_C)mT~CnAkH%9G5e2l2G%i z*^3Iz7B0$hGLCK%ovxT38k&wCAK!q`uC_T&-bMV8^U=0{RV;bS5S+TM6l{HoIma}M z=Ilz-G)wXwTkzjLqB=!A7&_VT<8K$Ft>t{nir%;HPqa@!H3VhwlZ}O$h7k+~!{O2o zBtkHy(dgx9&0YVft)Jg7HvEwaTc^6UwKZ!PgM)*Z2sthwGdgWz2+W3l;|6B%-mVnG zWnac?jpEJLDMTsg9dLF2!`W6`Mp5shw5!)mc_i=2~sDaOl(Bb}&LLW6t~7M5{iv4>AkfbqB$)E4dtB74Y)(=anmU z)+KA(!$&Zn$+u#A^BKWfpC1`{UN8FEywI6#?MmT_CDSiqTD|23?u$`jWT7rA={;Jz zmRb<(OPggFAF4(xy68^E&)^m!N;avJ+^qB}bPShwQCIEp_KEgn=ays~aUjsm=UwRe z)N1%7`e6UBRLufLa9r#=R$@S3(Lgpj_Gy2_L2z(uXjRR0Lo}))-Qqg9lh5aMouGV{ zPS#pI)QL1;txD_M8jI~rCU+!btvLpOe%%DcT;0?)T#a959hM8$OABOUv94HKGTl9( z?Rtz3FP|RR|I!Q3?SJ-zr}che1F1%2POjbDXII~~=GkU1&$w&b$iMzOcNwZ!t%uH; zCe{1b&AoMWU3kqeYD&{;nWE}0Mxsk5qtWOFJiog15e7P2TG~HKB(}VrNW3c$q>Ep_ zCGtu8(JPI2e>A_b-m`nRWM884kBRp9_me+PY41GTks%jPORHtE{0&IAkz*I*L|hDrvdhlDaOBvLV@E#<;9pl4g>GXOq+{;q zzk7M?jicu)=Tu4|pFw?MW>-npj&*m$;~m|Y(eWC$233`{cXiy?vEgTkqg=f68Pvl- zmtp?W4hEAWQ7^vo>b9l*!&qz2TP-au$b+kpp91x!cI_{Qcdc2|@xzd)ndVBfYF5Sg z&cu`PFF3DWncg-$|CZH?Bigtf0t&xf9fXs7|dv7Kub^w0FS)bh8>?J91>ap?>~i zOWU1%!Euly$vVhrs5(^NwoJPtPyw@}uIy4PMPL{_yF74Pt=m5E{Pmj93twF^|0=|; z8CimF;`*Z{(q+GEx7#=+^!XqNuP3olho}==hOSR-(U;2Oywb<{x7~1fy=T^=(29nc zO|;`mWEtNp30JPJeRA2Fk)lzDa|x3o2YM1$zDVz^nx3nx1tC#?#kNNn*V{#r%cGZ`JG_g>3A`0I7et!wChG0L@xj!+ @@ -64,12 +64,12 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo ST7920_WRITE_BYTE(0x01); //clear CGRAM ram u8g_Delay(15); //delay for CGRAM clear ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active - for(y=0;y Date: Mon, 27 Apr 2015 12:47:11 +0200 Subject: [PATCH 105/118] Give TALL_FONT_CORRECTION a default --- Marlin/dogm_lcd_implementation.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 927904c7a7..d0b9642d87 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -110,6 +110,10 @@ #define LCD_WIDTH_EDIT 22 #endif +#ifndef TALL_FONT_CORRECTION + #define TALL_FONT_CORRECTION 0 +#endif + #define START_ROW 0 // LCD selection From 1d9699be0f74b3f689128cdbbd38526112be2d7a Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 27 Apr 2015 13:16:20 +0200 Subject: [PATCH 106/118] Add some doku --- Documentation/LCDLanguageFont.md | 9 +++++---- Marlin/fonts/README.fonts | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/LCDLanguageFont.md b/Documentation/LCDLanguageFont.md index a1acfb63fb..ff9c1222e9 100644 --- a/Documentation/LCDLanguageFont.md +++ b/Documentation/LCDLanguageFont.md @@ -46,11 +46,9 @@ We have two different technologies for the displays: * nl Dutch * ca Catalan * eu Basque-Euskera + * cn Chinese + * jp Japanese (Katakana) - and recently on [Thingiverse](http://www.thingiverse.com/) a new port to - * jp [Japanese](http://www.thingiverse.com/thing:664397) - - appeared. ## The Problem All of this languages, except the English, normally use extended symbol sets, not contained in US-ASCII. @@ -132,6 +130,9 @@ We have two different technologies for the displays: You'll find all translatable strings in 'language_en.h'. Please don't translate any strings from 'language.h', this may break the serial protocol. + For information about fonts see: Marlin\fonts\README.fonts + + ## User Instructions Define your hardware and the wanted language in 'Configuration.h'. To find out what charset your hardware is, define language 'test' and compile. In the menu you will see two lines from the upper half of the charset. diff --git a/Marlin/fonts/README.fonts b/Marlin/fonts/README.fonts index a33e6afcd0..f7d41fa982 100644 --- a/Marlin/fonts/README.fonts +++ b/Marlin/fonts/README.fonts @@ -4,8 +4,9 @@ Then run make_fonts.bat what calls bdf2u8g.exe with the needed parameters to pro The .h files must be edited to replace '#include "u8g.h"' with '#include ', replace 'U8G_FONT_SECTION' with 'U8G_SECTION', insert '.progmem.' right behind the first '"' and moved to the main directory. How to integrate a new font: -Currently we are limited to 256 symbols per font. We use a menu system with 5 lines, on a display with 64 pixel height. That means we have 12 pixel for a line. To have some space in between the lines we can't use more then 10 pixel height for the symbols. -We use fixed width fonts. To fit 22 Symbols on the 128 pixel wide screen, the symbols can't be wider than 5 pixel. Maybe you can work with half symbols - two places in the charset will than build one wide symbol. +Currently we are limited to 256 symbols per font. We use a menu system with 5 lines, on a display with 64 pixel height. That means we have 12 pixel for a line. To have some space in between the lines we can't use more then 10 pixel height for the symbols. For up to 11 pixel set TALL_FONT_CORRECTION 1 when loading the font. +To fit 22 Symbols on the 128 pixel wide screen, the symbols can't be wider than 5 pixel, for the first 128 symbols. +For the second half of the font we now support up to 11x11 pixel. * Get 'Fony.exe' * Copy one of the existing *.fon files and work with this. From 6cba6bcd82f60f488518fe95ae1c65dc84fc3b60 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 27 Apr 2015 13:24:51 +0200 Subject: [PATCH 107/118] Add 'cn' to the other 'Configuration.h's --- Marlin/configurator/config/Configuration.h | 2 +- Marlin/example_configurations/Felix/Configuration.h | 2 +- Marlin/example_configurations/Felix/Configuration_DUAL.h | 2 +- Marlin/example_configurations/Hephestos/Configuration.h | 2 +- Marlin/example_configurations/K8200/Configuration.h | 2 +- Marlin/example_configurations/SCARA/Configuration.h | 2 +- Marlin/example_configurations/WITBOX/Configuration.h | 2 +- Marlin/example_configurations/delta/generic/Configuration.h | 2 +- Marlin/example_configurations/delta/kossel_mini/Configuration.h | 2 +- Marlin/example_configurations/makibox/Configuration.h | 2 +- Marlin/example_configurations/tvrrug/Round2/Configuration.h | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 59d13ab64e..9ed528059a 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -641,7 +641,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // @section lcd // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 558ee3bb03..5407cc7952 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -575,7 +575,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index 2e5633b8c1..aefabced9f 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -571,7 +571,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 69841816fd..596a286f51 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -595,7 +595,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 2987552f6d..d920757486 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -653,7 +653,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // @section lcd // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 6d70fa244f..c136191c40 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -626,7 +626,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 7022f78887..b7ed17ef54 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -594,7 +594,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index ae094ccac5..7f93c4d8b0 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -643,7 +643,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index f6b6a1e036..f90344613c 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -647,7 +647,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 500f47fe86..93e152e868 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -594,7 +594,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 314faf2d6a..ce662b2c03 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -600,7 +600,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic //==============================LCD and SD support============================= // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, test +// en, pl, fr, de, es, ru, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test // See also language.h //#define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) From 98ca46006c1c94680d8376ba9c63aab17c366c35 Mon Sep 17 00:00:00 2001 From: Steve Kelly Date: Wed, 22 Apr 2015 16:34:55 -0400 Subject: [PATCH 108/118] Allow Y to home before X with option in Configuration_adv.h. This addresses comments in #1956 and #1079. In particular, this is useful when both endstops are stationary on a CoreXY system, and the Y axis needs to be homed before the X so the flags are aligned. --- Marlin/Configuration_adv.h | 3 +++ Marlin/Marlin_main.cpp | 11 +++++++++-- Marlin/configurator/config/Configuration_adv.h | 3 +++ .../example_configurations/Felix/Configuration_adv.h | 3 +++ .../Hephestos/Configuration_adv.h | 3 +++ .../example_configurations/K8200/Configuration_adv.h | 3 +++ .../example_configurations/SCARA/Configuration_adv.h | 3 +++ .../example_configurations/WITBOX/Configuration_adv.h | 3 +++ .../delta/generic/Configuration_adv.h | 3 +++ .../delta/kossel_mini/Configuration_adv.h | 3 +++ .../makibox/Configuration_adv.h | 3 +++ .../tvrrug/Round2/Configuration_adv.h | 3 +++ 12 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6478eb923e..bdf856e7ed 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f350..eba95e21b5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1924,6 +1924,11 @@ inline void gcode_G28() { #endif // QUICK_HOME + #ifdef HOME_Y_BEFORE_X + // Home Y + if (home_all_axis || homeY) HOMEAXIS(Y); + #endif + // Home X if (home_all_axis || homeX) { #ifdef DUAL_X_CARRIAGE @@ -1943,8 +1948,10 @@ inline void gcode_G28() { #endif } - // Home Y - if (home_all_axis || homeY) HOMEAXIS(Y); + #ifndef HOME_Y_BEFORE_X + // Home Y + if (home_all_axis || homeY) HOMEAXIS(Y); + #endif // Set the X position, if included if (code_seen(axis_codes[X_AXIS]) && code_has_value()) diff --git a/Marlin/configurator/config/Configuration_adv.h b/Marlin/configurator/config/Configuration_adv.h index 6478eb923e..bdf856e7ed 100644 --- a/Marlin/configurator/config/Configuration_adv.h +++ b/Marlin/configurator/config/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index a80790b957..17649a9b3f 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 84536d044e..d9cd7c468a 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index a80790b957..17649a9b3f 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index edc2445af6..c97b03f710 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 15c5232848..a37f9edf5b 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 88b76c66e1..33969ba4c5 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {10, 10, 20} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 9b52ede7b7..34426b81d1 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {10, 10, 20} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 7b63732a69..85a8eef803 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index d221f080b4..4276d9aebf 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -195,6 +195,9 @@ #define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. +// When G28 is called, this option will make Y home before X +// #define HOME_Y_BEFORE_X + // @section machine #define AXIS_RELATIVE_MODES {false, false, false, false} From 6af40e9dc0e4e91a95e4f7ee0c7cbefbfdd19184 Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Mon, 27 Apr 2015 23:59:10 +0200 Subject: [PATCH 109/118] K8200 example Configuration.h: STRING_URL removed K8200 example Configuration.h: * STRING_URL removed: like proposed by thinkyhead in #1917 --- Marlin/example_configurations/K8200/Configuration.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index f324817c3c..43e15440e0 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -46,7 +46,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "https://github.com/CONSULitAS/Marlin-K8200/" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(K8200, CONSULitAS)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 From c5dfb355970427b848f927ad587e19bfa4884f03 Mon Sep 17 00:00:00 2001 From: CONSULitAS Date: Tue, 28 Apr 2015 01:03:54 +0200 Subject: [PATCH 110/118] language_de.h: updated translation and minor typos language_de.h: updated translation and minor typos --- Marlin/language_de.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/language_de.h b/Marlin/language_de.h index 8c8496f02c..57db43f245 100644 --- a/Marlin/language_de.h +++ b/Marlin/language_de.h @@ -13,7 +13,7 @@ //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_1 -#define WELCOME_MSG MACHINE_NAME " Bereit." +#define WELCOME_MSG MACHINE_NAME " bereit." #define MSG_SD_INSERTED "SDKarte erkannt." #define MSG_SD_REMOVED "SDKarte entfernt." #define MSG_MAIN "Hauptmenü" @@ -61,9 +61,9 @@ #define MSG_PID_D "PID D" #define MSG_PID_C "PID C" #define MSG_ACC "A" -#define MSG_VXY_JERK "V xy jerk" -#define MSG_VZ_JERK "V z jerk" -#define MSG_VE_JERK "V e jerk" +#define MSG_VXY_JERK "V xy Ruck" +#define MSG_VZ_JERK "V z Ruck" +#define MSG_VE_JERK "V e Ruck" #define MSG_VMAX "V max " // space by purpose #define MSG_X "x" #define MSG_Y "y" @@ -84,7 +84,7 @@ #define MSG_FILAMENT_SIZE_EXTRUDER_0 "Filament D 1" #define MSG_FILAMENT_SIZE_EXTRUDER_1 "Filament D 2" #define MSG_FILAMENT_SIZE_EXTRUDER_2 "Filament D 3" -#define MSG_CONTRAST "LCD contrast" +#define MSG_CONTRAST "LCD Kontrast" #define MSG_STORE_EPROM "EPROM speichern" #define MSG_LOAD_EPROM "EPROM laden" #define MSG_RESTORE_FAILSAFE "Standardkonfig." @@ -116,7 +116,7 @@ #define MSG_INIT_SDCARD "SDKarte erkennen"// Manually initialize the SD-card via user interface #define MSG_CNG_SDCARD "SDKarte erkennen"// SD-card changed by user. For machines with no autocarddetect. Both send "M21" #define MSG_ZPROBE_OUT "Sensor ausserhalb" -#define MSG_POSITION_UNKNOWN "X/Y vor Z Homen." +#define MSG_POSITION_UNKNOWN "X/Y vor Z homen." #define MSG_ZPROBE_ZOFFSET "Z Offset" #define MSG_BABYSTEP_X "Babystep X" #define MSG_BABYSTEP_Y "Babystep Y" @@ -126,7 +126,7 @@ #define MSG_END_MINUTE "Minuten" #ifdef DELTA_CALIBRATION_MENU - #define MSG_DELTA_CALIBRATE "Delta Kalibrieren" + #define MSG_DELTA_CALIBRATE "Delta kalibrieren" #define MSG_DELTA_CALIBRATE_X "Kalibriere X" #define MSG_DELTA_CALIBRATE_Y "Kalibriere Y" #define MSG_DELTA_CALIBRATE_Z "Kalibriere Z" From 5b248757c71441866ec6d7fdab8125845dd4f5e2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2015 19:11:25 -0700 Subject: [PATCH 111/118] Level Bed in Prepare submenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add “Level Bed” menu item for auto bed leveling - Hide the option if homing has not been done yet - Arrange the Prepare submenu more logically (?) - Add documentation comments, some white-space - Apply some coding standards here and there - Move old encoder multiplier debug option to `ultralcd.cpp` --- Marlin/Configuration_adv.h | 1 - .../configurator/config/Configuration_adv.h | 1 - Marlin/dogm_lcd_implementation.h | 1 + .../Felix/Configuration_adv.h | 1 - .../Hephestos/Configuration_adv.h | 1 - .../K8200/Configuration_adv.h | 1 - .../SCARA/Configuration_adv.h | 1 - .../WITBOX/Configuration_adv.h | 1 - .../delta/generic/Configuration_adv.h | 1 - .../delta/kossel_mini/Configuration_adv.h | 1 - .../makibox/Configuration_adv.h | 1 - .../tvrrug/Round2/Configuration_adv.h | 1 - Marlin/ultralcd.cpp | 415 +++++++++++++----- 13 files changed, 304 insertions(+), 123 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6478eb923e..d0d9329bff 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/configurator/config/Configuration_adv.h b/Marlin/configurator/config/Configuration_adv.h index 6478eb923e..d0d9329bff 100644 --- a/Marlin/configurator/config/Configuration_adv.h +++ b/Marlin/configurator/config/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 0965b90972..f8eb714aa2 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -172,6 +172,7 @@ char lcd_printPGM(const char* str) { static bool show_splashscreen = true; +/* Warning: This function is called from interrupt context */ static void lcd_implementation_init() { #ifdef LCD_PIN_BL // Enable LCD backlight diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index a80790b957..caad4c8fb9 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 84536d044e..30b37ec042 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index a80790b957..caad4c8fb9 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index edc2445af6..34e60fd96c 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 15c5232848..758f0e8f47 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 88b76c66e1..0360f0a5d4 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -259,7 +259,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 9b52ede7b7..f941bd2dcc 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 7b63732a69..3520c6342f 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index d221f080b4..77067bf892 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -258,7 +258,6 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 81844573ea..5dc918aeac 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -173,6 +173,9 @@ static void lcd_status_screen(); } while(0) #ifdef ENCODER_RATE_MULTIPLIER + + //#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + /** * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item */ @@ -246,6 +249,9 @@ menuFunc_t callbackFunc; // place-holders for Ki and Kd edits float raw_Ki, raw_Kd; +/** + * General function to go directly to a menu + */ static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint32_t encoder=0) { if (currentMenu != menu) { currentMenu = menu; @@ -260,7 +266,13 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint } } -/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ +/** + * + * "Info Screen" + * + * This is very display-dependent, so the lcd implementation draws this. + */ + static void lcd_status_screen() { encoderRateMultiplierEnabled = false; @@ -371,7 +383,12 @@ static void lcd_sdcard_stop() { lcd_setstatus(MSG_PRINT_ABORTED, true); } -/* Menu implementation */ +/** + * + * "Main" menu + * + */ + static void lcd_main_menu() { START_MENU(); MENU_ITEM(back, MSG_WATCH, lcd_status_screen); @@ -453,6 +470,12 @@ void lcd_set_home_offsets() { #endif //BABYSTEPPING +/** + * + * "Tune" submenu + * + */ + static void lcd_tune_menu() { START_MENU(); MENU_ITEM(back, MSG_MAIN, lcd_main_menu); @@ -594,17 +617,55 @@ void lcd_cooldown() { lcd_return_to_status(); } +/** + * + * "Prepare" submenu + * + */ + static void lcd_prepare_menu() { START_MENU(); + + // + // ^ Main + // MENU_ITEM(back, MSG_MAIN, lcd_main_menu); - #if defined( SDSUPPORT ) && defined( MENU_ADDAUTOSTART ) - MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd); - #endif - MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84")); + + // + // Auto Home + // MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); + + // + // Set Home Offsets + // MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets); //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0")); + // + // Level Bed + // + #ifdef ENABLE_AUTO_BED_LEVELING + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) + MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29")); + #elif defined(MANUAL_BED_LEVELING) + MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed); + #endif + + // + // Move Axis + // + MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu); + + // + // Disable Steppers + // + MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84")); + + // + // Preheat PLA + // Preheat ABS + // #if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0 MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu); @@ -615,8 +676,14 @@ static void lcd_prepare_menu() { #endif #endif + // + // Cooldown + // MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); + // + // Switch power on/off + // #if HAS_POWER_SWITCH if (powersupply) MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81")); @@ -624,12 +691,13 @@ static void lcd_prepare_menu() { MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80")); #endif - MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu); - - #if defined(MANUAL_BED_LEVELING) - MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed); + // + // Autostart + // + #if defined(SDSUPPORT) && defined(MENU_ADDAUTOSTART) + MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd); #endif - + END_MENU(); } @@ -657,6 +725,12 @@ inline void line_to_current(AxisEnum axis) { #endif } +/** + * + * "Prepare" > "Move Axis" submenu + * + */ + float move_menu_scale; static void lcd_move_menu_axis(); @@ -687,6 +761,12 @@ static void lcd_move_e() { if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); } +/** + * + * "Prepare" > "Move Xmm" > "Move XYZ" submenu + * + */ + static void lcd_move_menu_axis() { START_MENU(); MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); @@ -712,6 +792,12 @@ static void lcd_move_menu_01mm() { lcd_move_menu_axis(); } +/** + * + * "Prepare" > "Move Axis" submenu + * + */ + static void lcd_move_menu() { START_MENU(); MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu); @@ -722,6 +808,12 @@ static void lcd_move_menu() { END_MENU(); } +/** + * + * "Control" submenu + * + */ + static void lcd_control_menu() { START_MENU(); MENU_ITEM(back, MSG_MAIN, lcd_main_menu); @@ -744,6 +836,12 @@ static void lcd_control_menu() { END_MENU(); } +/** + * + * "Temperature" submenu + * + */ + #ifdef PIDTEMP // Helpers for editing PID Ki & Kd values @@ -775,6 +873,12 @@ static void lcd_control_menu() { #endif //PIDTEMP +/** + * + * "Control" > "Temperature" submenu + * + */ + static void lcd_control_temperature_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); @@ -863,6 +967,12 @@ static void lcd_control_temperature_menu() { END_MENU(); } +/** + * + * "Temperature" > "Preheat PLA conf" submenu + * + */ + static void lcd_control_temperature_preheat_pla_settings_menu() { START_MENU(); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); @@ -879,6 +989,12 @@ static void lcd_control_temperature_preheat_pla_settings_menu() { END_MENU(); } +/** + * + * "Temperature" > "Preheat ABS conf" submenu + * + */ + static void lcd_control_temperature_preheat_abs_settings_menu() { START_MENU(); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); @@ -895,6 +1011,12 @@ static void lcd_control_temperature_preheat_abs_settings_menu() { END_MENU(); } +/** + * + * "Control" > "Motion" submenu + * + */ + static void lcd_control_motion_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); @@ -931,6 +1053,12 @@ static void lcd_control_motion_menu() { END_MENU(); } +/** + * + * "Control" > "Filament" submenu + * + */ + static void lcd_control_volumetric_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); @@ -953,6 +1081,12 @@ static void lcd_control_volumetric_menu() { END_MENU(); } +/** + * + * "Control" > "Contrast" submenu + * + */ + #ifdef HAS_LCD_CONTRAST static void lcd_set_contrast() { if (encoderPosition != 0) { @@ -967,6 +1101,12 @@ static void lcd_control_volumetric_menu() { } #endif // HAS_LCD_CONTRAST +/** + * + * "Control" > "Retract" submenu + * + */ + #ifdef FWRETRACT static void lcd_control_retract_menu() { START_MENU(); @@ -999,6 +1139,12 @@ static void lcd_sd_updir() { currentMenuViewOffset = 0; } +/** + * + * "Print from SD" submenu + * + */ + void lcd_sdcard_menu() { if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card) uint16_t fileCnt = card.getnrfilenames(); @@ -1034,6 +1180,11 @@ void lcd_sdcard_menu() { END_MENU(); } +/** + * + * Functions for editing single values + * + */ #define menu_edit_type(_type, _name, _strFunc, scale) \ bool _menu_edit_ ## _name () { \ bool isClicked = LCD_CLICKED; \ @@ -1080,6 +1231,11 @@ menu_edit_type(float, float51, ftostr51, 10) menu_edit_type(float, float52, ftostr52, 100) menu_edit_type(unsigned long, long5, ftostr5, 0.01) +/** + * + * Handlers for RepRap World Keypad input + * + */ #ifdef REPRAPWORLD_KEYPAD static void reprapworld_keypad_move_z_up() { encoderPosition = 1; @@ -1114,10 +1270,14 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) static void reprapworld_keypad_move_home() { enqueuecommands_P((PSTR("G28"))); // move all axis home } -#endif //REPRAPWORLD_KEYPAD +#endif // REPRAPWORLD_KEYPAD -/** End of menus **/ +/** + * + * Audio feedback for controller clicks + * + */ void lcd_quick_feedback() { lcdDrawUpdate = 2; next_button_update_ms = millis() + 500; @@ -1146,11 +1306,15 @@ void lcd_quick_feedback() { #endif } -/** Menu action functions **/ -static void menu_action_back(menuFunc_t data) { lcd_goto_menu(data); } -static void menu_action_submenu(menuFunc_t data) { lcd_goto_menu(data); } +/** + * + * Menu actions + * + */ +static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); } +static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); } static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); } -static void menu_action_function(menuFunc_t data) { (*data)(); } +static void menu_action_function(menuFunc_t func) { (*func)(); } static void menu_action_sdfile(const char* filename, char* longFilename) { char cmd[30]; char* c; @@ -1243,6 +1407,19 @@ int lcd_strlen_P(const char *s) { return j; } +/** + * Update the LCD, read encoder buttons, etc. + * - Read button states + * - Check the SD Card slot state + * - Act on RepRap World keypad input + * - Update the encoder position + * - Apply acceleration to the encoder position + * - Reset the Info Screen timeout if there's any input + * - Update status indicators, if any + * - Clear the LCD if lcdDrawUpdate == 2 + * + * Warning: This function is called from interrupt context! + */ void lcd_update() { #ifdef ULTIPANEL static millis_t return_to_status_ms = 0; @@ -1381,7 +1558,7 @@ void lcd_update() { if (lcdDrawUpdate == 2) lcd_implementation_clear(); if (lcdDrawUpdate) lcdDrawUpdate--; - next_lcd_update_ms = millis() + LCD_UPDATE_INTERVAL; + next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; } } @@ -1454,112 +1631,116 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } #ifdef ULTIPANEL -//////////////////////// -// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement) -// These values are independent of which pins are used for EN_A and EN_B indications -// The rotary encoder part is also independent to the chipset used for the LCD -#if defined(EN_A) && defined(EN_B) - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 -#endif + /** + * Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement) + * These values are independent of which pins are used for EN_A and EN_B indications + * The rotary encoder part is also independent to the chipset used for the LCD + */ + #if defined(EN_A) && defined(EN_B) + #define encrot0 0 + #define encrot1 2 + #define encrot2 3 + #define encrot3 1 + #endif -/* Warning: This function is called from interrupt context */ -void lcd_buttons_update() { - #ifdef NEWPANEL - uint8_t newbutton = 0; - if (READ(BTN_EN1) == 0) newbutton |= EN_A; - if (READ(BTN_EN2) == 0) newbutton |= EN_B; - #if BTN_ENC > 0 - if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C; - #endif - buttons = newbutton; - #ifdef LCD_HAS_SLOW_BUTTONS - buttons |= slow_buttons; - #endif - #ifdef REPRAPWORLD_KEYPAD - // for the reprapworld_keypad - uint8_t newbutton_reprapworld_keypad=0; + /** + * Read encoder buttons from the hardware registers + * Warning: This function is called from interrupt context! + */ + void lcd_buttons_update() { + #ifdef NEWPANEL + uint8_t newbutton = 0; + if (READ(BTN_EN1) == 0) newbutton |= EN_A; + if (READ(BTN_EN2) == 0) newbutton |= EN_B; + #if BTN_ENC > 0 + if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C; + #endif + buttons = newbutton; + #ifdef LCD_HAS_SLOW_BUTTONS + buttons |= slow_buttons; + #endif + #ifdef REPRAPWORLD_KEYPAD + // for the reprapworld_keypad + uint8_t newbutton_reprapworld_keypad=0; + WRITE(SHIFT_LD, LOW); + WRITE(SHIFT_LD, HIGH); + for(int8_t i = 0; i < 8; i++) { + newbutton_reprapworld_keypad >>= 1; + if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7); + WRITE(SHIFT_CLK, HIGH); + WRITE(SHIFT_CLK, LOW); + } + buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0 + #endif + #else //read it from the shift register + uint8_t newbutton = 0; WRITE(SHIFT_LD, LOW); WRITE(SHIFT_LD, HIGH); - for(int8_t i = 0; i < 8; i++) { - newbutton_reprapworld_keypad >>= 1; - if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7); + unsigned char tmp_buttons = 0; + for(int8_t i=0; i<8; i++) { + newbutton >>= 1; + if (READ(SHIFT_OUT)) newbutton |= BIT(7); WRITE(SHIFT_CLK, HIGH); WRITE(SHIFT_CLK, LOW); } - buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0 - #endif - #else //read it from the shift register - uint8_t newbutton = 0; - WRITE(SHIFT_LD, LOW); - WRITE(SHIFT_LD, HIGH); - unsigned char tmp_buttons = 0; - for(int8_t i=0; i<8; i++) { - newbutton >>= 1; - if (READ(SHIFT_OUT)) newbutton |= BIT(7); - WRITE(SHIFT_CLK, HIGH); - WRITE(SHIFT_CLK, LOW); - } - buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0 - #endif //!NEWPANEL + buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0 + #endif //!NEWPANEL - //manage encoder rotation - uint8_t enc=0; - if (buttons & EN_A) enc |= B01; - if (buttons & EN_B) enc |= B10; - if (enc != lastEncoderBits) { - switch(enc) { - case encrot0: - if (lastEncoderBits==encrot3) encoderDiff++; - else if (lastEncoderBits==encrot1) encoderDiff--; - break; - case encrot1: - if (lastEncoderBits==encrot0) encoderDiff++; - else if (lastEncoderBits==encrot2) encoderDiff--; - break; - case encrot2: - if (lastEncoderBits==encrot1) encoderDiff++; - else if (lastEncoderBits==encrot3) encoderDiff--; - break; - case encrot3: - if (lastEncoderBits==encrot2) encoderDiff++; - else if (lastEncoderBits==encrot0) encoderDiff--; - break; + //manage encoder rotation + uint8_t enc=0; + if (buttons & EN_A) enc |= B01; + if (buttons & EN_B) enc |= B10; + if (enc != lastEncoderBits) { + switch(enc) { + case encrot0: + if (lastEncoderBits==encrot3) encoderDiff++; + else if (lastEncoderBits==encrot1) encoderDiff--; + break; + case encrot1: + if (lastEncoderBits==encrot0) encoderDiff++; + else if (lastEncoderBits==encrot2) encoderDiff--; + break; + case encrot2: + if (lastEncoderBits==encrot1) encoderDiff++; + else if (lastEncoderBits==encrot3) encoderDiff--; + break; + case encrot3: + if (lastEncoderBits==encrot2) encoderDiff++; + else if (lastEncoderBits==encrot0) encoderDiff--; + break; + } } + lastEncoderBits = enc; } - lastEncoderBits = enc; -} -bool lcd_detected(void) { - #if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE) - return lcd.LcdDetected() == 1; - #else - return true; - #endif -} - -void lcd_buzz(long duration, uint16_t freq) { - if (freq > 0) { - #if BEEPER > 0 - SET_OUTPUT(BEEPER); - tone(BEEPER, freq, duration); - delay(duration); - #elif defined(LCD_USE_I2C_BUZZER) - lcd.buzz(duration, freq); + bool lcd_detected(void) { + #if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE) + return lcd.LcdDetected() == 1; #else - delay(duration); + return true; #endif } - else { - delay(duration); + + void lcd_buzz(long duration, uint16_t freq) { + if (freq > 0) { + #if BEEPER > 0 + SET_OUTPUT(BEEPER); + tone(BEEPER, freq, duration); + delay(duration); + #elif defined(LCD_USE_I2C_BUZZER) + lcd.buzz(duration, freq); + #else + delay(duration); + #endif + } + else { + delay(duration); + } } -} -bool lcd_clicked() { return LCD_CLICKED; } + bool lcd_clicked() { return LCD_CLICKED; } -#endif //ULTIPANEL +#endif // ULTIPANEL /*********************************/ /** Number to string conversion **/ @@ -1621,8 +1802,7 @@ char *ftostr32(const float &x) { } // Convert float to string with 1.234 format -char *ftostr43(const float &x) -{ +char *ftostr43(const float &x) { long xx = x * 1000; if (xx >= 0) conv[0] = (xx / 1000) % 10 + '0'; @@ -1638,8 +1818,7 @@ char *ftostr43(const float &x) } // Convert float to string with 1.23 format -char *ftostr12ns(const float &x) -{ +char *ftostr12ns(const float &x) { long xx=x*100; xx=abs(xx); @@ -1799,6 +1978,12 @@ char *ftostr52(const float &x) { #ifdef MANUAL_BED_LEVELING static int _lcd_level_bed_position; + + /** + * MBL Wait for controller movement and clicks: + * - Movement adjusts the Z axis + * - Click saves the Z and goes to the next mesh point + */ static void _lcd_level_bed() { if (encoderPosition != 0) { refresh_cmd_timeout(); @@ -1844,6 +2029,9 @@ char *ftostr52(const float &x) { } } + /** + * MBL Move to mesh starting point + */ static void _lcd_level_bed_homing() { if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("XYZ"), "Homing"); if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) { @@ -1858,6 +2046,9 @@ char *ftostr52(const float &x) { lcdDrawUpdate = 2; } + /** + * MBL entry-point + */ static void lcd_level_bed() { axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false; mbl.reset(); From ff67ee73fcfbf3c2926367bd70c6614ad264fdb6 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 27 Apr 2015 23:29:16 -0300 Subject: [PATCH 112/118] Update Marlin_main.cpp Corrected "servo.h" to "Servo.h" because of the updated filename. --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ac86cb05b7..0ea5d8c3c9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -60,7 +60,7 @@ #endif #if NUM_SERVOS > 0 - #include "servo.h" + #include "Servo.h" #endif #if HAS_DIGIPOTSS From e44965933885da6f598436259e838e3576c7eeae Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 27 Apr 2015 23:30:11 -0300 Subject: [PATCH 113/118] Update Servo.cpp Updated "servo.h" to "Servo.h" --- Marlin/Servo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Servo.cpp b/Marlin/Servo.cpp index 81d73ae870..576b394fb7 100644 --- a/Marlin/Servo.cpp +++ b/Marlin/Servo.cpp @@ -48,7 +48,7 @@ #include #include -#include "servo.h" +#include "Servo.h" #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds From ff178d8cf7dc4bb6e585862da37ae1bed2766356 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2015 19:48:34 -0700 Subject: [PATCH 114/118] Change M421 to take coordinates This makes `M421` more amenable for irregular matrices --- Marlin/Marlin_main.cpp | 13 ++++++------- Marlin/configuration_store.cpp | 12 +++++------- Marlin/configurator/config/language.h | 2 +- Marlin/language.h | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index cbeb9a0912..61a4baa41d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -188,7 +188,7 @@ * M407 - Display measured filament diameter * M410 - Quickstop. Abort all the planned moves * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable - * M421 - Set a single Z coordinate in the Mesh Leveling grid. X Y Z + * M421 - Set a single Z coordinate in the Mesh Leveling grid. X Y Z * M500 - Store parameters in EEPROM * M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). * M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -4467,16 +4467,15 @@ inline void gcode_M410() { quickStop(); } * M421: Set a single Mesh Bed Leveling Z coordinate */ inline void gcode_M421() { - int x, y; - float z; + float x, y, z; bool err = false, hasX, hasY, hasZ; - if ((hasX = code_seen('X'))) x = code_value_short(); - if ((hasY = code_seen('Y'))) y = code_value_short(); + if ((hasX = code_seen('X'))) x = code_value(); + if ((hasY = code_seen('Y'))) y = code_value(); if ((hasZ = code_seen('Z'))) z = code_value(); if (!hasX || !hasY || !hasZ) { SERIAL_ERROR_START; - SERIAL_ERRORLNPGM(MSG_ERR_XYZ_REQUIRED_FOR_M421); + SERIAL_ERRORLNPGM(MSG_ERR_M421_REQUIRES_XYZ); err = true; } @@ -4486,7 +4485,7 @@ inline void gcode_M410() { quickStop(); } err = true; } - if (!err) mbl.z_values[y][x] = z; + if (!err) mbl.set_z(select_x_index(x), select_y_index(y), z); } #endif diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 0cd7faa7c1..782b5d320a 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -96,8 +96,8 @@ #include "configuration_store.h" #ifdef MESH_BED_LEVELING - #include "mesh_bed_leveling.h" -#endif // MESH_BED_LEVELING + #include "mesh_bed_leveling.h" +#endif void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) { uint8_t c; @@ -168,9 +168,7 @@ void Config_StoreSettings() { EEPROM_WRITE_VAR(i, mesh_num_x); EEPROM_WRITE_VAR(i, mesh_num_y); dummy = 0.0f; - for (int q=0; q out of range (0-1)" -#define MSG_ERR_XYZ_REQUIRED_FOR_M421 "M421 requires XYZ parameters" +#define MSG_ERR_M421_REQUIRES_XYZ "M421 requires XYZ parameters" #define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" #define MSG_M119_REPORT "Reporting endstop status" #define MSG_ENDSTOP_HIT "TRIGGERED" diff --git a/Marlin/language.h b/Marlin/language.h index b6beb47473..d8ceafb1a5 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -159,7 +159,7 @@ #define MSG_Z2_MAX "z2_max: " #define MSG_Z_PROBE "z_probe: " #define MSG_ERR_MATERIAL_INDEX "M145 S out of range (0-1)" -#define MSG_ERR_XYZ_REQUIRED_FOR_M421 "M421 requires XYZ parameters" +#define MSG_ERR_M421_REQUIRES_XYZ "M421 requires XYZ parameters" #define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" #define MSG_M119_REPORT "Reporting endstop status" #define MSG_ENDSTOP_HIT "TRIGGERED" From c36226c4dc0ef7153dd7e8b81749599989ee0fbe Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2015 20:55:19 -0700 Subject: [PATCH 115/118] Fix homing Z position Add `sync_plan_position()` after `axis_is_at_home(axis)` to keep the planner position in sync when homing. --- Marlin/Marlin_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index ac86cb05b7..88813d289e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1596,6 +1596,7 @@ static void homeaxis(AxisEnum axis) { // Set the axis position to its home position (plus home offsets) axis_is_at_home(axis); + sync_plan_position(); destination[axis] = current_position[axis]; feedrate = 0.0; From 71a0b1a5bb933cadb5b33855fb8a409f5793216b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2015 21:14:30 -0700 Subject: [PATCH 116/118] Disable endstops between homing bumps --- Marlin/Marlin_main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 88813d289e..4dd304d371 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1546,11 +1546,15 @@ static void homeaxis(AxisEnum axis) { current_position[axis] = 0; sync_plan_position(); + enable_endstops(false); // Disable endstops while moving away + // Move away from the endstop by the axis HOME_BUMP_MM destination[axis] = -home_bump_mm(axis) * axis_home_dir; line_to_destination(); st_synchronize(); + enable_endstops(true); // Enable endstops for next homing move + // Slow down the feedrate for the next move set_homing_bump_feedrate(axis); @@ -1587,10 +1591,12 @@ static void homeaxis(AxisEnum axis) { #ifdef DELTA // retrace by the amount specified in endstop_adj if (endstop_adj[axis] * axis_home_dir < 0) { + enable_endstops(false); // Disable endstops while moving away sync_plan_position(); destination[axis] = endstop_adj[axis]; line_to_destination(); st_synchronize(); + enable_endstops(true); // Enable endstops for next homing move } #endif From 0970102950578dca6f258f05fe3d20eb402451a3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2015 21:59:14 -0700 Subject: [PATCH 117/118] Remove obsolete STRING_URL --- Marlin/Configuration.h | 1 - Marlin/configurator/config/Configuration.h | 1 - Marlin/example_configurations/Felix/Configuration.h | 1 - Marlin/example_configurations/Felix/Configuration_DUAL.h | 1 - Marlin/example_configurations/Hephestos/Configuration.h | 1 - Marlin/example_configurations/SCARA/Configuration.h | 1 - Marlin/example_configurations/WITBOX/Configuration.h | 1 - Marlin/example_configurations/delta/generic/Configuration.h | 1 - Marlin/example_configurations/delta/kossel_mini/Configuration.h | 1 - Marlin/example_configurations/makibox/Configuration.h | 1 - Marlin/example_configurations/tvrrug/Round2/Configuration.h | 1 - 11 files changed, 11 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0ba1d0594b..455e46a195 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -41,7 +41,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/configurator/config/Configuration.h b/Marlin/configurator/config/Configuration.h index 9ed528059a..1d85de9266 100644 --- a/Marlin/configurator/config/Configuration.h +++ b/Marlin/configurator/config/Configuration.h @@ -41,7 +41,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 5407cc7952..63b3660d54 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index aefabced9f..085d95b271 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 596a286f51..c9c079ebe6 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(bq Hephestos)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index c136191c40..cdc036cb2e 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -57,7 +57,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index b7ed17ef54..343c3093ac 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(bq Witbox)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 7f93c4d8b0..9a1fe48756 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index f90344613c..33391863eb 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 93e152e868..918d5fa8bd 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index ce662b2c03..2fff0f21e3 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -39,7 +39,6 @@ Here are some standard links for getting your machine calibrated: // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION "1.0.3 dev" -#define STRING_URL "reprap.org" #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 From ae53b3cdc33094c68f504835b7a268c654a10f71 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2015 22:25:00 -0700 Subject: [PATCH 118/118] Fix the M303 S-1 report text --- Marlin/temperature.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index fa17b6c4c2..5c2a2a12e7 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -187,7 +187,7 @@ static void updateTemperaturesFromRawValues(); #endif //=========================================================================== -//============================= functions ============================ +//================================ Functions ================================ //=========================================================================== void PID_autotune(float temp, int extruder, int ncycles) @@ -341,9 +341,10 @@ void PID_autotune(float temp, int extruder, int ncycles) } if (cycles > ncycles) { SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED); - SERIAL_PROTOCOLPGM("#define DEFAULT_Kp "); SERIAL_PROTOCOLLN(Kp); - SERIAL_PROTOCOLPGM("#define DEFAULT_Ki "); SERIAL_PROTOCOLLN(Ki); - SERIAL_PROTOCOLPGM("#define DEFAULT_Kd "); SERIAL_PROTOCOLLN(Kd); + const char *estring = extruder < 0 ? "bed" : ""; + SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(Kp); + SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(Ki); + SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(Kd); return; } lcd_update();