MMU2 - removed conditional translation for SNMM_V2, new module mmu

This commit is contained in:
Robert Pelnar 2018-08-02 18:54:00 +02:00
parent 282ff6c577
commit 468873ec68
5 changed files with 673 additions and 632 deletions

View file

@ -121,6 +121,8 @@
#include <SPI.h> #include <SPI.h>
#endif #endif
#include "mmu.h"
#define VERSION_STRING "1.0.2" #define VERSION_STRING "1.0.2"
@ -296,11 +298,7 @@ unsigned long NcTime;
#define DEFAULT_RETRACTION 1 #define DEFAULT_RETRACTION 1
#define DEFAULT_RETRACTION_MM 4 //MM #define DEFAULT_RETRACTION_MM 4 //MM
#ifdef SNMM_V2
float default_retraction = DEFAULT_RETRACTION; float default_retraction = DEFAULT_RETRACTION;
#else //SNMM_V2
float default_retraction = DEFAULT_RETRACTION_MM;
#endif //SNMM_V2
float homing_feedrate[] = HOMING_FEEDRATE; float homing_feedrate[] = HOMING_FEEDRATE;
@ -3127,29 +3125,25 @@ void gcode_M600(bool automatic, float x_position, float y_position, float z_shif
lcd_change_fil_state = 0; lcd_change_fil_state = 0;
// Unload filament // Unload filament
#if defined (SNMM) || defined (SNMM_V2) if (mmu_enabled)
extr_unload(); //unload just current filament for multimaterial printers (used also in M702) extr_unload(); //unload just current filament for multimaterial printers (used also in M702)
#else else
unload_filament(); //unload filament for single material (used also in M702) unload_filament(); //unload filament for single material (used also in M702)
#endif
//finish moves //finish moves
st_synchronize(); st_synchronize();
if (!mmu_enabled)
#if !defined(SNMM_V2) && !defined(SNMM) {
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
lcd_change_fil_state = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Was filament unload successful?"), false, true);////MSG_UNLOAD_SUCCESSFUL c=20 r=2 lcd_change_fil_state = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Was filament unload successful?"), false, true);////MSG_UNLOAD_SUCCESSFUL c=20 r=2
if (lcd_change_fil_state == 0) lcd_show_fullscreen_message_and_wait_P(_i("Please open idler and remove filament manually."));////MSG_CHECK_IDLER c=20 r=4 if (lcd_change_fil_state == 0) lcd_show_fullscreen_message_and_wait_P(_i("Please open idler and remove filament manually."));////MSG_CHECK_IDLER c=20 r=4
lcd_update_enable(true); lcd_update_enable(true);
}
#endif
#ifdef SNMM_V2 if (mmu_enabled)
mmu_M600_load_filament(automatic); mmu_M600_load_filament(automatic);
#else else
M600_load_filament(); M600_load_filament();
#endif
if(!automatic) M600_check_state(); if(!automatic) M600_check_state();
@ -3197,70 +3191,70 @@ void gcode_M701()
{ {
printf_P(PSTR("gcode_M701 begin\n")); printf_P(PSTR("gcode_M701 begin\n"));
#if defined (SNMM) || defined (SNMM_V2) if (mmu_enabled)
extr_adj(snmm_extruder);//loads current extruder extr_adj(snmm_extruder);//loads current extruder
#else //defined (SNMM) || defined (SNMM_V2) else
enable_z(); {
custom_message = true; enable_z();
custom_message_type = 2; custom_message = true;
custom_message_type = 2;
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
fsensor_oq_meassure_start(40); fsensor_oq_meassure_start(40);
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT)); lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
current_position[E_AXIS] += 40; current_position[E_AXIS] += 40;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence
st_synchronize(); st_synchronize();
if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30; if (current_position[Z_AXIS] < 20) current_position[Z_AXIS] += 30;
current_position[E_AXIS] += 30; current_position[E_AXIS] += 30;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400 / 60, active_extruder); //fast sequence
st_synchronize(); st_synchronize();
current_position[E_AXIS] += 25; current_position[E_AXIS] += 25;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence
st_synchronize(); st_synchronize();
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) tone(BEEPER, 500);
tone(BEEPER, 500); delay_keep_alive(50);
delay_keep_alive(50); noTone(BEEPER);
noTone(BEEPER);
if (!farm_mode && loading_flag) { if (!farm_mode && loading_flag) {
bool clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true); bool clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true);
while (!clean) { while (!clean) {
lcd_update_enable(true); lcd_update_enable(true);
lcd_update(2); lcd_update(2);
current_position[E_AXIS] += 25; current_position[E_AXIS] += 25;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 100 / 60, active_extruder); //slow sequence
st_synchronize(); st_synchronize();
clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true); clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, true);
}
} }
}
lcd_update_enable(true);
lcd_update(2);
lcd_setstatuspgm(_T(WELCOME_MSG));
disable_z();
loading_flag = false;
custom_message = false;
custom_message_type = 0;
#ifdef FILAMENT_SENSOR
fsensor_oq_meassure_stop();
if (!fsensor_oq_result())
{
bool disable = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Fil. sensor response is poor, disable it?"), false, true);
lcd_update_enable(true); lcd_update_enable(true);
lcd_update(2); lcd_update(2);
if (disable) lcd_setstatuspgm(_T(WELCOME_MSG));
fsensor_disable(); disable_z();
} loading_flag = false;
custom_message = false;
custom_message_type = 0;
#ifdef FILAMENT_SENSOR
fsensor_oq_meassure_stop();
if (!fsensor_oq_result())
{
bool disable = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Fil. sensor response is poor, disable it?"), false, true);
lcd_update_enable(true);
lcd_update(2);
if (disable)
fsensor_disable();
}
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
#endif //defined (SNMM) || defined (SNMM_V2) }
} }
/** /**
* @brief Get serial number from 32U2 processor * @brief Get serial number from 32U2 processor
@ -6466,11 +6460,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
#endif #endif
} }
#ifdef SNMM_V2 if (mmu_enabled && code_seen("AUTO"))
if (code_seen("AUTO")) {
automatic = true; automatic = true;
}
#endif //SNMM_V2
gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late); gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late);
@ -6774,32 +6765,24 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
break; break;
case 701: //M701: load filament case 701: //M701: load filament
{ {
#ifdef SNMM_V2 if (mmu_enabled && code_seen('E'))
if (code_seen('E'))
{
snmm_extruder = code_value(); snmm_extruder = code_value();
}
#endif
gcode_M701(); gcode_M701();
} }
break; break;
case 702: case 702:
{ {
#if defined (SNMM) || defined (SNMM_V2) if (mmu_enabled)
if (code_seen('U')) { {
extr_unload_used(); //unload all filaments which were used in current print if (code_seen('U'))
extr_unload_used(); //unload all filaments which were used in current print
else if (code_seen('C'))
extr_unload(); //unload just current filament
else
extr_unload_all(); //unload all filaments
} }
else if (code_seen('C')) { else
extr_unload(); //unload just current filament unload_filament();
}
else {
extr_unload_all(); //unload all filaments
}
#else
unload_filament();
#endif
} }
break; break;
@ -6835,7 +6818,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
} }
snmm_filaments_used |= (1 << tmp_extruder); //for stop print snmm_filaments_used |= (1 << tmp_extruder); //for stop print
#if defined (SNMM_V2) if (mmu_enabled)
{
printf_P(PSTR("T code: %d \n"), tmp_extruder); printf_P(PSTR("T code: %d \n"), tmp_extruder);
fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder);
@ -6843,17 +6827,17 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
snmm_extruder = tmp_extruder; //filament change is finished snmm_extruder = tmp_extruder; //filament change is finished
if (*(strchr_pointer + index) == '?') { // for single material usage with mmu if (*(strchr_pointer + index) == '?')// for single material usage with mmu
mmu_load_to_nozzle(); mmu_load_to_nozzle();
}
else
{
#ifdef SNMM
} #ifdef LIN_ADVANCE
#elif defined(SNMM)
#ifdef LIN_ADVANCE
if (snmm_extruder != tmp_extruder) if (snmm_extruder != tmp_extruder)
clear_current_adv_vars(); //Check if the selected extruder is not the active one and reset LIN_ADVANCE variables if so. clear_current_adv_vars(); //Check if the selected extruder is not the active one and reset LIN_ADVANCE variables if so.
#endif #endif
snmm_extruder = tmp_extruder; snmm_extruder = tmp_extruder;
@ -6895,7 +6879,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
} }
delay(100); delay(100);
#else //SNMM and SNMM_V2 undefined: #else //SNMM
if (tmp_extruder >= EXTRUDERS) { if (tmp_extruder >= EXTRUDERS) {
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPGM("T"); SERIAL_ECHOPGM("T");
@ -6940,7 +6924,8 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
SERIAL_PROTOCOLLN((int)active_extruder); SERIAL_PROTOCOLLN((int)active_extruder);
} }
#endif #endif //SNMM
}
} }
} // end if(code_seen('T')) (end of T codes) } // end if(code_seen('T')) (end of T codes)
@ -9004,11 +8989,10 @@ void M600_check_state() {
switch(lcd_change_fil_state){ switch(lcd_change_fil_state){
// Filament failed to load so load it again // Filament failed to load so load it again
case 2: case 2:
#ifdef SNMM_V2 if (mmu_enabled)
mmu_M600_load_filament(false); //nonautomatic load; change to "wrong filament loaded" option? mmu_M600_load_filament(false); //nonautomatic load; change to "wrong filament loaded" option?
#else else
M600_load_filament_movements(); M600_load_filament_movements();
#endif
break; break;
// Filament loaded properly but color is not clear // Filament loaded properly but color is not clear
@ -9111,63 +9095,61 @@ void M600_wait_for_user() {
WRITE(BEEPER, LOW); WRITE(BEEPER, LOW);
} }
void mmu_M600_load_filament(bool automatic) { void mmu_M600_load_filament(bool automatic)
{
//load filament for mmu v2 //load filament for mmu v2
#ifdef SNMM_V2 bool response = false;
bool response = false; bool yes = false;
bool yes = false; if (!automatic)
if (!automatic) { {
yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false); yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
if(yes) tmp_extruder = choose_extruder_menu(); if (yes) tmp_extruder = choose_extruder_menu();
else tmp_extruder = snmm_extruder; else tmp_extruder = snmm_extruder;
}
} else
else { {
tmp_extruder = (tmp_extruder+1)%5; tmp_extruder = (tmp_extruder+1)%5;
} }
lcd_update_enable(false); lcd_update_enable(false);
lcd_clear(); lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT)); lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
lcd_print(" "); lcd_print(" ");
lcd_print(tmp_extruder + 1); lcd_print(tmp_extruder + 1);
snmm_filaments_used |= (1 << tmp_extruder); //for stop print snmm_filaments_used |= (1 << tmp_extruder); //for stop print
printf_P(PSTR("T code: %d \n"), tmp_extruder); printf_P(PSTR("T code: %d \n"), tmp_extruder);
fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder);
manage_response();
manage_response(); snmm_extruder = tmp_extruder; //filament change is finished
snmm_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle();
mmu_load_to_nozzle();
#endif
} }
void M600_load_filament_movements() { void M600_load_filament_movements()
{
#ifdef SNMM #ifdef SNMM
display_loading(); display_loading();
do { do
current_position[E_AXIS] += 0.002; {
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder); current_position[E_AXIS] += 0.002;
delay_keep_alive(2); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
} while (!lcd_clicked()); delay_keep_alive(2);
}
st_synchronize(); while (!lcd_clicked());
current_position[E_AXIS] += bowden_length[snmm_extruder]; st_synchronize();
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000, active_extruder); current_position[E_AXIS] += bowden_length[snmm_extruder];
current_position[E_AXIS] += FIL_LOAD_LENGTH - 60; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000, active_extruder);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1400, active_extruder); current_position[E_AXIS] += FIL_LOAD_LENGTH - 60;
current_position[E_AXIS] += 40; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 1400, active_extruder);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder); current_position[E_AXIS] += 40;
current_position[E_AXIS] += 10; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 400, active_extruder);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder); current_position[E_AXIS] += 10;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
#else #else
current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTFEED ; current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTFEED ;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EFEED, active_extruder);
#endif #endif
current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ; current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder);
lcd_loading_filament();
lcd_loading_filament();
} }
void M600_load_filament() { void M600_load_filament() {

423
Firmware/mmu.cpp Normal file
View file

@ -0,0 +1,423 @@
//mmu.cpp
#include "mmu.h"
#include "planner.h"
#include "language.h"
#include "lcd.h"
#include "uart2.h"
#include "temperature.h"
#include "Configuration_prusa.h"
extern const char* lcd_display_message_fullscreen_P(const char *msg);
extern void lcd_return_to_status();
#ifdef SNMM_V2
bool mmu_enabled = true;
#else //SNMM_V2
bool mmu_enabled = false;
#endif //SNMM_V2
uint8_t snmm_extruder = 0;
void extr_mov(float shift, float feed_rate)
{ //move extruder no matter what the current heater temperature is
set_extrude_min_temp(.0);
current_position[E_AXIS] += shift;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder);
set_extrude_min_temp(EXTRUDE_MINTEMP);
}
void change_extr(int extr) { //switches multiplexer for extruders
#ifdef SNMM
st_synchronize();
delay(100);
disable_e0();
disable_e1();
disable_e2();
snmm_extruder = extr;
pinMode(E_MUX0_PIN, OUTPUT);
pinMode(E_MUX1_PIN, OUTPUT);
switch (extr) {
case 1:
WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, LOW);
break;
case 2:
WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, HIGH);
break;
case 3:
WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, HIGH);
break;
default:
WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, LOW);
break;
}
delay(100);
#endif
}
int get_ext_nr()
{ //reads multiplexer input pins and return current extruder number (counted from 0)
#ifndef SNMM
return(snmm_extruder); //update needed
#else
return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
#endif
}
void display_loading()
{
switch (snmm_extruder)
{
case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
}
}
void extr_adj(int extruder) //loading filament for SNMM
{
#ifndef SNMM
printf_P(PSTR("L%d \n"),extruder);
fprintf_P(uart2io, PSTR("L%d\n"), extruder);
//show which filament is currently loaded
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
//if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1);
//else lcd.print(" ");
lcd_print(" ");
lcd_print(snmm_extruder + 1);
// get response
manage_response();
lcd_update_enable(true);
//lcd_return_to_status();
#else
bool correct;
max_feedrate[E_AXIS] =80;
//max_feedrate[E_AXIS] = 50;
START:
lcd_clear();
lcd_set_cursor(0, 0);
switch (extruder) {
case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
}
KEEPALIVE_STATE(PAUSED_FOR_USER);
do{
extr_mov(0.001,1000);
delay_keep_alive(2);
} while (!lcd_clicked());
//delay_keep_alive(500);
KEEPALIVE_STATE(IN_HANDLER);
st_synchronize();
//correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false);
//if (!correct) goto START;
//extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max)
//extr_mov(BOWDEN_LENGTH/2.f, 500);
extr_mov(bowden_length[extruder], 500);
lcd_clear();
lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1);
else lcd_print(" ");
lcd_print(snmm_extruder + 1);
lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
st_synchronize();
max_feedrate[E_AXIS] = 50;
lcd_update_enable(true);
lcd_return_to_status();
lcdDrawUpdate = 2;
#endif
}
void extr_unload()
{ //unload just current filament for multimaterial printers
#ifdef SNMM
float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
#endif
if (degHotend0() > EXTRUDE_MINTEMP)
{
#ifndef SNMM
st_synchronize();
//show which filament is currently unloaded
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
lcd_print(" ");
lcd_print(snmm_extruder + 1);
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
printf_P(PSTR("U0\n"));
fprintf_P(uart2io, PSTR("U0\n"));
// get response
manage_response();
lcd_update_enable(true);
#else //SNMM
lcd_clear();
lcd_display_message_fullscreen_P(PSTR(""));
max_feedrate[E_AXIS] = 50;
lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
lcd_print(" ");
lcd_print(snmm_extruder + 1);
lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
if (current_position[Z_AXIS] < 15) {
current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder);
}
current_position[E_AXIS] += 10; //extrusion
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder);
st_current_set(2, E_MOTOR_HIGH_CURRENT);
if (current_temperature[0] < 230) { //PLA & all other filaments
current_position[E_AXIS] += 5.4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
current_position[E_AXIS] += 3.2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
current_position[E_AXIS] += 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
}
else { //ABS
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
current_position[E_AXIS] += 4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
/*current_position[X_AXIS] += 23; //delay
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay
current_position[X_AXIS] -= 23; //delay
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/
delay_keep_alive(4700);
}
max_feedrate[E_AXIS] = 80;
current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
st_synchronize();
//st_current_init();
if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
else st_current_set(2, tmp_motor_loud[2]);
lcd_update_enable(true);
lcd_return_to_status();
max_feedrate[E_AXIS] = 50;
#endif //SNMM
}
else
{
lcd_clear();
lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR));
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
delay(2000);
lcd_clear();
}
//lcd_return_to_status();
}
//wrapper functions for loading filament
void extr_adj_0()
{
#ifndef SNMM
enquecommand_P(PSTR("M701 E0"));
#else
change_extr(0);
extr_adj(0);
#endif
}
void extr_adj_1()
{
#ifndef SNMM
enquecommand_P(PSTR("M701 E1"));
#else
change_extr(1);
extr_adj(1);
#endif
}
void extr_adj_2()
{
#ifndef SNMM
enquecommand_P(PSTR("M701 E2"));
#else
change_extr(2);
extr_adj(2);
#endif
}
void extr_adj_3()
{
#ifndef SNMM
enquecommand_P(PSTR("M701 E3"));
#else
change_extr(3);
extr_adj(3);
#endif
}
void extr_adj_4()
{
#ifndef SNMM
enquecommand_P(PSTR("M701 E4"));
#else
change_extr(4);
extr_adj(4);
#endif
}
void load_all()
{
#ifndef SNMM
enquecommand_P(PSTR("M701 E0"));
enquecommand_P(PSTR("M701 E1"));
enquecommand_P(PSTR("M701 E2"));
enquecommand_P(PSTR("M701 E3"));
enquecommand_P(PSTR("M701 E4"));
#else
for (int i = 0; i < 4; i++)
{
change_extr(i);
extr_adj(i);
}
#endif
}
//wrapper functions for changing extruders
void extr_change_0()
{
change_extr(0);
lcd_return_to_status();
}
void extr_change_1()
{
change_extr(1);
lcd_return_to_status();
}
void extr_change_2()
{
change_extr(2);
lcd_return_to_status();
}
void extr_change_3()
{
change_extr(3);
lcd_return_to_status();
}
//wrapper functions for unloading filament
void extr_unload_all()
{
if (degHotend0() > EXTRUDE_MINTEMP)
{
for (int i = 0; i < 4; i++)
{
change_extr(i);
extr_unload();
}
}
else
{
lcd_clear();
lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR));
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
delay(2000);
lcd_clear();
lcd_return_to_status();
}
}
//unloading just used filament (for snmm)
void extr_unload_used()
{
if (degHotend0() > EXTRUDE_MINTEMP) {
for (int i = 0; i < 4; i++) {
if (snmm_filaments_used & (1 << i)) {
change_extr(i);
extr_unload();
}
}
snmm_filaments_used = 0;
}
else {
lcd_clear();
lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR));
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
delay(2000);
lcd_clear();
lcd_return_to_status();
}
}
void extr_unload_0()
{
change_extr(0);
extr_unload();
}
void extr_unload_1()
{
change_extr(1);
extr_unload();
}
void extr_unload_2()
{
change_extr(2);
extr_unload();
}
void extr_unload_3()
{
change_extr(3);
extr_unload();
}
void extr_unload_4()
{
change_extr(4);
extr_unload();
}

30
Firmware/mmu.h Normal file
View file

@ -0,0 +1,30 @@
//mmu.h
#include <inttypes.h>
extern bool mmu_enabled;
extern uint8_t snmm_extruder;
extern void extr_mov(float shift, float feed_rate);
extern void change_extr(int extr);
extern int get_ext_nr();
extern void display_loading();
extern void extr_adj(int extruder);
extern void extr_unload();
extern void extr_adj_0();
extern void extr_adj_1();
extern void extr_adj_2();
extern void extr_adj_3();
extern void extr_adj_4();
extern void load_all();
extern void extr_change_0();
extern void extr_change_1();
extern void extr_change_2();
extern void extr_change_3();
extern void extr_unload_all();
extern void extr_unload_used();
extern void extr_unload_0();
extern void extr_unload_1();
extern void extr_unload_2();
extern void extr_unload_3();
extern void extr_unload_4();

View file

@ -33,10 +33,9 @@
#include "sound.h" #include "sound.h"
#ifdef SNMM_V2
#include "uart2.h" #include "uart2.h"
#endif //SNMM_V2
#include "mmu.h"
extern int lcd_change_fil_state; extern int lcd_change_fil_state;
extern bool fans_check_enabled; extern bool fans_check_enabled;
@ -73,9 +72,6 @@ extern void crashdet_disable();
#endif //TMC2130 #endif //TMC2130
#if defined (SNMM) || defined (SNMM_V2)
uint8_t snmm_extruder = 0;
#endif
#ifdef SDCARD_SORT_ALPHA #ifdef SDCARD_SORT_ALPHA
bool presort_flag = false; bool presort_flag = false;
@ -166,17 +162,8 @@ static bool lcd_selftest_fan_dialog(int _fan);
static bool lcd_selftest_fsensor(); static bool lcd_selftest_fsensor();
static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2);
static void lcd_colorprint_change(); static void lcd_colorprint_change();
static int get_ext_nr();
static void extr_adj_0();
static void extr_adj_1();
static void extr_adj_2();
static void extr_adj_3();
static void fil_load_menu(); static void fil_load_menu();
static void fil_unload_menu(); static void fil_unload_menu();
static void extr_unload_0();
static void extr_unload_1();
static void extr_unload_2();
static void extr_unload_3();
static void lcd_disable_farm_mode(); static void lcd_disable_farm_mode();
static void lcd_set_fan_check(); static void lcd_set_fan_check();
static char snmm_stop_print_menu(); static char snmm_stop_print_menu();
@ -1431,9 +1418,8 @@ void lcd_commands()
enquecommand_P(PSTR("M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP))); enquecommand_P(PSTR("M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP)));
enquecommand_P(PSTR("M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP))); enquecommand_P(PSTR("M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP)));
enquecommand_P(_T(MSG_M117_V2_CALIBRATION)); enquecommand_P(_T(MSG_M117_V2_CALIBRATION));
#ifdef SNMM_V2 if (mmu_enabled)
enquecommand_P(PSTR("T?")); enquecommand_P(PSTR("T?"));
#endif //SNMM_V2
enquecommand_P(PSTR("G28")); enquecommand_P(PSTR("G28"));
enquecommand_P(PSTR("G92 E0.0")); enquecommand_P(PSTR("G92 E0.0"));
lcd_commands_step = 8; lcd_commands_step = 8;
@ -1625,11 +1611,10 @@ void lcd_commands()
{ {
lcd_timeoutToStatus.start(); lcd_timeoutToStatus.start();
enquecommand_P(PSTR("M107")); //turn off printer fan enquecommand_P(PSTR("M107")); //turn off printer fan
#ifdef SNMM_V2 if (mmu_enabled)
enquecommand_P(PSTR("M702 C")); enquecommand_P(PSTR("M702 C"));
#else //SNMM_V2 else
enquecommand_P(PSTR("G1 E-0.07500 F2100.00000")); enquecommand_P(PSTR("G1 E-0.07500 F2100.00000"));
#endif //SNMM_V2
enquecommand_P(PSTR("M104 S0")); // turn off temperature enquecommand_P(PSTR("M104 S0")); // turn off temperature
enquecommand_P(PSTR("M140 S0")); // turn off heatbed enquecommand_P(PSTR("M140 S0")); // turn off heatbed
enquecommand_P(PSTR("G1 Z10 F1300.000")); enquecommand_P(PSTR("G1 Z10 F1300.000"));
@ -1701,11 +1686,10 @@ void lcd_commands()
enquecommand_P(PSTR("G1 X50 Y" STRINGIFY(Y_MAX_POS) " E0 F7000")); enquecommand_P(PSTR("G1 X50 Y" STRINGIFY(Y_MAX_POS) " E0 F7000"));
#endif #endif
lcd_ignore_click(false); lcd_ignore_click(false);
#if defined (SNMM) || defined (SNMM_V2) if (mmu_enabled)
lcd_commands_step = 8; lcd_commands_step = 8;
#else else
lcd_commands_step = 3; lcd_commands_step = 3;
#endif
} }
if (lcd_commands_step == 5 && !blocks_queued()) if (lcd_commands_step == 5 && !blocks_queued())
{ {
@ -1722,25 +1706,25 @@ void lcd_commands()
lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); lcd_setstatuspgm(_T(MSG_PRINT_ABORTED));
cancel_heatup = true; cancel_heatup = true;
setTargetBed(0); setTargetBed(0);
#if !(defined (SNMM) || defined (SNMM_V2)) if (mmu_enabled)
setAllTargetHotends(0); setAllTargetHotends(0);
#endif
manage_heater(); manage_heater();
custom_message = true; custom_message = true;
custom_message_type = 2; custom_message_type = 2;
lcd_commands_step = 5; lcd_commands_step = 5;
} }
if (lcd_commands_step == 7 && !blocks_queued()) { if (lcd_commands_step == 7 && !blocks_queued())
#ifdef SNMM_V2 {
enquecommand_P(PSTR("M702 C")); //current if (mmu_enabled)
#else //SNMM_V2 enquecommand_P(PSTR("M702 C")); //current
switch(snmm_stop_print_menu()) { else
switch(snmm_stop_print_menu())
{
case 0: enquecommand_P(PSTR("M702")); break;//all case 0: enquecommand_P(PSTR("M702")); break;//all
case 1: enquecommand_P(PSTR("M702 U")); break; //used case 1: enquecommand_P(PSTR("M702 U")); break; //used
case 2: enquecommand_P(PSTR("M702 C")); break; //current case 2: enquecommand_P(PSTR("M702 C")); break; //current
default: enquecommand_P(PSTR("M702")); break; default: enquecommand_P(PSTR("M702")); break;
} }
#endif //SNMM_V2
lcd_commands_step = 3; lcd_commands_step = 3;
} }
if (lcd_commands_step == 8 && !blocks_queued()) { //step 8 is here for delay (going to next step after execution of all gcodes from step 4) if (lcd_commands_step == 8 && !blocks_queued()) { //step 8 is here for delay (going to next step after execution of all gcodes from step 4)
@ -1851,7 +1835,7 @@ static float count_e(float layer_heigth, float extrusion_width, float extrusion_
return extr; return extr;
} }
static void lcd_return_to_status() void lcd_return_to_status()
{ {
lcd_refresh(); // to maybe revive the LCD if static electricity killed it. lcd_refresh(); // to maybe revive the LCD if static electricity killed it.
menu_goto(lcd_status_screen, 0, false, true); menu_goto(lcd_status_screen, 0, false, true);
@ -3284,8 +3268,14 @@ const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines)
// Disable update of the screen by the usual lcd_update(0) routine. // Disable update of the screen by the usual lcd_update(0) routine.
lcd_update_enable(false); lcd_update_enable(false);
lcd_clear(); lcd_clear();
// uint8_t nlines;
return lcd_display_message_fullscreen_nonBlocking_P(msg, nlines); return lcd_display_message_fullscreen_nonBlocking_P(msg, nlines);
} }
const char* lcd_display_message_fullscreen_P(const char *msg)
{
uint8_t nlines;
return lcd_display_message_fullscreen_P(msg, nlines);
}
/** /**
@ -4313,27 +4303,29 @@ void lcd_toshiba_flash_air_compatibility_toggle()
eeprom_update_byte((uint8_t*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY, card.ToshibaFlashAir_isEnabled()); eeprom_update_byte((uint8_t*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY, card.ToshibaFlashAir_isEnabled());
} }
void lcd_v2_calibration() { void lcd_v2_calibration()
#ifdef SNMM_V2 {
lcd_commands_type = LCD_COMMAND_V2_CAL; if (mmu_enabled)
#else //SNMM_V2
bool loaded = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is PLA filament loaded?"), false, true);////MSG_PLA_FILAMENT_LOADED c=20 r=2
if (loaded) {
lcd_commands_type = LCD_COMMAND_V2_CAL; lcd_commands_type = LCD_COMMAND_V2_CAL;
} else
else { {
lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 bool loaded = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is PLA filament loaded?"), false, true);////MSG_PLA_FILAMENT_LOADED c=20 r=2
for (int i = 0; i < 20; i++) { //wait max. 2s if (loaded) {
delay_keep_alive(100); lcd_commands_type = LCD_COMMAND_V2_CAL;
if (lcd_clicked()) { }
while (lcd_clicked()); else {
delay(10); lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4
while (lcd_clicked()); for (int i = 0; i < 20; i++) { //wait max. 2s
break; delay_keep_alive(100);
if (lcd_clicked()) {
while (lcd_clicked());
delay(10);
while (lcd_clicked());
break;
}
} }
} }
} }
#endif //SNMM_V2
lcd_return_to_status(); lcd_return_to_status();
lcd_update_enable(true); lcd_update_enable(true);
} }
@ -4942,13 +4934,9 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be
} }
char choose_extruder_menu() { char choose_extruder_menu()
{
#ifdef SNMM_V2 int items_no = mmu_enabled?5:4;
int items_no = 5;
#else
int items_no = 4;
#endif
int first = 0; int first = 0;
int enc_dif = 0; int enc_dif = 0;
char cursor_pos = 1; char cursor_pos = 1;
@ -5138,384 +5126,6 @@ static void lcd_disable_farm_mode()
} }
#if defined (SNMM) || defined(SNMM_V2)
static void extr_mov(float shift, float feed_rate) { //move extruder no matter what the current heater temperature is
set_extrude_min_temp(.0);
current_position[E_AXIS] += shift;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feed_rate, active_extruder);
set_extrude_min_temp(EXTRUDE_MINTEMP);
}
void change_extr(int extr) { //switches multiplexer for extruders
#ifndef SNMM_V2
st_synchronize();
delay(100);
disable_e0();
disable_e1();
disable_e2();
snmm_extruder = extr;
pinMode(E_MUX0_PIN, OUTPUT);
pinMode(E_MUX1_PIN, OUTPUT);
switch (extr) {
case 1:
WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, LOW);
break;
case 2:
WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, HIGH);
break;
case 3:
WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, HIGH);
break;
default:
WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, LOW);
break;
}
delay(100);
#endif
}
static int get_ext_nr() { //reads multiplexer input pins and return current extruder number (counted from 0)
#ifdef SNMM_V2
return(snmm_extruder); //update needed
#else
return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
#endif
}
void display_loading() {
switch (snmm_extruder) {
case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
}
}
void extr_adj(int extruder) //loading filament for SNMM
{
#ifdef SNMM_V2
printf_P(PSTR("L%d \n"),extruder);
fprintf_P(uart2io, PSTR("L%d\n"), extruder);
//show which filament is currently loaded
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
//if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd.setCursor(0, 1);
//else lcd.print(" ");
lcd_print(" ");
lcd_print(snmm_extruder + 1);
// get response
manage_response();
lcd_update_enable(true);
//lcd_return_to_status();
#else
bool correct;
max_feedrate[E_AXIS] =80;
//max_feedrate[E_AXIS] = 50;
START:
lcd_clear();
lcd_set_cursor(0, 0);
switch (extruder) {
case 1: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T1)); break;
case 2: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T2)); break;
case 3: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T3)); break;
default: lcd_display_message_fullscreen_P(_T(MSG_FILAMENT_LOADING_T0)); break;
}
KEEPALIVE_STATE(PAUSED_FOR_USER);
do{
extr_mov(0.001,1000);
delay_keep_alive(2);
} while (!lcd_clicked());
//delay_keep_alive(500);
KEEPALIVE_STATE(IN_HANDLER);
st_synchronize();
//correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false);
//if (!correct) goto START;
//extr_mov(BOWDEN_LENGTH/2.f, 500); //dividing by 2 is there because of max. extrusion length limitation (x_max + y_max)
//extr_mov(BOWDEN_LENGTH/2.f, 500);
extr_mov(bowden_length[extruder], 500);
lcd_clear();
lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
if(strlen(_T(MSG_LOADING_FILAMENT))>18) lcd_set_cursor(0, 1);
else lcd_print(" ");
lcd_print(snmm_extruder + 1);
lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
st_synchronize();
max_feedrate[E_AXIS] = 50;
lcd_update_enable(true);
lcd_return_to_status();
lcdDrawUpdate = 2;
#endif
}
void extr_unload() { //unload just current filament for multimaterial printers
#ifndef SNMM_V2
float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
uint8_t SilentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
#endif
if (degHotend0() > EXTRUDE_MINTEMP) {
#ifdef SNMM_V2
st_synchronize();
//show which filament is currently unloaded
lcd_update_enable(false);
lcd_clear();
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
lcd_print(" ");
lcd_print(snmm_extruder + 1);
current_position[E_AXIS] -= 80;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
st_synchronize();
printf_P(PSTR("U0\n"));
fprintf_P(uart2io, PSTR("U0\n"));
// get response
manage_response();
lcd_update_enable(true);
#else //SNMM_V2
lcd_clear();
lcd_display_message_fullscreen_P(PSTR(""));
max_feedrate[E_AXIS] = 50;
lcd_set_cursor(0, 0); lcd_puts_P(_T(MSG_UNLOADING_FILAMENT));
lcd_print(" ");
lcd_print(snmm_extruder + 1);
lcd_set_cursor(0, 2); lcd_puts_P(_T(MSG_PLEASE_WAIT));
if (current_position[Z_AXIS] < 15) {
current_position[Z_AXIS] += 15; //lifting in Z direction to make space for extrusion
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 25, active_extruder);
}
current_position[E_AXIS] += 10; //extrusion
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 10, active_extruder);
st_current_set(2, E_MOTOR_HIGH_CURRENT);
if (current_temperature[0] < 230) { //PLA & all other filaments
current_position[E_AXIS] += 5.4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2800 / 60, active_extruder);
current_position[E_AXIS] += 3.2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
current_position[E_AXIS] += 3;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3400 / 60, active_extruder);
}
else { //ABS
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2000 / 60, active_extruder);
current_position[E_AXIS] += 3.1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
current_position[E_AXIS] += 4;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
/*current_position[X_AXIS] += 23; //delay
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay
current_position[X_AXIS] -= 23; //delay
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 600 / 60, active_extruder); //delay*/
delay_keep_alive(4700);
}
max_feedrate[E_AXIS] = 80;
current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
current_position[E_AXIS] -= (bowden_length[snmm_extruder] + 60 + FIL_LOAD_LENGTH) / 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 500, active_extruder);
st_synchronize();
//st_current_init();
if (SilentMode != SILENT_MODE_OFF) st_current_set(2, tmp_motor[2]); //set back to normal operation currents
else st_current_set(2, tmp_motor_loud[2]);
lcd_update_enable(true);
lcd_return_to_status();
max_feedrate[E_AXIS] = 50;
#endif //SNMM_V2
}
else {
lcd_clear();
lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR));
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
delay(2000);
lcd_clear();
}
//lcd_return_to_status();
}
//wrapper functions for loading filament
static void extr_adj_0(){
#ifdef SNMM_V2
enquecommand_P(PSTR("M701 E0"));
#else
change_extr(0);
extr_adj(0);
#endif
}
static void extr_adj_1() {
#ifdef SNMM_V2
enquecommand_P(PSTR("M701 E1"));
#else
change_extr(1);
extr_adj(1);
#endif
}
static void extr_adj_2() {
#ifdef SNMM_V2
enquecommand_P(PSTR("M701 E2"));
#else
change_extr(2);
extr_adj(2);
#endif
}
static void extr_adj_3() {
#ifdef SNMM_V2
enquecommand_P(PSTR("M701 E3"));
#else
change_extr(3);
extr_adj(3);
#endif
}
static void extr_adj_4() {
#ifdef SNMM_V2
enquecommand_P(PSTR("M701 E4"));
#else
change_extr(4);
extr_adj(4);
#endif
}
static void load_all() {
#ifdef SNMM_V2
enquecommand_P(PSTR("M701 E0"));
enquecommand_P(PSTR("M701 E1"));
enquecommand_P(PSTR("M701 E2"));
enquecommand_P(PSTR("M701 E3"));
enquecommand_P(PSTR("M701 E4"));
#else
for (int i = 0; i < 4; i++) {
change_extr(i);
extr_adj(i);
}
#endif
}
//wrapper functions for changing extruders
static void extr_change_0() {
change_extr(0);
lcd_return_to_status();
}
static void extr_change_1() {
change_extr(1);
lcd_return_to_status();
}
static void extr_change_2() {
change_extr(2);
lcd_return_to_status();
}
static void extr_change_3() {
change_extr(3);
lcd_return_to_status();
}
//wrapper functions for unloading filament
void extr_unload_all() {
if (degHotend0() > EXTRUDE_MINTEMP) {
for (int i = 0; i < 4; i++) {
change_extr(i);
extr_unload();
}
}
else {
lcd_clear();
lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR));
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
delay(2000);
lcd_clear();
lcd_return_to_status();
}
}
//unloading just used filament (for snmm)
void extr_unload_used() {
if (degHotend0() > EXTRUDE_MINTEMP) {
for (int i = 0; i < 4; i++) {
if (snmm_filaments_used & (1 << i)) {
change_extr(i);
extr_unload();
}
}
snmm_filaments_used = 0;
}
else {
lcd_clear();
lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR));
lcd_set_cursor(0, 2);
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
delay(2000);
lcd_clear();
lcd_return_to_status();
}
}
static void extr_unload_0() {
change_extr(0);
extr_unload();
}
static void extr_unload_1() {
change_extr(1);
extr_unload();
}
static void extr_unload_2() {
change_extr(2);
extr_unload();
}
static void extr_unload_3() {
change_extr(3);
extr_unload();
}
static void extr_unload_4() {
change_extr(4);
extr_unload();
}
static void fil_load_menu() static void fil_load_menu()
{ {
MENU_BEGIN(); MENU_BEGIN();
@ -5526,9 +5136,8 @@ static void fil_load_menu()
MENU_ITEM_FUNCTION_P(_i("Load filament 3"), extr_adj_2);////MSG_LOAD_FILAMENT_3 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Load filament 3"), extr_adj_2);////MSG_LOAD_FILAMENT_3 c=17 r=0
MENU_ITEM_FUNCTION_P(_i("Load filament 4"), extr_adj_3);////MSG_LOAD_FILAMENT_4 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Load filament 4"), extr_adj_3);////MSG_LOAD_FILAMENT_4 c=17 r=0
#ifdef SNMM_V2 if (mmu_enabled)
MENU_ITEM_FUNCTION_P(_i("Load filament 5"), extr_adj_4); MENU_ITEM_FUNCTION_P(_i("Load filament 5"), extr_adj_4);
#endif
MENU_END(); MENU_END();
} }
@ -5543,9 +5152,8 @@ static void fil_unload_menu()
MENU_ITEM_FUNCTION_P(_i("Unload filament 3"), extr_unload_2);////MSG_UNLOAD_FILAMENT_3 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Unload filament 3"), extr_unload_2);////MSG_UNLOAD_FILAMENT_3 c=17 r=0
MENU_ITEM_FUNCTION_P(_i("Unload filament 4"), extr_unload_3);////MSG_UNLOAD_FILAMENT_4 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Unload filament 4"), extr_unload_3);////MSG_UNLOAD_FILAMENT_4 c=17 r=0
#ifdef SNMM_V2 if (mmu_enabled)
MENU_ITEM_FUNCTION_P(_i("Unload filament 5"), extr_unload_4);////MSG_UNLOAD_FILAMENT_4 c=17 r=0 MENU_ITEM_FUNCTION_P(_i("Unload filament 5"), extr_unload_4);////MSG_UNLOAD_FILAMENT_4 c=17 r=0
#endif
MENU_END(); MENU_END();
} }
@ -5561,10 +5169,10 @@ static void change_extr_menu(){
MENU_END(); MENU_END();
} }
#endif
//unload filament for single material printer (used in M702 gcode) //unload filament for single material printer (used in M702 gcode)
void unload_filament() { void unload_filament()
{
custom_message = true; custom_message = true;
custom_message_type = 2; custom_message_type = 2;
lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT)); lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT));
@ -5981,25 +5589,27 @@ static void lcd_main_menu()
} }
else else
{ {
#if defined (SNMM) || defined (SNMM_V2) if (mmu_enabled)
MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu); {
#ifdef SNMM_V2 MENU_ITEM_SUBMENU_P(_T(MSG_LOAD_FILAMENT), fil_load_menu);
MENU_ITEM_GCODE_P(_T(MSG_UNLOAD_FILAMENT), PSTR("M702 C")); if (mmu_enabled)
#else MENU_ITEM_GCODE_P(_T(MSG_UNLOAD_FILAMENT), PSTR("M702 C"));
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), fil_unload_menu); else
MENU_ITEM_SUBMENU_P(_i("Change extruder"), change_extr_menu);////MSG_CHANGE_EXTR c=20 r=1 {
#endif MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), fil_unload_menu);
MENU_ITEM_SUBMENU_P(_i("Change extruder"), change_extr_menu);////MSG_CHANGE_EXTR c=20 r=1
#else }
#ifdef FILAMENT_SENSOR }
if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true)))
MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0
else else
#endif //FILAMENT_SENSOR {
MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament); #ifdef FILAMENT_SENSOR
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament); if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true)))
#endif MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0
else
#endif //FILAMENT_SENSOR
MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament);
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament);
}
MENU_ITEM_SUBMENU_P(_T(MSG_SETTINGS), lcd_settings_menu); MENU_ITEM_SUBMENU_P(_T(MSG_SETTINGS), lcd_settings_menu);
if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_MENU_CALIBRATION), lcd_calibration_menu); if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_MENU_CALIBRATION), lcd_calibration_menu);

View file

@ -128,9 +128,8 @@ extern union MenuData menuData;
void lcd_menu_statistics(); void lcd_menu_statistics();
extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines);
inline const char* lcd_display_message_fullscreen_P(const char *msg) extern const char* lcd_display_message_fullscreen_P(const char *msg);
{ uint8_t nlines; return lcd_display_message_fullscreen_P(msg, nlines); }
extern void lcd_wait_for_click(); extern void lcd_wait_for_click();
extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
@ -186,10 +185,7 @@ extern union MenuData menuData;
#endif #endif
extern int8_t SilentModeMenu; extern int8_t SilentModeMenu;
#if defined (SNMM) || defined (SNMM_V2)
extern uint8_t snmm_extruder;
#endif // defined (SNMM) || defined (SNMM_V2)
extern bool cancel_heatup; extern bool cancel_heatup;
extern bool isPrintPaused; extern bool isPrintPaused;