diff --git a/.gitignore b/.gitignore index 380a02850..aa1d42424 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ applet/ *.bak *.DS_Store *.idea +*.s +*.i +*.ii diff --git a/.travis.yml b/.travis.yml index 766b2933c..cfcee4f77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,188 +26,144 @@ install: - mv LiquidCrystal_I2C/LiquidCrystal_I2C /usr/local/share/arduino/libraries/LiquidCrystal_I2C - git clone https://github.com/lincomatic/LiquidTWI2.git - mv LiquidTWI2 /usr/local/share/arduino/libraries/LiquidTWI2 - # Install astyle - - wget https://github.com/timonwong/astyle-mirror/archive/master.zip - - unzip master.zip - - cd astyle-mirror-master/build/gcc/ - - make prefix=$HOME astyle install before_script: # arduino requires an X server even with command line # https://github.com/arduino/Arduino/issues/1981 - Xvfb :1 -screen 0 1024x768x16 &> xvfb.log & # change back to home directory for compiling - cd $TRAVIS_BUILD_DIR - # Check style - # ~/bin/astyle --recursive --options=.astylerc "Marlin/*.h" "Marlin/*.cpp" script: - # Abort on style errors - # if [ "0" != `find . -name "*.orig" | wc -l` ] ; then echo "Improperly styled source -- run astyle" ; exit -999; fi - # Relaxed Travis check - # if [ "0" != `find . -name "*.orig" | wc -l` ] ; then echo "Improperly styled source -- run astyle" ; fi # build default config - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino - # backup configuration.h + - build_marlin + # Backup Configuration.h, Configuration_adv.h, and pins_RAMPS_14.h - cp Marlin/Configuration.h Marlin/Configuration.h.backup - cp Marlin/Configuration_adv.h Marlin/Configuration_adv.h.backup - - cp Marlin/pins_RAMPS_13.h Marlin/pins_RAMPS_13.h.backup + - cp Marlin/pins_RAMPS_14.h Marlin/pins_RAMPS_14.h.backup # add sensor for bed - - sed -i 's/#define TEMP_SENSOR_BED 0/#define TEMP_SENSOR_BED 1/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - opt_set TEMP_SENSOR_BED 1 + - build_marlin # change extruder numbers from 1 to 2 - - sed -i 's/#define MOTHERBOARD BOARD_RAMPS_13_EFB/#define MOTHERBOARD BOARD_RAMPS_13_EEB/g' Marlin/Configuration.h - - sed -i 's/#define EXTRUDERS 1/#define EXTRUDERS 2/g' Marlin/Configuration.h - - sed -i 's/#define TEMP_SENSOR_1 0/#define TEMP_SENSOR_1 1/g' Marlin/Configuration.h + - opt_set MOTHERBOARD BOARD_RAMPS_14_EEB + - opt_set EXTRUDERS 2 + - opt_set TEMP_SENSOR_1 1 #- cat Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - build_marlin # change extruder numbers from 2 to 3, needs to be a board with 3 extruders defined in pins.h - - sed -i 's/#define MOTHERBOARD BOARD_RAMPS_13_EEB/#define MOTHERBOARD BOARD_RUMBA/g' Marlin/Configuration.h - - sed -i 's/#define EXTRUDERS 2/#define EXTRUDERS 3/g' Marlin/Configuration.h - - sed -i 's/#define TEMP_SENSOR_2 0/#define TEMP_SENSOR_2 1/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - opt_set MOTHERBOARD BOARD_RUMBA + - opt_set EXTRUDERS 3 + - opt_set TEMP_SENSOR_2 1 + - build_marlin # enable PIDTEMPBED - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define PIDTEMPBED/#define PIDTEMPBED/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable PIDTEMPBED + - build_marlin # enable AUTO_BED_LEVELING - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define ENABLE_AUTO_BED_LEVELING/#define ENABLE_AUTO_BED_LEVELING/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable ENABLE_AUTO_BED_LEVELING + - build_marlin # enable AUTO_BED_LEVELING with servos - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define ENABLE_AUTO_BED_LEVELING/#define ENABLE_AUTO_BED_LEVELING/g' Marlin/Configuration.h - - sed -i 's/\/\/#define NUM_SERVOS/#define NUM_SERVOS/g' Marlin/Configuration.h - - sed -i 's/\/\/#define Z_ENDSTOP_SERVO_NR/#define Z_ENDSTOP_SERVO_NR/g' Marlin/Configuration.h - - sed -i 's/\/\/#define SERVO_ENDSTOP_ANGLES/#define SERVO_ENDSTOP_ANGLES/g' Marlin/Configuration.h - - sed -i 's/\/\/#define DEACTIVATE_SERVOS_AFTER_MOVE/#define DEACTIVATE_SERVOS_AFTER_MOVE/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable ENABLE_AUTO_BED_LEVELING NUM_SERVOS Z_ENDSTOP_SERVO_NR SERVO_ENDSTOP_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE + - build_marlin # enable EEPROM_SETTINGS & EEPROM_CHITCHAT - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define EEPROM_SETTINGS/#define EEPROM_SETTINGS/g' Marlin/Configuration.h - - sed -i 's/\/\/#define EEPROM_CHITCHAT/#define EEPROM_CHITCHAT/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT + - build_marlin ### LCDS ### # ULTIMAKERCONTROLLER - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define ULTIMAKERCONTROLLER/#define ULTIMAKERCONTROLLER/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable ULTIMAKERCONTROLLER + - build_marlin # MAKRPANEL # Needs to use melzi and sanguino hardware - #- cp Marlin/Configuration.h.backup Marlin/Configuration.h - #- sed -i 's/\/\/#define MAKRPANEL/#define MAKRPANEL/g' Marlin/Configuration.h - #- rm -rf .build/ - #- DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + #- restore_configs + #- opt_enable MAKRPANEL + #- build_marlin # REPRAP_DISCOUNT_SMART_CONTROLLER - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define REPRAP_DISCOUNT_SMART_CONTROLLER/#define REPRAP_DISCOUNT_SMART_CONTROLLER/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino - # G3D_PANE - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define G3D_PANEL/#define G3D_PANEL/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT + - build_marlin + # G3D_PANEL + - restore_configs + - opt_enable G3D_PANEL SDSUPPORT + - build_marlin # REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER/#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino - # REPRAPWORLD_KEYPAD + - restore_configs + - opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + - build_marlin + # REPRAPWORLD_KEYPAD # Cant find configuration details to get it to compile - #- cp Marlin/Configuration.h.backup Marlin/Configuration.h - #- sed -i 's/\/\/#define ULTRA_LCD/#define ULTRA_LCD/g' Marlin/Configuration.h - #- sed -i 's/\/\/#define REPRAPWORLD_KEYPAD/#define REPRAPWORLD_KEYPAD/g' Marlin/Configuration.h - #- sed -i 's/\/\/#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0/#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0/g' Marlin/Configuration.h - #- rm -rf .build/ - #- DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + #- restore_configs + #- opt_enable ULTRA_LCD REPRAPWORLD_KEYPAD REPRAPWORLD_KEYPAD_MOVE_STEP + #- build_marlin # RA_CONTROL_PANEL - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define RA_CONTROL_PANEL/#define RA_CONTROL_PANEL/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable RA_CONTROL_PANEL + - build_marlin ### I2C PANELS ### # LCD_I2C_SAINSMART_YWROBOT # Failing at the moment needs different library - #- cp Marlin/Configuration.h.backup Marlin/Configuration.h - #- sed -i 's/\/\/#define LCD_I2C_SAINSMART_YWROBOT/#define LCD_I2C_SAINSMART_YWROBOT/g' Marlin/Configuration.h - #- rm -rf .build/ - #- DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + #- restore_configs + #- opt_enable LCD_I2C_SAINSMART_YWROBOT + #- build_marlin # LCD_I2C_PANELOLU2 - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define LCD_I2C_PANELOLU2/#define LCD_I2C_PANELOLU2/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable LCD_I2C_PANELOLU2 + - build_marlin # LCD_I2C_VIKI - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define LCD_I2C_VIKI/#define LCD_I2C_VIKI/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable LCD_I2C_VIKI + - build_marlin + # LCM1602 + - restore_configs + - opt_enable LCM1602 + - build_marlin + # Enable FILAMENTCHANGEENABLE + - restore_configs + - opt_enable FILAMENTCHANGEENABLE + - build_marlin # Enable filament sensor - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define FILAMENT_SENSOR/#define FILAMENT_SENSOR/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino - # Enable filament sensor with LCD display - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define ULTIMAKERCONTROLLER/#define ULTIMAKERCONTROLLER/g' Marlin/Configuration.h - - sed -i 's/\/\/#define FILAMENT_SENSOR/#define FILAMENT_SENSOR/g' Marlin/Configuration.h - - sed -i 's/\/\/#define FILAMENT_LCD_DISPLAY/#define FILAMENT_LCD_DISPLAY/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable FILAMENT_SENSOR + - build_marlin + # Enable filament sensor with LCD display + - restore_configs + - opt_enable ULTIMAKERCONTROLLER FILAMENT_SENSOR FILAMENT_LCD_DISPLAY + - build_marlin # Enable COREXY - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define COREXY/#define COREXY/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable COREXY + - build_marlin # Enable COREXZ - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define COREXZ/#define COREXZ/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - restore_configs + - opt_enable COREXZ + - build_marlin # Enable Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - sed -i 's/\/\/#define Z_DUAL_STEPPER_DRIVERS/#define Z_DUAL_STEPPER_DRIVERS/g' Marlin/Configuration_adv.h - - sed -i 's/\ \ \/\/\ \#define Z_DUAL_ENDSTOPS/#define Z_DUAL_ENDSTOPS/g' Marlin/Configuration_adv.h - - sed -i 's/#define X_MAX_PIN 2/#define X_MAX_PIN -1/g' Marlin/pins_RAMPS_13.h - - sed -i 's/\ \ \ \ \#define Z2_MAX_PIN 36/#define Z2_MAX_PIN 2/g' Marlin/Configuration_adv.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino - - cp Marlin/Configuration.h.backup Marlin/Configuration.h - - cp Marlin/Configuration_adv.h.backup Marlin/Configuration_adv.h - - cp Marlin/pins_RAMPS_13.h.backup Marlin/pins_RAMPS_13.h + - restore_configs + - opt_enable_adv Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS + - pins_set RAMPS_14 X_MAX_PIN -1 + - opt_set_adv Z2_MAX_PIN 2 + - build_marlin + - restore_configs ######## Example Configurations ############## # Delta Config (generic) - - cp Marlin/example_configurations/delta/generic/Configuration* Marlin/ - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - use_example_configs delta/generic + - build_marlin # Delta Config (generic) + ABL + ALLEN_KEY - - cp Marlin/example_configurations/delta/generic/Configuration* Marlin/ - - sed -i 's/#define DISABLE_MIN_ENDSTOPS/\/\/#define DISABLE_MIN_ENDSTOPS/g' Marlin/Configuration.h - - sed -i 's/\/\/#define AUTO_BED_LEVELING_FEATURE/#define AUTO_BED_LEVELING_FEATURE/g' Marlin/Configuration.h - - sed -i 's/\/\/#define Z_PROBE_ALLEN_KEY/#define Z_PROBE_ALLEN_KEY/g' Marlin/Configuration.h - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - use_example_configs delta/generic + - opt_disable DISABLE_MIN_ENDSTOPS + - opt_enable AUTO_BED_LEVELING_FEATURE Z_PROBE_ALLEN_KEY + - build_marlin # Delta Config (Mini Kossel) - - cp Marlin/example_configurations/delta/kossel_mini/Configuration* Marlin/ - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - use_example_configs delta/kossel_mini + - build_marlin # Makibox Config need to check board type for Teensy++ 2.0 - #- cp Marlin/example_configurations/makibox/Configuration* Marlin/ - #- rm -rf .build/ - #- DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + #- use_example_configs makibox + #- build_marlin # SCARA Config - - cp Marlin/example_configurations/SCARA/Configuration* Marlin/ - - rm -rf .build/ - - DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + - use_example_configs SCARA + - build_marlin # tvrrug Config need to check board type for sanguino atmega644p - #- cp Marlin/example_configurations/tvrrug/Round2/Configuration* Marlin/ - #- rm -rf .build/ - #- DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino + #- use_example_configs tvrrug/Round2 + #- build_marlin ######## Board Types ############# diff --git a/ArduinoAddons/Arduino_1.6.x/hardware/marlin/avr/boards.txt b/ArduinoAddons/Arduino_1.6.x/hardware/marlin/avr/boards.txt index e1e1a7a32..fd3c85af6 100644 --- a/ArduinoAddons/Arduino_1.6.x/hardware/marlin/avr/boards.txt +++ b/ArduinoAddons/Arduino_1.6.x/hardware/marlin/avr/boards.txt @@ -95,7 +95,7 @@ rambo.build.variant=rambo sanguino.name=Sanguino sanguino.upload.tool=arduino:avrdude -sanguino.upload.protocol=stk500 +sanguino.upload.protocol=arduino sanguino.upload.maximum_size=131072 sanguino.upload.speed=57600 diff --git a/LinuxAddons/bin/build_marlin b/LinuxAddons/bin/build_marlin new file mode 100755 index 000000000..3af5aa12e --- /dev/null +++ b/LinuxAddons/bin/build_marlin @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf .build/ +DISPLAY=:1.0 ~/bin/arduino --verify --board marlin:avr:mega Marlin/Marlin.ino diff --git a/LinuxAddons/bin/opt_disable b/LinuxAddons/bin/opt_disable new file mode 100755 index 000000000..36646dbe6 --- /dev/null +++ b/LinuxAddons/bin/opt_disable @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +for opt in "$@" ; do + eval "sed -i 's/\(\/\/ *\)*\(\#define *$opt\)/\/\/\2/g' Marlin/Configuration.h" +done diff --git a/LinuxAddons/bin/opt_enable b/LinuxAddons/bin/opt_enable new file mode 100755 index 000000000..42233f063 --- /dev/null +++ b/LinuxAddons/bin/opt_enable @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +for opt in "$@" ; do + eval "sed -i 's/\/\/ *\(#define *$opt\)/\1/g' Marlin/Configuration.h" +done diff --git a/LinuxAddons/bin/opt_enable_adv b/LinuxAddons/bin/opt_enable_adv new file mode 100755 index 000000000..89dfce121 --- /dev/null +++ b/LinuxAddons/bin/opt_enable_adv @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +for opt in "$@" ; do + eval "sed -i 's/\/\/ *\(#define *$opt\)/\1/g' Marlin/Configuration_adv.h" +done diff --git a/LinuxAddons/bin/opt_set b/LinuxAddons/bin/opt_set new file mode 100755 index 000000000..fda7f379a --- /dev/null +++ b/LinuxAddons/bin/opt_set @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +eval "sed -i 's/\(#define *$1\) *.*$/\1 $2/g' Marlin/Configuration.h" diff --git a/LinuxAddons/bin/opt_set_adv b/LinuxAddons/bin/opt_set_adv new file mode 100755 index 000000000..9ce1e4ca7 --- /dev/null +++ b/LinuxAddons/bin/opt_set_adv @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +eval "sed -i 's/\(#define *$1\) *.*$/\1 $2/g' Marlin/Configuration_adv.h" diff --git a/LinuxAddons/bin/pins_set b/LinuxAddons/bin/pins_set new file mode 100755 index 000000000..4fe401c6a --- /dev/null +++ b/LinuxAddons/bin/pins_set @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +eval "sed -i 's/\(#define *$2\) *.*$/\1 $3/g' Marlin/pins_$1.h" diff --git a/LinuxAddons/bin/restore_configs b/LinuxAddons/bin/restore_configs new file mode 100755 index 000000000..ca77e556a --- /dev/null +++ b/LinuxAddons/bin/restore_configs @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +cp Marlin/Configuration.h.backup Marlin/Configuration.h +cp Marlin/Configuration_adv.h.backup Marlin/Configuration_adv.h +cp Marlin/pins_RAMPS_14.h.backup Marlin/pins_RAMPS_14.h diff --git a/LinuxAddons/bin/use_example_configs b/LinuxAddons/bin/use_example_configs new file mode 100755 index 000000000..d1e6e468f --- /dev/null +++ b/LinuxAddons/bin/use_example_configs @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +eval "cp Marlin/example_configurations/$1/Configuration* Marlin/" diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index 979ddb791..824252ac6 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -45,11 +45,26 @@ #define DOGLCD // Support for I2C LCD 128x64 (Controller SSD1306 graphic Display Family) #endif - #if ENABLED(PANEL_ONE) #define ULTIMAKERCONTROLLER #endif + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + #define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER + + #ifndef ENCODER_PULSES_PER_STEP + #define ENCODER_PULSES_PER_STEP 4 + #endif + + #ifndef ENCODER_STEPS_PER_MENU_ITEM + #define ENCODER_STEPS_PER_MENU_ITEM 1 + #endif + + #ifndef LONG_FILENAME_HOST_SUPPORT + #define LONG_FILENAME_HOST_SUPPORT + #endif + #endif + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define DOGLCD #define U8GLIB_ST7920 @@ -135,28 +150,35 @@ // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #if ENABLED(SAV_3DLCD) - #define SR_LCD_2W_NL // Non latching 2 wire shiftregister + #define SR_LCD_2W_NL // Non latching 2 wire shift register #define ULTIPANEL #define NEWPANEL #endif + #if ENABLED(DOGLCD) // Change number of lines to match the DOG graphic display + #ifndef LCD_WIDTH + #define LCD_WIDTH 22 + #endif + #ifndef LCD_HEIGHT + #define LCD_HEIGHT 5 + #endif + #endif + #if ENABLED(ULTIPANEL) #define NEWPANEL //enable this if you have a click-encoder panel #define ULTRA_LCD - #if ENABLED(DOGLCD) // Change number of lines to match the DOG graphic display - #define LCD_WIDTH 22 - #define LCD_HEIGHT 5 - #else + #ifndef LCD_WIDTH #define LCD_WIDTH 20 + #endif + #ifndef LCD_HEIGHT #define LCD_HEIGHT 4 #endif #else //no panel but just LCD #if ENABLED(ULTRA_LCD) - #if ENABLED(DOGLCD) // Change number of lines to match the 128x64 graphics display - #define LCD_WIDTH 22 - #define LCD_HEIGHT 5 - #else + #ifndef LCD_WIDTH #define LCD_WIDTH 16 + #endif + #ifndef LCD_HEIGHT #define LCD_HEIGHT 2 #endif #endif @@ -242,9 +264,20 @@ /** * Axis lengths */ - #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS) - #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS) - #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS) + #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS)) + #define Y_MAX_LENGTH (Y_MAX_POS - (Y_MIN_POS)) + #define Z_MAX_LENGTH (Z_MAX_POS - (Z_MIN_POS)) + + /** + * CoreXY and CoreXZ + */ + #if ENABLED(COREXY) + #define CORE_AXIS_2 B_AXIS + #define CORE_AXIS_3 Z_AXIS + #elif ENABLED(COREXZ) + #define CORE_AXIS_2 C_AXIS + #define CORE_AXIS_3 Y_AXIS + #endif /** * SCARA @@ -263,8 +296,8 @@ #define Z_HOME_POS MANUAL_Z_HOME_POS #else //!MANUAL_HOME_POSITIONS – Use home switch positions based on homing direction and travel limits #if ENABLED(BED_CENTER_AT_0_0) - #define X_HOME_POS X_MAX_LENGTH * X_HOME_DIR * 0.5 - #define Y_HOME_POS Y_MAX_LENGTH * Y_HOME_DIR * 0.5 + #define X_HOME_POS (X_MAX_LENGTH) * (X_HOME_DIR) * 0.5 + #define Y_HOME_POS (Y_MAX_LENGTH) * (Y_HOME_DIR) * 0.5 #else #define X_HOME_POS (X_HOME_DIR < 0 ? X_MIN_POS : X_MAX_POS) #define Y_HOME_POS (Y_HOME_DIR < 0 ? Y_MIN_POS : Y_MAX_POS) @@ -292,6 +325,13 @@ #define Z_SAFE_HOMING #endif + /** + * Avoid double-negatives for enabling features + */ + #if DISABLED(DISABLE_HOST_KEEPALIVE) + #define HOST_KEEPALIVE_FEATURE + #endif + /** * MAX_STEP_FREQUENCY differs for TOSHIBA */ @@ -312,14 +352,30 @@ * Advance calculated values */ #if ENABLED(ADVANCE) - #define EXTRUSION_AREA (0.25 * D_FILAMENT * D_FILAMENT * M_PI) - #define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS] / EXTRUSION_AREA) + #define EXTRUSION_AREA (0.25 * (D_FILAMENT) * (D_FILAMENT) * M_PI) + #define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS] / (EXTRUSION_AREA)) #endif #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) #undef SD_DETECT_INVERTED #endif + /** + * Set defaults for missing (newer) options + */ + #ifndef DISABLE_INACTIVE_X + #define DISABLE_INACTIVE_X DISABLE_X + #endif + #ifndef DISABLE_INACTIVE_Y + #define DISABLE_INACTIVE_Y DISABLE_Y + #endif + #ifndef DISABLE_INACTIVE_Z + #define DISABLE_INACTIVE_Z DISABLE_Z + #endif + #ifndef DISABLE_INACTIVE_E + #define DISABLE_INACTIVE_E DISABLE_E + #endif + // Power Signal Control Definitions // By default use ATX definition #ifndef POWER_SUPPLY @@ -337,7 +393,10 @@ /** * Temp Sensor defines */ - #if TEMP_SENSOR_0 == -2 + #if TEMP_SENSOR_0 == -3 + #define HEATER_0_USES_MAX6675 + #define MAX6675_IS_MAX31855 + #elif TEMP_SENSOR_0 == -2 #define HEATER_0_USES_MAX6675 #elif TEMP_SENSOR_0 == -1 #define HEATER_0_USES_AD595 @@ -422,7 +481,9 @@ #define HAS_AUTO_FAN_2 (PIN_EXISTS(EXTRUDER_2_AUTO_FAN)) #define HAS_AUTO_FAN_3 (PIN_EXISTS(EXTRUDER_3_AUTO_FAN)) #define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3) - #define HAS_FAN (PIN_EXISTS(FAN)) + #define HAS_FAN0 (PIN_EXISTS(FAN)) + #define HAS_FAN1 (PIN_EXISTS(FAN1) && CONTROLLERFAN_PIN != FAN1_PIN && EXTRUDER_0_AUTO_FAN_PIN != FAN1_PIN && EXTRUDER_1_AUTO_FAN_PIN != FAN1_PIN && EXTRUDER_2_AUTO_FAN_PIN != FAN1_PIN) + #define HAS_FAN2 (PIN_EXISTS(FAN2) && CONTROLLERFAN_PIN != FAN2_PIN && EXTRUDER_0_AUTO_FAN_PIN != FAN2_PIN && EXTRUDER_1_AUTO_FAN_PIN != FAN2_PIN && EXTRUDER_2_AUTO_FAN_PIN != FAN2_PIN) #define HAS_CONTROLLERFAN (PIN_EXISTS(CONTROLLERFAN)) #define HAS_SERVOS (defined(NUM_SERVOS) && NUM_SERVOS > 0) #define HAS_SERVO_0 (PIN_EXISTS(SERVO0)) @@ -462,6 +523,7 @@ #define HAS_E1_ENABLE (PIN_EXISTS(E1_ENABLE)) #define HAS_E2_ENABLE (PIN_EXISTS(E2_ENABLE)) #define HAS_E3_ENABLE (PIN_EXISTS(E3_ENABLE)) + #define HAS_E4_ENABLE (PIN_EXISTS(E4_ENABLE)) #define HAS_X_DIR (PIN_EXISTS(X_DIR)) #define HAS_X2_DIR (PIN_EXISTS(X2_DIR)) #define HAS_Y_DIR (PIN_EXISTS(Y_DIR)) @@ -472,6 +534,7 @@ #define HAS_E1_DIR (PIN_EXISTS(E1_DIR)) #define HAS_E2_DIR (PIN_EXISTS(E2_DIR)) #define HAS_E3_DIR (PIN_EXISTS(E3_DIR)) + #define HAS_E4_DIR (PIN_EXISTS(E4_DIR)) #define HAS_X_STEP (PIN_EXISTS(X_STEP)) #define HAS_X2_STEP (PIN_EXISTS(X2_STEP)) #define HAS_Y_STEP (PIN_EXISTS(Y_STEP)) @@ -482,6 +545,7 @@ #define HAS_E1_STEP (PIN_EXISTS(E1_STEP)) #define HAS_E2_STEP (PIN_EXISTS(E2_STEP)) #define HAS_E3_STEP (PIN_EXISTS(E3_STEP)) + #define HAS_E4_STEP (PIN_EXISTS(E4_STEP)) /** * Helper Macros for heaters and extruder fan @@ -504,10 +568,32 @@ #if HAS_HEATER_BED #define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN, v) #endif - #if HAS_FAN - #define WRITE_FAN(v) WRITE(FAN_PIN, v) + + /** + * Up to 3 PWM fans + */ + #if HAS_FAN2 + #define FAN_COUNT 3 + #elif HAS_FAN1 + #define FAN_COUNT 2 + #elif HAS_FAN0 + #define FAN_COUNT 1 + #else + #define FAN_COUNT 0 #endif + #if HAS_FAN0 + #define WRITE_FAN(v) WRITE(FAN_PIN, v) + #define WRITE_FAN0(v) WRITE_FAN(v) + #endif + #if HAS_FAN1 + #define WRITE_FAN1(v) WRITE(FAN1_PIN, v) + #endif + #if HAS_FAN2 + #define WRITE_FAN2(v) WRITE(FAN2_PIN, v) + #endif + #define WRITE_FAN_N(n, v) WRITE_FAN##n(v) + #define HAS_BUZZER (PIN_EXISTS(BEEPER) || defined(LCD_USE_I2C_BUZZER)) #if defined(NUM_SERVOS) && NUM_SERVOS > 0 @@ -526,5 +612,10 @@ #endif #endif + #if ( (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) || HAS_Z_PROBE ) && \ + ( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) ) + #define HAS_Z_MIN_PROBE + #endif + #endif //CONFIGURATION_LCD #endif //CONDITIONALS_H diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c4fa028ce..fff1dd567 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -70,7 +70,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_RAMPS_13_EFB + #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif // Optional custom name for your RepStrap or other custom machine @@ -110,6 +110,7 @@ Here are some standard links for getting your machine calibrated: //--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table // //// Temperature sensor settings: +// -3 is thermocouple with MAX31855 (only for sensor 0) // -2 is thermocouple with MAX6675 (only for sensor 0) // -1 is thermocouple with AD595 // 0 is not used @@ -129,6 +130,7 @@ Here are some standard links for getting your machine calibrated: // 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 +// 70 is the 100K thermistor found in the bq Hephestos 2 // // 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k // (but gives greater accuracy and more stable PID) @@ -144,7 +146,7 @@ Here are some standard links for getting your machine calibrated: // Use it for Testing or Development purposes. NEVER for production machine. //#define DUMMY_THERMISTOR_998_VALUE 25 //#define DUMMY_THERMISTOR_999_VALUE 100 -// :{ '0': "Not used", '4': "10k !! do not use for a hotend. Bad resolution at high temp. !!", '1': "100k / 4.7k - EPCOS", '51': "100k / 1k - EPCOS", '6': "100k / 4.7k EPCOS - Not as accurate as Table 1", '5': "100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '7': "100k / 4.7k Honeywell 135-104LAG-J01", '71': "100k / 4.7k Honeywell 135-104LAF-J01", '8': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9': "100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10': "100k / 4.7k RS 198-961", '11': "100k / 4.7k beta 3950 1%", '12': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13': "100k Hisens 3950 1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '60': "100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '55': "100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '2': "200k / 4.7k - ATC Semitec 204GT-2", '52': "200k / 1k - ATC Semitec 204GT-2", '-2': "Thermocouple + MAX6675 (only for sensor 0)", '-1': "Thermocouple + AD595", '3': "Mendel-parts / 4.7k", '1047': "Pt1000 / 4.7k", '1010': "Pt1000 / 1k (non standard)", '20': "PT100 (Ultimainboard V2.x)", '147': "Pt100 / 4.7k", '110': "Pt100 / 1k (non-standard)", '998': "Dummy 1", '999': "Dummy 2" } +// :{ '0': "Not used", '4': "10k !! do not use for a hotend. Bad resolution at high temp. !!", '1': "100k / 4.7k - EPCOS", '51': "100k / 1k - EPCOS", '6': "100k / 4.7k EPCOS - Not as accurate as Table 1", '5': "100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '7': "100k / 4.7k Honeywell 135-104LAG-J01", '71': "100k / 4.7k Honeywell 135-104LAF-J01", '8': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9': "100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10': "100k / 4.7k RS 198-961", '11': "100k / 4.7k beta 3950 1%", '12': "100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13': "100k Hisens 3950 1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '60': "100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '55': "100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '2': "200k / 4.7k - ATC Semitec 204GT-2", '52': "200k / 1k - ATC Semitec 204GT-2", '-3': "Thermocouple + MAX31855 (only for sensor 0)", '-2': "Thermocouple + MAX6675 (only for sensor 0)", '-1': "Thermocouple + AD595", '3': "Mendel-parts / 4.7k", '1047': "Pt1000 / 4.7k", '1010': "Pt1000 / 1k (non standard)", '20': "PT100 (Ultimainboard V2.x)", '147': "Pt100 / 4.7k", '110': "Pt100 / 1k (non-standard)", '998': "Dummy 1", '999': "Dummy 2" } #define TEMP_SENSOR_0 1 #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 @@ -178,14 +180,9 @@ Here are some standard links for getting your machine calibrated: #define HEATER_3_MAXTEMP 275 #define BED_MAXTEMP 150 -// If your bed has low resistance e.g. .6 ohm and throws the fuse you can duty cycle it to reduce the -// average current. The value should be an integer and the heat bed will be turned on for 1 interval of -// HEATER_BED_DUTY_CYCLE_DIVIDER intervals. -//#define HEATER_BED_DUTY_CYCLE_DIVIDER 4 - // If you want the M105 heater power reported in watts, define the BED_WATTS, and (shared for all extruders) EXTRUDER_WATTS -//#define EXTRUDER_WATTS (12.0*12.0/6.7) // P=I^2/R -//#define BED_WATTS (12.0*12.0/1.1) // P=I^2/R +//#define EXTRUDER_WATTS (12.0*12.0/6.7) // P=U^2/R +//#define BED_WATTS (12.0*12.0/1.1) // P=U^2/R //=========================================================================== //============================= PID Settings ================================ @@ -253,13 +250,13 @@ Here are some standard links for getting your machine calibrated: #define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER //limit for the integral term - //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) + //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) #define DEFAULT_bedKp 10.00 #define DEFAULT_bedKi .023 #define DEFAULT_bedKd 305.4 - //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) + //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from pidautotune //#define DEFAULT_bedKp 97.1 //#define DEFAULT_bedKi 1.41 @@ -284,16 +281,15 @@ Here are some standard links for getting your machine calibrated: //=========================================================================== /** - * Thermal Runaway Protection protects your printer from damage and fire if a + * Thermal Protection protects your printer from damage and fire if a * thermistor falls out or temperature sensors fail in any way. * * The issue: If a thermistor falls out or a temperature sensor fails, * Marlin can no longer sense the actual temperature. Since a disconnected * thermistor reads as a low temperature, the firmware will keep the heater on. * - * The solution: Once the temperature reaches the target, start observing. - * If the temperature stays too far below the target (hysteresis) for too long, - * the firmware will halt as a safety precaution. + * If you get "Thermal Runaway" or "Heating failed" errors the + * details can be tuned in Configuration_adv.h */ #define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders @@ -341,10 +337,52 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define DISABLE_MAX_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS -// 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_MIN_PROBE_ENDSTOP below. If you are using the Z Min endstop on your Z probe, -// this has no effect. +//=========================================================================== +//============================= Z Probe Options ============================= +//=========================================================================== + +// Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine. +// With this option the Z_MIN_PROBE_PIN will only be used for probing, never for homing. +// +// *** PLEASE READ ALL INSTRUCTIONS BELOW FOR SAFETY! *** +// +// To continue using the Z-min-endstop for homing, be sure to disable Z_SAFE_HOMING. +// Example: To park the head outside the bed area when homing with G28. +// +// To use a separate Z probe, your board must define a Z_MIN_PROBE_PIN. +// +// For a servo-based Z probe, you must set up servo support below, including +// NUM_SERVOS, Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOP_ANGLES. +// +// - RAMPS 1.3/1.4 boards may be able to use the 5V, GND, and Aux4->D32 pin. +// - Use 5V for powered (usu. inductive) sensors. +// - Otherwise connect: +// - normally-closed switches to GND and D32. +// - normally-open switches to 5V and D32. +// +// Normally-closed switches are advised and are the default. +// +// The Z_MIN_PROBE_PIN sets the Arduino pin to use. (See your board's pins file.) +// Since the RAMPS Aux4->D32 pin maps directly to the Arduino D32 pin, D32 is the +// default pin for all RAMPS-based boards. Some other boards map differently. +// To set or change the pin for your board, edit the appropriate pins_XXXXX.h file. +// +// WARNING: +// Setting the wrong pin may have unexpected and potentially disastrous consequences. +// Use with caution and do your homework. +// +//#define Z_MIN_PROBE_ENDSTOP + +// Enable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN to use the Z_MIN_PIN for your Z_MIN_PROBE. +// The Z_MIN_PIN will then be used for both Z-homing and probing. +#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN + +// To use a probe you must enable one of the two options above! + +// This option disables the use of the Z_MIN_PROBE_PIN +// To enable the Z probe pin but disable its use, uncomment the line below. This only affects a +// Z probe switch if you have a separate Z min endstop also and have activated Z_MIN_PROBE_ENDSTOP above. +// If you're using the Z MIN endstop connector for your Z probe, this has no effect. //#define DISABLE_Z_MIN_PROBE_ENDSTOP // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 @@ -354,11 +392,13 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define Z_ENABLE_ON 0 #define E_ENABLE_ON 0 // For all extruders -// Disables axis when it's not being used. +// Disables axis stepper immediately 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 +// Warn on display about possibly reduced accuracy +//#define DISABLE_REDUCED_ACCURACY_WARNING // @section extruder @@ -381,6 +421,8 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define INVERT_E3_DIR false // @section homing +//#define MIN_Z_HEIGHT_FOR_HOMING 4 // (in mm) Minimal z height before homing (G28) for Z clearance above the bed, clamps, ... + // Be sure you have this distance over your Z_MAX_POS in case. // ENDSTOP SETTINGS: // Sets direction of endstops when homing; 1=MAX, -1=MIN @@ -416,24 +458,26 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #endif //=========================================================================== -//=========================== 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. -#if ENABLED(MANUAL_BED_LEVELING) - #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. -#endif // MANUAL_BED_LEVELING - #if ENABLED(MESH_BED_LEVELING) #define MESH_MIN_X 10 - #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X) + #define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X)) #define MESH_MIN_Y 10 - #define MESH_MAX_Y (Y_MAX_POS - MESH_MIN_Y) + #define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y)) #define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited. #define MESH_NUM_Y_POINTS 3 #define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0. + + //#define MANUAL_BED_LEVELING // Add display menu option for bed leveling. + + #if ENABLED(MANUAL_BED_LEVELING) + #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. + #endif // MANUAL_BED_LEVELING + #endif // MESH_BED_LEVELING //=========================================================================== @@ -444,7 +488,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line) //#define DEBUG_LEVELING_FEATURE -#define Z_MIN_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled. +#define Z_MIN_PROBE_REPEATABILITY_TEST // If not commented out, Z Probe Repeatability test will be included if Auto Bed Leveling is Enabled. #if ENABLED(AUTO_BED_LEVELING_FEATURE) @@ -456,7 +500,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // This mode is preferred because there are more measurements. // // - "3-point" mode - // Probe 3 arbitrary points on the bed (that aren't colinear) + // Probe 3 arbitrary points on the bed (that aren't collinear) // You specify the XY coordinates of all 3 points. // Enable this to sample the bed in a grid (least squares solution). @@ -478,25 +522,37 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #else // !AUTO_BED_LEVELING_GRID - // Arbitrary points to probe. - // A simple cross-product is used to estimate the plane of the bed. - #define ABL_PROBE_PT_1_X 15 - #define ABL_PROBE_PT_1_Y 180 - #define ABL_PROBE_PT_2_X 15 - #define ABL_PROBE_PT_2_Y 20 - #define ABL_PROBE_PT_3_X 170 - #define ABL_PROBE_PT_3_Y 20 + // Arbitrary points to probe. + // A simple cross-product is used to estimate the plane of the bed. + #define ABL_PROBE_PT_1_X 15 + #define ABL_PROBE_PT_1_Y 180 + #define ABL_PROBE_PT_2_X 15 + #define ABL_PROBE_PT_2_Y 20 + #define ABL_PROBE_PT_3_X 170 + #define ABL_PROBE_PT_3_Y 20 #endif // AUTO_BED_LEVELING_GRID - // Offsets to the Z probe relative to the nozzle tip. + // Z Probe to nozzle (X,Y) offset, relative to (0, 0). // X and Y offsets must be integers. - #define X_PROBE_OFFSET_FROM_EXTRUDER -25 // Z probe to nozzle X offset: -left +right - #define Y_PROBE_OFFSET_FROM_EXTRUDER -29 // Z probe to nozzle Y offset: -front +behind - #define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35 // Z probe to nozzle Z offset: -below (always!) - - #define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z axis before homing (G28) for Z probe clearance. - // Be sure you have this distance over your Z_MAX_POS in case. + // + // In the following example the X and Y offsets are both positive: + // #define X_PROBE_OFFSET_FROM_EXTRUDER 10 + // #define Y_PROBE_OFFSET_FROM_EXTRUDER 10 + // + // +-- BACK ---+ + // | | + // L | (+) P | R <-- probe (20,20) + // E | | I + // F | (-) N (+) | G <-- nozzle (10,10) + // T | | H + // | (-) | T + // | | + // O-- FRONT --+ + // (0,0) + #define X_PROBE_OFFSET_FROM_EXTRUDER 10 // X offset: -left [of the nozzle] +right + #define Y_PROBE_OFFSET_FROM_EXTRUDER 10 // Y offset: -front [of the nozzle] +behind + #define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below [the nozzle] (always negative!) #define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min. @@ -504,17 +560,29 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define Z_RAISE_BETWEEN_PROBINGS 5 // How much the Z axis will be raised when traveling from between next probing points. #define Z_RAISE_AFTER_PROBING 15 // How much the Z axis will be raised after the last probing point. -//#define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" // These commands will be executed in the end of G29 routine. - // Useful to retract a deployable Z probe. + //#define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" // These commands will be executed in the end of G29 routine. + // Useful to retract a deployable Z probe. - //#define Z_PROBE_SLED // Turn on if you have a Z probe mounted on a sled like those designed by Charles Bell. + // Probes are sensors/switches that need to be activated before they can be used + // and deactivated after the use. + // Allen Key Probes, Servo Probes, Z-Sled Probes, FIX_MOUNTED_PROBE, ... . You have to activate one of these for the AUTO_BED_LEVELING_FEATURE + + // A fix mounted probe, like the normal inductive probe, must be deactivated to go below Z_PROBE_OFFSET_FROM_EXTRUDER + // when the hardware endstops are active. + //#define FIX_MOUNTED_PROBE + + // A Servo Probe can be defined in the servo section below. + + // An Allen Key Probe is currently predefined only in the delta example configurations. + + //#define Z_PROBE_SLED // Enable if you have a Z probe mounted on a sled like those designed by Charles Bell. //#define SLED_DOCKING_OFFSET 5 // The extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like. + // If you've enabled AUTO_BED_LEVELING_FEATURE and are using the Z Probe for Z Homing, + // it is highly recommended you leave Z_SAFE_HOMING enabled! - //If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing, - //it is highly recommended you let this Z_SAFE_HOMING enabled!!! - - #define Z_SAFE_HOMING // This feature is meant to avoid Z homing with Z probe outside the bed area. + #define Z_SAFE_HOMING // Use the z-min-probe for homing to z-min - not the z-min-endstop. + // This feature is meant to avoid Z homing with Z probe outside the bed area. // When defined, it will: // - Allow Z homing only after X and Y homing AND stepper drivers still enabled. // - If stepper drivers timeout, it will need X and Y homing again before Z homing. @@ -528,37 +596,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #endif - // Support for a dedicated Z probe endstop separate from the Z min endstop. - // If you would like to use both a Z probe and a Z min endstop together, - // uncomment #define Z_MIN_PROBE_ENDSTOP and read the instructions below. - // If you still want to use the Z min endstop for homing, disable Z_SAFE_HOMING above. - // Example: To park the head outside the bed area when homing with G28. - // - // WARNING: - // The Z min endstop will need to set properly as it would without a Z probe - // to prevent head crashes and premature stopping during a print. - // - // To use a separate Z probe endstop, you must have a Z_MIN_PROBE_PIN - // defined in the pins_XXXXX.h file for your control board. - // If you are using a servo based Z probe, you will need to enable NUM_SERVOS, - // Z_ENDSTOP_SERVO_NR and SERVO_ENDSTOP_ANGLES in the R/C SERVO support below. - // RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin - // in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, - // otherwise connect to ground and D32 for normally closed configuration - // and 5V and D32 for normally open configurations. - // Normally closed configuration is advised and assumed. - // The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. - // Z_MIN_PROBE_PIN is setting the pin to use on the Arduino. - // Since the D32 pin on the RAMPS maps to D32 on Arduino, this works. - // D32 is currently selected in the RAMPS 1.3/1.4 pin file. - // All other boards will need changes to the respective pins_XXXXX.h file. - // - // WARNING: - // Setting the wrong pin may have unexpected and potentially disastrous outcomes. - // Use with caution and do your homework. - // - //#define Z_MIN_PROBE_ENDSTOP - #endif // AUTO_BED_LEVELING_FEATURE @@ -632,6 +669,14 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define EEPROM_CHITCHAT // Please keep turned on if you can. #endif +// +// Host Keepalive +// +// By default Marlin will send a busy status message to the host +// every 2 seconds when it can't accept commands. +// +//#define DISABLE_HOST_KEEPALIVE // Enable this option if your host doesn't like keepalive messages. + // // M100 Free Memory Watcher // @@ -652,13 +697,13 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // @section lcd // Define your display language below. Replace (en) with your language code and uncomment. -// en, pl, fr, de, es, ru, bg, it, pt, pt-br, fi, an, nl, ca, eu, kana, kana_utf8, cn, test +// en, pl, fr, de, es, ru, bg, it, pt, pt_utf8, pt-br, pt-br_utf8, fi, an, nl, ca, eu, kana, kana_utf8, cn, cz, test // See also language.h #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 +// See also https://github.com/MarlinFirmware/Marlin/wiki/LCD-Language #define DISPLAY_CHARSET_HD44780_JAPAN // this is the most common hardware //#define DISPLAY_CHARSET_HD44780_WESTERN //#define DISPLAY_CHARSET_HD44780_CYRILLIC @@ -666,12 +711,12 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define ULTRA_LCD //general LCD support, also 16x2 //#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family) //#define SDSUPPORT // Enable SD Card Support in Hardware Console -// Changed behaviour! If you need SDSUPPORT uncomment it! -//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error) -//#define SDEXTRASLOW // Use even slower SD transfer mode (not normally needed - uncomment if you're getting volume init error) + // Changed behaviour! If you need SDSUPPORT uncomment it! +//#define SPI_SPEED SPI_HALF_SPEED // (also SPI_QUARTER_SPEED, SPI_EIGHTH_SPEED) Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error) //#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 REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. @@ -688,13 +733,13 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD // http://panucatt.com -// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino //#define VIKI2 //#define miniVIKI // This is a new controller currently under development. https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/ // -// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino //#define ELB_FULL_GRAPHIC_CONTROLLER //#define SD_DETECT_INVERTED @@ -709,7 +754,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB) // http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller // -// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino //#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER // The RepRapWorld REPRAPWORLD_KEYPAD v1.1 @@ -732,6 +777,8 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define LCD_I2C_SAINSMART_YWROBOT +//#define LCM1602 // LCM1602 Adapter for 16x2 LCD + // PANELOLU2 LCD with status LEDs, separate encoder and click inputs // // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 ) @@ -743,9 +790,9 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs //#define LCD_I2C_VIKI - + // SSD1306 OLED generic display support -// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib +// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino //#define U8GLIB_SSD1306 // Shift register panels @@ -757,7 +804,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // @section extras -// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino +// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino //#define FAST_PWM_FAN // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency @@ -839,19 +886,21 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // 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 DEFAULT_NOMINAL_FILAMENT_DIA 3.00 //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) -//defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#if ENABLED(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 -//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 + #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_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 +#endif #include "Configuration_adv.h" #include "thermistortables.h" diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 51141fc3c..5328a7417 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -17,6 +17,20 @@ /** * Thermal Protection parameters */ + /** + * Thermal Protection protects your printer from damage and fire if a + * thermistor falls out or temperature sensors fail in any way. + * + * The issue: If a thermistor falls out or a temperature sensor fails, + * Marlin can no longer sense the actual temperature. Since a disconnected + * thermistor reads as a low temperature, the firmware will keep the heater on. + * + * The solution: Once the temperature reaches the target, start observing. + * If the temperature stays too far below the target (hysteresis) for too long (period), + * the firmware will halt the machine as a safety precaution. + * + * If you get false positives for "Thermal Runaway" increase THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD + */ #if ENABLED(THERMAL_PROTECTION_HOTENDS) #define THERMAL_PROTECTION_PERIOD 40 // Seconds #define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius @@ -26,11 +40,19 @@ * WATCH_TEMP_PERIOD to expire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, * but only if the current temperature is far enough below the target for a reliable test. + * + * If you get false positives for "Heating failed" increase WATCH_TEMP_PERIOD and/or decrease WATCH_TEMP_INCREASE + * WATCH_TEMP_INCREASE should not be below 2. */ #define WATCH_TEMP_PERIOD 16 // Seconds #define WATCH_TEMP_INCREASE 4 // Degrees Celsius #endif + /** + * Thermal Protection parameters for the bed + * are like the above for the hotends. + * WATCH_TEMP_BED_PERIOD and WATCH_TEMP_BED_INCREASE are not imlemented now. + */ #if ENABLED(THERMAL_PROTECTION_BED) #define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius @@ -52,7 +74,7 @@ * The maximum buffered steps/sec of the extruder motor is called "se". * Start autotemp mode with M109 S B F * The target temperature is set to mintemp+factor*se[steps/sec] and is limited by - * mintemp and maxtemp. Turn this off by excuting M109 without F* + * mintemp and maxtemp. Turn this off by executing M109 without F* * Also, if the temperature is set to a value below mintemp, it will not be changed by autotemp. * On an Ultimaker, some initial testing worked with M109 S215 B260 F1 in the start.gcode */ @@ -137,7 +159,7 @@ #if ENABLED(Z_DUAL_STEPPER_DRIVERS) // Z_DUAL_ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper. - // That way the machine is capable to align the bed during home, since both Z steppers are homed. + // That way the machine is capable to align the bed during home, since both Z steppers are homed. // There is also an implementation of M666 (software endstops adjustment) to this feature. // After Z homing, this adjustment is applied to just one of the steppers in order to align the bed. // One just need to home the Z axis and measure the distance difference between both Z axis and apply the math: Z adjust = Z - Z2. @@ -232,7 +254,13 @@ #define INVERT_E_STEP_PIN false // Default stepper release if idle. Set to 0 to deactivate. -#define DEFAULT_STEPPER_DEACTIVE_TIME 60 +// Steppers will shut down DEFAULT_STEPPER_DEACTIVE_TIME seconds after the last move when DISABLE_INACTIVE_? is true. +// Time can be set by M18 and M84. +#define DEFAULT_STEPPER_DEACTIVE_TIME 120 +#define DISABLE_INACTIVE_X true +#define DISABLE_INACTIVE_Y true +#define DISABLE_INACTIVE_Z true // set to false if the nozzle will fall down on your printed part when print has finished. +#define DISABLE_INACTIVE_E true #define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate #define DEFAULT_MINTRAVELFEEDRATE 0.0 @@ -268,6 +296,9 @@ // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) #define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) +// Motor Current controlled via PWM (Overridable on supported boards with PWM-driven motor driver current) +//#define PWM_MOTOR_CURRENT {1300, 1300, 1250} // Values in milliamps + // uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro //#define DIGIPOT_I2C // Number of channels available for I2C digipot, For Azteeg X3 Pro we have 8 @@ -335,8 +366,8 @@ // save 3120 bytes of PROGMEM by commenting out #define USE_BIG_EDIT_FONT // we don't have a big font for Cyrillic, Kana //#define USE_BIG_EDIT_FONT - - // If you have spare 2300Byte of progmem and want to use a + + // If you have spare 2300Byte of progmem and want to use a // smaller font on the Info-screen uncomment the next line. //#define USE_SMALL_INFOFONT #endif // DOGLCD @@ -344,13 +375,13 @@ // @section more // The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation. -//#define USE_WATCHDOG +#define USE_WATCHDOG #if ENABLED(USE_WATCHDOG) -// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on. -// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset. -// However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled. -//#define WATCHDOG_RESET_MANUAL + // If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on. + // The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset. + // However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled. + //#define WATCHDOG_RESET_MANUAL #endif // @section lcd @@ -361,7 +392,7 @@ //#define BABYSTEPPING #if ENABLED(BABYSTEPPING) #define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions - //not implemented for CoreXY and deltabots! + //not implemented for deltabots! #define BABYSTEP_INVERT_Z false //true for inverse movements in Z #define BABYSTEP_MULTIPLICATOR 1 //faster movements #endif @@ -380,7 +411,6 @@ #if ENABLED(ADVANCE) #define EXTRUDER_ADVANCE_K .0 #define D_FILAMENT 2.85 - #define STEPS_MM_E 836 #endif // @section extras @@ -389,7 +419,7 @@ #define MM_PER_ARC_SEGMENT 1 #define N_ARC_CORRECTION 25 -const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement +const unsigned int dropsegments = 5; //everything with less than this number of steps will be ignored as move and joined with the next movement // @section temperature @@ -461,8 +491,8 @@ const unsigned int dropsegments=5; //everything with less than this number of st #endif /******************************************************************************\ - * enable this section if you have TMC26X motor drivers. - * you need to import the TMC26XStepper library into the arduino IDE for this + * enable this section if you have TMC26X motor drivers. + * you need to import the TMC26XStepper library into the Arduino IDE for this ******************************************************************************/ // @section tmc @@ -470,61 +500,61 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HAVE_TMCDRIVER #if ENABLED(HAVE_TMCDRIVER) -//#define X_IS_TMC + //#define X_IS_TMC #define X_MAX_CURRENT 1000 //in mA #define X_SENSE_RESISTOR 91 //in mOhms #define X_MICROSTEPS 16 //number of microsteps - -//#define X2_IS_TMC + + //#define X2_IS_TMC #define X2_MAX_CURRENT 1000 //in mA #define X2_SENSE_RESISTOR 91 //in mOhms #define X2_MICROSTEPS 16 //number of microsteps - -//#define Y_IS_TMC + + //#define Y_IS_TMC #define Y_MAX_CURRENT 1000 //in mA #define Y_SENSE_RESISTOR 91 //in mOhms #define Y_MICROSTEPS 16 //number of microsteps - -//#define Y2_IS_TMC + + //#define Y2_IS_TMC #define Y2_MAX_CURRENT 1000 //in mA #define Y2_SENSE_RESISTOR 91 //in mOhms - #define Y2_MICROSTEPS 16 //number of microsteps - -//#define Z_IS_TMC + #define Y2_MICROSTEPS 16 //number of microsteps + + //#define Z_IS_TMC #define Z_MAX_CURRENT 1000 //in mA #define Z_SENSE_RESISTOR 91 //in mOhms #define Z_MICROSTEPS 16 //number of microsteps - -//#define Z2_IS_TMC + + //#define Z2_IS_TMC #define Z2_MAX_CURRENT 1000 //in mA #define Z2_SENSE_RESISTOR 91 //in mOhms #define Z2_MICROSTEPS 16 //number of microsteps - -//#define E0_IS_TMC + + //#define E0_IS_TMC #define E0_MAX_CURRENT 1000 //in mA #define E0_SENSE_RESISTOR 91 //in mOhms #define E0_MICROSTEPS 16 //number of microsteps - -//#define E1_IS_TMC + + //#define E1_IS_TMC #define E1_MAX_CURRENT 1000 //in mA #define E1_SENSE_RESISTOR 91 //in mOhms - #define E1_MICROSTEPS 16 //number of microsteps - -//#define E2_IS_TMC + #define E1_MICROSTEPS 16 //number of microsteps + + //#define E2_IS_TMC #define E2_MAX_CURRENT 1000 //in mA #define E2_SENSE_RESISTOR 91 //in mOhms - #define E2_MICROSTEPS 16 //number of microsteps - -//#define E3_IS_TMC + #define E2_MICROSTEPS 16 //number of microsteps + + //#define E3_IS_TMC #define E3_MAX_CURRENT 1000 //in mA #define E3_SENSE_RESISTOR 91 //in mOhms - #define E3_MICROSTEPS 16 //number of microsteps + #define E3_MICROSTEPS 16 //number of microsteps #endif /******************************************************************************\ - * enable this section if you have L6470 motor drivers. - * you need to import the L6470 library into the arduino IDE for this + * enable this section if you have L6470 motor drivers. + * you need to import the L6470 library into the Arduino IDE for this ******************************************************************************/ // @section l6470 @@ -532,69 +562,66 @@ const unsigned int dropsegments=5; //everything with less than this number of st //#define HAVE_L6470DRIVER #if ENABLED(HAVE_L6470DRIVER) -//#define X_IS_L6470 + //#define X_IS_L6470 #define X_MICROSTEPS 16 //number of microsteps - #define X_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define X_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define X_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define X_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define X2_IS_L6470 + + //#define X2_IS_L6470 #define X2_MICROSTEPS 16 //number of microsteps - #define X2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define X2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define X2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define X2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define Y_IS_L6470 + + //#define Y_IS_L6470 #define Y_MICROSTEPS 16 //number of microsteps - #define Y_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Y_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define Y_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define Y_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define Y2_IS_L6470 - #define Y2_MICROSTEPS 16 //number of microsteps - #define Y2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + + //#define Y2_IS_L6470 + #define Y2_MICROSTEPS 16 //number of microsteps + #define Y2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define Y2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off - #define Y2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define Z_IS_L6470 + #define Y2_STALLCURRENT 1500 //current in mA where the driver will detect a stall + + //#define Z_IS_L6470 #define Z_MICROSTEPS 16 //number of microsteps - #define Z_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Z_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define Z_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define Z_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define Z2_IS_L6470 + + //#define Z2_IS_L6470 #define Z2_MICROSTEPS 16 //number of microsteps - #define Z2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Z2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define Z2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define Z2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define E0_IS_L6470 + + //#define E0_IS_L6470 #define E0_MICROSTEPS 16 //number of microsteps - #define E0_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E0_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define E0_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E0_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define E1_IS_L6470 - #define E1_MICROSTEPS 16 //number of microsteps + + //#define E1_IS_L6470 #define E1_MICROSTEPS 16 //number of microsteps - #define E1_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E1_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define E1_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E1_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define E2_IS_L6470 - #define E2_MICROSTEPS 16 //number of microsteps + + //#define E2_IS_L6470 #define E2_MICROSTEPS 16 //number of microsteps - #define E2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define E2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - -//#define E3_IS_L6470 - #define E3_MICROSTEPS 16 //number of microsteps + + //#define E3_IS_L6470 #define E3_MICROSTEPS 16 //number of microsteps - #define E3_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E3_K_VAL 50 // 0 - 255, Higher values, are higher power. Be careful not to go too high #define E3_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E3_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + #endif #include "Conditionals.h" diff --git a/Marlin/Default_Version.h b/Marlin/Default_Version.h index ea5727fba..b27b997e6 100644 --- a/Marlin/Default_Version.h +++ b/Marlin/Default_Version.h @@ -6,9 +6,9 @@ // #error "You must specify the following parameters related to your distribution" #if true -#define SHORT_BUILD_VERSION "1.1.0-RC3" -#define DETAILED_BUILD_VERSION "1.1.0-RC3 From Archive" -#define STRING_DISTRIBUTION_DATE "2015-12-01 12:00" +#define SHORT_BUILD_VERSION "1.1.0-RC4" +#define DETAILED_BUILD_VERSION "1.1.0-RC4 From Archive" +#define STRING_DISTRIBUTION_DATE "2016-03-07 12:00" // It might also be appropriate to define a location where additional information can be found -#define SOURCE_CODE_URL "http:// ..." +// #define SOURCE_CODE_URL "http:// ..." #endif \ No newline at end of file diff --git a/Marlin/Makefile b/Marlin/Makefile index 68b0de0ba..27cc5a7c5 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -12,14 +12,14 @@ # # Detailed instructions for using the makefile: # -# 1. Modify the line containg "ARDUINO_INSTALL_DIR" to point to the directory that +# 1. Modify the line containing "ARDUINO_INSTALL_DIR" to point to the directory that # contains the Arduino installation (for example, under Mac OS X, this # might be /Applications/Arduino.app/Contents/Resources/Java). # # 2. Modify the line containing "UPLOAD_PORT" to refer to the filename # representing the USB or serial connection to your Arduino board # (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file -# changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*). +# changes, you can use * as a wild card (e.g. UPLOAD_PORT = /dev/tty.usb*). # # 3. Set the line containing "MCU" to match your board's processor. # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth @@ -163,6 +163,9 @@ MCU ?= at90usb1286 else ifeq ($(HARDWARE_MOTHERBOARD),81) HARDWARE_VARIANT ?= Teensy MCU ?= at90usb1286 +else ifeq ($(HARDWARE_MOTHERBOARD),811) +HARDWARE_VARIANT ?= Teensy +MCU ?= at90usb1286 else ifeq ($(HARDWARE_MOTHERBOARD),82) HARDWARE_VARIANT ?= Teensy MCU ?= at90usb646 @@ -218,7 +221,7 @@ endif # Set to 16Mhz if not yet set. F_CPU ?= 16000000 -# Arduino containd the main source code for the Arduino +# Arduino contained the main source code for the Arduino # Libraries, the "hardware variant" are for boards # that derives from that, and their source are present in # the main Marlin source directory @@ -287,7 +290,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \ SdFile.cpp SdVolume.cpp planner.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 buzzer.cpp + dac_mcp4728.cpp vector_3.cpp qr_solve.cpp buzzer.cpp ifeq ($(LIQUID_TWI2), 0) CXXSRC += LiquidCrystal.cpp else @@ -300,7 +303,7 @@ SRC += twi.c CXXSRC += Wire.cpp endif -#Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version +#Check for Arduino 1.0.0 or higher and use the correct source files for that version ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true) CXXSRC += main.cpp else @@ -421,7 +424,7 @@ lss: $(BUILD_DIR)/$(TARGET).lss sym: $(BUILD_DIR)/$(TARGET).sym # Program the device. -# Do not try to reset an arduino if it's not one +# Do not try to reset an Arduino if it's not one upload: $(BUILD_DIR)/$(TARGET).hex ifeq (${AVRDUDE_PROGRAMMER}, arduino) stty hup < $(UPLOAD_PORT); true diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index b25df0607..35ab606d2 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -6,7 +6,7 @@ #define FORCE_INLINE __attribute__((always_inline)) inline /** - * Compiler warning on unused varable. + * Compiler warning on unused variable. */ #define UNUSED(x) (void) (x) @@ -45,13 +45,6 @@ typedef unsigned long millis_t; #include "MarlinSerial.h" -#ifndef cbi - #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) -#endif -#ifndef sbi - #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) -#endif - #include "WString.h" #ifdef USBCON @@ -110,7 +103,11 @@ FORCE_INLINE void serialprintPGM(const char* str) { void get_command(); -void idle(); // the standard idle routine calls manage_inactivity(false) +void idle( + #if ENABLED(FILAMENTCHANGEENABLE) + bool no_stepper_sleep=false // pass true to keep steppers from disabling on timeout + #endif +); void manage_inactivity(bool ignore_stepper_queue = false); @@ -217,12 +214,12 @@ void Stop(); * 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), - DEBUG_LEVELING = BIT(5) + DEBUG_ECHO = _BV(0), + DEBUG_INFO = _BV(1), + DEBUG_ERRORS = _BV(2), + DEBUG_DRYRUN = _BV(3), + DEBUG_COMMUNICATION = _BV(4), + DEBUG_LEVELING = _BV(5) }; extern uint8_t marlin_debug_flags; @@ -230,8 +227,9 @@ extern bool Running; inline bool IsRunning() { return Running; } inline bool IsStopped() { return !Running; } -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 +bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); //put a single ASCII command at the end of the current buffer or return false when it is full +void enqueue_and_echo_command_now(const char* cmd); // enqueue now, only return when the command has been enqueued +void enqueue_and_echo_commands_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]); @@ -259,11 +257,9 @@ extern float home_offset[3]; // axis[n].home_offset extern float min_pos[3]; // axis[n].min_pos extern float max_pos[3]; // axis[n].max_pos extern bool axis_known_position[3]; // axis[n].is_known +extern bool axis_homed[3]; // axis[n].is_homed #if ENABLED(DELTA) - extern float delta[3]; - extern float endstop_adj[3]; // axis[n].endstop_adj - extern float delta_radius; #ifndef DELTA_RADIUS_TRIM_TOWER_1 #define DELTA_RADIUS_TRIM_TOWER_1 0.0 #endif @@ -273,7 +269,6 @@ extern bool axis_known_position[3]; // axis[n].is_known #ifndef DELTA_RADIUS_TRIM_TOWER_3 #define DELTA_RADIUS_TRIM_TOWER_3 0.0 #endif - extern float delta_diagonal_rod; #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER_1 #define DELTA_DIAGONAL_ROD_TRIM_TOWER_1 0.0 #endif @@ -283,7 +278,14 @@ extern bool axis_known_position[3]; // axis[n].is_known #ifndef DELTA_DIAGONAL_ROD_TRIM_TOWER_3 #define DELTA_DIAGONAL_ROD_TRIM_TOWER_3 0.0 #endif + extern float delta[3]; + extern float endstop_adj[3]; // axis[n].endstop_adj + extern float delta_radius; + extern float delta_diagonal_rod; extern float delta_segments_per_second; + extern float delta_diagonal_rod_trim_tower_1; + extern float delta_diagonal_rod_trim_tower_2; + extern float delta_diagonal_rod_trim_tower_3; void calculate_delta(float cartesian[3]); void recalc_delta_settings(float radius, float diagonal_rod); #if ENABLED(AUTO_BED_LEVELING_FEATURE) @@ -308,19 +310,17 @@ extern bool axis_known_position[3]; // axis[n].is_known extern float extrude_min_temp; #endif -extern int fanSpeed; +#if FAN_COUNT > 0 + extern int fanSpeeds[FAN_COUNT]; +#endif #if ENABLED(BARICUDA) extern int ValvePressure; extern int EtoPPressure; #endif -#if ENABLED(FAN_SOFT_PWM) - extern unsigned char fanSpeedSoftPwm; -#endif - #if ENABLED(FILAMENT_SENSOR) - extern float filament_width_nominal; //holds the theoretical filament diameter ie., 3.00 or 1.75 + extern float filament_width_nominal; //holds the theoretical filament diameter i.e., 3.00 or 1.75 extern bool filament_sensor; //indicates that filament sensor readings should control extrusion extern float filament_width_meas; //holds the filament diameter as accurately measured extern signed char measurement_delay[]; //ring buffer to delay measurement @@ -351,6 +351,15 @@ extern uint8_t active_extruder; extern void digipot_i2c_init(); #endif +#if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675) + void print_heaterstates(); +#endif + extern void calculate_volumetric_multipliers(); +// Print job timer related functions +millis_t print_job_timer(); +bool print_job_start(millis_t t = 0); +bool print_job_stop(bool force = false); + #endif //MARLIN_H diff --git a/Marlin/Marlin.ino b/Marlin/Marlin.ino index 09e73dcc1..7450ee1fd 100644 --- a/Marlin/Marlin.ino +++ b/Marlin/Marlin.ino @@ -40,6 +40,10 @@ #elif ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008) #include #include + #elif ENABLED(LCM1602) + #include + #include + #include #elif ENABLED(DOGLCD) #include // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/) #else diff --git a/Marlin/MarlinSerial.cpp b/Marlin/MarlinSerial.cpp index ad23a0620..b35ece685 100644 --- a/Marlin/MarlinSerial.cpp +++ b/Marlin/MarlinSerial.cpp @@ -33,16 +33,19 @@ #endif FORCE_INLINE void store_char(unsigned char c) { - int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE; + CRITICAL_SECTION_START; + uint8_t h = rx_buffer.head; + uint8_t i = (uint8_t)(h + 1) & (RX_BUFFER_SIZE - 1); - // if we should be storing the received character into the location - // just before the tail (meaning that the head would advance to the - // current location of the tail), we're about to overflow the buffer - // and so we don't write the character or advance the head. - if (i != rx_buffer.tail) { - rx_buffer.buffer[rx_buffer.head] = c; - rx_buffer.head = i; - } + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if (i != rx_buffer.tail) { + rx_buffer.buffer[h] = c; + rx_buffer.head = i; + } + CRITICAL_SECTION_END; } @@ -76,7 +79,7 @@ void MarlinSerial::begin(long baud) { #endif if (useU2X) { - M_UCSRxA = BIT(M_U2Xx); + M_UCSRxA = _BV(M_U2Xx); baud_setting = (F_CPU / 4 / baud - 1) / 2; } else { @@ -88,50 +91,56 @@ void MarlinSerial::begin(long baud) { M_UBRRxH = baud_setting >> 8; M_UBRRxL = baud_setting; - sbi(M_UCSRxB, M_RXENx); - sbi(M_UCSRxB, M_TXENx); - sbi(M_UCSRxB, M_RXCIEx); + SBI(M_UCSRxB, M_RXENx); + SBI(M_UCSRxB, M_TXENx); + SBI(M_UCSRxB, M_RXCIEx); } void MarlinSerial::end() { - cbi(M_UCSRxB, M_RXENx); - cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + CBI(M_UCSRxB, M_RXENx); + CBI(M_UCSRxB, M_TXENx); + CBI(M_UCSRxB, M_RXCIEx); } int MarlinSerial::peek(void) { - if (rx_buffer.head == rx_buffer.tail) { - return -1; + int v; + CRITICAL_SECTION_START; + uint8_t t = rx_buffer.tail; + if (rx_buffer.head == t) { + v = -1; } else { - return rx_buffer.buffer[rx_buffer.tail]; + v = rx_buffer.buffer[t]; } + CRITICAL_SECTION_END; + return v; } int MarlinSerial::read(void) { - // if the head isn't ahead of the tail, we don't have any characters - if (rx_buffer.head == rx_buffer.tail) { - return -1; + int v; + CRITICAL_SECTION_START; + uint8_t t = rx_buffer.tail; + if (rx_buffer.head == t) { + v = -1; } else { - unsigned char c = rx_buffer.buffer[rx_buffer.tail]; - rx_buffer.tail = (unsigned int)(rx_buffer.tail + 1) % RX_BUFFER_SIZE; - return c; + v = rx_buffer.buffer[t]; + rx_buffer.tail = (uint8_t)(t + 1) & (RX_BUFFER_SIZE - 1); } + CRITICAL_SECTION_END; + return v; } void MarlinSerial::flush() { - // don't reverse this or there may be problems if the RX interrupt - // occurs after reading the value of rx_buffer_head but before writing - // the value to rx_buffer_tail; the previous value of rx_buffer_head - // may be written to rx_buffer_tail, making it appear as if the buffer // don't reverse this or there may be problems if the RX interrupt // occurs after reading the value of rx_buffer_head but before writing // the value to rx_buffer_tail; the previous value of rx_buffer_head // may be written to rx_buffer_tail, making it appear as if the buffer // were full, not empty. - rx_buffer.head = rx_buffer.tail; + CRITICAL_SECTION_START; + rx_buffer.head = rx_buffer.tail; + CRITICAL_SECTION_END; } diff --git a/Marlin/MarlinSerial.h b/Marlin/MarlinSerial.h index c59884a28..1c4cf9ed6 100644 --- a/Marlin/MarlinSerial.h +++ b/Marlin/MarlinSerial.h @@ -23,6 +23,12 @@ #define MarlinSerial_h #include "Marlin.h" +#ifndef CRITICAL_SECTION_START + #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); + #define CRITICAL_SECTION_END SREG = _sreg; +#endif + + #ifndef SERIAL_PORT #define SERIAL_PORT 0 #endif @@ -69,13 +75,18 @@ // using a ring buffer (I think), in which rx_buffer_head is the index of the // location to which to write the next incoming character and rx_buffer_tail // is the index of the location from which to read. -#define RX_BUFFER_SIZE 128 - +// 256 is the max limit due to uint8_t head and tail. Use only powers of 2. (...,16,32,64,128,256) +#ifndef RX_BUFFER_SIZE + #define RX_BUFFER_SIZE 128 +#endif +#if !((RX_BUFFER_SIZE == 256) ||(RX_BUFFER_SIZE == 128) ||(RX_BUFFER_SIZE == 64) ||(RX_BUFFER_SIZE == 32) ||(RX_BUFFER_SIZE == 16) ||(RX_BUFFER_SIZE == 8) ||(RX_BUFFER_SIZE == 4) ||(RX_BUFFER_SIZE == 2)) + #error RX_BUFFER_SIZE has to be a power of 2 and >= 2 +#endif struct ring_buffer { unsigned char buffer[RX_BUFFER_SIZE]; - int head; - int tail; + volatile uint8_t head; + volatile uint8_t tail; }; #if UART_PRESENT(SERIAL_PORT) @@ -92,8 +103,12 @@ class MarlinSerial { //: public Stream int read(void); void flush(void); - FORCE_INLINE int available(void) { - return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; + FORCE_INLINE uint8_t available(void) { + CRITICAL_SECTION_START; + uint8_t h = rx_buffer.head; + uint8_t t = rx_buffer.tail; + CRITICAL_SECTION_END; + return (uint8_t)(RX_BUFFER_SIZE + h - t) & (RX_BUFFER_SIZE - 1); } FORCE_INLINE void write(uint8_t c) { @@ -105,16 +120,19 @@ class MarlinSerial { //: public Stream FORCE_INLINE void checkRx(void) { if (TEST(M_UCSRxA, M_RXCx)) { unsigned char c = M_UDRx; - int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE; + CRITICAL_SECTION_START; + uint8_t h = rx_buffer.head; + uint8_t i = (uint8_t)(h + 1) & (RX_BUFFER_SIZE - 1); - // if we should be storing the received character into the location - // just before the tail (meaning that the head would advance to the - // current location of the tail), we're about to overflow the buffer - // and so we don't write the character or advance the head. - if (i != rx_buffer.tail) { - rx_buffer.buffer[rx_buffer.head] = c; - rx_buffer.head = i; - } + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if (i != rx_buffer.tail) { + rx_buffer.buffer[h] = c; + rx_buffer.head = i; + } + CRITICAL_SECTION_END; } } diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1de6a9fec..27f16b99c 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -68,13 +68,17 @@ #include #endif +#if ENABLED(DAC_STEPPER_CURRENT) + #include "stepper_dac.h" +#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 * * Help us document these G-codes online: - * - http://marlinfirmware.org/index.php/G-Code + * - https://github.com/MarlinFirmware/Marlin/wiki/G-Code-in-Marlin * - http://reprap.org/wiki/G-code * * ----------------- @@ -203,6 +207,8 @@ * M605 - Set dual x-carriage movement mode: S [ X R ] * M907 - Set digital trimpot motor current using axis codes. * M908 - Control digital trimpot directly. + * M909 - DAC_STEPPER_CURRENT: Print digipot/DAC current value + * M910 - DAC_STEPPER_CURRENT: Commit digipot/DAC value to external EEPROM via I2C * M350 - Set microstepping mode. * M351 - Toggle MS1 MS2 pins directly. * @@ -245,6 +251,7 @@ static float feedrate = 1500.0, saved_feedrate; float current_position[NUM_AXIS] = { 0.0 }; static float destination[NUM_AXIS] = { 0.0 }; bool axis_known_position[3] = { false }; +bool axis_homed[3] = { false }; static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0; @@ -266,8 +273,11 @@ float home_offset[3] = { 0 }; float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; +#if FAN_COUNT > 0 + int fanSpeeds[FAN_COUNT] = { 0 }; +#endif + uint8_t active_extruder = 0; -int fanSpeed = 0; bool cancel_heatup = false; const char errormagic[] PROGMEM = "Error:"; @@ -275,21 +285,17 @@ const char echomagic[] PROGMEM = "echo:"; const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; static bool relative_mode = false; //Determines Absolute or Relative Coordinates -static char serial_char; static int serial_count = 0; -static boolean comment_mode = false; static char* seen_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.) 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 millis_t previous_cmd_ms = 0; static millis_t max_inactive_time = 0; -static millis_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME * 1000L; +static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000L; 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 no_wait_for_cooling = true; -bool target_direction; #if ENABLED(AUTO_BED_LEVELING_FEATURE) int xy_travel_speed = XY_TRAVEL_SPEED; @@ -410,9 +416,7 @@ bool target_direction; static bool filrunoutEnqueued = false; #endif -#if ENABLED(SDSUPPORT) - static bool fromsd[BUFSIZE]; -#endif +static bool send_ok[BUFSIZE]; #if HAS_SERVOS Servo servo[NUM_SERVOS]; @@ -427,6 +431,26 @@ bool target_direction; int lpq_len = 20; #endif +#if ENABLED(HOST_KEEPALIVE_FEATURE) + + // States for managing Marlin and host communication + // Marlin sends messages if blocked or busy + enum MarlinBusyState { + NOT_BUSY, // Not in a handler + IN_HANDLER, // Processing a GCode + IN_PROCESS, // Known to be blocking command input (as in G29) + PAUSED_FOR_USER, // Blocking pending any input + PAUSED_FOR_INPUT // Blocking pending text input (concept) + }; + + static MarlinBusyState busy_state = NOT_BUSY; + static millis_t next_busy_signal_ms = -1; + #define KEEPALIVE_STATE(n) do{ busy_state = n; }while(0) +#else + #define host_keepalive() ; + #define KEEPALIVE_STATE(n) ; +#endif // HOST_KEEPALIVE_FEATURE + //=========================================================================== //================================ Functions ================================ //=========================================================================== @@ -443,10 +467,16 @@ void serial_echopair_P(const char* s_P, float v) { serialprintPGM(s_P); 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 gcode_M114(); + #if ENABLED(PREVENT_DANGEROUS_EXTRUDE) float extrude_min_temp = EXTRUDE_MINTEMP; #endif +#if ENABLED(HAS_Z_MIN_PROBE) + extern volatile bool z_probe_is_active; +#endif + #if ENABLED(SDSUPPORT) #include "SdFatUtil.h" int freeMemory() { return SdFatUtil::FreeRam(); } @@ -468,29 +498,25 @@ extern "C" { #endif //!SDSUPPORT /** - * Inject the next command from the command queue, when possible - * Return false only if no command was pending + * Inject the next "immediate" command, when possible. + * Return true if any immediate commands remain to inject. */ static bool drain_queued_commands_P() { - if (!queued_commands_P) return false; - - // Get the next 30 chars from the sequence of gcodes to run - char cmd[30]; - strncpy_P(cmd, queued_commands_P, sizeof(cmd) - 1); - cmd[sizeof(cmd) - 1] = '\0'; - - // Look for the end of line, or the end of sequence - size_t i = 0; - 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 (c) - queued_commands_P += i + 1; // move to next command - else - queued_commands_P = NULL; // will have no more commands in the sequence + if (queued_commands_P != NULL) { + size_t i = 0; + char c, cmd[30]; + strncpy_P(cmd, queued_commands_P, sizeof(cmd) - 1); + cmd[sizeof(cmd) - 1] = '\0'; + while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command + cmd[i] = '\0'; + if (enqueue_and_echo_command(cmd)) { // success? + if (c) // newline char? + queued_commands_P += i + 1; // advance to the next command + else + queued_commands_P = NULL; // nul char? no more commands + } } - return true; + return (queued_commands_P != NULL); // return whether any more remain } /** @@ -498,32 +524,49 @@ static bool drain_queued_commands_P() { * 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) { +void enqueue_and_echo_commands_P(const char* pgcode) { queued_commands_P = pgcode; drain_queued_commands_P(); // first command executed asap (when possible) } /** - * 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 + * Once a new command is in the ring buffer, call this to commit it */ -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_Enqueueing); - SERIAL_ECHO(command); - SERIAL_ECHOLNPGM("\""); +inline void _commit_command(bool say_ok) { + send_ok[cmd_queue_index_w] = say_ok; cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE; commands_in_queue++; +} + +/** + * Copy a command directly into the main command buffer, from RAM. + * Returns true if successfully adds the command + */ +inline bool _enqueuecommand(const char* cmd, bool say_ok=false) { + if (*cmd == ';' || commands_in_queue >= BUFSIZE) return false; + strcpy(command_queue[cmd_queue_index_w], cmd); + _commit_command(say_ok); return true; } +void enqueue_and_echo_command_now(const char* cmd) { + while (!enqueue_and_echo_command(cmd)) idle(); +} + +/** + * Enqueue with Serial Echo + */ +bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) { + if (_enqueuecommand(cmd, say_ok)) { + SERIAL_ECHO_START; + SERIAL_ECHOPGM(MSG_Enqueueing); + SERIAL_ECHO(cmd); + SERIAL_ECHOLNPGM("\""); + return true; + } + return false; +} + void setup_killpin() { #if HAS_KILL SET_INPUT(KILL_PIN); @@ -592,12 +635,26 @@ void servo_init() { servo[3].detach(); #endif - // Set position of Servo Endstops that are defined - #if HAS_SERVO_ENDSTOPS + #if HAS_SERVO_ENDSTOPS + + z_probe_is_active = false; + + /** + * Set position of all defined Servo Endstops + * + * ** UNSAFE! - NEEDS UPDATE! ** + * + * The servo might be deployed and positioned too low to stow + * when starting up the machine or rebooting the board. + * There's no way to know where the nozzle is positioned until + * homing has been done - no homing with z-probe without init! + * + */ for (int i = 0; i < 3; i++) if (servo_endstop_id[i] >= 0) servo[servo_endstop_id[i]].move(servo_endstop_angle[i][1]); - #endif + + #endif // HAS_SERVO_ENDSTOPS } @@ -631,6 +688,13 @@ void servo_init() { * • status LEDs */ void setup() { + + #ifdef DISABLE_JTAG + // Disable JTAG on AT90USB chips to free up pins for IO + MCUCR = 0x80; + MCUCR = 0x80; + #endif + setup_killpin(); setup_filrunoutpin(); setup_powerhold(); @@ -673,9 +737,8 @@ void setup() { SERIAL_ECHOPGM(MSG_PLANNER_BUFFER_BYTES); SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); - #if ENABLED(SDSUPPORT) - for (int8_t i = 0; i < BUFSIZE; i++) fromsd[i] = false; - #endif + // Send "ok" after commands by default + for (int8_t i = 0; i < BUFSIZE; i++) send_ok[i] = true; // loads data from EEPROM if available else uses defaults (and resets step acceleration rate) Config_RetrieveSettings(); @@ -734,7 +797,7 @@ void setup() { * - Call LCD update */ void loop() { - if (commands_in_queue < BUFSIZE - 1) get_command(); + if (commands_in_queue < BUFSIZE) get_command(); #if ENABLED(SDSUPPORT) card.checkautostart(false); @@ -750,6 +813,7 @@ void loop() { // M29 closes the file card.closefile(); SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED); + ok_to_send(); } else { // Write the string from the read buffer to SD @@ -757,7 +821,7 @@ void loop() { if (card.logging) process_next_command(); // The card is saving because it's logging else - SERIAL_PROTOCOLLNPGM(MSG_OK); + ok_to_send(); } } else @@ -793,9 +857,12 @@ void gcode_line_error(const char* err, bool doFlush = true) { */ void get_command() { + static char serial_line_buffer[MAX_CMD_SIZE]; + static boolean serial_comment_mode = false; + if (drain_queued_commands_P()) return; // priority is given to non-serial commands - #if ENABLED(NO_TIMEOUTS) + #if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0 static millis_t last_command_time = 0; millis_t ms = millis(); @@ -810,29 +877,21 @@ void get_command() { // while (commands_in_queue < BUFSIZE && MYSERIAL.available() > 0) { - #if ENABLED(NO_TIMEOUTS) - last_command_time = ms; - #endif - - serial_char = MYSERIAL.read(); + char serial_char = MYSERIAL.read(); // - // If the character ends the line, or the line is full... + // If the character ends the line // - if (serial_char == '\n' || serial_char == '\r' || serial_count >= MAX_CMD_SIZE - 1) { + if (serial_char == '\n' || serial_char == '\r') { - // end of line == end of comment - comment_mode = false; + serial_comment_mode = false; // end of line == end of comment if (!serial_count) return; // empty lines just exit - char* command = command_queue[cmd_queue_index_w]; - command[serial_count] = 0; // terminate string + serial_line_buffer[serial_count] = 0; // terminate string + serial_count = 0; //reset buffer - // this item in the queue is not from sd - #if ENABLED(SDSUPPORT) - fromsd[cmd_queue_index_w] = false; - #endif + char* command = serial_line_buffer; while (*command == ' ') command++; // skip any leading spaces char* npos = (*command == 'N') ? command : NULL; // Require the N parameter to start the line @@ -864,7 +923,7 @@ void get_command() { } // if no errors, continue parsing } - else if (npos == command) { + else { gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM)); return; } @@ -897,48 +956,60 @@ void get_command() { // If command was e-stop process now if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED)); - cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE; - commands_in_queue += 1; + #if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0 + last_command_time = ms; + #endif - serial_count = 0; //clear buffer + // Add the command to the queue + _enqueuecommand(serial_line_buffer, true); + } + else if (serial_count >= MAX_CMD_SIZE - 1) { + // Keep fetching, but ignore normal characters beyond the max length + // The command will be injected when EOL is reached } else if (serial_char == '\\') { // Handle escapes - if (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { + if (MYSERIAL.available() > 0) { // if we have one more character, copy it over serial_char = MYSERIAL.read(); - command_queue[cmd_queue_index_w][serial_count++] = serial_char; + serial_line_buffer[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) command_queue[cmd_queue_index_w][serial_count++] = serial_char; + else { // it's not a newline, carriage return or escape char + if (serial_char == ';') serial_comment_mode = true; + if (!serial_comment_mode) serial_line_buffer[serial_count++] = serial_char; } - } + + } // queue has space, serial has data #if ENABLED(SDSUPPORT) - if (!card.sdprinting || serial_count) return; + static bool stop_buffering = false, + sd_comment_mode = false; + + if (!card.sdprinting) 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. + // if it occurs, stop_buffering is triggered and the buffer is run dry. // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing - static bool stop_buffering = false; if (commands_in_queue == 0) stop_buffering = false; - while (!card.eof() && commands_in_queue < BUFSIZE && !stop_buffering) { + uint16_t sd_count = 0; + bool card_eof = card.eof(); + while (commands_in_queue < BUFSIZE && !card_eof && !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 + char sd_char = (char)n; + card_eof = card.eof(); + if (card_eof || n == -1 + || sd_char == '\n' || sd_char == '\r' + || ((sd_char == '#' || sd_char == ':') && !sd_comment_mode) ) { - if (card.eof()) { + if (card_eof) { SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED); - print_job_stop_ms = millis(); + print_job_stop(true); char time[30]; - millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000; + millis_t t = print_job_timer(); 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; @@ -947,24 +1018,24 @@ void get_command() { card.printingHasFinished(); card.checkautostart(true); } - if (serial_char == '#') stop_buffering = true; + if (sd_char == '#') stop_buffering = true; - if (!serial_count) { - comment_mode = false; //for new command - return; //if empty line - } - command_queue[cmd_queue_index_w][serial_count] = 0; //terminate string - // if (!comment_mode) { - 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 + sd_comment_mode = false; //for new command + + if (!sd_count) continue; //skip empty lines + + command_queue[cmd_queue_index_w][sd_count] = '\0'; //terminate string + sd_count = 0; //clear buffer + + _commit_command(false); + } + else if (sd_count >= MAX_CMD_SIZE - 1) { + // Keep fetching, but ignore normal characters beyond the max length + // The command will be injected when EOL is reached } else { - if (serial_char == ';') comment_mode = true; - if (!comment_mode) command_queue[cmd_queue_index_w][serial_count++] = serial_char; + if (sd_char == ';') sd_comment_mode = true; + if (!sd_comment_mode) command_queue[cmd_queue_index_w][sd_count++] = sd_char; } } @@ -974,6 +1045,7 @@ void get_command() { bool code_has_value() { int i = 1; char c = seen_pointer[i]; + while (c == ' ') c = seen_pointer[++i]; if (c == '-' || c == '+') c = seen_pointer[++i]; if (c == '.') c = seen_pointer[++i]; return (c >= '0' && c <= '9'); @@ -1280,6 +1352,8 @@ static void setup_for_endstop_move() { static void run_z_probe() { + refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding + #if ENABLED(DELTA) float start_z = current_position[Z_AXIS]; @@ -1322,7 +1396,7 @@ static void setup_for_endstop_move() { st_synchronize(); // Tell the planner where we ended up - Get this from the stepper handler - zPosition = st_get_position_mm(Z_AXIS); + zPosition = st_get_axis_position_mm(Z_AXIS); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS]); // move up the retract distance @@ -1340,7 +1414,7 @@ static void setup_for_endstop_move() { 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); + current_position[Z_AXIS] = st_get_axis_position_mm(Z_AXIS); sync_plan_position(); #if ENABLED(DEBUG_LEVELING_FEATURE) @@ -1401,19 +1475,19 @@ static void setup_for_endstop_move() { inline void raise_z_after_probing() { do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); } static void clean_up_after_endstop_move() { - #if ENABLED(ENDSTOPS_ONLY_FOR_HOMING) - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (marlin_debug_flags & DEBUG_LEVELING) { - SERIAL_ECHOLNPGM("clean_up_after_endstop_move > ENDSTOPS_ONLY_FOR_HOMING > enable_endstops(false)"); - } - #endif - enable_endstops(false); + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (marlin_debug_flags & DEBUG_LEVELING) { + SERIAL_ECHOLNPGM("clean_up_after_endstop_move > ENDSTOPS_ONLY_FOR_HOMING > endstops_not_homing()"); + } #endif + endstops_not_homing(); feedrate = saved_feedrate; feedrate_multiplier = saved_feedrate_multiplier; refresh_cmd_timeout(); } + #if ENABLED(HAS_Z_MIN_PROBE) + static void deploy_z_probe() { #if ENABLED(DEBUG_LEVELING_FEATURE) @@ -1422,6 +1496,8 @@ static void setup_for_endstop_move() { } #endif + if (z_probe_is_active) return; + #if HAS_SERVO_ENDSTOPS // Engage Z Servo endstop if enabled @@ -1461,20 +1537,19 @@ static void setup_for_endstop_move() { if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; - // Move to trigger deployment - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) - feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_X != Z_PROBE_ALLEN_KEY_DEPLOY_2_X) - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_X; - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Y != Z_PROBE_ALLEN_KEY_DEPLOY_2_Y) - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Y; - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Z != Z_PROBE_ALLEN_KEY_DEPLOY_2_Z) - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Z; + // Move to trigger deployment + if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) + feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; + if (Z_PROBE_ALLEN_KEY_DEPLOY_3_X != Z_PROBE_ALLEN_KEY_DEPLOY_2_X) + destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_X; + if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Y != Z_PROBE_ALLEN_KEY_DEPLOY_2_Y) + destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Y; + if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Z != Z_PROBE_ALLEN_KEY_DEPLOY_2_Z) + destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Z; - prepare_move_raw(); - - #endif - } + prepare_move_raw(); + #endif + } // Partially Home X,Y for safety destination[X_AXIS] = destination[X_AXIS] * 0.75; @@ -1501,6 +1576,12 @@ static void setup_for_endstop_move() { #endif // Z_PROBE_ALLEN_KEY + #if ENABLED(FIX_MOUNTED_PROBE) + // Noting to be done. Just set z_probe_is_active + #endif + + z_probe_is_active = true; + } static void stow_z_probe(bool doRaise = true) { @@ -1510,6 +1591,8 @@ static void setup_for_endstop_move() { } #endif + if (!z_probe_is_active) return; + #if HAS_SERVO_ENDSTOPS // Retract Z Servo endstop if enabled @@ -1594,12 +1677,19 @@ static void setup_for_endstop_move() { Stop(); } #endif // Z_PROBE_ALLEN_KEY + + #if ENABLED(FIX_MOUNTED_PROBE) + // Noting to be done. Just set z_probe_is_active + #endif + + z_probe_is_active = false; } + #endif // HAS_Z_MIN_PROBE enum ProbeAction { ProbeStay = 0, - ProbeDeploy = BIT(0), - ProbeStow = BIT(1), + ProbeDeploy = _BV(0), + ProbeStow = _BV(1), ProbeDeployAndStow = (ProbeDeploy | ProbeStow) }; @@ -1628,13 +1718,13 @@ static void setup_for_endstop_move() { #if ENABLED(DEBUG_LEVELING_FEATURE) if (marlin_debug_flags & DEBUG_LEVELING) { - SERIAL_ECHOPAIR("> do_blocking_move_to_xy ", x - X_PROBE_OFFSET_FROM_EXTRUDER); - SERIAL_ECHOPAIR(", ", y - Y_PROBE_OFFSET_FROM_EXTRUDER); + SERIAL_ECHOPAIR("> do_blocking_move_to_xy ", x - (X_PROBE_OFFSET_FROM_EXTRUDER)); + SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); SERIAL_EOL; } #endif - do_blocking_move_to_xy(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER); // this also updates current_position + do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); // this also updates current_position #if DISABLED(Z_PROBE_SLED) && DISABLED(Z_PROBE_ALLEN_KEY) if (probe_action & ProbeDeploy) { @@ -1751,7 +1841,9 @@ static void setup_for_endstop_move() { void raise_z_for_servo() { float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_PROBING; - z_dest += axis_known_position[Z_AXIS] ? zprobe_zoffset : zpos; + // The zprobe_zoffset is negative any switch below the nozzle, so + // multiply by Z_HOME_DIR (-1) to move enough away from bed for the probe + z_dest += axis_known_position[Z_AXIS] ? zprobe_zoffset * Z_HOME_DIR : zpos; if (zpos < z_dest) do_blocking_move_to_z(z_dest); // also updates current_position } @@ -1759,6 +1851,11 @@ static void setup_for_endstop_move() { #endif // AUTO_BED_LEVELING_FEATURE +static void unknown_position_error() { + LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); +} #if ENABLED(Z_PROBE_SLED) @@ -1779,10 +1876,11 @@ static void setup_for_endstop_move() { SERIAL_EOL; } #endif + + if (z_probe_is_active == dock) return; + if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) { - LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); + unknown_position_error(); return; } @@ -1801,6 +1899,8 @@ static void setup_for_endstop_move() { digitalWrite(SLED_PIN, HIGH); // turn on magnet } do_blocking_move_to_x(oldXpos); // return to position before docking + + z_probe_is_active = dock; } #endif // Z_PROBE_SLED @@ -1841,9 +1941,7 @@ static void homeaxis(AxisEnum axis) { if (axis == Z_AXIS) { if (axis_home_dir < 0) dock_sled(false); } - #endif - - #if SERVO_LEVELING && DISABLED(Z_PROBE_SLED) + #elif SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE) // Deploy a Z probe if there is one, and homing towards the bed if (axis == Z_AXIS) { @@ -1854,8 +1952,10 @@ static void homeaxis(AxisEnum axis) { #if HAS_SERVO_ENDSTOPS // Engage Servo endstop if enabled - if (axis != Z_AXIS && servo_endstop_id[axis] >= 0) + if (axis != Z_AXIS && servo_endstop_id[axis] >= 0) { servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][0]); + z_probe_is_active = true; + } #endif // Set a flag for Z motor locking @@ -1981,15 +2081,14 @@ static void homeaxis(AxisEnum axis) { feedrate = 0.0; endstops_hit_on_purpose(); // clear endstop hit flags axis_known_position[axis] = true; + axis_homed[axis] = true; #if ENABLED(Z_PROBE_SLED) // bring Z probe back if (axis == Z_AXIS) { if (axis_home_dir < 0) dock_sled(true); } - #endif - - #if SERVO_LEVELING && DISABLED(Z_PROBE_SLED) + #elif SERVO_LEVELING || ENABLED(FIX_MOUNTED_PROBE) // Deploy a Z probe if there is one, and homing towards the bed if (axis == Z_AXIS) { @@ -2016,6 +2115,7 @@ static void homeaxis(AxisEnum axis) { } #endif servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]); + z_probe_is_active = false; } #endif } @@ -2117,6 +2217,35 @@ void unknown_command_error() { SERIAL_ECHOPGM("\"\n"); } +#if ENABLED(HOST_KEEPALIVE_FEATURE) + + void host_keepalive() { + millis_t ms = millis(); + if (busy_state != NOT_BUSY) { + if (ms < next_busy_signal_ms) return; + switch (busy_state) { + case NOT_BUSY: + break; + case IN_HANDLER: + case IN_PROCESS: + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_BUSY_PROCESSING); + break; + case PAUSED_FOR_USER: + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_USER); + break; + case PAUSED_FOR_INPUT: + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_INPUT); + break; + } + } + next_busy_signal_ms = ms + 2000UL; + } + +#endif //HOST_KEEPALIVE_FEATURE + /** * G0, G1: Coordinated movement of X Y Z E axes */ @@ -2255,7 +2384,7 @@ inline void gcode_G28() { setup_for_endstop_move(); - set_destination_to_current(); + set_destination_to_current(); // Directly after a reset this is all 0. Later we get a hint if we have to raise z or not. feedrate = 0.0; @@ -2268,7 +2397,7 @@ inline void gcode_G28() { sync_plan_position(); // Move all carriages up together until the first endstop is hit. - for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * Z_MAX_LENGTH; + for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * (Z_MAX_LENGTH); feedrate = 1.732 * homing_feedrate[X_AXIS]; line_to_destination(); st_synchronize(); @@ -2298,36 +2427,40 @@ inline void gcode_G28() { home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ); - if (home_all_axis || homeZ) { - - #if Z_HOME_DIR > 0 // If homing away from BED do Z first + #if Z_HOME_DIR > 0 // If homing away from BED do Z first + if (home_all_axis || homeZ) { HOMEAXIS(Z); #if ENABLED(DEBUG_LEVELING_FEATURE) if (marlin_debug_flags & DEBUG_LEVELING) { print_xyz("> HOMEAXIS(Z) > current_position", current_position); } #endif + } - #elif DISABLED(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0 + #elif defined(MIN_Z_HEIGHT_FOR_HOMING) && MIN_Z_HEIGHT_FOR_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); + // Raise Z before homing any other axes and z is not already high enough (never lower z) + if (current_position[Z_AXIS] <= MIN_Z_HEIGHT_FOR_HOMING) { + destination[Z_AXIS] = MIN_Z_HEIGHT_FOR_HOMING; + feedrate = max_feedrate[Z_AXIS] * 60; // feedrate (mm/m) = max_feedrate (mm/s) #if ENABLED(DEBUG_LEVELING_FEATURE) if (marlin_debug_flags & DEBUG_LEVELING) { - SERIAL_ECHOPAIR("Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING); + SERIAL_ECHOPAIR("Raise Z (before homing) to ", (float)(MIN_Z_HEIGHT_FOR_HOMING)); SERIAL_EOL; + print_xyz("> (home_all_axis || homeZ) > current_position", current_position); print_xyz("> (home_all_axis || homeZ) > destination", destination); } #endif - feedrate = max_feedrate[Z_AXIS] * 60; line_to_destination(); st_synchronize(); - #endif - - } // home_all_axis || homeZ + // Update the current Z position even if it currently not real from Z-home + // otherwise each call to line_to_destination() will want to move Z-axis + // by MIN_Z_HEIGHT_FOR_HOMING. + current_position[Z_AXIS] = destination[Z_AXIS]; + } + #endif #if ENABLED(QUICK_HOME) @@ -2441,33 +2574,33 @@ inline void gcode_G28() { if (home_all_axis) { - current_position[Z_AXIS] = 0; + // At this point we already have Z at MIN_Z_HEIGHT_FOR_HOMING height + // No need to move Z any more as this height should already be safe + // enough to reach Z_SAFE_HOMING XY positions. + // Just make sure the planner is in sync. sync_plan_position(); // // Set the Z 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 + 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] = current_position[Z_AXIS]; //z is already at the right height feedrate = XY_TRAVEL_SPEED; #if ENABLED(DEBUG_LEVELING_FEATURE) if (marlin_debug_flags & DEBUG_LEVELING) { - SERIAL_ECHOPAIR("Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING); - SERIAL_EOL; - print_xyz("> home_all_axis > current_position", current_position); - print_xyz("> home_all_axis > destination", destination); + print_xyz("> Z_SAFE_HOMING > home_all_axis > current_position", current_position); + print_xyz("> Z_SAFE_HOMING > home_all_axis > destination", destination); } #endif - // This could potentially move X, Y, Z all together + // Move in the XY plane line_to_destination(); st_synchronize(); - // Set current X, Y is the Z_SAFE_HOMING_POINT minus PROBE_OFFSET_FROM_EXTRUDER + // Update the current positions for XY, Z is still at least at + // MIN_Z_HEIGHT_FOR_HOMING height, no changes there. current_position[X_AXIS] = destination[X_AXIS]; current_position[Y_AXIS] = destination[Y_AXIS]; @@ -2483,30 +2616,10 @@ inline void gcode_G28() { // Make sure the Z probe is within the physical limits // NOTE: This doesn't necessarily ensure the Z 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) - - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (marlin_debug_flags & DEBUG_LEVELING) { - SERIAL_ECHOPAIR("Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING); - SERIAL_EOL; - print_xyz("> homeZ > current_position", current_position); - print_xyz("> homeZ > destination", destination); - } - #endif - - line_to_destination(); - st_synchronize(); + 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)) { // Home the Z axis HOMEAXIS(Z); @@ -2518,9 +2631,7 @@ inline void gcode_G28() { } } else { - LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); + unknown_position_error(); } } // !home_all_axes && homeZ @@ -2595,6 +2706,8 @@ inline void gcode_G28() { } #endif + gcode_M114(); // Send end position to RepetierHost + } #if ENABLED(MESH_BED_LEVELING) @@ -2657,7 +2770,7 @@ inline void gcode_G28() { case MeshStart: mbl.reset(); probe_point = 0; - enqueuecommands_P(PSTR("G28\nG29 S2")); + enqueue_and_echo_commands_P(PSTR("G28\nG29 S2")); break; case MeshNext: @@ -2672,8 +2785,8 @@ inline void gcode_G28() { } else { // For others, save the Z of the previous point, then raise Z again. - ix = (probe_point - 1) % MESH_NUM_X_POINTS; - iy = (probe_point - 1) / MESH_NUM_X_POINTS; + ix = (probe_point - 1) % (MESH_NUM_X_POINTS); + iy = (probe_point - 1) / (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]); current_position[Z_AXIS] = MESH_HOME_SEARCH_Z; @@ -2681,9 +2794,9 @@ inline void gcode_G28() { st_synchronize(); } // Is there another point to sample? Move there. - if (probe_point < MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS) { - ix = probe_point % MESH_NUM_X_POINTS; - iy = probe_point / MESH_NUM_X_POINTS; + if (probe_point < (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) { + ix = probe_point % (MESH_NUM_X_POINTS); + iy = probe_point / (MESH_NUM_X_POINTS); 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); @@ -2696,7 +2809,7 @@ inline void gcode_G28() { SERIAL_PROTOCOLLNPGM("Mesh probing done."); probe_point = -1; mbl.active = 1; - enqueuecommands_P(PSTR("G28")); + enqueue_and_echo_commands_P(PSTR("G28")); } break; @@ -2791,9 +2904,7 @@ inline void gcode_G28() { // Don't allow auto-leveling without homing first if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) { - LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN); + unknown_position_error(); return; } @@ -2835,18 +2946,18 @@ inline void gcode_G28() { back_probe_bed_position = code_seen('B') ? code_value_short() : BACK_PROBE_BED_POSITION; bool left_out_l = left_probe_bed_position < MIN_PROBE_X, - left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE, + left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE), right_out_r = right_probe_bed_position > MAX_PROBE_X, right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE, front_out_f = front_probe_bed_position < MIN_PROBE_Y, - front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - MIN_PROBE_EDGE, + front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - (MIN_PROBE_EDGE), back_out_b = back_probe_bed_position > MAX_PROBE_Y, back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE; if (left_out || right_out || front_out || back_out) { if (left_out) { out_of_range_error(PSTR("(L)eft")); - left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - MIN_PROBE_EDGE; + left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - (MIN_PROBE_EDGE); } if (right_out) { out_of_range_error(PSTR("(R)ight")); @@ -2854,7 +2965,7 @@ inline void gcode_G28() { } if (front_out) { out_of_range_error(PSTR("(F)ront")); - front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - MIN_PROBE_EDGE; + front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - (MIN_PROBE_EDGE); } if (back_out) { out_of_range_error(PSTR("(B)ack")); @@ -3044,11 +3155,16 @@ inline void gcode_G28() { if (do_topography_map) { SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n"); - SERIAL_PROTOCOLPGM("+-----------+\n"); - SERIAL_PROTOCOLPGM("|...Back....|\n"); - SERIAL_PROTOCOLPGM("|Left..Right|\n"); - SERIAL_PROTOCOLPGM("|...Front...|\n"); - SERIAL_PROTOCOLPGM("+-----------+\n"); + SERIAL_PROTOCOLPGM(" +--- BACK --+\n"); + SERIAL_PROTOCOLPGM(" | |\n"); + SERIAL_PROTOCOLPGM(" L | (+) | R\n"); + SERIAL_PROTOCOLPGM(" E | | I\n"); + SERIAL_PROTOCOLPGM(" F | (-) N (+) | G\n"); + SERIAL_PROTOCOLPGM(" T | | H\n"); + SERIAL_PROTOCOLPGM(" | (-) | T\n"); + SERIAL_PROTOCOLPGM(" | |\n"); + SERIAL_PROTOCOLPGM(" O-- FRONT --+\n"); + SERIAL_PROTOCOLPGM(" (0,0)\n"); float min_diff = 999; @@ -3063,8 +3179,7 @@ inline void gcode_G28() { apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); - if (eqnBVector[ind] - z_tmp < min_diff) - min_diff = eqnBVector[ind] - z_tmp; + NOMORE(min_diff, eqnBVector[ind] - z_tmp); if (diff >= 0.0) SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment @@ -3131,7 +3246,7 @@ inline void gcode_G28() { #if ENABLED(Z_PROBE_ALLEN_KEY) stow_z_probe(); #elif Z_RAISE_AFTER_PROBING > 0 - raise_z_after_probing(); + raise_z_after_probing(); // ??? #endif #else // !DELTA if (verbose_level > 0) @@ -3144,7 +3259,7 @@ inline void gcode_G28() { float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER, y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER, z_tmp = current_position[Z_AXIS], - real_z = st_get_position_mm(Z_AXIS); //get the real Z (since plan_get_position is now correcting the plane) + real_z = st_get_axis_position_mm(Z_AXIS); //get the real Z (since plan_get_position is now correcting the plane) #if ENABLED(DEBUG_LEVELING_FEATURE) if (marlin_debug_flags & DEBUG_LEVELING) { @@ -3198,6 +3313,11 @@ inline void gcode_G28() { // Sled assembly for Cartesian bots #if ENABLED(Z_PROBE_SLED) dock_sled(true); // dock the sled + #elif Z_RAISE_AFTER_PROBING > 0 + // Raise Z axis for non-delta and non servo based probes + #if !defined(HAS_SERVO_ENDSTOPS) && DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED) + raise_z_after_probing(); + #endif #endif #endif // !DELTA @@ -3209,19 +3329,26 @@ inline void gcode_G28() { SERIAL_ECHOLNPGM(Z_PROBE_END_SCRIPT); } #endif - enqueuecommands_P(PSTR(Z_PROBE_END_SCRIPT)); + enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT)); + #if ENABLED(HAS_Z_MIN_PROBE) + z_probe_is_active = false; + #endif st_synchronize(); #endif + KEEPALIVE_STATE(IN_HANDLER); + #if ENABLED(DEBUG_LEVELING_FEATURE) if (marlin_debug_flags & DEBUG_LEVELING) { SERIAL_ECHOLNPGM("<<< gcode_G29"); } #endif + gcode_M114(); // Send end position to RepetierHost + } - #if DISABLED(Z_PROBE_SLED) + #if DISABLED(Z_PROBE_SLED) // could be avoided /** * G30: Do a single Z probe at the current XY @@ -3230,11 +3357,11 @@ inline void gcode_G28() { #if HAS_SERVO_ENDSTOPS raise_z_for_servo(); #endif - deploy_z_probe(); // Engage Z Servo endstop if available + deploy_z_probe(); // Engage Z Servo endstop if available. Z_PROBE_SLED is missed her. st_synchronize(); // TODO: clear the leveling matrix or the planner will be set incorrectly - setup_for_endstop_move(); + setup_for_endstop_move(); // to late. Must be done before deploying. feedrate = homing_feedrate[Z_AXIS]; @@ -3247,12 +3374,14 @@ inline void gcode_G28() { SERIAL_PROTOCOL(current_position[Z_AXIS] + 0.0001); SERIAL_EOL; - clean_up_after_endstop_move(); + clean_up_after_endstop_move(); // to early. must be done after the stowing. #if HAS_SERVO_ENDSTOPS raise_z_for_servo(); #endif - stow_z_probe(false); // Retract Z Servo endstop if available + stow_z_probe(false); // Retract Z Servo endstop if available. Z_PROBE_SLED is missed her. + + gcode_M114(); // Send end position to RepetierHost } #endif //!Z_PROBE_SLED @@ -3319,12 +3448,16 @@ inline void gcode_G92() { refresh_cmd_timeout(); if (codenum > 0) { codenum += previous_cmd_ms; // wait until this time for a click + KEEPALIVE_STATE(PAUSED_FOR_USER); while (millis() < codenum && !lcd_clicked()) idle(); + KEEPALIVE_STATE(IN_HANDLER); lcd_ignore_click(false); } else { if (!lcd_detected()) return; + KEEPALIVE_STATE(PAUSED_FOR_USER); while (!lcd_clicked()) idle(); + KEEPALIVE_STATE(IN_HANDLER); } if (IS_SD_PRINTING) LCD_MESSAGEPGM(MSG_RESUMING); @@ -3368,7 +3501,7 @@ inline void gcode_M17() { } /** - * M23: Select a file + * M23: Open a file */ inline void gcode_M23() { card.openFile(current_command_args, true); @@ -3379,7 +3512,7 @@ inline void gcode_M17() { */ inline void gcode_M24() { card.startFileprint(); - print_job_start_ms = millis(); + print_job_start(); } /** @@ -3435,8 +3568,7 @@ inline void gcode_M17() { * M31: Get the time since the start of SD Print (or last M109) */ inline void gcode_M31() { - print_job_stop_ms = millis(); - millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000; + millis_t t = print_job_timer(); int min = t / 60, sec = t % 60; char time[30]; sprintf_P(time, PSTR("%i min, %i sec"), min, sec); @@ -3470,8 +3602,9 @@ inline void gcode_M31() { card.setIndex(code_value_short()); card.startFileprint(); - if (!call_procedure) - print_job_start_ms = millis(); //procedure calls count as normal print time. + + // Procedure calls count as normal print time. + if (!call_procedure) print_job_start(); } } @@ -3506,31 +3639,39 @@ inline void gcode_M31() { /** * M42: Change pin status via GCode + * + * P Pin number (LED if omitted) + * S Pin status from 0 - 255 */ inline void gcode_M42() { if (code_seen('S')) { - int pin_status = code_value_short(), - pin_number = LED_PIN; + int pin_status = code_value_short(); + if (pin_status < 0 || pin_status > 255) return; - if (code_seen('P') && pin_status >= 0 && pin_status <= 255) - pin_number = code_value_short(); + int pin_number = code_seen('P') ? code_value_short() : LED_PIN; + if (pin_number < 0) return; - for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) { - if (sensitive_pins[i] == pin_number) { - pin_number = -1; - break; + for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) + if (pin_number == sensitive_pins[i]) return; + + pinMode(pin_number, OUTPUT); + digitalWrite(pin_number, pin_status); + analogWrite(pin_number, pin_status); + + #if FAN_COUNT > 0 + switch (pin_number) { + #if HAS_FAN0 + case FAN_PIN: fanSpeeds[0] = pin_status; break; + #endif + #if HAS_FAN1 + case FAN1_PIN: fanSpeeds[1] = pin_status; break; + #endif + #if HAS_FAN2 + case FAN2_PIN: fanSpeeds[2] = pin_status; break; + #endif } - } - - #if HAS_FAN - if (pin_number == FAN_PIN) fanSpeed = pin_status; #endif - if (pin_number > -1) { - pinMode(pin_number, OUTPUT); - digitalWrite(pin_number, pin_status); - analogWrite(pin_number, pin_status); - } } // code_seen('S') } @@ -3556,6 +3697,7 @@ inline void gcode_M42() { * V = Verbose level (0-4, default=1) * E = Engage Z probe for each reading * L = Number of legs of movement before probe + * S = Schizoid (Or Star if you prefer) * * This function assumes the bed has been homed. Specifically, that a G28 command * as been issued prior to invoking the M48 Z probe repeatability measurement function. @@ -3564,8 +3706,13 @@ inline void gcode_M42() { */ inline void gcode_M48() { + if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS] || !axis_known_position[Z_AXIS]) { + unknown_position_error(); + return; + } + double sum = 0.0, mean = 0.0, sigma = 0.0, sample_set[50]; - uint8_t verbose_level = 1, n_samples = 10, n_legs = 0; + uint8_t verbose_level = 1, n_samples = 10, n_legs = 0, schizoid_flag = 0; if (code_seen('V')) { verbose_level = code_value_short(); @@ -3586,50 +3733,57 @@ inline void gcode_M42() { } } - 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), - E_current = st_get_position_mm(E_AXIS), - X_probe_location = X_current, Y_probe_location = Y_current, + float X_current = current_position[X_AXIS], + Y_current = current_position[Y_AXIS], + Z_current = current_position[Z_AXIS], + X_probe_location = X_current + X_PROBE_OFFSET_FROM_EXTRUDER, + Y_probe_location = Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER, Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING; - bool deploy_probe_for_each_reading = code_seen('E'); if (code_seen('X')) { - X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER; - if (X_probe_location < X_MIN_POS || X_probe_location > X_MAX_POS) { - out_of_range_error(PSTR("X")); - return; - } + X_probe_location = code_value(); + #if DISABLED(DELTA) + if (X_probe_location < MIN_PROBE_X || X_probe_location > MAX_PROBE_X) { + out_of_range_error(PSTR("X")); + return; + } + #endif } if (code_seen('Y')) { - Y_probe_location = code_value() - Y_PROBE_OFFSET_FROM_EXTRUDER; - if (Y_probe_location < Y_MIN_POS || Y_probe_location > Y_MAX_POS) { - out_of_range_error(PSTR("Y")); - return; - } + Y_probe_location = code_value(); + #if DISABLED(DELTA) + if (Y_probe_location < MIN_PROBE_Y || Y_probe_location > MAX_PROBE_Y) { + out_of_range_error(PSTR("Y")); + return; + } + #endif } - if (code_seen('L')) { + #if ENABLED(DELTA) + if (sqrt(X_probe_location * X_probe_location + Y_probe_location * Y_probe_location) > DELTA_PROBEABLE_RADIUS) { + SERIAL_PROTOCOLPGM("? (X,Y) location outside of probeable radius.\n"); + return; + } + #endif + + bool seen_L = code_seen('L'); + + if (seen_L) { n_legs = code_value_short(); - if (n_legs == 1) n_legs = 2; if (n_legs < 0 || n_legs > 15) { SERIAL_PROTOCOLPGM("?Number of legs in movement not plausible (0-15).\n"); return; } + if (n_legs == 1) n_legs = 2; } - // - // Do all the preliminary setup work. First raise the Z probe. - // + if (code_seen('S')) { + schizoid_flag++; + if (!seen_L) n_legs = 7; + } - st_synchronize(); - plan_bed_level_matrix.set_to_identity(); - plan_buffer_line(X_current, Y_current, Z_start_location, E_current, homing_feedrate[Z_AXIS] / 60, active_extruder); - st_synchronize(); - - // // Now get everything to the specified probe point So we can safely do a probe to // get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. @@ -3637,90 +3791,112 @@ inline void gcode_M42() { if (verbose_level > 2) SERIAL_PROTOCOLPGM("Positioning the probe...\n"); - plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, - E_current, - homing_feedrate[X_AXIS] / 60, - active_extruder); - st_synchronize(); + #if ENABLED(DELTA) + reset_bed_level(); // we don't do bed level correction in M48 because we want the raw data when we probe + #else + plan_bed_level_matrix.set_to_identity(); // we don't do bed level correction in M48 because we wantthe raw data when we probe + #endif - 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] = E_current = st_get_position_mm(E_AXIS); + if (Z_start_location < Z_RAISE_BEFORE_PROBING * 2.0) + do_blocking_move_to_z(Z_start_location); + + do_blocking_move_to_xy(X_probe_location - X_PROBE_OFFSET_FROM_EXTRUDER, Y_probe_location - Y_PROBE_OFFSET_FROM_EXTRUDER); // // OK, do the initial probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - - deploy_z_probe(); - setup_for_endstop_move(); - run_z_probe(); - current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); - Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; + probe_pt(X_probe_location, Y_probe_location, Z_RAISE_BEFORE_PROBING, + deploy_probe_for_each_reading ? ProbeDeployAndStow : ProbeDeploy, + verbose_level); - plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, - E_current, - homing_feedrate[X_AXIS] / 60, - active_extruder); - st_synchronize(); - current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); - - if (deploy_probe_for_each_reading) stow_z_probe(); + raise_z_after_probing(); for (uint8_t n = 0; n < n_samples; n++) { - // 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 - + randomSeed(millis()); + delay(500); if (n_legs) { - 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 + float radius, angle = random(0.0, 360.0); + int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise - //SERIAL_ECHOPAIR("starting radius: ",radius); - //SERIAL_ECHOPAIR(" theta: ",theta); - //SERIAL_ECHOPAIR(" direction: ",dir); - //SERIAL_EOL; + radius = random( + #if ENABLED(DELTA) + DELTA_PROBEABLE_RADIUS / 8, DELTA_PROBEABLE_RADIUS / 3 + #else + 5, X_MAX_LENGTH / 8 + #endif + ); + + if (verbose_level > 3) { + SERIAL_ECHOPAIR("Starting radius: ", radius); + SERIAL_ECHOPAIR(" angle: ", angle); + delay(100); + if (dir > 0) + SERIAL_ECHO(" Direction: Counter Clockwise \n"); + else + SERIAL_ECHO(" Direction: Clockwise \n"); + delay(100); + } for (uint8_t l = 0; l < n_legs - 1; l++) { - ms = millis(); - theta += RADIANS(dir * (ms % 20L)); - radius += (ms % 10L) - 5L; - if (radius < 0.0) radius = -radius; - - X_current = X_probe_location + cos(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); - + double delta_angle; + if (schizoid_flag) + delta_angle = dir * 2.0 * 72.0; // The points of a 5 point star are 72 degrees apart. We need to + // skip a point and go to the next one on the star. + else + delta_angle = dir * (float) random(25, 45); // If we do this line, we are just trying to move further + // around the circle. + angle += delta_angle; + while (angle > 360.0) // We probably do not need to keep the angle between 0 and 2*PI, but the + angle -= 360.0; // Arduino documentation says the trig functions should not be given values + while (angle < 0.0) // outside of this range. It looks like they behave correctly with + angle += 360.0; // numbers outside of the range, but just to be safe we clamp them. + X_current = X_probe_location - X_PROBE_OFFSET_FROM_EXTRUDER + cos(RADIANS(angle)) * radius; + Y_current = Y_probe_location - Y_PROBE_OFFSET_FROM_EXTRUDER + sin(RADIANS(angle)) * radius; + #if DISABLED(DELTA) + X_current = constrain(X_current, X_MIN_POS, X_MAX_POS); + Y_current = constrain(Y_current, Y_MIN_POS, Y_MAX_POS); + #else + // If we have gone out too far, we can do a simple fix and scale the numbers + // back in closer to the origin. + while (sqrt(X_current * X_current + Y_current * Y_current) > DELTA_PROBEABLE_RADIUS) { + X_current /= 1.25; + Y_current /= 1.25; + if (verbose_level > 3) { + SERIAL_ECHOPAIR("Pulling point towards center:", X_current); + SERIAL_ECHOPAIR(", ", Y_current); + SERIAL_EOL; + delay(50); + } + } + #endif if (verbose_level > 3) { + SERIAL_PROTOCOL("Going to:"); SERIAL_ECHOPAIR("x: ", X_current); SERIAL_ECHOPAIR("y: ", Y_current); + SERIAL_ECHOPAIR(" z: ", current_position[Z_AXIS]); SERIAL_EOL; + delay(55); } - - do_blocking_move_to(X_current, Y_current, Z_current); // this also updates current_position - + do_blocking_move_to_xy(X_current, Y_current); } // n_legs loop - - // 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 - if (deploy_probe_for_each_reading) { - deploy_z_probe(); - delay(1000); + // We don't really have to do this move, but if we don't we can see a funny shift in the Z Height + // Because the user might not have the Z_RAISE_BEFORE_PROBING height identical to the + // Z_RAISE_BETWEEN_PROBING height. This gets us back to the probe location at the same height that + // we have been running around the circle at. + do_blocking_move_to_xy(X_probe_location - X_PROBE_OFFSET_FROM_EXTRUDER, Y_probe_location - Y_PROBE_OFFSET_FROM_EXTRUDER); + if (deploy_probe_for_each_reading) + sample_set[n] = probe_pt(X_probe_location, Y_probe_location, Z_RAISE_BEFORE_PROBING, ProbeDeployAndStow, verbose_level); + else { + if (n == n_samples - 1) + sample_set[n] = probe_pt(X_probe_location, Y_probe_location, Z_RAISE_BEFORE_PROBING, ProbeStow, verbose_level); else + sample_set[n] = probe_pt(X_probe_location, Y_probe_location, Z_RAISE_BEFORE_PROBING, ProbeStay, verbose_level); } - setup_for_endstop_move(); - run_z_probe(); - - sample_set[n] = current_position[Z_AXIS]; - // // Get the current mean for the data points we have so far // @@ -3738,13 +3914,13 @@ inline void gcode_M42() { sum += ss * ss; } sigma = sqrt(sum / (n + 1)); - if (verbose_level > 1) { SERIAL_PROTOCOL(n + 1); SERIAL_PROTOCOLPGM(" of "); SERIAL_PROTOCOL((int)n_samples); SERIAL_PROTOCOLPGM(" z: "); SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6); + delay(50); if (verbose_level > 2) { SERIAL_PROTOCOLPGM(" mean: "); SERIAL_PROTOCOL_F(mean, 6); @@ -3752,36 +3928,28 @@ inline void gcode_M42() { SERIAL_PROTOCOL_F(sigma, 6); } } - if (verbose_level > 0) SERIAL_EOL; + delay(50); + do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); + } // End of probe loop code - plan_buffer_line(X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS] / 60, active_extruder); - st_synchronize(); - - // Stow between - if (deploy_probe_for_each_reading) { - stow_z_probe(); - delay(1000); - } - } - - // Stow after - if (!deploy_probe_for_each_reading) { - stow_z_probe(); - delay(1000); - } - - clean_up_after_endstop_move(); + // raise_z_after_probing(); if (verbose_level > 0) { SERIAL_PROTOCOLPGM("Mean: "); SERIAL_PROTOCOL_F(mean, 6); SERIAL_EOL; + delay(25); } SERIAL_PROTOCOLPGM("Standard Deviation: "); SERIAL_PROTOCOL_F(sigma, 6); SERIAL_EOL; SERIAL_EOL; + delay(25); + + clean_up_after_endstop_move(); + + gcode_M114(); // Send end position to RepetierHost } #endif // AUTO_BED_LEVELING_FEATURE && Z_MIN_PROBE_REPEATABILITY_TEST @@ -3801,16 +3969,13 @@ inline void gcode_M104() { setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset); #endif } + + print_job_stop(); } -/** - * M105: Read hot end and bed temperature - */ -inline void gcode_M105() { - if (setTargetedHotend(105)) return; +#if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675) - #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675) - SERIAL_PROTOCOLPGM(MSG_OK); + void print_heaterstates() { #if HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675) SERIAL_PROTOCOLPGM(" T:"); SERIAL_PROTOCOL_F(degHotend(target_extruder), 1); @@ -3823,78 +3988,119 @@ inline void gcode_M105() { SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOL_F(degTargetBed(), 1); #endif - for (int8_t e = 0; e < EXTRUDERS; ++e) { - SERIAL_PROTOCOLPGM(" T"); - SERIAL_PROTOCOL(e); - SERIAL_PROTOCOLCHAR(':'); - SERIAL_PROTOCOL_F(degHotend(e), 1); - SERIAL_PROTOCOLPGM(" /"); - SERIAL_PROTOCOL_F(degTargetHotend(e), 1); - } + #if EXTRUDERS > 1 + for (int8_t e = 0; e < EXTRUDERS; ++e) { + SERIAL_PROTOCOLPGM(" T"); + SERIAL_PROTOCOL(e); + SERIAL_PROTOCOLCHAR(':'); + SERIAL_PROTOCOL_F(degHotend(e), 1); + SERIAL_PROTOCOLPGM(" /"); + SERIAL_PROTOCOL_F(degTargetHotend(e), 1); + } + #endif + #if HAS_TEMP_BED + SERIAL_PROTOCOLPGM(" B@:"); + #ifdef BED_WATTS + SERIAL_PROTOCOL(((BED_WATTS) * getHeaterPower(-1)) / 127); + SERIAL_PROTOCOLCHAR('W'); + #else + SERIAL_PROTOCOL(getHeaterPower(-1)); + #endif + #endif + SERIAL_PROTOCOLPGM(" @:"); + #ifdef EXTRUDER_WATTS + SERIAL_PROTOCOL(((EXTRUDER_WATTS) * getHeaterPower(target_extruder)) / 127); + SERIAL_PROTOCOLCHAR('W'); + #else + SERIAL_PROTOCOL(getHeaterPower(target_extruder)); + #endif + #if EXTRUDERS > 1 + for (int8_t e = 0; e < EXTRUDERS; ++e) { + SERIAL_PROTOCOLPGM(" @"); + SERIAL_PROTOCOL(e); + SERIAL_PROTOCOLCHAR(':'); + #ifdef EXTRUDER_WATTS + SERIAL_PROTOCOL(((EXTRUDER_WATTS) * getHeaterPower(e)) / 127); + SERIAL_PROTOCOLCHAR('W'); + #else + SERIAL_PROTOCOL(getHeaterPower(e)); + #endif + } + #endif + #if ENABLED(SHOW_TEMP_ADC_VALUES) + #if HAS_TEMP_BED + SERIAL_PROTOCOLPGM(" ADC B:"); + SERIAL_PROTOCOL_F(degBed(), 1); + SERIAL_PROTOCOLPGM("C->"); + SERIAL_PROTOCOL_F(rawBedTemp() / OVERSAMPLENR, 0); + #endif + for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { + SERIAL_PROTOCOLPGM(" T"); + SERIAL_PROTOCOL(cur_extruder); + SERIAL_PROTOCOLCHAR(':'); + SERIAL_PROTOCOL_F(degHotend(cur_extruder), 1); + SERIAL_PROTOCOLPGM("C->"); + SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder) / OVERSAMPLENR, 0); + } + #endif + } +#endif + +/** + * M105: Read hot end and bed temperature + */ +inline void gcode_M105() { + if (setTargetedHotend(105)) return; + + #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675) + SERIAL_PROTOCOLPGM(MSG_OK); + print_heaterstates(); #else // !HAS_TEMP_0 && !HAS_TEMP_BED SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS); #endif - SERIAL_PROTOCOLPGM(" @:"); - #ifdef EXTRUDER_WATTS - SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(target_extruder)) / 127); - SERIAL_PROTOCOLCHAR('W'); - #else - SERIAL_PROTOCOL(getHeaterPower(target_extruder)); - #endif - - SERIAL_PROTOCOLPGM(" B@:"); - #ifdef BED_WATTS - SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1)) / 127); - SERIAL_PROTOCOLCHAR('W'); - #else - SERIAL_PROTOCOL(getHeaterPower(-1)); - #endif - - #if ENABLED(SHOW_TEMP_ADC_VALUES) - #if HAS_TEMP_BED - SERIAL_PROTOCOLPGM(" ADC B:"); - SERIAL_PROTOCOL_F(degBed(), 1); - SERIAL_PROTOCOLPGM("C->"); - SERIAL_PROTOCOL_F(rawBedTemp() / OVERSAMPLENR, 0); - #endif - for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) { - SERIAL_PROTOCOLPGM(" T"); - SERIAL_PROTOCOL(cur_extruder); - SERIAL_PROTOCOLCHAR(':'); - SERIAL_PROTOCOL_F(degHotend(cur_extruder), 1); - SERIAL_PROTOCOLPGM("C->"); - SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder) / OVERSAMPLENR, 0); - } - #endif - SERIAL_EOL; } -#if HAS_FAN +#if FAN_COUNT > 0 /** * M106: Set Fan Speed + * + * S Speed between 0-255 + * P Fan index, if more than one fan */ - inline void gcode_M106() { fanSpeed = code_seen('S') ? constrain(code_value_short(), 0, 255) : 255; } + inline void gcode_M106() { + uint16_t s = code_seen('S') ? code_value_short() : 255, + p = code_seen('P') ? code_value_short() : 0; + NOMORE(s, 255); + if (p < FAN_COUNT) fanSpeeds[p] = s; + } /** * M107: Fan Off */ - inline void gcode_M107() { fanSpeed = 0; } + inline void gcode_M107() { + uint16_t p = code_seen('P') ? code_value_short() : 0; + if (p < FAN_COUNT) fanSpeeds[p] = 0; + } -#endif // HAS_FAN +#endif // FAN_COUNT > 0 /** - * M109: Wait for extruder(s) to reach temperature + * M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating. + * Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling. */ inline void gcode_M109() { + bool no_wait_for_cooling = true; + + // Start hook must happen before setTargetHotend() + print_job_start(); + if (setTargetedHotend(109)) return; if (marlin_debug_flags & DEBUG_DRYRUN) return; - LCD_MESSAGEPGM(MSG_HEATING); - no_wait_for_cooling = code_seen('S'); if (no_wait_for_cooling || code_seen('R')) { float temp = code_value(); @@ -3903,8 +4109,12 @@ inline void gcode_M109() { if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset); #endif + + if (temp > degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING); } + if (print_job_stop()) LCD_MESSAGEPGM(WELCOME_MSG); + #if ENABLED(AUTOTEMP) autotemp_enabled = code_seen('F'); if (autotemp_enabled) autotemp_factor = code_value(); @@ -3912,34 +4122,36 @@ inline void gcode_M109() { if (code_seen('B')) autotemp_max = code_value(); #endif - millis_t temp_ms = millis(); + // Exit if the temperature is above target and not waiting for cooling + if (no_wait_for_cooling && !isHeatingHotend(target_extruder)) return; - /* See if we are heating up or cooling down */ - target_direction = isHeatingHotend(target_extruder); // true if heating, false if cooling - - cancel_heatup = false; + // Prevents a wait-forever situation if R is misused i.e. M109 R0 + // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP + if (degTargetHotend(target_extruder) < (EXTRUDE_MINTEMP/2)) return; #ifdef TEMP_RESIDENCY_TIME 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) && ((residency_start_ms == -1) || - (residency_start_ms >= 0 && (((unsigned int)(millis() - residency_start_ms)) < (TEMP_RESIDENCY_TIME * 1000UL))))) + // Loop until the temperature has stabilized + #define TEMP_CONDITIONS (residency_start_ms < 0 || now < residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL) #else - while (target_direction ? (isHeatingHotend(target_extruder)) : (isCoolingHotend(target_extruder) && (no_wait_for_cooling == false))) + // Loop until the temperature is very close target + #define TEMP_CONDITIONS (fabs(degHotend(target_extruder) - degTargetHotend(target_extruder)) < 0.75f) #endif //TEMP_RESIDENCY_TIME - { // while loop - 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); + cancel_heatup = false; + millis_t now = millis(), next_temp_ms = now + 1000UL; + while (!cancel_heatup && TEMP_CONDITIONS) { + now = millis(); + if (now > next_temp_ms) { //Print temp & remaining time every 1s while waiting + next_temp_ms = now + 1000UL; + #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675) + print_heaterstates(); + #endif #ifdef TEMP_RESIDENCY_TIME SERIAL_PROTOCOLPGM(" W:"); - if (residency_start_ms > -1) { - temp_ms = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residency_start_ms)) / 1000UL; - SERIAL_PROTOCOLLN(temp_ms); + if (residency_start_ms >= 0) { + long rem = (((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL; + SERIAL_PROTOCOLLN(rem); } else { SERIAL_PROTOCOLLNPGM("?"); @@ -3947,26 +4159,21 @@ inline void gcode_M109() { #else SERIAL_EOL; #endif - temp_ms = millis(); } idle(); + refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out #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 ((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) ) - { + // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time. + // Restart the timer whenever the temperature falls outside the hysteresis. + if (labs(degHotend(target_extruder) - degTargetHotend(target_extruder)) > ((residency_start_ms < 0) ? TEMP_WINDOW : TEMP_HYSTERESIS)) residency_start_ms = millis(); - } #endif //TEMP_RESIDENCY_TIME - } + + } // while(!cancel_heatup && TEMP_CONDITIONS) LCD_MESSAGEPGM(MSG_HEATING_COMPLETE); - refresh_cmd_timeout(); - print_job_start_ms = previous_cmd_ms; } #if HAS_TEMP_BED @@ -3979,36 +4186,37 @@ inline void gcode_M109() { if (marlin_debug_flags & DEBUG_DRYRUN) return; LCD_MESSAGEPGM(MSG_BED_HEATING); - no_wait_for_cooling = code_seen('S'); + bool no_wait_for_cooling = code_seen('S'); if (no_wait_for_cooling || code_seen('R')) setTargetBed(code_value()); - millis_t temp_ms = millis(); + // Exit if the temperature is above target and not waiting for cooling + if (no_wait_for_cooling && !isHeatingBed()) return; cancel_heatup = false; - target_direction = isHeatingBed(); // true if heating, false if cooling - - 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; - float tt = degHotend(active_extruder); - SERIAL_PROTOCOLPGM("T:"); - SERIAL_PROTOCOL(tt); - SERIAL_PROTOCOLPGM(" E:"); - SERIAL_PROTOCOL((int)active_extruder); - SERIAL_PROTOCOLPGM(" B:"); - SERIAL_PROTOCOL_F(degBed(), 1); + millis_t now = millis(), next_temp_ms = now + 1000UL; + while (!cancel_heatup && degTargetBed() != degBed()) { + millis_t now = millis(); + if (now > next_temp_ms) { //Print Temp Reading every 1 second while heating up. + next_temp_ms = now + 1000UL; + print_heaterstates(); SERIAL_EOL; } idle(); + refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out } LCD_MESSAGEPGM(MSG_BED_DONE); - refresh_cmd_timeout(); } #endif // HAS_TEMP_BED +/** + * M110: Set Current Line Number + */ +inline void gcode_M110() { + if (code_seen('N')) gcode_N = code_value_long(); +} + /** * M111: Set the debug level */ @@ -4085,7 +4293,7 @@ inline void gcode_M140() { * F */ inline void gcode_M145() { - uint8_t material = code_seen('S') ? code_value_short() : 0; + int8_t material = code_seen('S') ? code_value_short() : 0; if (material < 0 || material > 1) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX); @@ -4163,7 +4371,13 @@ inline void gcode_M140() { inline void gcode_M81() { disable_all_heaters(); finishAndDisableSteppers(); - fanSpeed = 0; + #if FAN_COUNT > 0 + #if FAN_COUNT > 1 + for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0; + #else + fanSpeeds[0] = 0; + #endif + #endif delay(1000); // Wait 1 second before switching off #if HAS_SUICIDE st_synchronize(); @@ -4264,12 +4478,33 @@ inline void gcode_M114() { SERIAL_PROTOCOLPGM(" E:"); SERIAL_PROTOCOL(current_position[E_AXIS]); - SERIAL_PROTOCOLPGM(MSG_COUNT_X); - SERIAL_PROTOCOL(st_get_position_mm(X_AXIS)); - SERIAL_PROTOCOLPGM(" Y:"); - SERIAL_PROTOCOL(st_get_position_mm(Y_AXIS)); - SERIAL_PROTOCOLPGM(" Z:"); - SERIAL_PROTOCOL(st_get_position_mm(Z_AXIS)); + CRITICAL_SECTION_START; + extern volatile long count_position[NUM_AXIS]; + long xpos = count_position[X_AXIS], + ypos = count_position[Y_AXIS], + zpos = count_position[Z_AXIS]; + CRITICAL_SECTION_END; + + #if ENABLED(COREXY) || ENABLED(COREXZ) + SERIAL_PROTOCOLPGM(MSG_COUNT_A); + #else + SERIAL_PROTOCOLPGM(MSG_COUNT_X); + #endif + SERIAL_PROTOCOL(xpos); + + #if ENABLED(COREXY) + SERIAL_PROTOCOLPGM(" B:"); + #else + SERIAL_PROTOCOLPGM(" Y:"); + #endif + SERIAL_PROTOCOL(ypos); + + #if ENABLED(COREXZ) + SERIAL_PROTOCOLPGM(" C:"); + #else + SERIAL_PROTOCOLPGM(" Z:"); + #endif + SERIAL_PROTOCOL(zpos); SERIAL_EOL; @@ -4348,14 +4583,14 @@ inline void gcode_M119() { } /** - * M120: Enable endstops + * M120: Enable endstops and set non-homing endstop state to "enabled" */ -inline void gcode_M120() { enable_endstops(true); } +inline void gcode_M120() { enable_endstops_globally(true); } /** - * M121: Disable endstops + * M121: Disable endstops and set non-homing endstop state to "disabled" */ -inline void gcode_M121() { enable_endstops(false); } +inline void gcode_M121() { enable_endstops_globally(false); } #if ENABLED(BLINKM) @@ -4730,19 +4965,18 @@ inline void gcode_M226() { if (servo_index >= 0 && servo_index < NUM_SERVOS) servo[servo_index].move(servo_position); else { - SERIAL_ECHO_START; - SERIAL_ECHO("Servo "); - SERIAL_ECHO(servo_index); - SERIAL_ECHOLN(" out of range"); + SERIAL_ERROR_START; + SERIAL_ERROR("Servo "); + SERIAL_ERROR(servo_index); + SERIAL_ERRORLN(" out of range"); } } else if (servo_index >= 0) { - SERIAL_PROTOCOL(MSG_OK); - SERIAL_PROTOCOL(" Servo "); - SERIAL_PROTOCOL(servo_index); - SERIAL_PROTOCOL(": "); - SERIAL_PROTOCOL(servo[servo_index].read()); - SERIAL_EOL; + SERIAL_ECHO_START; + SERIAL_ECHO(" Servo "); + SERIAL_ECHO(servo_index); + SERIAL_ECHO(": "); + SERIAL_ECHOLN(servo[servo_index].read()); } } @@ -4793,27 +5027,27 @@ inline void gcode_M226() { #endif updatePID(); - SERIAL_PROTOCOL(MSG_OK); + SERIAL_ECHO_START; #if ENABLED(PID_PARAMS_PER_EXTRUDER) - SERIAL_PROTOCOL(" e:"); // specify extruder in serial output - SERIAL_PROTOCOL(e); + SERIAL_ECHO(" e:"); // specify extruder in serial output + SERIAL_ECHO(e); #endif // PID_PARAMS_PER_EXTRUDER - SERIAL_PROTOCOL(" p:"); - SERIAL_PROTOCOL(PID_PARAM(Kp, e)); - SERIAL_PROTOCOL(" i:"); - SERIAL_PROTOCOL(unscalePID_i(PID_PARAM(Ki, e))); - SERIAL_PROTOCOL(" d:"); - SERIAL_PROTOCOL(unscalePID_d(PID_PARAM(Kd, e))); + SERIAL_ECHO(" p:"); + SERIAL_ECHO(PID_PARAM(Kp, e)); + SERIAL_ECHO(" i:"); + SERIAL_ECHO(unscalePID_i(PID_PARAM(Ki, e))); + SERIAL_ECHO(" d:"); + SERIAL_ECHO(unscalePID_d(PID_PARAM(Kd, e))); #if ENABLED(PID_ADD_EXTRUSION_RATE) - SERIAL_PROTOCOL(" c:"); + SERIAL_ECHO(" c:"); //Kc does not have scaling applied above, or in resetting defaults - SERIAL_PROTOCOL(PID_PARAM(Kc, e)); + SERIAL_ECHO(PID_PARAM(Kc, e)); #endif SERIAL_EOL; } else { - SERIAL_ECHO_START; - SERIAL_ECHOLN(MSG_INVALID_EXTRUDER); + SERIAL_ERROR_START; + SERIAL_ERRORLN(MSG_INVALID_EXTRUDER); } } @@ -4827,14 +5061,13 @@ inline void gcode_M226() { if (code_seen('D')) bedKd = scalePID_d(code_value()); updatePID(); - SERIAL_PROTOCOL(MSG_OK); - SERIAL_PROTOCOL(" p:"); - SERIAL_PROTOCOL(bedKp); - SERIAL_PROTOCOL(" i:"); - SERIAL_PROTOCOL(unscalePID_i(bedKi)); - SERIAL_PROTOCOL(" d:"); - SERIAL_PROTOCOL(unscalePID_d(bedKd)); - SERIAL_EOL; + SERIAL_ECHO_START; + SERIAL_ECHO(" p:"); + SERIAL_ECHO(bedKp); + SERIAL_ECHO(" i:"); + SERIAL_ECHO(unscalePID_i(bedKi)); + SERIAL_ECHO(" d:"); + SERIAL_ECHOLN(unscalePID_d(bedKd)); } #endif // PIDTEMPBED @@ -4904,15 +5137,27 @@ inline void gcode_M226() { /** * M303: PID relay autotune - * S sets the target temperature. (default target temperature = 150C) - * E (-1 for the bed) + * + * S sets the target temperature. (default 150C) + * E (-1 for the bed) (default 0) * C + * U with a non-zero value will apply the result to current settings */ inline void gcode_M303() { int e = code_seen('E') ? code_value_short() : 0; int c = code_seen('C') ? code_value_short() : 5; + bool u = code_seen('U') && code_value_short() != 0; + float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0); - PID_autotune(temp, e, c); + + if (e >= 0 && e < EXTRUDERS) + target_extruder = e; + + KEEPALIVE_STATE(NOT_BUSY); // don't send "busy: processing" messages during autotune output + + PID_autotune(temp, e, c, u); + + KEEPALIVE_STATE(IN_HANDLER); } #if ENABLED(SCARA) @@ -5087,7 +5332,7 @@ inline void gcode_M400() { st_synchronize(); } */ inline void gcode_M405() { if (code_seen('D')) meas_delay_cm = code_value(); - if (meas_delay_cm > MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; + NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY); if (delay_index2 == -1) { //initialize the ring buffer if it has not been done since startup int temp_ratio = widthFil_to_size_ratio(); @@ -5193,7 +5438,7 @@ inline void gcode_M428() { SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR); LCD_ALERTMESSAGEPGM("Err: Too far!"); #if HAS_BUZZER - enqueuecommands_P(PSTR("M300 S40 P200")); + buzz(200, 40); #endif err = true; break; @@ -5207,7 +5452,8 @@ inline void gcode_M428() { sync_plan_position(); LCD_ALERTMESSAGEPGM("Offset applied."); #if HAS_BUZZER - enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200")); + buzz(200, 659); + buzz(200, 698); #endif } } @@ -5263,7 +5509,7 @@ inline void gcode_M503() { float value = code_value(); if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) { zprobe_zoffset = value; - SERIAL_ECHOPGM(MSG_OK); + SERIAL_ECHO(zprobe_zoffset); } else { SERIAL_ECHOPGM(MSG_Z_MIN); @@ -5361,6 +5607,7 @@ inline void gcode_M503() { delay(100); LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE); millis_t next_tick = 0; + KEEPALIVE_STATE(PAUSED_FOR_USER); while (!lcd_clicked()) { #if DISABLED(AUTO_FILAMENT_CHANGE) millis_t ms = millis(); @@ -5368,9 +5615,7 @@ inline void gcode_M503() { lcd_quick_feedback(); next_tick = ms + 2500; // feedback every 2.5s while waiting } - manage_heater(); - manage_inactivity(true); - lcd_update(); + idle(true); #else current_position[E_AXIS] += AUTO_FILAMENT_CHANGE_LENGTH; destination[E_AXIS] = current_position[E_AXIS]; @@ -5378,6 +5623,7 @@ inline void gcode_M503() { st_synchronize(); #endif } // while(!lcd_clicked) + KEEPALIVE_STATE(IN_HANDLER); lcd_quick_feedback(); // click sound feedback #if ENABLED(AUTO_FILAMENT_CHANGE) @@ -5491,23 +5737,46 @@ inline void gcode_M907() { // this one uses actual amps in floating point for (int i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) digipot_i2c_set_current(i, code_value()); // for each additional extruder (named B,C,D,E..., channels 4,5,6,7...) - for (int i = NUM_AXIS; i < DIGIPOT_I2C_NUM_CHANNELS; i++) if (code_seen('B' + i - NUM_AXIS)) digipot_i2c_set_current(i, code_value()); + for (int i = NUM_AXIS; i < DIGIPOT_I2C_NUM_CHANNELS; i++) if (code_seen('B' + i - (NUM_AXIS))) digipot_i2c_set_current(i, code_value()); + #endif + #if ENABLED(DAC_STEPPER_CURRENT) + if (code_seen('S')) { + float dac_percent = code_value(); + for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent); + } + for (uint8_t i = 0; i < NUM_AXIS; i++) if (code_seen(axis_codes[i])) dac_current_percent(i, code_value()); #endif } -#if HAS_DIGIPOTSS +#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT) /** * M908: Control digital trimpot directly (M908 P S) */ inline void gcode_M908() { - digitalPotWrite( - code_seen('P') ? code_value() : 0, - code_seen('S') ? code_value() : 0 - ); + #if HAS_DIGIPOTSS + digitalPotWrite( + code_seen('P') ? code_value() : 0, + code_seen('S') ? code_value() : 0 + ); + #endif + #ifdef DAC_STEPPER_CURRENT + dac_current_raw( + code_seen('P') ? code_value_long() : -1, + code_seen('S') ? code_value_short() : 0 + ); + #endif } -#endif // HAS_DIGIPOTSS + #if ENABLED(DAC_STEPPER_CURRENT) // As with Printrbot RevF + + inline void gcode_M909() { dac_print_values(); } + + inline void gcode_M910() { dac_commit_eeprom(); } + + #endif + +#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT #if HAS_MICROSTEPS @@ -5595,12 +5864,8 @@ inline void gcode_T(uint8_t tmp_extruder) { } // apply Y & Z extruder offset (x offset is already used in determining home pos) - current_position[Y_AXIS] = current_position[Y_AXIS] - - extruder_offset[Y_AXIS][active_extruder] + - extruder_offset[Y_AXIS][tmp_extruder]; - current_position[Z_AXIS] = current_position[Z_AXIS] - - extruder_offset[Z_AXIS][active_extruder] + - extruder_offset[Z_AXIS][tmp_extruder]; + current_position[Y_AXIS] -= extruder_offset[Y_AXIS][active_extruder] - extruder_offset[Y_AXIS][tmp_extruder]; + current_position[Z_AXIS] -= extruder_offset[Z_AXIS][active_extruder] - extruder_offset[Z_AXIS][tmp_extruder]; active_extruder = tmp_extruder; // This function resets the max/min values - the current position may be overwritten below. @@ -5627,9 +5892,24 @@ inline void gcode_T(uint8_t tmp_extruder) { delayed_move_time = 0; } #else // !DUAL_X_CARRIAGE - // Offset extruder (only by XY) - for (int i = X_AXIS; i <= Y_AXIS; i++) - current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder]; + #if ENABLED(AUTO_BED_LEVELING_FEATURE) + // Offset extruder, make sure to apply the bed level rotation matrix + vector_3 tmp_offset_vec = vector_3(extruder_offset[X_AXIS][tmp_extruder], + extruder_offset[Y_AXIS][tmp_extruder], + extruder_offset[Z_AXIS][tmp_extruder]), + act_offset_vec = vector_3(extruder_offset[X_AXIS][active_extruder], + extruder_offset[Y_AXIS][active_extruder], + extruder_offset[Z_AXIS][active_extruder]), + offset_vec = tmp_offset_vec - act_offset_vec; + offset_vec.apply_rotation(plan_bed_level_matrix.transpose(plan_bed_level_matrix)); + current_position[X_AXIS] += offset_vec.x; + current_position[Y_AXIS] += offset_vec.y; + current_position[Z_AXIS] += offset_vec.z; + #else // !AUTO_BED_LEVELING_FEATURE + // Offset extruder (only by XY) + for (int i=X_AXIS; i<=Y_AXIS; i++) + current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder]; + #endif // !AUTO_BED_LEVELING_FEATURE // Set the new active extruder and position active_extruder = tmp_extruder; #endif // !DUAL_X_CARRIAGE @@ -5669,7 +5949,7 @@ void process_next_command() { // Sanitize the current command: // - Skip leading spaces - // - Bypass N[0-9][0-9]*[ ]* + // - Bypass N[-0-9][0-9]*[ ]* // - Overwrite * with nul to mark the end while (*current_command == ' ') ++current_command; if (*current_command == 'N' && ((current_command[1] >= '0' && current_command[1] <= '9') || current_command[1] == '-')) { @@ -5683,8 +5963,12 @@ void process_next_command() { // Get the command code, which must be G, M, or T char command_code = *current_command; + // Skip the letter-code and spaces to get the numeric part + current_command_args = current_command + 1; + while (*current_command_args == ' ') ++current_command_args; + // The code must have a numeric value - bool code_is_good = (current_command[1] >= '0' && current_command[1] <= '9'); + bool code_is_good = (*current_command_args >= '0' && *current_command_args <= '9'); int codenum; // define ahead of goto @@ -5693,14 +5977,14 @@ void process_next_command() { // Args pointer optimizes code_seen, especially those taking XYZEF // This wastes a little cpu on commands that expect no arguments. - current_command_args = current_command; - while (*current_command_args && *current_command_args != ' ') ++current_command_args; - while (*current_command_args == ' ') ++current_command_args; + while (*current_command_args == ' ' || (*current_command_args >= '0' && *current_command_args <= '9')) ++current_command_args; // Interpret the code int seen_pointer = current_command; codenum = code_value_short(); + KEEPALIVE_STATE(IN_HANDLER); + // Handle a known G, M, or T switch (command_code) { case 'G': switch (codenum) { @@ -5848,6 +6132,10 @@ void process_next_command() { gcode_M104(); break; + case 110: // M110: Set Current Line Number + gcode_M110(); + break; + case 111: // M111: Set debug level gcode_M111(); break; @@ -5862,6 +6150,7 @@ void process_next_command() { case 105: // M105: Read current temperature gcode_M105(); + KEEPALIVE_STATE(NOT_BUSY); return; // "ok" already printed case 109: // M109: Wait for temperature @@ -5874,14 +6163,14 @@ void process_next_command() { break; #endif // HAS_TEMP_BED - #if HAS_FAN + #if FAN_COUNT > 0 case 106: // M106: Fan On gcode_M106(); break; case 107: // M107: Fan Off gcode_M107(); break; - #endif // HAS_FAN + #endif // FAN_COUNT > 0 #if ENABLED(BARICUDA) // PWM for HEATER_1_PIN @@ -6187,11 +6476,25 @@ void process_next_command() { gcode_M907(); break; - #if HAS_DIGIPOTSS + #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT) + case 908: // M908 Control digital trimpot directly. gcode_M908(); break; - #endif // HAS_DIGIPOTSS + + #if ENABLED(DAC_STEPPER_CURRENT) // As with Printrbot RevF + + case 909: // M909 Print digipot/DAC current value + gcode_M909(); + break; + + case 910: // M910 Commit digipot/DAC value to external EEPROM + gcode_M910(); + break; + + #endif + + #endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT #if HAS_MICROSTEPS @@ -6218,6 +6521,8 @@ void process_next_command() { default: code_is_good = false; } + KEEPALIVE_STATE(NOT_BUSY); + ExitUnknownCommand: // Still unknown command? Throw an error @@ -6236,12 +6541,16 @@ void FlushSerialRequestResend() { void ok_to_send() { refresh_cmd_timeout(); - #if ENABLED(SDSUPPORT) - if (fromsd[cmd_queue_index_r]) return; - #endif + if (!send_ok[cmd_queue_index_r]) return; SERIAL_PROTOCOLPGM(MSG_OK); #if ENABLED(ADVANCED_OK) - SERIAL_PROTOCOLPGM(" N"); SERIAL_PROTOCOL(gcode_LastN); + char* p = command_queue[cmd_queue_index_r]; + if (*p == 'N') { + SERIAL_PROTOCOL(' '); + SERIAL_ECHO(*p++); + while ((*p >= '0' && *p <= '9') || *p == '-') + SERIAL_ECHO(*p++); + } SERIAL_PROTOCOLPGM(" P"); SERIAL_PROTOCOL(int(BLOCK_BUFFER_SIZE - movesplanned() - 1)); SERIAL_PROTOCOLPGM(" B"); SERIAL_PROTOCOL(BUFSIZE - commands_in_queue); #endif @@ -6285,9 +6594,9 @@ void clamp_to_software_endstops(float target[3]) { delta_tower2_y = -COS_60 * (radius + DELTA_RADIUS_TRIM_TOWER_2); delta_tower3_x = 0.0; // back middle tower delta_tower3_y = (radius + DELTA_RADIUS_TRIM_TOWER_3); - delta_diagonal_rod_2_tower_1 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_1); - delta_diagonal_rod_2_tower_2 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_2); - delta_diagonal_rod_2_tower_3 = sq(delta_diagonal_rod + delta_diagonal_rod_trim_tower_3); + delta_diagonal_rod_2_tower_1 = sq(diagonal_rod + delta_diagonal_rod_trim_tower_1); + delta_diagonal_rod_2_tower_2 = sq(diagonal_rod + delta_diagonal_rod_trim_tower_2); + delta_diagonal_rod_2_tower_3 = sq(diagonal_rod + delta_diagonal_rod_trim_tower_3); } void calculate_delta(float cartesian[3]) { @@ -6382,34 +6691,38 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_ set_current_to_destination(); return; } - float nx, ny, ne, normalized_dist; - if (ix > pix && (x_splits) & BIT(ix)) { + float nx, ny, nz, ne, normalized_dist; + if (ix > pix && TEST(x_splits, ix)) { nx = mbl.get_x(ix); normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]); ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist; + nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist; - x_splits ^= BIT(ix); + CBI(x_splits, ix); } - else if (ix < pix && (x_splits) & BIT(pix)) { + else if (ix < pix && TEST(x_splits, pix)) { nx = mbl.get_x(pix); normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]); ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist; + nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist; - x_splits ^= BIT(pix); + CBI(x_splits, pix); } - else if (iy > piy && (y_splits) & BIT(iy)) { + else if (iy > piy && TEST(y_splits, iy)) { ny = mbl.get_y(iy); normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]); nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist; + nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist; - y_splits ^= BIT(iy); + CBI(y_splits, iy); } - else if (iy < piy && (y_splits) & BIT(piy)) { + else if (iy < piy && TEST(y_splits, piy)) { ny = mbl.get_y(piy); normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]); nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist; + nz = current_position[Z_AXIS] + (z - current_position[Z_AXIS]) * normalized_dist; ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist; - y_splits ^= BIT(piy); + CBI(y_splits, piy); } else { // Already split on a border @@ -6420,10 +6733,12 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_ // Do the split and look for more borders destination[X_AXIS] = nx; destination[Y_AXIS] = ny; + destination[Z_AXIS] = nz; destination[E_AXIS] = ne; - mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits); + mesh_plan_buffer_line(nx, ny, nz, ne, feed_rate, extruder, x_splits, y_splits); destination[X_AXIS] = x; destination[Y_AXIS] = y; + destination[Z_AXIS] = z; destination[E_AXIS] = e; mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits); } @@ -6625,7 +6940,7 @@ void plan_arc( float mm_of_travel = hypot(angular_travel * radius, fabs(linear_travel)); if (mm_of_travel < 0.001) return; - uint16_t segments = floor(mm_of_travel / MM_PER_ARC_SEGMENT); + uint16_t segments = floor(mm_of_travel / (MM_PER_ARC_SEGMENT)); if (segments == 0) segments = 1; float theta_per_segment = angular_travel / segments; @@ -6734,11 +7049,11 @@ void plan_arc( #if HAS_CONTROLLERFAN void controllerFan() { - static millis_t lastMotor = 0; // Last time a motor was turned on - static millis_t lastMotorCheck = 0; // Last time the state was checked + static millis_t lastMotorOn = 0; // Last time a motor was turned on + static millis_t nextMotorCheck = 0; // Last time the state was checked millis_t ms = millis(); - if (ms >= lastMotorCheck + 2500) { // Not a time critical function, so we only check every 2500ms - lastMotorCheck = ms; + if (ms >= nextMotorCheck) { + nextMotorCheck = ms + 2500; // Not a time critical function, so only check every 2.5s if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || soft_pwm_bed > 0 || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled... #if EXTRUDERS > 1 @@ -6754,9 +7069,12 @@ void plan_arc( #endif #endif ) { - lastMotor = ms; //... set time to NOW so the fan will turn on + lastMotorOn = ms; //... set time to NOW so the fan will turn on } - uint8_t speed = (lastMotor == 0 || ms >= lastMotor + (CONTROLLERFAN_SECS * 1000UL)) ? 0 : CONTROLLERFAN_SPEED; + + // Fan off if no steppers have been enabled for CONTROLLERFAN_SECS seconds + uint8_t speed = (lastMotorOn == 0 || ms >= lastMotorOn + (CONTROLLERFAN_SECS) * 1000UL) ? 0 : CONTROLLERFAN_SPEED; + // allows digital or PWM fan output to be used (see M42 handling) digitalWrite(CONTROLLERFAN_PIN, speed); analogWrite(CONTROLLERFAN_PIN, speed); @@ -6892,9 +7210,18 @@ void disable_all_steppers() { /** * Standard idle routine keeps the machine alive */ -void idle() { +void idle( + #if ENABLED(FILAMENTCHANGEENABLE) + bool no_stepper_sleep/*=false*/ + #endif +) { manage_heater(); - manage_inactivity(); + manage_inactivity( + #if ENABLED(FILAMENTCHANGEENABLE) + no_stepper_sleep + #endif + ); + host_keepalive(); lcd_update(); } @@ -6917,7 +7244,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { filrunout(); #endif - if (commands_in_queue < BUFSIZE - 1) get_command(); + if (commands_in_queue < BUFSIZE) get_command(); millis_t ms = millis(); @@ -6925,16 +7252,16 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { if (stepper_inactive_time && ms > previous_cmd_ms + stepper_inactive_time && !ignore_stepper_queue && !blocks_queued()) { - #if DISABLE_X == true + #if ENABLED(DISABLE_INACTIVE_X) disable_x(); #endif - #if DISABLE_Y == true + #if ENABLED(DISABLE_INACTIVE_Y) disable_y(); #endif - #if DISABLE_Z == true + #if ENABLED(DISABLE_INACTIVE_Z) disable_z(); #endif - #if DISABLE_E == true + #if ENABLED(DISABLE_INACTIVE_E) disable_e0(); disable_e1(); disable_e2(); @@ -6974,7 +7301,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { const int HOME_DEBOUNCE_DELAY = 2500; if (!READ(HOME_PIN)) { if (!homeDebounceCount) { - enqueuecommands_P(PSTR("G28")); + enqueue_and_echo_commands_P(PSTR("G28")); LCD_MESSAGEPGM(MSG_AUTO_HOME); } if (homeDebounceCount < HOME_DEBOUNCE_DELAY) @@ -6989,7 +7316,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #endif #if ENABLED(EXTRUDER_RUNOUT_PREVENT) - if (ms > previous_cmd_ms + 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) { @@ -7018,8 +7345,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { } float oldepos = current_position[E_AXIS], oldedes = destination[E_AXIS]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], - destination[E_AXIS] + EXTRUDER_RUNOUT_EXTRUDE * EXTRUDER_RUNOUT_ESTEPS / axis_steps_per_unit[E_AXIS], - EXTRUDER_RUNOUT_SPEED / 60. * EXTRUDER_RUNOUT_ESTEPS / axis_steps_per_unit[E_AXIS], active_extruder); + destination[E_AXIS] + (EXTRUDER_RUNOUT_EXTRUDE) * (EXTRUDER_RUNOUT_ESTEPS) / axis_steps_per_unit[E_AXIS], + (EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / axis_steps_per_unit[E_AXIS], active_extruder); current_position[E_AXIS] = oldepos; destination[E_AXIS] = oldedes; plan_set_e_position(oldepos); @@ -7088,7 +7415,11 @@ void kill(const char* lcd_msg) { for (int i = 5; i--; lcd_update()) delay(200); // Wait a short time cli(); // disable interrupts suicide(); - while (1) { /* Intentionally left empty */ } // Wait for reset + while (1) { + #if ENABLED(USE_WATCHDOG) + watchdog_reset(); + #endif + } // Wait for reset } #if ENABLED(FILAMENT_RUNOUT_SENSOR) @@ -7096,7 +7427,7 @@ void kill(const char* lcd_msg) { void filrunout() { if (!filrunoutEnqueued) { filrunoutEnqueued = true; - enqueuecommands_P(PSTR(FILAMENT_RUNOUT_SCRIPT)); + enqueue_and_echo_commands_P(PSTR(FILAMENT_RUNOUT_SCRIPT)); st_synchronize(); } } @@ -7189,7 +7520,7 @@ bool setTargetedHotend(int code) { SERIAL_CHAR('M'); SERIAL_ECHO(code); SERIAL_ECHOPGM(" " MSG_INVALID_EXTRUDER " "); - SERIAL_ECHOLN(target_extruder); + SERIAL_ECHOLN((int)target_extruder); return true; } } @@ -7206,3 +7537,50 @@ void calculate_volumetric_multipliers() { for (int i = 0; i < EXTRUDERS; i++) volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]); } + +/** + * Start the print job timer + * + * The print job is only started if all extruders have their target temp at zero + * otherwise the print job timew would be reset everytime a M109 is received. + * + * @param t start timer timestamp + * + * @return true if the timer was started at function call + */ +bool print_job_start(millis_t t /* = 0 */) { + for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false; + print_job_start_ms = (t) ? t : millis(); + print_job_stop_ms = 0; + return true; +} + +/** + * Output the print job timer in seconds + * + * @return the number of seconds + */ +millis_t print_job_timer() { + if (!print_job_start_ms) return 0; + return (((print_job_stop_ms > print_job_start_ms) + ? print_job_stop_ms : millis()) - print_job_start_ms) / 1000; +} + +/** + * Check if the running print job has finished and stop the timer + * + * When the target temperature for all extruders is zero then we assume that the + * print job has finished printing. There are some special conditions under which + * this assumption may not be valid: If during a print job for some reason the + * user decides to bring a nozzle temp down and only then heat the other afterwards. + * + * @param force stops the timer ignoring all pre-checks + * + * @return boolean true if the print job has finished printing + */ +bool print_job_stop(bool force /* = false */) { + if (!print_job_start_ms) return false; + if (!force) for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false; + print_job_stop_ms = millis(); + return true; +} diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 6831380bc..e2802acc0 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -32,8 +32,8 @@ * Babystepping */ #if ENABLED(BABYSTEPPING) - #if ENABLED(COREXY) && ENABLED(BABYSTEP_XY) - #error BABYSTEPPING only implemented for Z axis on CoreXY. + #if DISABLED(ULTRA_LCD) + #error BABYSTEPPING requires an LCD controller. #endif #if ENABLED(SCARA) #error BABYSTEPPING is not implemented for SCARA yet. @@ -112,6 +112,7 @@ /** * Mesh Bed Leveling */ + #if ENABLED(MESH_BED_LEVELING) #if ENABLED(DELTA) #error MESH_BED_LEVELING does not yet support DELTA printers. @@ -122,8 +123,38 @@ #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 +#elif ENABLED(MANUAL_BED_LEVELING) + #error MESH_BED_LEVELING is required for MANUAL_BED_LEVELING. #endif +/** + * Probes + */ + + /** + * A probe needs a pin + */ +#if (!((HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) || HAS_Z_PROBE )) && ( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)) + #error A probe needs a pin! [Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN || HAS_Z_PROBE] +#endif + +#if ((HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) && HAS_Z_PROBE) && ( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)) + #error A probe should not be connected to more then one pin! [Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN || HAS_Z_PROBE] +#endif + + /** + * Require one kind of probe + */ +#if ENABLED(AUTO_BED_LEVELING_FEATURE) && !( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)) + #error For AUTO_BED_LEVELING_FEATURE define one kind of probe! {Servo | Z_PROBE_ALLEN_KEY | Z_PROBE_SLED | FIX_MOUNTED_PROBE] +#endif + +#if ENABLED(Z_SAFE_HOMING)&& !( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED)) + #error For Z_SAFE_HOMING define one kind of probe! {Servo | Z_PROBE_ALLEN_KEY | Z_PROBE_SLED | FIX_MOUNTED_PROBE] +#endif + +// To do: Fail with more then one probe defined + /** * Auto Bed Leveling */ @@ -228,10 +259,6 @@ #error You cannot use Z_PROBE_SLED with DELTA. #endif - #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) - #error Z_MIN_PROBE_REPEATABILITY_TEST is not supported with DELTA yet. - #endif - #endif #endif @@ -261,22 +288,36 @@ /** * Make sure auto fan pins don't conflict with the fan pin */ -#if HAS_AUTO_FAN && HAS_FAN - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN - #error You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN. - #elif EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN - #error You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN. - #elif EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN - #error You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN. - #elif EXTRUDER_3_AUTO_FAN_PIN == FAN_PIN - #error You cannot set EXTRUDER_3_AUTO_FAN_PIN equal to FAN_PIN. +#if HAS_AUTO_FAN + #if HAS_FAN0 + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #error You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN. + #elif EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #error You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN. + #elif EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #error You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN. + #elif EXTRUDER_3_AUTO_FAN_PIN == FAN_PIN + #error You cannot set EXTRUDER_3_AUTO_FAN_PIN equal to FAN_PIN. + #endif #endif #endif -#if HAS_FAN && CONTROLLERFAN_PIN == FAN_PIN +#if HAS_FAN0 && CONTROLLERFAN_PIN == FAN_PIN #error You cannot set CONTROLLERFAN_PIN equal to FAN_PIN. #endif +#if HAS_CONTROLLERFAN + #if EXTRUDER_0_AUTO_FAN_PIN == CONTROLLERFAN_PIN + #error You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to CONTROLLERFAN_PIN. + #elif EXTRUDER_1_AUTO_FAN_PIN == CONTROLLERFAN_PIN + #error You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to CONTROLLERFAN_PIN. + #elif EXTRUDER_2_AUTO_FAN_PIN == CONTROLLERFAN_PIN + #error You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to CONTROLLERFAN_PIN. + #elif EXTRUDER_3_AUTO_FAN_PIN == CONTROLLERFAN_PIN + #error You cannot set EXTRUDER_3_AUTO_FAN_PIN equal to CONTROLLERFAN_PIN. + #endif +#endif + /** * Test Heater, Temp Sensor, and Extruder Pins; Sensor Type must also be set. */ @@ -361,6 +402,12 @@ #error HAS_AUTOMATIC_VERSIONING deprecated - use USE_AUTOMATIC_VERSIONING instead #elif defined(ENABLE_AUTO_BED_LEVELING) #error ENABLE_AUTO_BED_LEVELING deprecated - use AUTO_BED_LEVELING_FEATURE instead +#elif defined(SDSLOW) + #error SDSLOW deprecated - set SPI_SPEED to SPI_HALF_SPEED instead +#elif defined(SDEXTRASLOW) + #error SDEXTRASLOW deprecated - set SPI_SPEED to SPI_QUARTER_SPEED instead +#elif defined(Z_RAISE_BEFORE_HOMING) + #error Z_RAISE_BEFORE_HOMING is deprecated. Use MIN_Z_HEIGHT_FOR_HOMING instead. #endif #endif //SANITYCHECK_H diff --git a/Marlin/Sd2Card.cpp b/Marlin/Sd2Card.cpp index dbb025f5d..d2415a25a 100644 --- a/Marlin/Sd2Card.cpp +++ b/Marlin/Sd2Card.cpp @@ -35,8 +35,8 @@ */ static void spiInit(uint8_t spiRate) { // See avr processor documentation - SPCR = BIT(SPE) | BIT(MSTR) | (spiRate >> 1); - SPSR = spiRate & 1 || spiRate == 6 ? 0 : BIT(SPI2X); + SPCR = _BV(SPE) | _BV(MSTR) | (spiRate >> 1); + SPSR = spiRate & 1 || spiRate == 6 ? 0 : _BV(SPI2X); } //------------------------------------------------------------------------------ /** SPI receive a byte */ @@ -498,9 +498,13 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) { spiRec(); #endif chipSelectHigh(); + // Send an additional dummy byte, required by Toshiba Flash Air SD Card + spiSend(0XFF); return true; fail: chipSelectHigh(); + // Send an additional dummy byte, required by Toshiba Flash Air SD Card + spiSend(0XFF); return false; } //------------------------------------------------------------------------------ diff --git a/Marlin/Sd2PinMap.h b/Marlin/Sd2PinMap.h index 94dbd6df7..2f4ceec16 100644 --- a/Marlin/Sd2PinMap.h +++ b/Marlin/Sd2PinMap.h @@ -405,10 +405,10 @@ static inline __attribute__((always_inline)) void setPinMode(uint8_t pin, uint8_t mode) { if (__builtin_constant_p(pin) && pin < digitalPinCount) { if (mode) { - *digitalPinMap[pin].ddr |= BIT(digitalPinMap[pin].bit); + SBI(*digitalPinMap[pin].ddr, digitalPinMap[pin].bit); } else { - *digitalPinMap[pin].ddr &= ~BIT(digitalPinMap[pin].bit); + CBI(*digitalPinMap[pin].ddr, digitalPinMap[pin].bit); } } else { @@ -428,10 +428,10 @@ static inline __attribute__((always_inline)) void fastDigitalWrite(uint8_t pin, uint8_t value) { if (__builtin_constant_p(pin) && pin < digitalPinCount) { if (value) { - *digitalPinMap[pin].port |= BIT(digitalPinMap[pin].bit); + SBI(*digitalPinMap[pin].port, digitalPinMap[pin].bit); } else { - *digitalPinMap[pin].port &= ~BIT(digitalPinMap[pin].bit); + CBI(*digitalPinMap[pin].port, digitalPinMap[pin].bit); } } else { diff --git a/Marlin/SdBaseFile.cpp b/Marlin/SdBaseFile.cpp index 3806ac982..61deafde9 100644 --- a/Marlin/SdBaseFile.cpp +++ b/Marlin/SdBaseFile.cpp @@ -291,7 +291,7 @@ bool SdBaseFile::getFilename(char* name) { return true; } //------------------------------------------------------------------------------ -void SdBaseFile::getpos(fpos_t* pos) { +void SdBaseFile::getpos(filepos_t* pos) { pos->position = curPosition_; pos->cluster = curCluster_; } @@ -923,7 +923,7 @@ fail: * \return The byte if no error and not at eof else -1; */ int SdBaseFile::peek() { - fpos_t pos; + filepos_t pos; getpos(&pos); int c = read(); if (c >= 0) setpos(&pos); @@ -1049,9 +1049,8 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { if (!isOpen() || !(flags_ & O_READ)) goto fail; // max bytes left in file - if (nbyte >= (fileSize_ - curPosition_)) { - nbyte = fileSize_ - curPosition_; - } + NOMORE(nbyte, fileSize_ - curPosition_); + // amount left to read toRead = nbyte; while (toRead > 0) { @@ -1077,7 +1076,7 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) { uint16_t n = toRead; // amount to be read from current block - if (n > (512 - offset)) n = 512 - offset; + NOMORE(n, 512 - offset); // no buffering needed if n == 512 if (n == 512 && block != vol_->cacheBlockNumber()) { @@ -1135,7 +1134,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 if (VFAT->firstClusterLow == 0 && (VFAT->sequenceNumber & 0x1F) > 0 && (VFAT->sequenceNumber & 0x1F) <= MAX_VFAT_ENTRIES) { // TODO: Store the filename checksum to verify if a none-long filename aware system modified the file table. - n = ((VFAT->sequenceNumber & 0x1F) - 1) * FILENAME_LENGTH; + n = ((VFAT->sequenceNumber & 0x1F) - 1) * (FILENAME_LENGTH); for (uint8_t i = 0; i < FILENAME_LENGTH; i++) longFilename[n + i] = (i < 5) ? VFAT->name1[i] : (i < 11) ? VFAT->name2[i - 5] : VFAT->name3[i - 11]; // If this VFAT entry is the last one, add a NUL terminator at the end of the string @@ -1479,7 +1478,7 @@ fail: return false; } //------------------------------------------------------------------------------ -void SdBaseFile::setpos(fpos_t* pos) { +void SdBaseFile::setpos(filepos_t* pos) { curPosition_ = pos->position; curCluster_ = pos->cluster; } @@ -1758,7 +1757,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) { uint16_t n = 512 - blockOffset; // lesser of space and amount to write - if (n > nToWrite) n = nToWrite; + NOMORE(n, nToWrite); // block for data write uint32_t block = vol_->clusterStartBlock(curCluster_) + blockOfCluster; diff --git a/Marlin/SdBaseFile.h b/Marlin/SdBaseFile.h index 84d72b7b4..f2d2b594d 100644 --- a/Marlin/SdBaseFile.h +++ b/Marlin/SdBaseFile.h @@ -31,16 +31,16 @@ #include "SdVolume.h" //------------------------------------------------------------------------------ /** - * \struct fpos_t + * \struct filepos_t * \brief internal type for istream * do not use in user apps */ -struct fpos_t { +struct filepos_t { /** stream position */ uint32_t position; /** cluster for position */ uint32_t cluster; - fpos_t() : position(0), cluster(0) {} + filepos_t() : position(0), cluster(0) {} }; // use the gnu style oflag in open() @@ -196,11 +196,11 @@ class SdBaseFile { /** get position for streams * \param[out] pos struct to receive position */ - void getpos(fpos_t* pos); + void getpos(filepos_t* pos); /** set position for streams * \param[out] pos struct with value for new position */ - void setpos(fpos_t* pos); + void setpos(filepos_t* pos); //---------------------------------------------------------------------------- bool close(); bool contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock); diff --git a/Marlin/SdVolume.cpp b/Marlin/SdVolume.cpp index a9ef8ea75..9120d1933 100644 --- a/Marlin/SdVolume.cpp +++ b/Marlin/SdVolume.cpp @@ -296,7 +296,7 @@ int32_t SdVolume::freeClusterCount() { for (uint32_t lba = fatStartBlock_; todo; todo -= n, lba++) { if (!cacheRawBlock(lba, CACHE_FOR_READ)) return -1; - if (todo < n) n = todo; + NOMORE(n, todo); if (fatType_ == 16) { for (uint16_t i = 0; i < n; i++) { if (cacheBuffer_.fat16[i] == 0) free++; @@ -364,7 +364,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) { blocksPerCluster_ = fbs->sectorsPerCluster; // determine shift that is same as multiply by blocksPerCluster_ clusterSizeShift_ = 0; - while (blocksPerCluster_ != BIT(clusterSizeShift_)) { + while (blocksPerCluster_ != _BV(clusterSizeShift_)) { // error if not power of 2 if (clusterSizeShift_++ > 7) goto fail; } diff --git a/Marlin/boards.h b/Marlin/boards.h index 0355dbf01..f364172ce 100644 --- a/Marlin/boards.h +++ b/Marlin/boards.h @@ -40,6 +40,7 @@ #define BOARD_TEENSYLU 8 // Teensylu #define BOARD_RUMBA 80 // Rumba #define BOARD_PRINTRBOARD 81 // Printrboard (AT90USB1286) +#define BOARD_PRINTRBOARD_REVF 811 // Printrboard Revision F (AT90USB1286) #define BOARD_BRAINWAVE 82 // Brainwave (AT90USB646) #define BOARD_SAV_MKI 83 // SAV Mk-I (AT90USB1286) #define BOARD_TEENSY2 84 // Teensy++2.0 (AT90USB1286) - CLI compile: DEFINES=AT90USBxx_TEENSYPP_ASSIGNMENTS HARDWARE_MOTHERBOARD=84 make @@ -54,6 +55,7 @@ #define BOARD_OMCA 91 // Final OMCA board #define BOARD_RAMBO 301 // Rambo #define BOARD_MINIRAMBO 302 // Mini-Rambo +#define BOARD_AJ4P 303 // AJ4P #define BOARD_MEGACONTROLLER 310 // Mega controller #define BOARD_ELEFU_3 21 // Elefu Ra Board (v3) #define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board @@ -61,6 +63,7 @@ #define BOARD_MKS_BASE 40 // MKS BASE 1.0 #define BOARD_BAM_DICE 401 // 2PrintBeta BAM&DICE with STK drivers #define BOARD_BAM_DICE_DUE 402 // 2PrintBeta BAM&DICE Due with STK drivers +#define BOARD_BQ_ZUM_MEGA_3D 503 // bq ZUM Mega 3D #define BOARD_99 99 // This is in pins.h but...? diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 61f4a93cc..c3585e31e 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m // close() is done automatically by destructor of SdFile } else { - char pn0 = p.name[0]; + uint8_t pn0 = p.name[0]; if (pn0 == DIR_NAME_FREE) break; if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue; if (longFilename[0] == '.') continue; @@ -195,11 +195,7 @@ void CardReader::initsd() { cardOK = false; if (root.isOpen()) root.close(); - #if ENABLED(SDEXTRASLOW) - #define SPI_SPEED SPI_QUARTER_SPEED - #elif ENABLED(SDSLOW) - #define SPI_SPEED SPI_HALF_SPEED - #else + #ifndef SPI_SPEED #define SPI_SPEED SPI_FULL_SPEED #endif @@ -247,6 +243,14 @@ void CardReader::release() { cardOK = false; } +void CardReader::openAndPrintFile(const char *name) { + char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2]; // Room for "M23 ", names with slashes, a null, and one extra + sprintf_P(cmd, PSTR("M23 %s"), name); + for (char *c = &cmd[4]; *c; c++) *c = tolower(*c); + enqueue_and_echo_command_now(cmd); + enqueue_and_echo_commands_P(PSTR("M24")); +} + void CardReader::startFileprint() { if (cardOK) sdprinting = true; @@ -268,7 +272,7 @@ void CardReader::getAbsFilename(char *t) { workDirParents[i].getFilename(t); //SDBaseFile.getfilename! while (*t && cnt < MAXPATHNAMELENGTH) { t++; cnt++; } //crawl counter forward. } - if (cnt < MAXPATHNAMELENGTH - FILENAME_LENGTH) + if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH)) file.getFilename(t); else t[0] = 0; @@ -504,10 +508,7 @@ void CardReader::checkautostart(bool force) { while (root.readDir(p, NULL) > 0) { for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]); if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) { - char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2]; - sprintf_P(cmd, PSTR("M23 %s"), autoname); - enqueuecommand(cmd); - enqueuecommands_P(PSTR("M24")); + openAndPrintFile(autoname); found = true; } } @@ -593,7 +594,7 @@ void CardReader::printingHasFinished() { sdprinting = false; if (SD_FINISHED_STEPPERRELEASE) { //finishAndDisableSteppers(); - enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); + enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND)); } autotempShutdown(); } diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index 78f2d289f..db68710d7 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -23,6 +23,7 @@ public: void removeFile(char* name); void closefile(bool store_location=false); void release(); + void openAndPrintFile(const char *name); void startFileprint(); void pauseSDPrint(); void getStatus(); diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 3fcd64973..785d4cb50 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -14,79 +14,85 @@ * */ -#define EEPROM_VERSION "V21" +#define EEPROM_VERSION "V22" /** - * V19 EEPROM Layout: + * V21 EEPROM Layout: * - * ver - * 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) + * 100 Version (char x4) + * + * 104 M92 XYZE axis_steps_per_unit (float x4) + * 120 M203 XYZE max_feedrate (float x4) + * 136 M201 XYZE max_acceleration_units_per_sq_second (uint32_t x4) + * 152 M204 P acceleration (float) + * 156 M204 R retract_acceleration (float) + * 160 M204 T travel_acceleration (float) + * 164 M205 S minimumfeedrate (float) + * 168 M205 T mintravelfeedrate (float) + * 172 M205 B minsegmenttime (ulong) + * 176 M205 X max_xy_jerk (float) + * 180 M205 Z max_z_jerk (float) + * 184 M205 E max_e_jerk (float) + * 188 M206 XYZ home_offset (float x3) * * Mesh bed leveling: - * M420 S active - * mesh_num_x (set in firmware) - * mesh_num_y (set in firmware) - * M421 XYZ z_values[][] - * M851 zprobe_zoffset + * 200 M420 S active (bool) + * 201 mesh_num_x (uint8 as set in firmware) + * 202 mesh_num_y (uint8 as set in firmware) + * 203 M421 XYZ z_values[][] (float x9, by default) + * 239 M851 zprobe_zoffset (float) * * DELTA: - * M666 XYZ endstop_adj (x3) - * M665 R delta_radius - * M665 L delta_diagonal_rod - * M665 S delta_segments_per_second - * - * ULTIPANEL: - * 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: - * 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] - * M301 L lpq_len - * - * PIDTEMPBED: - * M304 PID bedKp, bedKi, bedKd - * - * DOGLCD: - * M250 C lcd_contrast - * - * SCARA: - * M365 XYZ axis_scaling (x3) - * - * FWRETRACT: - * 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 - * - * M200 D volumetric_enabled (D>0 makes this enabled) - * - * M200 T D filament_size (x4) (T0..3) + * 243 M666 XYZ endstop_adj (float x3) + * 255 M665 R delta_radius (float) + * 259 M665 L delta_diagonal_rod (float) + * 263 M665 S delta_segments_per_second (float) + * 267 M665 A delta_diagonal_rod_trim_tower_1 (float) + * 271 M665 B delta_diagonal_rod_trim_tower_2 (float) + * 275 M665 C delta_diagonal_rod_trim_tower_3 (float) * * Z_DUAL_ENDSTOPS: - * M666 Z z_endstop_adj + * 279 M666 Z z_endstop_adj (float) + * + * ULTIPANEL: + * 283 M145 S0 H plaPreheatHotendTemp (int) + * 285 M145 S0 B plaPreheatHPBTemp (int) + * 287 M145 S0 F plaPreheatFanSpeed (int) + * 289 M145 S1 H absPreheatHotendTemp (int) + * 291 M145 S1 B absPreheatHPBTemp (int) + * 293 M145 S1 F absPreheatFanSpeed (int) + * + * PIDTEMP: + * 295 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4) + * 311 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4) + * 327 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4) + * 343 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4) + * 359 M301 L lpq_len (int) + * + * PIDTEMPBED: + * 361 M304 PID bedKp, bedKi, bedKd (float x3) + * + * DOGLCD: + * 373 M250 C lcd_contrast (int) + * + * SCARA: + * 375 M365 XYZ axis_scaling (float x3) + * + * FWRETRACT: + * 387 M209 S autoretract_enabled (bool) + * 388 M207 S retract_length (float) + * 392 M207 W retract_length_swap (float) + * 396 M207 F retract_feedrate (float) + * 400 M207 Z retract_zlift (float) + * 404 M208 S retract_recover_length (float) + * 408 M208 W retract_recover_length_swap (float) + * 412 M208 F retract_recover_feedrate (float) + * + * Volumetric Extrusion: + * 416 M200 D volumetric_enabled (bool) + * 417 M200 T D filament_size (float x4) (T0..3) + * + * 433 This Slot is Available! * */ #include "Marlin.h" @@ -133,6 +139,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { #if ENABLED(EEPROM_SETTINGS) +/** + * Store Configuration Settings - M500 + */ + void Config_StoreSettings() { float dummy = 0.0f; char ver[4] = "000"; @@ -156,7 +166,7 @@ void Config_StoreSettings() { uint8_t mesh_num_y = 3; #if ENABLED(MESH_BED_LEVELING) // Compile time test that sizeof(mbl.z_values) is as expected - typedef char c_assert[(sizeof(mbl.z_values) == MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS * sizeof(dummy)) ? 1 : -1]; + typedef char c_assert[(sizeof(mbl.z_values) == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS) * sizeof(dummy)) ? 1 : -1]; mesh_num_x = MESH_NUM_X_POINTS; mesh_num_y = MESH_NUM_Y_POINTS; EEPROM_WRITE_VAR(i, mbl.active); @@ -182,13 +192,16 @@ void Config_StoreSettings() { EEPROM_WRITE_VAR(i, delta_radius); // 1 float EEPROM_WRITE_VAR(i, delta_diagonal_rod); // 1 float EEPROM_WRITE_VAR(i, delta_segments_per_second); // 1 float + EEPROM_WRITE_VAR(i, delta_diagonal_rod_trim_tower_1); // 1 float + EEPROM_WRITE_VAR(i, delta_diagonal_rod_trim_tower_2); // 1 float + EEPROM_WRITE_VAR(i, delta_diagonal_rod_trim_tower_3); // 1 float #elif ENABLED(Z_DUAL_ENDSTOPS) - EEPROM_WRITE_VAR(i, z_endstop_adj); // 1 floats + EEPROM_WRITE_VAR(i, z_endstop_adj); // 1 float dummy = 0.0f; - for (int q = 5; q--;) EEPROM_WRITE_VAR(i, dummy); + for (uint8_t q = 8; q--;) EEPROM_WRITE_VAR(i, dummy); #else dummy = 0.0f; - for (int q = 6; q--;) EEPROM_WRITE_VAR(i, dummy); + for (uint8_t q = 9; q--;) EEPROM_WRITE_VAR(i, dummy); #endif #if DISABLED(ULTIPANEL) @@ -203,7 +216,7 @@ void Config_StoreSettings() { EEPROM_WRITE_VAR(i, absPreheatHPBTemp); EEPROM_WRITE_VAR(i, absPreheatFanSpeed); - for (int e = 0; e < 4; e++) { + for (uint8_t e = 0; e < 4; e++) { #if ENABLED(PIDTEMP) if (e < EXTRUDERS) { @@ -223,7 +236,7 @@ void Config_StoreSettings() { dummy = DUMMY_PID_VALUE; // When read, will not change the existing value EEPROM_WRITE_VAR(i, dummy); dummy = 0.0f; - for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy); + for (uint8_t q = 3; q--;) EEPROM_WRITE_VAR(i, dummy); } } // Extruders Loop @@ -277,7 +290,7 @@ void Config_StoreSettings() { EEPROM_WRITE_VAR(i, volumetric_enabled); // Save filament sizes - for (int q = 0; q < 4; q++) { + for (uint8_t q = 0; q < 4; q++) { if (q < EXTRUDERS) dummy = filament_size[q]; EEPROM_WRITE_VAR(i, dummy); } @@ -339,10 +352,10 @@ void Config_RetrieveSettings() { EEPROM_READ_VAR(i, mbl.z_values); } else { mbl.reset(); - for (int q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy); + for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy); } #else - for (int q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy); + for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy); #endif // MESH_BED_LEVELING #if DISABLED(AUTO_BED_LEVELING_FEATURE) @@ -355,13 +368,16 @@ void Config_RetrieveSettings() { EEPROM_READ_VAR(i, delta_radius); // 1 float EEPROM_READ_VAR(i, delta_diagonal_rod); // 1 float EEPROM_READ_VAR(i, delta_segments_per_second); // 1 float + EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_1); // 1 float + EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_2); // 1 float + EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_3); // 1 float #elif ENABLED(Z_DUAL_ENDSTOPS) EEPROM_READ_VAR(i, z_endstop_adj); dummy = 0.0f; - for (int q=5; q--;) EEPROM_READ_VAR(i, dummy); + for (uint8_t q=8; q--;) EEPROM_READ_VAR(i, dummy); #else dummy = 0.0f; - for (int q=6; q--;) EEPROM_READ_VAR(i, dummy); + for (uint8_t q=9; q--;) EEPROM_READ_VAR(i, dummy); #endif #if DISABLED(ULTIPANEL) @@ -377,7 +393,7 @@ void Config_RetrieveSettings() { EEPROM_READ_VAR(i, absPreheatFanSpeed); #if ENABLED(PIDTEMP) - for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin + for (uint8_t e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin EEPROM_READ_VAR(i, dummy); // Kp if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) { // do not need to scale PID values as the values in EEPROM are already scaled @@ -391,12 +407,12 @@ void Config_RetrieveSettings() { #endif } else { - for (int q=3; q--;) EEPROM_READ_VAR(i, dummy); // Ki, Kd, Kc + for (uint8_t q=3; q--;) EEPROM_READ_VAR(i, dummy); // Ki, Kd, Kc } } #else // !PIDTEMP // 4 x 4 = 16 slots for PID parameters - for (int q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc + for (uint8_t q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc #endif // !PIDTEMP #if DISABLED(PID_ADD_EXTRUSION_RATE) @@ -415,7 +431,7 @@ void Config_RetrieveSettings() { EEPROM_READ_VAR(i, bedKd); } else { - for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd + for (uint8_t q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd } #if DISABLED(HAS_LCD_CONTRAST) @@ -450,7 +466,7 @@ void Config_RetrieveSettings() { EEPROM_READ_VAR(i, volumetric_enabled); - for (int q = 0; q < 4; q++) { + for (uint8_t q = 0; q < 4; q++) { EEPROM_READ_VAR(i, dummy); if (q < EXTRUDERS) filament_size[q] = dummy; } @@ -518,6 +534,9 @@ void Config_ResetDefault() { delta_radius = DELTA_RADIUS; delta_diagonal_rod = DELTA_DIAGONAL_ROD; delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND; + delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1; + delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2; + delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3; recalc_delta_settings(delta_radius, delta_diagonal_rod); #elif ENABLED(Z_DUAL_ENDSTOPS) z_endstop_adj = 0; @@ -538,7 +557,7 @@ void Config_ResetDefault() { #if ENABLED(PIDTEMP) #if ENABLED(PID_PARAMS_PER_EXTRUDER) - for (int e = 0; e < EXTRUDERS; e++) + for (uint8_t e = 0; e < EXTRUDERS; e++) #else int e = 0; UNUSED(e); // only need to write once #endif @@ -686,8 +705,8 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOPAIR(" X", (unsigned long)MESH_NUM_X_POINTS); SERIAL_ECHOPAIR(" Y", (unsigned long)MESH_NUM_Y_POINTS); SERIAL_EOL; - for (int y = 0; y < MESH_NUM_Y_POINTS; y++) { - for (int x = 0; x < MESH_NUM_X_POINTS; x++) { + for (uint8_t y = 0; y < MESH_NUM_Y_POINTS; y++) { + for (uint8_t x = 0; x < MESH_NUM_X_POINTS; x++) { CONFIG_ECHO_START; SERIAL_ECHOPAIR(" M421 X", mbl.get_x(x)); SERIAL_ECHOPAIR(" Y", mbl.get_y(y)); @@ -708,11 +727,16 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOPAIR(" Z", endstop_adj[Z_AXIS]); SERIAL_EOL; CONFIG_ECHO_START; - SERIAL_ECHOLNPGM("Delta settings: L=delta_diagonal_rod, R=delta_radius, S=delta_segments_per_second"); - CONFIG_ECHO_START; + if (!forReplay) { + SERIAL_ECHOLNPGM("Delta settings: L=diagonal_rod, R=radius, S=segments_per_second, ABC=diagonal_rod_trim_tower_[123]"); + CONFIG_ECHO_START; + } SERIAL_ECHOPAIR(" M665 L", delta_diagonal_rod); SERIAL_ECHOPAIR(" R", delta_radius); SERIAL_ECHOPAIR(" S", delta_segments_per_second); + SERIAL_ECHOPAIR(" A", delta_diagonal_rod_trim_tower_1); + SERIAL_ECHOPAIR(" B", delta_diagonal_rod_trim_tower_2); + SERIAL_ECHOPAIR(" C", delta_diagonal_rod_trim_tower_3); SERIAL_EOL; #elif ENABLED(Z_DUAL_ENDSTOPS) CONFIG_ECHO_START; @@ -730,12 +754,12 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOLNPGM("Material heatup parameters:"); CONFIG_ECHO_START; } - SERIAL_ECHOPAIR(" M145 M0 H", (unsigned long)plaPreheatHotendTemp); + SERIAL_ECHOPAIR(" M145 S0 H", (unsigned long)plaPreheatHotendTemp); SERIAL_ECHOPAIR(" B", (unsigned long)plaPreheatHPBTemp); SERIAL_ECHOPAIR(" F", (unsigned long)plaPreheatFanSpeed); SERIAL_EOL; CONFIG_ECHO_START; - SERIAL_ECHOPAIR(" M145 M1 H", (unsigned long)absPreheatHotendTemp); + SERIAL_ECHOPAIR(" M145 S1 H", (unsigned long)absPreheatHotendTemp); SERIAL_ECHOPAIR(" B", (unsigned long)absPreheatHPBTemp); SERIAL_ECHOPAIR(" F", (unsigned long)absPreheatFanSpeed); SERIAL_EOL; diff --git a/Marlin/configurator/config/_htaccess b/Marlin/configurator/config/_htaccess deleted file mode 100644 index f28955094..000000000 --- a/Marlin/configurator/config/_htaccess +++ /dev/null @@ -1 +0,0 @@ -Header set Access-Control-Allow-Origin "*" diff --git a/Marlin/configurator/config/boards.h b/Marlin/configurator/config/boards.h deleted file mode 100644 index f6bbc9d67..000000000 --- a/Marlin/configurator/config/boards.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef BOARDS_H -#define BOARDS_H - -#define BOARD_UNKNOWN -1 - -#define BOARD_GEN7_CUSTOM 10 // Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics" -#define BOARD_GEN7_12 11 // Gen7 v1.1, v1.2 -#define BOARD_GEN7_13 12 // Gen7 v1.3 -#define BOARD_GEN7_14 13 // Gen7 v1.4 -#define BOARD_CHEAPTRONIC 2 // Cheaptronic v1.0 -#define BOARD_SETHI 20 // Sethi 3D_1 -#define BOARD_RAMPS_OLD 3 // MEGA/RAMPS up to 1.2 -#define BOARD_RAMPS_13_EFB 33 // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed) -#define BOARD_RAMPS_13_EEB 34 // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed) -#define BOARD_RAMPS_13_EFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Fan) -#define BOARD_RAMPS_13_EEF 36 // RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Fan) -#define BOARD_RAMPS_13_SF 38 // RAMPS 1.3 / 1.4 (Power outputs: Spindle, Controller Fan) -#define BOARD_FELIX2 37 // Felix 2.0+ Electronics Board (RAMPS like) -#define BOARD_RIGIDBOARD 42 // Invent-A-Part RigidBoard -#define BOARD_GEN6 5 // Gen6 -#define BOARD_GEN6_DELUXE 51 // Gen6 deluxe -#define BOARD_SANGUINOLOLU_11 6 // Sanguinololu < 1.2 -#define BOARD_SANGUINOLOLU_12 62 // Sanguinololu 1.2 and above -#define BOARD_MELZI 63 // Melzi -#define BOARD_STB_11 64 // STB V1.1 -#define BOARD_AZTEEG_X1 65 // Azteeg X1 -#define BOARD_MELZI_MAKR3D 66 // Melzi with ATmega1284 (MaKr3d version) -#define BOARD_AZTEEG_X3 67 // Azteeg X3 -#define BOARD_AZTEEG_X3_PRO 68 // Azteeg X3 Pro -#define BOARD_ULTIMAKER 7 // Ultimaker -#define BOARD_ULTIMAKER_OLD 71 // Ultimaker (Older electronics. Pre 1.5.4. This is rare) -#define BOARD_ULTIMAIN_2 72 // Ultimainboard 2.x (Uses TEMP_SENSOR 20) -#define BOARD_3DRAG 77 // 3Drag Controller -#define BOARD_K8200 78 // Vellemann K8200 Controller (derived from 3Drag Controller) -#define BOARD_TEENSYLU 8 // Teensylu -#define BOARD_RUMBA 80 // Rumba -#define BOARD_PRINTRBOARD 81 // Printrboard (AT90USB1286) -#define BOARD_BRAINWAVE 82 // Brainwave (AT90USB646) -#define BOARD_SAV_MKI 83 // SAV Mk-I (AT90USB1286) -#define BOARD_TEENSY2 84 // Teensy++2.0 (AT90USB1286) - CLI compile: DEFINES=AT90USBxx_TEENSYPP_ASSIGNMENTS HARDWARE_MOTHERBOARD=84 make -#define BOARD_BRAINWAVE_PRO 85 // Brainwave Pro (AT90USB1286) -#define BOARD_GEN3_PLUS 9 // Gen3+ -#define BOARD_GEN3_MONOLITHIC 22 // Gen3 Monolithic Electronics -#define BOARD_MEGATRONICS 70 // Megatronics -#define BOARD_MEGATRONICS_2 701 // Megatronics v2.0 -#define BOARD_MINITRONICS 702 // Minitronics v1.0/1.1 -#define BOARD_MEGATRONICS_3 703 // Megatronics v3.0 -#define BOARD_OMCA_A 90 // Alpha OMCA board -#define BOARD_OMCA 91 // Final OMCA board -#define BOARD_RAMBO 301 // Rambo -#define BOARD_MINIRAMBO 302 // Mini-Rambo -#define BOARD_MEGACONTROLLER 310 // Mega controller -#define BOARD_ELEFU_3 21 // Elefu Ra Board (v3) -#define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board -#define BOARD_LEAPFROG 999 // Leapfrog -#define BOARD_MKS_BASE 40 // MKS BASE 1.0 -#define BOARD_BAM_DICE 401 // 2PrintBeta BAM&DICE with STK drivers -#define BOARD_BAM_DICE_DUE 402 // 2PrintBeta BAM&DICE Due with STK drivers - -#define BOARD_99 99 // This is in pins.h but...? - -#define MB(board) (MOTHERBOARD==BOARD_##board) - -#endif //__BOARDS_H diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h deleted file mode 100644 index 46a306c9a..000000000 --- a/Marlin/configurator/config/language.h +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef LANGUAGE_H -#define LANGUAGE_H - -#include "Configuration.h" - -#define LANGUAGE_CONCAT(M) #M -#define GENERATE_LANGUAGE_INCLUDE(M) LANGUAGE_CONCAT(language_##M.h) - - -// NOTE: IF YOU CHANGE LANGUAGE FILES OR MERGE A FILE WITH CHANGES -// -// ==> ALWAYS TRY TO COMPILE MARLIN WITH/WITHOUT "ULTIPANEL" / "ULTRALCD" / "SDSUPPORT" #define IN "Configuration.h" -// ==> ALSO TRY ALL AVAILABLE LANGUAGE OPTIONS -// See also documentation/LCDLanguageFont.md - -// Languages -// en English -// pl Polish -// fr French -// de German -// es Spanish -// ru Russian -// bg Bulgarian -// it Italian -// pt Portuguese -// pt-br Portuguese (Brazil) -// fi Finnish -// an Aragonese -// nl Dutch -// ca Catalan -// eu Basque-Euskera -// kana Japanese -// kana_utf Japanese -// cn Chinese - -// fallback if no language is set, don't change -#ifndef LANGUAGE_INCLUDE - #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en) -#endif - -#if ENABLED(USE_AUTOMATIC_VERSIONING) - #include "_Version.h" -#else - #include "Default_Version.h" -#endif - -#define PROTOCOL_VERSION "1.0" - -#if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2) - #define MACHINE_NAME "Ultimaker" - #define SOURCE_CODE_URL "https://github.com/Ultimaker/Marlin" -#elif MB(RUMBA) - #define MACHINE_NAME "Rumba" -#elif MB(3DRAG) - #define MACHINE_NAME "3Drag" - #define SOURCE_CODE_URL "http://3dprint.elettronicain.it/" -#elif MB(K8200) - #define MACHINE_NAME "K8200" - #define SOURCE_CODE_URL "https://github.com/CONSULitAS/Marlin-K8200" -#elif MB(5DPRINT) - #define MACHINE_NAME "Makibox" -#elif MB(SAV_MKI) - #define MACHINE_NAME "SAV MkI" - #define SOURCE_CODE_URL "https://github.com/fmalpartida/Marlin/tree/SAV-MkI-config" -#elif !defined(MACHINE_NAME) - #define MACHINE_NAME "3D Printer" -#endif - -#ifdef CUSTOM_MACHINE_NAME - #undef MACHINE_NAME - #define MACHINE_NAME CUSTOM_MACHINE_NAME -#endif - -#ifndef SOURCE_CODE_URL - #define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin" -#endif - -#ifndef DETAILED_BUILD_VERSION - #error BUILD_VERSION Information must be specified -#endif - -#ifndef MACHINE_UUID - #define MACHINE_UUID "00000000-0000-0000-0000-000000000000" -#endif - - -#define STRINGIFY_(n) #n -#define STRINGIFY(n) STRINGIFY_(n) - - -// Common LCD messages - - /* nothing here yet */ - -// Common serial messages -#define MSG_MARLIN "Marlin" - -// Serial Console Messages (do not translate those!) - -#define MSG_Enqueueing "enqueueing \"" -#define MSG_POWERUP "PowerUp" -#define MSG_EXTERNAL_RESET " External Reset" -#define MSG_BROWNOUT_RESET " Brown out Reset" -#define MSG_WATCHDOG_RESET " Watchdog Reset" -#define MSG_SOFTWARE_RESET " Software Reset" -#define MSG_AUTHOR " | Author: " -#define MSG_CONFIGURATION_VER " Last Updated: " -#define MSG_FREE_MEMORY " Free Memory: " -#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " -#define MSG_OK "ok" -#define MSG_WAIT "wait" -#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_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: " -#define MSG_FILE_PRINTED "Done printing file" -#define MSG_BEGIN_FILE_LIST "Begin file list" -#define MSG_END_FILE_LIST "End file list" -#define MSG_INVALID_EXTRUDER "Invalid extruder" -#define MSG_INVALID_SOLENOID "Invalid solenoid" -#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature" -#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n" -#define MSG_COUNT_X " Count X: " -#define MSG_ERR_KILLED "Printer halted. kill() called!" -#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" -#define MSG_RESEND "Resend: " -#define MSG_UNKNOWN_COMMAND "Unknown command: \"" -#define MSG_ACTIVE_EXTRUDER "Active Extruder: " -#define MSG_X_MIN "x_min: " -#define MSG_X_MAX "x_max: " -#define MSG_Y_MIN "y_min: " -#define MSG_Y_MAX "y_max: " -#define MSG_Z_MIN "z_min: " -#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_M421_REQUIRES_XYZ "M421 requires XYZ parameters" -#define MSG_ERR_MESH_INDEX_OOB "Mesh XY index is out of bounds" -#define MSG_ERR_M428_TOO_FAR "Too far from reference point" -#define MSG_M119_REPORT "Reporting endstop status" -#define MSG_ENDSTOP_HIT "TRIGGERED" -#define MSG_ENDSTOP_OPEN "open" -#define MSG_HOTEND_OFFSET "Hotend offsets:" - -#define MSG_SD_CANT_OPEN_SUBDIR "Cannot open subdir" -#define MSG_SD_INIT_FAIL "SD init fail" -#define MSG_SD_VOL_INIT_FAIL "volume.init failed" -#define MSG_SD_OPENROOT_FAIL "openRoot failed" -#define MSG_SD_CARD_OK "SD card ok" -#define MSG_SD_WORKDIR_FAIL "workDir open failed" -#define MSG_SD_OPEN_FILE_FAIL "open failed, File: " -#define MSG_SD_FILE_OPENED "File opened: " -#define MSG_SD_SIZE " Size: " -#define MSG_SD_FILE_SELECTED "File selected" -#define MSG_SD_WRITE_TO_FILE "Writing to file: " -#define MSG_SD_PRINTING_BYTE "SD printing byte " -#define MSG_SD_NOT_PRINTING "Not SD printing" -#define MSG_SD_ERR_WRITE_TO_FILE "error writing to file" -#define MSG_SD_CANT_ENTER_SUBDIR "Cannot enter subdir: " - -#define MSG_STEPPER_TOO_HIGH "Steprate too high: " -#define MSG_ENDSTOPS_HIT "endstops hit: " -#define MSG_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented" -#define MSG_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented" -#define MSG_TOO_COLD_FOR_M600 "M600 Hotend too cold to change filament" -#define MSG_BABYSTEPPING_X "Babystepping X" -#define MSG_BABYSTEPPING_Y "Babystepping Y" -#define MSG_BABYSTEPPING_Z "Babystepping Z" -#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Error in menu structure" - -#define MSG_ERR_EEPROM_WRITE "Error writing to EEPROM!" - -// temperature.cpp strings -#define MSG_PID_AUTOTUNE "PID Autotune" -#define MSG_PID_AUTOTUNE_START MSG_PID_AUTOTUNE " start" -#define MSG_PID_AUTOTUNE_FAILED MSG_PID_AUTOTUNE " failed!" -#define MSG_PID_BAD_EXTRUDER_NUM MSG_PID_AUTOTUNE_FAILED " Bad extruder number" -#define MSG_PID_TEMP_TOO_HIGH MSG_PID_AUTOTUNE_FAILED " Temperature too high" -#define MSG_PID_TIMEOUT MSG_PID_AUTOTUNE_FAILED " timeout" -#define MSG_BIAS " bias: " -#define MSG_D " d: " -#define MSG_T_MIN " min: " -#define MSG_T_MAX " max: " -#define MSG_KU " Ku: " -#define MSG_TU " Tu: " -#define MSG_CLASSIC_PID " Classic PID " -#define MSG_KP " Kp: " -#define MSG_KI " Ki: " -#define MSG_KD " Kd: " -#define MSG_B "B:" -#define MSG_T "T:" -#define MSG_AT " @:" -#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 " -#define MSG_PID_DEBUG_PTERM " pTerm " -#define MSG_PID_DEBUG_ITERM " iTerm " -#define MSG_PID_DEBUG_DTERM " dTerm " -#define MSG_PID_DEBUG_CTERM " cTerm " -#define MSG_INVALID_EXTRUDER_NUM " - Invalid extruder number !" - -#define MSG_HEATER_BED "bed" -#define MSG_STOPPED_HEATER ", system stopped! Heater_ID: " -#define MSG_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !" -#define MSG_T_HEATING_FAILED "Heating failed" -#define MSG_T_THERMAL_RUNAWAY "Thermal Runaway" -#define MSG_T_MAXTEMP "MAXTEMP triggered" -#define MSG_T_MINTEMP "MINTEMP triggered" - -// Debug -#define MSG_DEBUG_ECHO "DEBUG ECHO ENABLED" -#define MSG_DEBUG_INFO "DEBUG INFO ENABLED" -#define MSG_DEBUG_ERRORS "DEBUG ERRORS ENABLED" -#define MSG_DEBUG_DRYRUN "DEBUG DRYRUN ENABLED" - -// LCD Menu Messages - -#if DISABLED(DISPLAY_CHARSET_HD44780_JAPAN) && DISABLED(DISPLAY_CHARSET_HD44780_WESTERN) && DISABLED(DISPLAY_CHARSET_HD44780_CYRILLIC) - #define DISPLAY_CHARSET_HD44780_JAPAN -#endif - -#include LANGUAGE_INCLUDE -#include "language_en.h" - -#endif //__LANGUAGE_H diff --git a/Marlin/configurator/css/configurator.css b/Marlin/configurator/css/configurator.css deleted file mode 100644 index 88332075f..000000000 --- a/Marlin/configurator/css/configurator.css +++ /dev/null @@ -1,344 +0,0 @@ -/* configurator.css */ -/* Styles for Marlin Configurator */ - -.clear { clear: both; } - -/* Prevent selection except PRE tags */ -* { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - } -pre { - -webkit-touch-callout: text; - -webkit-user-select: text; - -khtml-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - user-select: text; - } - -body { margin: 0; padding: 0; background: #56A; color: #000; font-family: monospace; } -#main { - max-width: 1100px; - margin: 0 auto 10px; - padding: 0 2%; width: 96%; - } - -h1, h2, h3, h4, h5, h6 { clear: both; } - -h1, p.info { font-family: sans-serif; } -h1 { - height: 38px; - margin-bottom: -30px; - color: #FFF; - background: transparent url(logo.png) right top no-repeat; - } -p.info { padding: 0; color: #000; } -p.info span { color: #800; } - -#message { text-align: center; } -#message { width: 80%; margin: 0 auto 0.25em; color: #FF0; } -#message p { padding: 2px 0; font-weight: bold; border-radius: 0.8em; } -#message p.message { color: #080; background: #CFC; } -#message p.error { color: #F00; background: #FF4; } -#message p.warning { color: #FF0; background: #BA4; } -#message p.message span, -#message p.error span, -#message p.warning span { - color: #A00; - background: rgba(255, 255, 255, 1); - border: 1px solid rgba(0,0,0,0.5); - border-radius: 1em; - float: right; - margin-right: 0.5em; - padding: 0 3px; - font-family: sans-serif; - font-size: small; - position: relative; - top: -1px; - } - -#help strong { color: #0DD; } -img { display: none; } - -/* Forms */ - -#config_form { - display: block; - background: #EEE; - padding: 6px 20px 20px; - color: #000; - position: relative; - border-radius: 1.5em; - border-top-left-radius: 0; - } -fieldset { - height: 16.1em; - overflow-y: scroll; - overflow-x: hidden; - margin-top: 10px; - } -label, input, select, textarea { display: block; float: left; margin: 1px 0; } -label.newline, textarea, fieldset { clear: both; } -label { - width: 120px; /* label area */ - height: 1em; - padding: 10px 460px 10px 1em; - margin-right: -450px; - text-align: right; - } -label.blocked, label.added.blocked, label.added.blocked.sublabel { color: #AAA; } - -label.added.sublabel { - width: auto; - margin: 11px -2.5em 0 1em; - padding: 0 3em 0 0; - font-style: italic; - color: #444; - } -label+label.added.sublabel { - margin-left: 0; - } - -input[type="text"], select { margin: 0.75em 0 0; } -input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; } -input[type="checkbox"].enabler, input[type="radio"].enabler { margin-left: 1em; } - -input:disabled { color: #BBB; } - -#config_form input[type="text"].subitem { width: 4em; } -#config_form input[type="text"].subitem+.subitem { margin-left: 4px; } - -input[type="text"].added { width: 20em; } -label.added { - width: 265px; /* label area */ - height: 1em; - padding: 10px 370px 10px 1em; - margin-right: -360px; - text-align: right; - } - -ul.tabs { padding: 0; list-style: none; } -ul.tabs li { display: inline; } -ul.tabs li a, -ul.tabs li a.active:hover, -ul.tabs li a.active:active { - display: block; - float: left; - background: #1E4059; - color: #CCC; - font-size: 110%; - border-radius: 0.25em 0.25em 0 0; - margin: 0 4px 0 0; - padding: 2px 8px; - text-decoration: none; - font-family: georgia,"times new roman",times; - } -ul.tabs li a.active:link, -ul.tabs li a.active:visited { - background: #DDD; - color: #06F; - cursor: default; - margin-top: -4px; - padding-bottom: 4px; - padding-top: 4px; - } -ul.tabs li a:hover, -ul.tabs li a:active { - background: #000; - color: #FFF; - } - -fieldset { display: none; border: 1px solid #AAA; border-radius: 1em; } -fieldset legend { display: none; } - -.hilightable span { - display: block; - float: left; - width: 100%; - height: 1.3em; - background: rgba(225,255,0,1); - margin: 0 -100% -1em 0; - } - -#serial_stepper { padding-top: 0.75em; display: block; float: left; } -/*#SERIAL_PORT { display: none; }*/ - -/* Tooltips */ - -#tooltip { - display: none; - max-width: 30em; - padding: 8px; - border: 2px solid #73d699; - border-radius: 1em; - position: absolute; - z-index: 999; - font-family: sans-serif; - font-size: 85%; - color: #000; - line-height: 1.1; - background: #e2ff99; /* Old browsers */ - background: -moz-linear-gradient(top, #e2ff99 0%, #73d699 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e2ff99), color-stop(100%,#73d699)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #e2ff99 0%,#73d699 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #e2ff99 0%,#73d699 100%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, #e2ff99 0%,#73d699 100%); /* IE10+ */ - background: linear-gradient(to bottom, #e2ff99 0%,#73d699 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e2ff99', endColorstr='#73d699',GradientType=0 ); /* IE6-9 */ - -webkit-box-shadow: 0px 6px 25px -4px rgba(0,0,0,0.75); - -moz-box-shadow: 0px 6px 25px -4px rgba(0,0,0,0.75); - box-shadow: 0px 6px 25px -4px rgba(0,0,0,0.75); - } -#tooltip>span { - position: absolute; - content: ""; - width: 0; - height: 0; - border-left: 8px solid transparent; - border-right: 8px solid transparent; - border-top: 8px solid #73d699; - z-index: 999; - bottom: -10px; - left: 20px; - } -#tooltip>strong { color: #00B; } - -/* Tooltips Checkbox */ - -#tipson { - width: auto; - height: auto; - padding: 0; - margin-right: 0; - float: right; - font-weight: bold; - font-size: 100%; - font-family: helvetica; - text-align: left; - cursor: pointer; - } -#tipson input { float: none; display: inline; cursor: pointer; } - -/* Config Text */ - -pre.config { - height: 25em; - padding: 10px; - border: 2px solid #888; - border-radius: 5px; - overflow: auto; - clear: both; - background-color: #FFF; - color: #000; - font-family: "Fira Mono", monospace; - font-size: small; - } - -/* Pre Headers */ - -h2 { - width: 100%; - margin: 12px -300px 4px 0; - padding: 0; - float: left; - } - -/* Disclosure Widget */ - -span.disclose, a.download, a.download-all {︎ - display: block; - float: right; - margin-top: 12px; - } - -span.disclose { - margin-right: -10px; /* total width */ - margin-left: 14px; - width: 0; - height: 0; - position: relative; - left: 3px; - top: 3px; - cursor: pointer; - border-left: 8px solid transparent; - border-right: 8px solid transparent; - border-top: 10px solid #000; - } -span.disclose.closed { - margin-right: -8px; /* total width */ - margin-left: 10px; - left: 0; - top: 0; - border-top: 8px solid transparent; - border-bottom: 8px solid transparent; - border-right: 10px solid #000; - } -span.disclose.almost { - -ms-transform: rotate(45deg); /* IE 9 */ - -webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */ - transform: rotate(45deg); - } -span.disclose.closed.almost { - left: 1px; - top: 3px; - -ms-transform: rotate(315deg); /* IE 9 */ - -webkit-transform: rotate(315deg); /* Chrome, Safari, Opera */ - transform: rotate(315deg); - } - -/* Download Button */ - -a.download, a.download-all { - visibility: hidden; - padding: 2px; - border: 1px solid #494; - border-radius: 4px; - margin: 12px 0 0; - background: #FFF; - color: #494; - font-family: sans-serif; - font-size: small; - font-weight: bold; - text-decoration: none; - } -a.download-all { margin: 9px 2em 0; color: #449; border-color: #449; } - -input[type="text"].one_of_2 { max-width: 15%; } -input[type="text"].one_of_3 { max-width: 10%; } -input[type="text"].one_of_4 { max-width: 7%; } - -select.one_of_2 { max-width: 15%; } -select.one_of_3 { max-width: 10%; } -select.one_of_4 { max-width: 14%; } -select.one_of_4+span.label+select.one_of_4+span.label { clear: both; margin-left: 265px; padding-left: 1.75em; } -select.one_of_4+span.label+select.one_of_4+span.label+select.one_of_4+span.label { clear: none; margin-left: 1em; padding-left: 0; } - -@media all and (min-width: 1140px) { - - #main { max-width: 10000px; } - - fieldset { float: left; width: 50%; height: auto; } - - #config_text, #config_adv_text { float: right; clear: right; width: 45%; } - - pre.config { height: 20em; } - - .disclose { display: none; } - - input[type="text"].one_of_2 { max-width: 15%; } - input[type="text"].one_of_3 { max-width: 9%; } - input[type="text"].one_of_4 { max-width: 8%; } - - select.one_of_2 { max-width: 15%; } - select.one_of_3 { max-width: 10%; } - select.one_of_4 { max-width: 16%; } - -} - -/*label.blocked, .blocked { display: none; }*/ - diff --git a/Marlin/configurator/css/logo.png b/Marlin/configurator/css/logo.png deleted file mode 100644 index 0618dc17a..000000000 Binary files a/Marlin/configurator/css/logo.png and /dev/null differ diff --git a/Marlin/configurator/index.html b/Marlin/configurator/index.html deleted file mode 100644 index 385109c9e..000000000 --- a/Marlin/configurator/index.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - Marlin Firmware Configurator - - - - - - - - - - - - -
-

