Skip to content
Snippets Groups Projects
Marlin.cpp 28.9 KiB
Newer Older
  • Learn to ignore specific revisions
  •   #if ENABLED(COOLANT_MIST)
        OUT_WRITE(COOLANT_MIST_PIN, COOLANT_MIST_INVERT);   // Init Mist Coolant OFF
      #endif
      #if ENABLED(COOLANT_FLOOD)
        OUT_WRITE(COOLANT_FLOOD_PIN, COOLANT_FLOOD_INVERT); // Init Flood Coolant OFF
      #endif
    
    
      #if HAS_BED_PROBE
        endstops.enable_z_probe(false);
      #endif
    
    
      #if ENABLED(USE_CONTROLLER_FAN)
    
    Scott Lahteine's avatar
    Scott Lahteine committed
        SET_OUTPUT(CONTROLLER_FAN_PIN);
    
      #endif
    
      #if HAS_STEPPER_RESET
        enableStepperDrivers();
      #endif
    
      #if ENABLED(DIGIPOT_I2C)
        digipot_i2c_init();
      #endif
    
      #if ENABLED(DAC_STEPPER_CURRENT)
        dac_init();
      #endif
    
    
      #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
    
    Scott Lahteine's avatar
    Scott Lahteine committed
        OUT_WRITE(SOL1_PIN, LOW); // OFF
    
    Scott Lahteine's avatar
    Scott Lahteine committed
      #if HAS_HOME
        SET_INPUT_PULLUP(HOME_PIN);
      #endif
    
    Scott Lahteine's avatar
    Scott Lahteine committed
      #if PIN_EXISTS(STAT_LED_RED)
    
    Scott Lahteine's avatar
    Scott Lahteine committed
        OUT_WRITE(STAT_LED_RED_PIN, LOW); // OFF
    
    Scott Lahteine's avatar
    Scott Lahteine committed
      #if PIN_EXISTS(STAT_LED_BLUE)
    
    Scott Lahteine's avatar
    Scott Lahteine committed
        OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF
    
      #if HAS_COLOR_LEDS
        leds.setup();
    
      #if HAS_CASE_LIGHT
    
        #if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
    
          if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
    
        update_case_light();
      #endif
    
    
      #if ENABLED(MK2_MULTIPLEXER)
        SET_OUTPUT(E_MUX0_PIN);
        SET_OUTPUT(E_MUX1_PIN);
        SET_OUTPUT(E_MUX2_PIN);
      #endif
    
      #if HAS_FANMUX
        fanmux_init();
      #endif
    
      #if ENABLED(MIXING_EXTRUDER)
        mixer.init();
    
      #if ENABLED(BLTOUCH)
    
        bltouch.init(/*set_voltage=*/true);
    
      #if ENABLED(I2C_POSITION_ENCODERS)
        I2CPEM.init();
      #endif
    
    
      #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
        i2c.onReceive(i2c_on_receive);
        i2c.onRequest(i2c_on_request);
      #endif
    
    GMagician's avatar
    GMagician committed
      #if DO_SWITCH_EXTRUDER
    
        move_extruder_servo(0);   // Initialize extruder servo
    
        // Initialize nozzle servo(s)
        #if SWITCHING_NOZZLE_TWO_SERVOS
          lower_nozzle(0);
          raise_nozzle(1);
        #else
          move_nozzle_servo(0);
        #endif
    
      #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
        mpe_settings_init();
      #endif
    
    
      #if ENABLED(PARKING_EXTRUDER)
    
        pe_solenoid_init();
    
      #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
        est_init();
      #endif
    
    
      #if ENABLED(POWER_LOSS_RECOVERY)
    
        recovery.check();
    
      #if ENABLED(USE_WATCHDOG)
        watchdog_init();          // Reinit watchdog after HAL_get_reset_source call
    
    
      #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
        init_closedloop();
      #endif
    
      #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
        card.beginautostart();
    
    
      #if HAS_TRINAMIC && DISABLED(PS_DEFAULT_OFF)
        test_tmc_connection(true, true, true, true);
      #endif
    
    revilor's avatar
    revilor committed
    
      #if ENABLED(PRUSA_MMU2)
        mmu2.init();
      #endif
    
    }
    
    /**
     * The main Marlin program loop
     *
     *  - Save or log commands to SD
     *  - Process available commands (if not saving)
     *  - Call endstop manager
    
     *  - Call inactivity manager
    
        idle(); // Do an idle first so boot is slightly faster
    
    
        #if ENABLED(SDSUPPORT)
    
          card.checkautostart();
    
          if (card.flag.abort_sd_printing) {
    
            card.stopSDPrint(
              #if SD_RESORT
                true
              #endif
            );
    
            quickstop_stepper();
            print_job_timer.stop();
    
            #if DISABLED(SD_ABORT_NO_COOLDOWN)
              thermalManager.disable_all_heaters();
            #endif
    
            wait_for_heatup = false;
    
            #if ENABLED(POWER_LOSS_RECOVERY)
              card.removeJobRecoveryFile();
            #endif
    
            #ifdef EVENT_GCODE_SD_STOP
    
              queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));
    
    Scott Lahteine's avatar
    Scott Lahteine committed
            #endif
    
        #endif // SDSUPPORT
    
        if (queue.length < BUFSIZE) queue.get_available_commands();
        queue.advance();
    
        endstops.event_handler();