Prusa3d Marlin fork
Classes | Enumerations | Functions | Variables
Marlin_main.cpp File Reference

Classes

class  AutoReportFeatures
 

Enumerations

enum  MeshLevelingState { MeshReport , MeshStart , MeshNext , MeshSet }
 

Functions

static void print_time_remaining_init ()
 
static void wait_for_heater (long codenum, uint8_t extruder)
 
static void gcode_G28 (bool home_x_axis, bool home_y_axis, bool home_z_axis)
 
static void gcode_M105 ()
 
static void temp_compensation_start ()
 
static void temp_compensation_apply ()
 
static uint8_t get_PRUSA_SN (char *SN)
 
void serial_echopair_P (const char *s_P, float v)
 
void serial_echopair_P (const char *s_P, double v)
 
void serial_echopair_P (const char *s_P, unsigned long v)
 
void serialprintPGM (const char *str)
 
void serialprintlnPGM (const char *str)
 
int freeMemory ()
 
void setup_killpin ()
 
void setup_homepin (void)
 
void setup_photpin ()
 
void setup_powerhold ()
 
void suicide ()
 
void servo_init ()
 
bool __attribute__ ((noinline)) printJobOngoing()
 
bool printingIsPaused ()
 
void debug_printer_states ()
 debug printer states More...
 
bool check_fsensor ()
 
void crashdet_stop_and_save_print ()
 
void crashdet_restore_print_and_continue ()
 
void crashdet_fmt_error (char *buf, uint8_t mask)
 
void crashdet_detected (uint8_t mask)
 
void crashdet_recover ()
 
void crashdet_cancel ()
 Crash detection cancels the print.
 
void failstats_reset_print ()
 
void watchdogEarlyDisable (void)
 
void softReset (void)
 
static void factory_reset_stats ()
 
static void factory_reset (char level)
 
int uart_putchar (char c, FILE *)
 
void lcd_splash ()
 
void factory_reset ()
 
void show_fw_version_warnings ()
 
static void check_if_fw_is_on_right_printer ()
 try to check if firmware is on right type of printer
 
uint8_t check_printer_version ()
 
void update_sec_lang_from_external_flash ()
 
uint8_t lang_xflash_enum_codes (uint16_t *codes)
 
void list_sec_lang_from_external_flash ()
 
static void fw_crash_init ()
 
static void fw_kill_init ()
 
static void xflash_err_msg ()
 
void setup ()
 
static void crash_and_burn (dump_crash_reason reason)
 
 ISR (WDT_vect)
 
 ISR (BADISR_vect)
 
void stack_error ()
 
void host_autoreport ()
 
void host_keepalive ()
 
void loop ()
 
 DEFINE_PGM_READ_ANY (float, float)
 
 DEFINE_PGM_READ_ANY (signed char, byte)
 
 XYZ_CONSTS_FROM_CONFIG (float, base_min_pos, MIN_POS)
 
 XYZ_CONSTS_FROM_CONFIG (float, base_max_pos, MAX_POS)
 
 XYZ_CONSTS_FROM_CONFIG (float, base_home_pos, HOME_POS)
 
 XYZ_CONSTS_FROM_CONFIG (float, max_length, MAX_LENGTH)
 
 XYZ_CONSTS_FROM_CONFIG (float, home_retract_mm, HOME_RETRACT_MM)
 
 XYZ_CONSTS_FROM_CONFIG (signed char, home_dir, HOME_DIR)
 
static void axis_is_at_home (uint8_t axis)
 
static int setup_for_endstop_move (bool enable_endstops_now=true)
 
static void clean_up_after_endstop_move (int original_feedmultiply)
 
static void set_bed_level_equation_lsq (double *plane_equation_coefficients)
 
static void set_bed_level_equation_3pts (float z_at_pt_1, float z_at_pt_2, float z_at_pt_3)
 
static void run_z_probe ()
 
static void do_blocking_move_to (float x, float y, float z)
 
static void do_blocking_move_relative (float offset_x, float offset_y, float offset_z)
 
static float probe_pt (float x, float y, float z_before)
 Probe bed height at position (x,y), returns the measured z value.
 
void gcode_M900 ()
 
bool check_commands ()
 
float raise_z (float delta)
 Safely move Z-axis by distance delta (mm) More...
 
void raise_z_above (float target)
 
bool calibrate_z_auto ()
 
void check_Z_crash (void)
 