Marlin Configurator

-

Select presets (coming soon), modify, and download.

- -
-
- -
- -
- - - - Download Zip - -
- Info -
- -
- Machine - -
- - - - - - - - - - - - - - - - - - -
- -
- Homing -
- -
- Temperature - - - - - - - - - - -
- -
- Extruder -
- -
- LCD / SD -
- -
- Bed Leveling -
- -
- FW Retract -
- -
- TMC -
- -
- L6470 -
- -
- Extras -
- -
- More… -
- -
-

Configuration.h

- - Download -

-        
- -
-

Configuration_adv.h

- - Download -

-        
- -
-
-
- - diff --git a/Marlin/configurator/js/FileSaver.min.js b/Marlin/configurator/js/FileSaver.min.js deleted file mode 100755 index f7319603d..000000000 --- a/Marlin/configurator/js/FileSaver.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ -var saveAs=saveAs||typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator)||function(view){"use strict";if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var doc=view.document,get_URL=function(){return view.URL||view.webkitURL||view},save_link=doc.createElementNS("http://www.w3.org/1999/xhtml","a"),can_use_save_link="download"in save_link,click=function(node){var event=doc.createEvent("MouseEvents");event.initMouseEvent("click",true,false,view,0,0,0,0,0,false,false,false,false,0,null);node.dispatchEvent(event)},webkit_req_fs=view.webkitRequestFileSystem,req_fs=view.requestFileSystem||webkit_req_fs||view.mozRequestFileSystem,throw_outside=function(ex){(view.setImmediate||view.setTimeout)(function(){throw ex},0)},force_saveable_type="application/octet-stream",fs_min_size=0,arbitrary_revoke_timeout=500,revoke=function(file){var revoker=function(){if(typeof file==="string"){get_URL().revokeObjectURL(file)}else{file.remove()}};if(view.chrome){revoker()}else{setTimeout(revoker,arbitrary_revoke_timeout)}},dispatch=function(filesaver,event_types,event){event_types=[].concat(event_types);var i=event_types.length;while(i--){var listener=filesaver["on"+event_types[i]];if(typeof listener==="function"){try{listener.call(filesaver,event||filesaver)}catch(ex){throw_outside(ex)}}}},FileSaver=function(blob,name){var filesaver=this,type=blob.type,blob_changed=false,object_url,target_view,dispatch_all=function(){dispatch(filesaver,"writestart progress write writeend".split(" "))},fs_error=function(){if(blob_changed||!object_url){object_url=get_URL().createObjectURL(blob)}if(target_view){target_view.location.href=object_url}else{var new_tab=view.open(object_url,"_blank");if(new_tab==undefined&&typeof safari!=="undefined"){view.location.href=object_url}}filesaver.readyState=filesaver.DONE;dispatch_all();revoke(object_url)},abortable=function(func){return function(){if(filesaver.readyState!==filesaver.DONE){return func.apply(this,arguments)}}},create_if_not_found={create:true,exclusive:false},slice;filesaver.readyState=filesaver.INIT;if(!name){name="download"}if(can_use_save_link){object_url=get_URL().createObjectURL(blob);save_link.href=object_url;save_link.download=name;click(save_link);filesaver.readyState=filesaver.DONE;dispatch_all();revoke(object_url);return}if(view.chrome&&type&&type!==force_saveable_type){slice=blob.slice||blob.webkitSlice;blob=slice.call(blob,0,blob.size,force_saveable_type);blob_changed=true}if(webkit_req_fs&&name!=="download"){name+=".download"}if(type===force_saveable_type||webkit_req_fs){target_view=view}if(!req_fs){fs_error();return}fs_min_size+=blob.size;req_fs(view.TEMPORARY,fs_min_size,abortable(function(fs){fs.root.getDirectory("saved",create_if_not_found,abortable(function(dir){var save=function(){dir.getFile(name,create_if_not_found,abortable(function(file){file.createWriter(abortable(function(writer){writer.onwriteend=function(event){target_view.location.href=file.toURL();filesaver.readyState=filesaver.DONE;dispatch(filesaver,"writeend",event);revoke(file)};writer.onerror=function(){var error=writer.error;if(error.code!==error.ABORT_ERR){fs_error()}};"writestart progress write abort".split(" ").forEach(function(event){writer["on"+event]=filesaver["on"+event]});writer.write(blob);filesaver.abort=function(){writer.abort();filesaver.readyState=filesaver.DONE};filesaver.readyState=filesaver.WRITING}),fs_error)}),fs_error)};dir.getFile(name,{create:false},abortable(function(file){file.remove();save()}),abortable(function(ex){if(ex.code===ex.NOT_FOUND_ERR){save()}else{fs_error()}}))}),fs_error)}),fs_error)},FS_proto=FileSaver.prototype,saveAs=function(blob,name){return new FileSaver(blob,name)};FS_proto.abort=function(){var filesaver=this;filesaver.readyState=filesaver.DONE;dispatch(filesaver,"abort")};FS_proto.readyState=FS_proto.INIT=0;FS_proto.WRITING=1;FS_proto.DONE=2;FS_proto.error=FS_proto.onwritestart=FS_proto.onprogress=FS_proto.onwrite=FS_proto.onabort=FS_proto.onerror=FS_proto.onwriteend=null;return saveAs}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!=null){define([],function(){return saveAs})} diff --git a/Marlin/configurator/js/binaryfileuploader.js b/Marlin/configurator/js/binaryfileuploader.js deleted file mode 100644 index 0a1f38f3d..000000000 --- a/Marlin/configurator/js/binaryfileuploader.js +++ /dev/null @@ -1,79 +0,0 @@ -function BinaryFileUploader(o) { - this.options = null; - - - this._defaultOptions = { - element: null, // HTML file element - onFileLoad: function(file) { - console.log(file.toString()); - } - }; - - - this._init = function(o) { - if (!this.hasFileUploaderSupport()) return; - - this._verifyDependencies(); - - this.options = this._mergeObjects(this._defaultOptions, o); - this._verifyOptions(); - - this.addFileChangeListener(); - } - - - this.hasFileUploaderSupport = function() { - return !!(window.File && window.FileReader && window.FileList && window.Blob); - } - - this.addFileChangeListener = function() { - this.options.element.addEventListener( - 'change', - this._bind(this, this.onFileChange) - ); - } - - this.onFileChange = function(e) { - // TODO accept multiple files - var file = e.target.files[0], - reader = new FileReader(); - - reader.onload = this._bind(this, this.onFileLoad); - reader.readAsBinaryString(file); - } - - this.onFileLoad = function(e) { - var content = e.target.result, - string = new BinaryString(content); - this.options.onFileLoad(string); - } - - - this._mergeObjects = function(starting, override) { - var merged = starting; - for (key in override) merged[key] = override[key]; - - return merged; - } - - this._verifyOptions = function() { - if (!(this.options.element && this.options.element.type && this.options.element.type === 'file')) { - throw 'Invalid element param in options. Must be a file upload DOM element'; - } - - if (typeof this.options.onFileLoad !== 'function') { - throw 'Invalid onFileLoad param in options. Must be a function'; - } - } - - this._verifyDependencies = function() { - if (!window.BinaryString) throw 'BinaryString is missing. Check that you\'ve correctly included it'; - } - - // helper function for binding methods to objects - this._bind = function(object, method) { - return function() {return method.apply(object, arguments);}; - } - - this._init(o); -} diff --git a/Marlin/configurator/js/binarystring.js b/Marlin/configurator/js/binarystring.js deleted file mode 100644 index 06af64fe2..000000000 --- a/Marlin/configurator/js/binarystring.js +++ /dev/null @@ -1,168 +0,0 @@ -function BinaryString(source) { - this._source = null; - this._bytes = []; - this._pos = 0; - this._length = 0; - - this._init = function(source) { - this._source = source; - this._bytes = this._stringToBytes(this._source); - this._length = this._bytes.length; - } - - this.current = function() {return this._pos;} - - this.rewind = function() {return this.jump(0);} - this.end = function() {return this.jump(this.length() - 1);} - this.next = function() {return this.jump(this.current() + 1);} - this.prev = function() {return this.jump(this.current() - 1);} - - this.jump = function(pos) { - if (pos < 0 || pos >= this.length()) return false; - - this._pos = pos; - return true; - } - - this.readByte = function(pos) { - pos = (typeof pos == 'number') ? pos : this.current(); - return this.readBytes(1, pos)[0]; - } - - this.readBytes = function(length, pos) { - length = length || 1; - pos = (typeof pos == 'number') ? pos : this.current(); - - if (pos > this.length() || - pos < 0 || - length <= 0 || - pos + length > this.length() || - pos + length < 0 - ) { - return false; - } - - var bytes = []; - - for (var i = pos; i < pos + length; i++) { - bytes.push(this._bytes[i]); - } - - return bytes; - } - - this.length = function() {return this._length;} - - this.toString = function() { - var string = '', - length = this.length(); - - for (var i = 0; i < length; i++) { - string += String.fromCharCode(this.readByte(i)); - } - - return string; - } - - this.toUtf8 = function() { - var inc = 0, - string = '', - length = this.length(); - - // determine if first 3 characters are the BOM - // then skip them in output if so - if (length >= 3 && - this.readByte(0) === 0xEF && - this.readByte(1) === 0xBB && - this.readByte(2) === 0xBF - ) { - inc = 3; - } - - for (; inc < length; inc++) { - var byte1 = this.readByte(inc), - byte2 = 0, - byte3 = 0, - byte4 = 0, - code1 = 0, - code2 = 0, - point = 0; - - switch (true) { - // single byte character; same as ascii - case (byte1 < 0x80): - code1 = byte1; - break; - - // 2 byte character - case (byte1 >= 0xC2 && byte1 < 0xE0): - byte2 = this.readByte(++inc); - - code1 = ((byte1 & 0x1F) << 6) + - (byte2 & 0x3F); - break; - - // 3 byte character - case (byte1 >= 0xE0 && byte1 < 0xF0): - byte2 = this.readByte(++inc); - byte3 = this.readByte(++inc); - - code1 = ((byte1 & 0xFF) << 12) + - ((byte2 & 0x3F) << 6) + - (byte3 & 0x3F); - break; - - // 4 byte character - case (byte1 >= 0xF0 && byte1 < 0xF5): - byte2 = this.readByte(++inc); - byte3 = this.readByte(++inc); - byte4 = this.readByte(++inc); - - point = ((byte1 & 0x07) << 18) + - ((byte2 & 0x3F) << 12) + - ((byte3 & 0x3F) << 6) + - (byte4 & 0x3F) - point -= 0x10000; - - code1 = (point >> 10) + 0xD800; - code2 = (point & 0x3FF) + 0xDC00; - break; - - default: - throw 'Invalid byte ' + this._byteToString(byte1) + ' whilst converting to UTF-8'; - break; - } - - string += (code2) ? String.fromCharCode(code1, code2) - : String.fromCharCode(code1); - } - - return string; - } - - this.toArray = function() {return this.readBytes(this.length() - 1, 0);} - - - this._stringToBytes = function(str) { - var bytes = [], - chr = 0; - - for (var i = 0; i < str.length; i++) { - chr = str.charCodeAt(i); - bytes.push(chr & 0xFF); - } - - return bytes; - } - - this._byteToString = function(byte) { - var asString = byte.toString(16).toUpperCase(); - while (asString.length < 2) { - asString = '0' + asString; - } - - return '0x' + asString; - } - - this._init(source); -} diff --git a/Marlin/configurator/js/configurator.js b/Marlin/configurator/js/configurator.js deleted file mode 100644 index 1a0da92ab..000000000 --- a/Marlin/configurator/js/configurator.js +++ /dev/null @@ -1,1432 +0,0 @@ -/** - * configurator.js - * - * Marlin Configuration Utility - * - Web form for entering configuration options - * - A reprap calculator to calculate movement values - * - Uses HTML5 to generate downloadables in Javascript - * - Reads and parses standard configuration files from local folders - * - * Supporting functions - * - Parser to read Marlin Configuration.h and Configuration_adv.h files - * - Utilities to replace values in configuration files - */ - -"use strict"; - -$(function(){ - -/** - * Github API useful GET paths. (Start with "https://api.github.com/repos/:owner/:repo/") - * - * contributors Get a list of contributors - * tags Get a list of tags - * contents/[path]?ref=branch/tag/commit Get the contents of a file - */ - - // GitHub - // Warning! Limited to 60 requests per hour! -var config = { - type: 'github', - host: 'https://api.github.com', - owner: 'MarlinFirmware', - repo: 'Marlin', - ref: 'Development', - path: 'Marlin/configurator/config' -}; -/**/ - -/* // Remote -var config = { - type: 'remote', - host: 'http://www.thinkyhead.com', - path: '_marlin/config' -}; -/**/ - -/* // Local -var config = { - type: 'local', - path: 'config' -}; -/**/ - -function github_command(conf, command, path) { - var req = conf.host+'/repos/'+conf.owner+'/'+conf.repo+'/'+command; - if (path) req += '/' + path; - return req; -} -function config_path(item) { - var path = '', ref = ''; - switch(config.type) { - case 'github': - path = github_command(config, 'contents', config.path); - if (config.ref !== undefined) ref = '?ref=' + config.ref; - break; - case 'remote': - path = config.host + '/' + config.path + '/'; - break; - case 'local': - path = config.path + '/'; - break; - } - return path + '/' + item + ref; -} - -// Extend builtins -String.prototype.lpad = function(len, chr) { - if (chr === undefined) { chr = ' '; } - var s = this+'', need = len - s.length; - if (need > 0) { s = new Array(need+1).join(chr) + s; } - return s; -}; - -String.prototype.prePad = function(len, chr) { return len ? this.lpad(len, chr) : this; }; -String.prototype.zeroPad = function(len) { return this.prePad(len, '0'); }; -String.prototype.toHTML = function() { return jQuery('
').text(this).html(); }; -String.prototype.regEsc = function() { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); } -String.prototype.lineCount = function(ind) { var len = (ind === undefined ? this : this.substr(0,ind*1)).split(/\r?\n|\r/).length; return len > 0 ? len - 1 : 0; }; -String.prototype.line = function(num) { var arr = this.split(/\r?\n|\r/); return num < arr.length ? arr[1*num] : ''; }; -String.prototype.replaceLine = function(num,txt) { var arr = this.split(/\r?\n|\r/); if (num < arr.length) { arr[num] = txt; return arr.join('\n'); } else return this; } -String.prototype.toLabel = function() { return this.replace(/[\[\]]/g, '').replace(/_/g, ' ').toTitleCase(); } -String.prototype.toTitleCase = function() { return this.replace(/([A-Z])(\w+)/gi, function(m,p1,p2) { return p1.toUpperCase() + p2.toLowerCase(); }); } -Number.prototype.limit = function(m1, m2) { - if (m2 == null) return this > m1 ? m1 : this; - return this < m1 ? m1 : this > m2 ? m2 : this; -}; -Date.prototype.fileStamp = function(filename) { - var fs = this.getFullYear() - + ((this.getMonth()+1)+'').zeroPad(2) - + (this.getDate()+'').zeroPad(2) - + (this.getHours()+'').zeroPad(2) - + (this.getMinutes()+'').zeroPad(2) - + (this.getSeconds()+'').zeroPad(2); - - if (filename !== undefined) - return filename.replace(/^(.+)(\.\w+)$/g, '$1-['+fs+']$2'); - - return fs; -} - -/** - * selectField.addOptions takes an array or keyed object - */ -$.fn.extend({ - addOptions: function(arrObj) { - return this.each(function() { - var sel = $(this); - var isArr = Object.prototype.toString.call(arrObj) == "[object Array]"; - $.each(arrObj, function(k, v) { - sel.append( $('