void homeaxis (uint8_t axis, uint8_t cnt, uint8_t *pstep) void homeaxis(uint8_t axis
 
 if ((axis==X_AXIS)?HOMEAXIS_DO(X):(axis==Y_AXIS)?HOMEAXIS_DO(Y):0)
 
else if ((axis==Z_AXIS)?HOMEAXIS_DO(Z):0)
 
 enable_endstops (endstops_enabled)
 
void home_xy ()
 
void refresh_cmd_timeout (void)
 
void retract (bool retracting, bool swapretract=false)
 
void change_power_mode_live (uint8_t mode)
 
void force_high_power_mode (bool start_high_power_section)
 
static void gcode_G28 (bool home_x_axis, long home_x_value, bool home_y_axis, long home_y_value, bool home_z_axis, long home_z_value, bool calib, bool without_mbl) static void gcode_G28(bool home_x_axis
 
 SERIAL_ECHOPGM ("G28, initial ")
 
 print_world_coordinates ()
 
 print_physical_coordinates ()
 
 if (home_all_axes) home_x
 
plan_bed_level_matrix set_to_identity ()
 
 world2machine_revert_to_uncorrected ()
 Set calibration matrix to identity and update current position with absolute position. More...
 
 if (home_z) babystep_undo() = cs.zprobe_zoffset
 
 set_destination_to_current ()
 
 if (home_x &&home_y)
 
 if (home_x)
 
 if (home_y)
 
 if (home_x_axis &&home_x_value !=0) current_position[X_AXIS]
 
 if (home_y_axis &&home_y_value !=0) current_position[Y_AXIS]
 
 if (home_z_axis &&home_z_value !=0) current_position[Z_AXIS]
 
 plan_set_position_curposXYZE ()
 
 clean_up_after_endstop_move (l_feedmultiply)
 
 endstops_hit_on_purpose ()
 
 world2machine_initialize ()
 Read and apply validated calibration data from EEPROM.
 
 world2machine_update_current ()
 Update current position after switching to corrected coordinates. More...
 
 if (home_x_axis||home_y_axis||without_mbl||home_z_axis)
 
 prusa_statistics (20)
 
 st_synchronize ()
 
 SERIAL_ECHOPGM ("G28, final ")
 
 print_mesh_bed_leveling_table ()
 
static void gcode_G80 ()
 
static void gcode_G81_M420 ()
 

Variables

CardReader card
 
float default_retraction = DEFAULT_RETRACTION
 
uint8_t axis_relative_modes = 0
 
int feedmultiply =100
 
int extrudemultiply =100
 
bool homing_flag = false
 
bool did_pause_print
 
LongTimer safetyTimer
 
static LongTimer crashDetTimer
 
bool mesh_bed_leveling_flag = false
 
uint32_t total_filament_used
 
HeatingStatus heating_status
 
int fan_edge_counter [2]
 
int fan_speed [2]
 
float extruder_multiplier [EXTRUDERS]
 
float current_position [NUM_AXIS] = { 0.0, 0.0, 0.0, 0.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 }
 
bool axis_known_position [3] = {false, false, false}
 
static float pause_position [3] = { X_PAUSE_POS, Y_PAUSE_POS, Z_PAUSE_LIFT }
 
uint8_t fanSpeed = 0
 Print fan speed, ranges from 0 to 255.
 
uint8_t newFanSpeed = 0
 
bool retracted [EXTRUDERS]
 
bool retracted_swap [EXTRUDERS]
 
float retract_length_swap = RETRACT_LENGTH_SWAP
 
float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP
 
static bool temp_compensation_retracted = false
 
bool powersupply = false
 
static bool cancel_heatup = false
 
int8_t busy_state = NOT_BUSY
 
static long prev_busy_signal_ms = -1
 
static uint8_t host_keepalive_interval = HOST_KEEPALIVE_INTERVAL
 
const char errormagic[] PROGMEM = "Error:"
 
float saved_start_position [NUM_AXIS] = {SAVED_START_POSITION_UNSET, 0, 0, 0}
 
uint16_t saved_segment_idx = 0
 
bool isPartialBackupAvailable
 
uint8_t print_percent_done_normal = PRINT_PERCENT_DONE_INIT
 
uint8_t print_percent_done_silent = PRINT_PERCENT_DONE_INIT
 
uint16_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT
 
uint16_t print_time_remaining_silent = PRINT_TIME_REMAINING_INIT
 
uint16_t print_time_to_change_normal = PRINT_TIME_REMAINING_INIT
 
uint16_t print_time_to_change_silent = PRINT_TIME_REMAINING_INIT
 
uint32_t IP_address = 0
 
const char axis_codes [NUM_AXIS] = {'X', 'Y', 'Z', 'E'}
 
float destination [NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0}
 
static float offset [2] = {0.0, 0.0}
 
float feedrate = 1500.0
 
static float saved_feedrate
 
static LongTimer previous_millis_cmd
 
static uint32_t max_inactive_time = 0
 
static uint32_t stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l
 
static uint32_t safetytimer_inactive_time = DEFAULT_SAFETYTIMER_TIME_MINS*60*1000ul
 
ShortTimer usb_timer
 
bool Stopped =false
 
bool processing_tcode
 
Servo servos [NUM_SERVOS]
 
static bool target_direction
 
static uint32_t chdkHigh = 0
 
static bool chdkActive = false
 
static bool uvlo_auto_recovery_ready = false
 
static int saved_feedmultiply_mm = 100
 
uint8_t temp
 
uint8_t fans
 
uint8_t pos
 
uint8_t ar4
 
uint8_t ar5
 
uint8_t ar6
 
uint8_t ar7
 
AutoReportFeatures autoReportFeatures
 
static uint16_t gcode_in_progress = 0
 
static uint16_t mcode_in_progress = 0
 
 C
 
unsigned int __heap_start
 
void * __brkval
 
bool fans_check_enabled = true
 
static FILE _uartout
 
void uint8_t cnt
 
static void long home_x_value
 
static void long bool home_y_axis
 
static void long bool long home_y_value
 
static void long bool long bool home_z_axis
 
static void long bool long bool long home_z_value
 
static void long bool long bool long bool without_mbl
 
bool home_x = home_x_axis
 
bool home_y = home_y_axis
 
bool home_z = home_z_axis
 
bool home_all_axes = home_x == home_y && home_x == home_z
 
uint8_t mbl_was_active = mbl.active
 
mbl active = 0
 
int l_feedmultiply = setup_for_endstop_move()
 
RAM save/restore printing
bool saved_printing = false
 Print is paused and saved in RAM.
 
uint32_t saved_sdpos = 0
 SD card position, or line number in case of USB printing.
 
uint8_t saved_printing_type = PowerPanic::PRINT_TYPE_NONE
 
float saved_pos [NUM_AXIS] = { X_COORD_INVALID, 0, 0, 0 }
 
uint16_t saved_feedrate2 = 0
 Default feedrate (truncated from float)
 
static int saved_feedmultiply2 = 0
 
uint16_t saved_extruder_temperature
 Active extruder temperature.
 
uint8_t saved_bed_temperature
 Bed temperature.
 
bool saved_extruder_relative_mode
 
uint8_t saved_fan_speed = 0
 Print fan speed, ranges from 0 to 255. More...
 

Function Documentation

◆ check_fsensor()

bool check_fsensor ( )

Beware - mcode_in_progress is set as soon as the command gets really processed, which is not the same as posting the M600 command into the command queue There can be a considerable lag between posting M600 and its real processing which might result in posting multiple M600's into the command queue Instead, the fsensor uses another state variable :( , which is set to true, when the M600 command is enqued and is reset to false when the fsensor returns into its filament runout finished handler I'd normally change this macro, but who knows what would happen in the MMU :)

◆ clean_up_after_endstop_move()

static void clean_up_after_endstop_move ( int  original_feedmultiply)
static
Parameters
original_feedmultiplyfeedmultiply to restore

◆ debug_printer_states()

void debug_printer_states ( )

This outputs a lot over serial and should be only used

  • when debugging LCD menus
  • or other functions related to these states To reduce the output feel free to comment out the lines you aren't troubleshooting.

◆ gcode_M900()

void gcode_M900 ( )
inline

M900: Set and/or Get advance K factor

K<factor> Set advance K factor

◆ host_autoreport()

void host_autoreport ( )

Output autoreport values according to features requested in M155

◆ host_keepalive()

void host_keepalive ( )

Output a "busy" message at regular intervals while the machine is not accepting commands.

◆ raise_z()

float raise_z ( float  delta)
Parameters
deltatravel distance in mm
Returns
The actual travel distance in mm. Endstop may limit the requested move.

◆ setup_for_endstop_move()

static int setup_for_endstop_move ( bool  enable_endstops_now = true)
static
Returns
original feedmultiply

◆ world2machine_revert_to_uncorrected()

world2machine_revert_to_uncorrected ( )

Wait for the motors to stop and then update the current position with the absolute values.

◆ world2machine_update_current()

world2machine_update_current ( )

When switching from absolute to corrected coordinates, this will get the absolute coordinates from the servos, applies the inverse world2machine transformation and stores the result into current_position[x,y].

Variable Documentation

◆ C

C
extern
Initial value:
{
extern unsigned int __bss_end

◆ cnt

void uint8_t cnt
Initial value:
{
bool endstops_enabled = enable_endstops(true)

◆ extruder_multiplier

float extruder_multiplier[EXTRUDERS]
Initial value:
= {1.0
#if EXTRUDERS > 1
, 1.0
#if EXTRUDERS > 2
, 1.0
#endif
#endif
}

◆ retracted

bool retracted[EXTRUDERS]
Initial value:
={false
#if EXTRUDERS > 1
, false
#if EXTRUDERS > 2
, false
#endif
#endif
}

◆ retracted_swap

bool retracted_swap[EXTRUDERS]
Initial value:
={false
#if EXTRUDERS > 1
, false
#if EXTRUDERS > 2
, false
#endif
#endif
}

◆ saved_fan_speed

uint8_t saved_fan_speed = 0

Print fan speed

◆ without_mbl

void long bool long bool long bool without_mbl
Initial value:
{
st_synchronize()