Merge remote-tracking branch 'refs/remotes/prusa3d/MK2' into MK2-DE

This commit is contained in:
3d-gussner 2017-09-11 11:26:49 +02:00
commit c443992b3c
18 changed files with 401 additions and 141 deletions

View File

@ -5,7 +5,7 @@
#include "Configuration_prusa.h" #include "Configuration_prusa.h"
// Firmware version // Firmware version
#define FW_version "3.0.12-3" #define FW_version "3.0.12-5"
#define FW_PRUSA3D_MAGIC "PRUSA3DFW" #define FW_PRUSA3D_MAGIC "PRUSA3DFW"
#define FW_PRUSA3D_MAGIC_LEN 10 #define FW_PRUSA3D_MAGIC_LEN 10
@ -252,7 +252,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop. const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
//#define DISABLE_MAX_ENDSTOPS #define DISABLE_MAX_ENDSTOPS
//#define DISABLE_MIN_ENDSTOPS //#define DISABLE_MIN_ENDSTOPS
// Disable max endstops for compatibility with endstop checking routine // Disable max endstops for compatibility with endstop checking routine
@ -463,7 +463,13 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// please keep turned on if you can. // please keep turned on if you can.
//#define EEPROM_CHITCHAT //#define EEPROM_CHITCHAT
// Host Keepalive
//
// When enabled Marlin will send a busy status message to the host
// every couple of seconds when it can't accept commands.
//
#define HOST_KEEPALIVE_FEATURE // Disable this if your host doesn't like keepalive messages
#define HOST_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113.
//LCD and SD support //LCD and SD support
#define ULTRA_LCD //general LCD support, also 16x2 #define ULTRA_LCD //general LCD support, also 16x2

View File

@ -261,7 +261,7 @@
#define SD_SORT_ALPHA 1 #define SD_SORT_ALPHA 1
#define SD_SORT_NONE 2 #define SD_SORT_NONE 2
#define SDSORT_LIMIT 40 // Maximum number of sorted items (10-256). #define SDSORT_LIMIT 20 // Maximum number of sorted items (10-256).
#define FOLDER_SORTING -1 // -1=above 0=none 1=below #define FOLDER_SORTING -1 // -1=above 0=none 1=below
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code. #define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM true // Pre-allocate a static array for faster pre-sorting. #define SDSORT_USES_RAM true // Pre-allocate a static array for faster pre-sorting.

View File

@ -109,6 +109,8 @@ FORCE_INLINE void serialprintPGM(const char *str)
} }
} }
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
bool is_buffer_empty(); bool is_buffer_empty();
void get_command(); void get_command();
void process_commands(); void process_commands();
@ -281,6 +283,10 @@ extern float retract_length, retract_length_swap, retract_feedrate, retract_zlif
extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate; extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
#endif #endif
#ifdef HOST_KEEPALIVE_FEATURE
extern uint8_t host_keepalive_interval;
#endif
extern unsigned long starttime; extern unsigned long starttime;
extern unsigned long stoptime; extern unsigned long stoptime;
extern int bowden_length[4]; extern int bowden_length[4];
@ -302,6 +308,10 @@ extern unsigned int custom_message_type;
extern unsigned int custom_message_state; extern unsigned int custom_message_state;
extern char snmm_filaments_used; extern char snmm_filaments_used;
extern unsigned long PingTime; extern unsigned long PingTime;
extern unsigned long NcTime;
extern bool no_response;
extern uint8_t important_status;
extern uint8_t saved_filament_type;
// Handling multiple extruders pins // Handling multiple extruders pins
@ -312,8 +322,6 @@ extern void digipot_i2c_set_current( int channel, float current );
extern void digipot_i2c_init(); extern void digipot_i2c_init();
#endif #endif
#endif
//Long pause //Long pause
extern int saved_feedmultiply; extern int saved_feedmultiply;
extern float HotendTempBckp; extern float HotendTempBckp;
@ -346,8 +354,30 @@ float d_ReadData();
void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_points_num, float shift_x, float shift_y); void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_points_num, float shift_x, float shift_y);
#endif #endif
float temp_comp_interpolation(float temperature); float temp_comp_interpolation(float temperature);
void temp_compensation_apply(); void temp_compensation_apply();
void temp_compensation_start(); void temp_compensation_start();
void wait_for_heater(long codenum); void wait_for_heater(long codenum);
void serialecho_temperatures(); void serialecho_temperatures();
void proc_commands();
#ifdef 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)
};
#define KEEPALIVE_STATE(n) do { busy_state = n;} while (0)
extern void host_keepalive();
extern MarlinBusyState busy_state;
#endif //HOST_KEEPALIVE_FEATURE
#endif //ifndef marlin.h

View File

@ -64,7 +64,7 @@ FORCE_INLINE void store_char(unsigned char c)
store_char(c); store_char(c);
} }
} }
#ifndef SNMM
SIGNAL(USART2_RX_vect) SIGNAL(USART2_RX_vect)
{ {
if (selectedSerialPort == 1) { if (selectedSerialPort == 1) {
@ -82,6 +82,7 @@ FORCE_INLINE void store_char(unsigned char c)
} }
} }
#endif #endif
#endif
// Constructors //////////////////////////////////////////////////////////////// // Constructors ////////////////////////////////////////////////////////////////
@ -122,7 +123,7 @@ void MarlinSerial::begin(long baud)
sbi(M_UCSRxB, M_TXENx); sbi(M_UCSRxB, M_TXENx);
sbi(M_UCSRxB, M_RXCIEx); sbi(M_UCSRxB, M_RXCIEx);
#ifndef SNMM
// set up the second serial port // set up the second serial port
if (useU2X) { if (useU2X) {
UCSR2A = 1 << U2X2; UCSR2A = 1 << U2X2;
@ -139,6 +140,7 @@ void MarlinSerial::begin(long baud)
sbi(UCSR2B, RXEN2); sbi(UCSR2B, RXEN2);
sbi(UCSR2B, TXEN2); sbi(UCSR2B, TXEN2);
sbi(UCSR2B, RXCIE2); sbi(UCSR2B, RXCIE2);
#endif
} }
void MarlinSerial::end() void MarlinSerial::end()
@ -146,10 +148,12 @@ void MarlinSerial::end()
cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_RXENx);
cbi(M_UCSRxB, M_TXENx); cbi(M_UCSRxB, M_TXENx);
cbi(M_UCSRxB, M_RXCIEx); cbi(M_UCSRxB, M_RXCIEx);
#ifndef SNMM
cbi(UCSR2B, RXEN2); cbi(UCSR2B, RXEN2);
cbi(UCSR2B, TXEN2); cbi(UCSR2B, TXEN2);
cbi(UCSR2B, RXCIE2); cbi(UCSR2B, RXCIE2);
#endif
} }

View File

@ -101,18 +101,56 @@ class MarlinSerial //: public Stream
{ {
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
} }
FORCE_INLINE void write(uint8_t c)
{
while (!((M_UCSRxA) & (1 << M_UDREx)))
;
M_UDRx = c; void write(uint8_t c)
} {
#ifdef SNMM // don't do the second serial port when multimaterialing
while (!((M_UCSRxA) & (1 << M_UDREx)))
;
M_UDRx = c;
#else
if (selectedSerialPort == 0) {
while (!((M_UCSRxA) & (1 << M_UDREx)))
;
M_UDRx = c;
}
else if (selectedSerialPort == 1) {
while (!((UCSR2A) & (1 << UDRE2)))
;
UDR2 = c;
}
#endif
}
void checkRx(void) void checkRx(void)
{ {
#ifdef SNMM
if((M_UCSRxA & (1<<M_RXCx)) != 0) {
// Test for a framing error.
if (M_UCSRxA & (1<<M_FEx)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = M_UDRx;
} else {
unsigned char c = M_UDRx;
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// 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;
}
selectedSerialPort = 0;
}
}
#else
if (selectedSerialPort == 0) { if (selectedSerialPort == 0) {
if((M_UCSRxA & (1<<M_RXCx)) != 0) { if((M_UCSRxA & (1<<M_RXCx)) != 0) {
// Test for a framing error. // Test for a framing error.
@ -156,6 +194,7 @@ class MarlinSerial //: public Stream
} }
} }
} }
#endif
} }

View File

@ -150,6 +150,7 @@
// Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling // Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
// IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F // IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
// M112 - Emergency stop // M112 - Emergency stop
// M113 - Get or set the timeout interval for Host Keepalive "busy" messages
// M114 - Output current position to serial port // M114 - Output current position to serial port
// M115 - Capabilities string // M115 - Capabilities string
// M117 - display message // M117 - display message
@ -225,6 +226,8 @@ CardReader card;
unsigned long TimeSent = millis(); unsigned long TimeSent = millis();
unsigned long TimeNow = millis(); unsigned long TimeNow = millis();
unsigned long PingTime = millis(); unsigned long PingTime = millis();
unsigned long NcTime;
union Data union Data
{ {
byte b[2]; byte b[2];
@ -370,6 +373,16 @@ int fanSpeed=0;
bool cancel_heatup = false ; bool cancel_heatup = false ;
#ifdef HOST_KEEPALIVE_FEATURE
MarlinBusyState busy_state = NOT_BUSY;
static long prev_busy_signal_ms = -1;
uint8_t host_keepalive_interval = HOST_KEEPALIVE_INTERVAL;
#else
#define host_keepalive();
#define KEEPALIVE_STATE(n);
#endif
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
//Variables for Filament Sensor input //Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
@ -385,6 +398,10 @@ bool cancel_heatup = false ;
const char errormagic[] PROGMEM = "Error:"; const char errormagic[] PROGMEM = "Error:";
const char echomagic[] PROGMEM = "echo:"; const char echomagic[] PROGMEM = "echo:";
bool no_response = false;
uint8_t important_status;
uint8_t saved_filament_type;
//=========================================================================== //===========================================================================
//=============================Private Variables============================= //=============================Private Variables=============================
//=========================================================================== //===========================================================================
@ -755,10 +772,12 @@ void enquecommand(const char *cmd, bool from_progmem)
strcpy_P(cmdbuffer + bufindw + 1, cmd); strcpy_P(cmdbuffer + bufindw + 1, cmd);
else else
strcpy(cmdbuffer + bufindw + 1, cmd); strcpy(cmdbuffer + bufindw + 1, cmd);
SERIAL_ECHO_START; if (!farm_mode) {
SERIAL_ECHORPGM(MSG_Enqueing); SERIAL_ECHO_START;
SERIAL_ECHO(cmdbuffer + bufindw + 1); SERIAL_ECHORPGM(MSG_Enqueing);
SERIAL_ECHOLNPGM("\""); SERIAL_ECHO(cmdbuffer + bufindw + 1);
SERIAL_ECHOLNPGM("\"");
}
bufindw += len + 2; bufindw += len + 2;
if (bufindw == sizeof(cmdbuffer)) if (bufindw == sizeof(cmdbuffer))
bufindw = 0; bufindw = 0;
@ -791,10 +810,12 @@ void enquecommand_front(const char *cmd, bool from_progmem)
else else
strcpy(cmdbuffer + bufindr + 1, cmd); strcpy(cmdbuffer + bufindr + 1, cmd);
++ buflen; ++ buflen;
SERIAL_ECHO_START; if (!farm_mode) {
SERIAL_ECHOPGM("Enqueing to the front: \""); SERIAL_ECHO_START;
SERIAL_ECHO(cmdbuffer + bufindr + 1); SERIAL_ECHOPGM("Enqueing to the front: \"");
SERIAL_ECHOLNPGM("\""); SERIAL_ECHO(cmdbuffer + bufindr + 1);
SERIAL_ECHOLNPGM("\"");
}
#ifdef CMDBUFFER_DEBUG #ifdef CMDBUFFER_DEBUG
cmdqueue_dump_to_serial(); cmdqueue_dump_to_serial();
#endif /* CMDBUFFER_DEBUG */ #endif /* CMDBUFFER_DEBUG */
@ -942,7 +963,7 @@ void factory_reset(char level, bool quiet)
// Force the "Follow calibration flow" message at the next boot up. // Force the "Follow calibration flow" message at the next boot up.
calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION); calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION);
farm_no = 0; farm_no = 0;
farm_mode == false; farm_mode = false;
eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode); eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode);
EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no); EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no);
@ -1005,11 +1026,13 @@ void setup()
setup_powerhold(); setup_powerhold();
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE); farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no); EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
//if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode
if (farm_no == 0xFFFF) farm_no = 0; if (farm_no == 0xFFFF) farm_no = 0;
if (farm_mode) if (farm_mode)
{ {
prusa_statistics(8); prusa_statistics(8);
no_response = true; //we need confirmation by recieving PRUSA thx
important_status = 8;
selectedSerialPort = 1; selectedSerialPort = 1;
} else { } else {
selectedSerialPort = 0; selectedSerialPort = 0;
@ -1018,6 +1041,7 @@ void setup()
SERIAL_PROTOCOLLNPGM("start"); SERIAL_PROTOCOLLNPGM("start");
SERIAL_ECHO_START; SERIAL_ECHO_START;
#if 0 #if 0
SERIAL_ECHOLN("Reading eeprom from 0 to 100: start"); SERIAL_ECHOLN("Reading eeprom from 0 to 100: start");
for (int i = 0; i < 4096; ++i) { for (int i = 0; i < 4096; ++i) {
@ -1078,6 +1102,7 @@ void setup()
world2machine_reset(); world2machine_reset();
lcd_init(); lcd_init();
KEEPALIVE_STATE(PAUSED_FOR_USER);
if (!READ(BTN_ENC)) if (!READ(BTN_ENC))
{ {
_delay_ms(1000); _delay_ms(1000);
@ -1099,7 +1124,7 @@ void setup()
_delay_ms(2000); _delay_ms(2000);
char level = reset_menu(); char level = reset_menu();
factory_reset(level, false); factory_reset(level, false);
@ -1160,15 +1185,7 @@ void setup()
#if defined(Z_AXIS_ALWAYS_ON) #if defined(Z_AXIS_ALWAYS_ON)
enable_z(); enable_z();
#endif #endif
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode
if (farm_no == 0xFFFF) farm_no = 0;
if (farm_mode)
{
prusa_statistics(8);
}
// Enable Toshiba FlashAir SD card / WiFi enahanced card. // Enable Toshiba FlashAir SD card / WiFi enahanced card.
card.ToshibaFlashAir_enable(eeprom_read_byte((unsigned char*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY) == 1); card.ToshibaFlashAir_enable(eeprom_read_byte((unsigned char*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY) == 1);
// Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false), // Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false),
@ -1245,6 +1262,7 @@ void setup()
// Store the currently running firmware into an eeprom, // Store the currently running firmware into an eeprom,
// so the next time the firmware gets updated, it will know from which version it has been updated. // so the next time the firmware gets updated, it will know from which version it has been updated.
update_current_firmware_version_to_eeprom(); update_current_firmware_version_to_eeprom();
KEEPALIVE_STATE(NOT_BUSY);
} }
void trace(); void trace();
@ -1321,6 +1339,36 @@ int serial_read_stream() {
} }
} }
#ifdef HOST_KEEPALIVE_FEATURE
/**
* Output a "busy" message at regular intervals
* while the machine is not accepting commands.
*/
void host_keepalive() {
if (farm_mode) return;
long ms = millis();
if (host_keepalive_interval && busy_state != NOT_BUSY) {
if (ms - prev_busy_signal_ms < 1000UL * host_keepalive_interval) return;
switch (busy_state) {
case IN_HANDLER:
case IN_PROCESS:
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("busy: processing");
break;
case PAUSED_FOR_USER:
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("busy: paused for user");
break;
case PAUSED_FOR_INPUT:
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("busy: paused for input");
break;
}
}
prev_busy_signal_ms = ms;
}
#endif
// The loop() function is called in an endless loop by the Arduino framework from the default main() routine. // The loop() function is called in an endless loop by the Arduino framework from the default main() routine.
// Before loop(), the setup() function is called by the main() routine. // Before loop(), the setup() function is called by the main() routine.
void loop() void loop()
@ -1376,6 +1424,7 @@ void loop()
if (! cmdbuffer_front_already_processed) if (! cmdbuffer_front_already_processed)
cmdqueue_pop_front(); cmdqueue_pop_front();
cmdbuffer_front_already_processed = false; cmdbuffer_front_already_processed = false;
host_keepalive();
} }
} }
//check heater every n milliseconds //check heater every n milliseconds
@ -1385,6 +1434,16 @@ void loop()
lcd_update(); lcd_update();
} }
void proc_commands() {
if (buflen)
{
process_commands();
if (!cmdbuffer_front_already_processed)
cmdqueue_pop_front();
cmdbuffer_front_already_processed = false;
}
}
void get_command() void get_command()
{ {
// Test and reserve space for the new command string. // Test and reserve space for the new command string.
@ -2084,6 +2143,8 @@ void process_commands()
float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
int8_t SilentMode; int8_t SilentMode;
#endif #endif
KEEPALIVE_STATE(IN_HANDLER);
if (code_seen("M117")) { //moved to highest priority place to be able to to print strings which includes "G", "PRUSA" and "^" if (code_seen("M117")) { //moved to highest priority place to be able to to print strings which includes "G", "PRUSA" and "^"
starpos = (strchr(strchr_pointer + 5, '*')); starpos = (strchr(strchr_pointer + 5, '*'));
if (starpos != NULL) if (starpos != NULL)
@ -2096,11 +2157,18 @@ void process_commands()
PingTime = millis(); PingTime = millis();
//MYSERIAL.print(farm_no); MYSERIAL.println(": OK"); //MYSERIAL.print(farm_no); MYSERIAL.println(": OK");
} }
} } else if (code_seen("PRN")) {
else if (code_seen("PRN")) {
MYSERIAL.println(status_number); MYSERIAL.println(status_number);
}else if (code_seen("fn")) { } else if (code_seen("RESET")) {
// careful!
if (farm_mode) {
asm volatile(" jmp 0x3E000");
}
else {
MYSERIAL.println("Not in farm mode.");
}
} else if (code_seen("fn")) {
if (farm_mode) { if (farm_mode) {
MYSERIAL.println(farm_no); MYSERIAL.println(farm_no);
} }
@ -2108,6 +2176,9 @@ void process_commands()
MYSERIAL.println("Not in farm mode."); MYSERIAL.println("Not in farm mode.");
} }
}
else if (code_seen("thx")) {
no_response = false;
}else if (code_seen("fv")) { }else if (code_seen("fv")) {
// get file version // get file version
#ifdef SDSUPPORT #ifdef SDSUPPORT
@ -2407,7 +2478,7 @@ void process_commands()
prepare_arc_move(false); prepare_arc_move(false);
} }
break; break;
case 4: // G4 dwell case 4: // G4 dwell
codenum = 0; codenum = 0;
if(code_seen('P')) codenum = code_value(); // milliseconds to wait if(code_seen('P')) codenum = code_value(); // milliseconds to wait
if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
@ -2440,8 +2511,7 @@ void process_commands()
#endif //FWRETRACT #endif //FWRETRACT
case 28: //G28 Home all Axis one at a time case 28: //G28 Home all Axis one at a time
homing_flag = true; homing_flag = true;
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef ENABLE_AUTO_BED_LEVELING
plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data)
#endif //ENABLE_AUTO_BED_LEVELING #endif //ENABLE_AUTO_BED_LEVELING
@ -2888,6 +2958,7 @@ void process_commands()
enquecommand_front_P((PSTR("G28 W0"))); enquecommand_front_P((PSTR("G28 W0")));
break; break;
} }
KEEPALIVE_STATE(NOT_BUSY); //no need to print busy messages as we print current temperatures periodicaly
SERIAL_ECHOLNPGM("PINDA probe calibration start"); SERIAL_ECHOLNPGM("PINDA probe calibration start");
custom_message = true; custom_message = true;
custom_message_type = 4; custom_message_type = 4;
@ -3288,6 +3359,7 @@ void process_commands()
current_position[E_AXIS] += DEFAULT_RETRACTION; current_position[E_AXIS] += DEFAULT_RETRACTION;
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], 400, active_extruder);
} }
KEEPALIVE_STATE(NOT_BUSY);
// Restore custom message state // Restore custom message state
custom_message = custom_message_old; custom_message = custom_message_old;
custom_message_type = custom_message_type_old; custom_message_type = custom_message_type_old;
@ -3432,7 +3504,9 @@ void process_commands()
case 98: //activate farm mode case 98: //activate farm mode
farm_mode = 1; farm_mode = 1;
PingTime = millis(); PingTime = millis();
EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no);
eeprom_update_byte((unsigned char *)EEPROM_FARM_MODE, farm_mode); eeprom_update_byte((unsigned char *)EEPROM_FARM_MODE, farm_mode);
break; break;
case 99: //deactivate farm mode case 99: //deactivate farm mode
@ -3485,29 +3559,33 @@ void process_commands()
while (*src == ' ') ++src; while (*src == ' ') ++src;
if (!hasP && !hasS && *src != '\0') { if (!hasP && !hasS && *src != '\0') {
lcd_setstatus(src); lcd_setstatus(src);
} else { } else {
LCD_MESSAGERPGM(MSG_USERWAIT); LCD_MESSAGERPGM(MSG_USERWAIT);
} }
lcd_ignore_click(); //call lcd_ignore_click aslo for else ??? lcd_ignore_click(); //call lcd_ignore_click aslo for else ???
st_synchronize(); st_synchronize();
previous_millis_cmd = millis(); previous_millis_cmd = millis();
if (codenum > 0){ if (codenum > 0){
codenum += millis(); // keep track of when we started waiting codenum += millis(); // keep track of when we started waiting
KEEPALIVE_STATE(PAUSED_FOR_USER);
while(millis() < codenum && !lcd_clicked()){ while(millis() < codenum && !lcd_clicked()){
manage_heater(); manage_heater();
manage_inactivity(true); manage_inactivity(true);
lcd_update(); lcd_update();
} }
KEEPALIVE_STATE(IN_HANDLER);
lcd_ignore_click(false); lcd_ignore_click(false);
}else{ }else{
if (!lcd_detected()) if (!lcd_detected())
break; break;
KEEPALIVE_STATE(PAUSED_FOR_USER);
while(!lcd_clicked()){ while(!lcd_clicked()){
manage_heater(); manage_heater();
manage_inactivity(true); manage_inactivity(true);
lcd_update(); lcd_update();
} }
KEEPALIVE_STATE(IN_HANDLER);
} }
if (IS_SD_PRINTING) if (IS_SD_PRINTING)
LCD_MESSAGERPGM(MSG_RESUMING); LCD_MESSAGERPGM(MSG_RESUMING);
@ -3695,7 +3773,6 @@ void process_commands()
{ {
// Only Z calibration? // Only Z calibration?
bool onlyZ = code_seen('Z'); bool onlyZ = code_seen('Z');
if (!onlyZ) { if (!onlyZ) {
setTargetBed(0); setTargetBed(0);
setTargetHotend(0, 0); setTargetHotend(0, 0);
@ -3718,7 +3795,9 @@ void process_commands()
memset(axis_known_position, 0, sizeof(axis_known_position)); memset(axis_known_position, 0, sizeof(axis_known_position));
// Let the user move the Z axes up to the end stoppers. // Let the user move the Z axes up to the end stoppers.
KEEPALIVE_STATE(PAUSED_FOR_USER);
if (lcd_calibrate_z_end_stop_manual( onlyZ )) { if (lcd_calibrate_z_end_stop_manual( onlyZ )) {
KEEPALIVE_STATE(IN_HANDLER);
refresh_cmd_timeout(); refresh_cmd_timeout();
if (((degHotend(0) > MAX_HOTEND_TEMP_CALIBRATION) || (degBed() > MAX_BED_TEMP_CALIBRATION)) && (!onlyZ)) { if (((degHotend(0) > MAX_HOTEND_TEMP_CALIBRATION) || (degBed() > MAX_BED_TEMP_CALIBRATION)) && (!onlyZ)) {
lcd_wait_for_cool_down(); lcd_wait_for_cool_down();
@ -3798,6 +3877,7 @@ void process_commands()
} }
} else { } else {
// Timeouted. // Timeouted.
KEEPALIVE_STATE(IN_HANDLER);
} }
lcd_update_enable(true); lcd_update_enable(true);
break; break;
@ -3828,8 +3908,10 @@ void process_commands()
case 47: case 47:
// M47: Prusa3D: Show end stops dialog on the display. // M47: Prusa3D: Show end stops dialog on the display.
KEEPALIVE_STATE(PAUSED_FOR_USER);
lcd_diag_show_end_stops(); lcd_diag_show_end_stops();
break; KEEPALIVE_STATE(IN_HANDLER);
break;
#if 0 #if 0
case 48: // M48: scan the bed induction sensor points, print the sensor trigger coordinates to the serial line for visualization on the PC. case 48: // M48: scan the bed induction sensor points, print the sensor trigger coordinates to the serial line for visualization on the PC.
@ -4212,6 +4294,7 @@ Sigma_Exit:
}} }}
#endif #endif
SERIAL_PROTOCOLLN(""); SERIAL_PROTOCOLLN("");
KEEPALIVE_STATE(NOT_BUSY);
return; return;
break; break;
case 109: case 109:
@ -4249,11 +4332,14 @@ Sigma_Exit:
/* See if we are heating up or cooling down */ /* See if we are heating up or cooling down */
target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
KEEPALIVE_STATE(NOT_BUSY);
cancel_heatup = false; cancel_heatup = false;
wait_for_heater(codenum); //loops until target temperature is reached wait_for_heater(codenum); //loops until target temperature is reached
LCD_MESSAGERPGM(MSG_HEATING_COMPLETE); LCD_MESSAGERPGM(MSG_HEATING_COMPLETE);
KEEPALIVE_STATE(IN_HANDLER);
heating_status = 2; heating_status = 2;
if (farm_mode) { prusa_statistics(2); }; if (farm_mode) { prusa_statistics(2); };
@ -4281,6 +4367,7 @@ Sigma_Exit:
cancel_heatup = false; cancel_heatup = false;
target_direction = isHeatingBed(); // true if heating, false if cooling target_direction = isHeatingBed(); // true if heating, false if cooling
KEEPALIVE_STATE(NOT_BUSY);
while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) ) while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
{ {
if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up. if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
@ -4303,6 +4390,7 @@ Sigma_Exit:
lcd_update(); lcd_update();
} }
LCD_MESSAGERPGM(MSG_BED_DONE); LCD_MESSAGERPGM(MSG_BED_DONE);
KEEPALIVE_STATE(IN_HANDLER);
heating_status = 4; heating_status = 4;
previous_millis_cmd = millis(); previous_millis_cmd = millis();
@ -4446,6 +4534,18 @@ Sigma_Exit:
else else
gcode_LastN = 0; gcode_LastN = 0;
break; break;
#ifdef HOST_KEEPALIVE_FEATURE
case 113: // M113 - Get or set Host Keepalive interval
if (code_seen('S')) {
host_keepalive_interval = (uint8_t)code_value_short();
NOMORE(host_keepalive_interval, 60);
} else {
SERIAL_ECHO_START;
SERIAL_ECHOPAIR("M113 S", (unsigned long)host_keepalive_interval);
SERIAL_PROTOCOLLN("");
}
break;
#endif
case 115: // M115 case 115: // M115
if (code_seen('V')) { if (code_seen('V')) {
// Report the Prusa version number. // Report the Prusa version number.
@ -4993,7 +5093,8 @@ Sigma_Exit:
temp=70; temp=70;
if (code_seen('S')) temp=code_value(); if (code_seen('S')) temp=code_value();
if (code_seen('C')) c=code_value(); if (code_seen('C')) c=code_value();
PID_autotune(temp, e, c);
PID_autotune(temp, e, c);
} }
break; break;
case 400: // M400 finish all moves case 400: // M400 finish all moves
@ -5270,6 +5371,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
int counterBeep = 0; int counterBeep = 0;
lcd_wait_interact(); lcd_wait_interact();
load_filament_time = millis(); load_filament_time = millis();
KEEPALIVE_STATE(PAUSED_FOR_USER);
while(!lcd_clicked()){ while(!lcd_clicked()){
cnt++; cnt++;
@ -5306,14 +5408,17 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
} }
} }
KEEPALIVE_STATE(IN_HANDLER);
WRITE(BEEPER, LOW); WRITE(BEEPER, LOW);
#ifdef SNMM #ifdef SNMM
display_loading(); display_loading();
KEEPALIVE_STATE(PAUSED_FOR_USER);
do { do {
target[E_AXIS] += 0.002; target[E_AXIS] += 0.002;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 500, active_extruder); plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 500, active_extruder);
delay_keep_alive(2); delay_keep_alive(2);
} while (!lcd_clicked()); } while (!lcd_clicked());
KEEPALIVE_STATE(IN_HANDLER);
/*if (millis() - load_filament_time > 2) { /*if (millis() - load_filament_time > 2) {
load_filament_time = millis(); load_filament_time = millis();
target[E_AXIS] += 0.001; target[E_AXIS] += 0.001;
@ -5353,7 +5458,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
lcd_loading_filament(); lcd_loading_filament();
while ((lcd_change_fil_state == 0)||(lcd_change_fil_state != 1)){ while ((lcd_change_fil_state == 0)||(lcd_change_fil_state != 1)){
lcd_change_fil_state = 0; lcd_change_fil_state = 0;
KEEPALIVE_STATE(PAUSED_FOR_USER);
lcd_alright(); lcd_alright();
KEEPALIVE_STATE(IN_HANDLER);
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
@ -5526,6 +5633,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
break; break;
case 701: //M701: load filament case 701: //M701: load filament
{ {
#ifdef SNMM
extr_adj(snmm_extruder);//loads current extruder
#else
enable_z(); enable_z();
custom_message = true; custom_message = true;
custom_message_type = 2; custom_message_type = 2;
@ -5557,6 +5667,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
loading_flag = false; loading_flag = false;
custom_message = false; custom_message = false;
custom_message_type = 0; custom_message_type = 0;
#endif
} }
break; break;
case 702: case 702:
@ -5629,7 +5740,6 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
pinMode(E_MUX0_PIN, OUTPUT); pinMode(E_MUX0_PIN, OUTPUT);
pinMode(E_MUX1_PIN, OUTPUT); pinMode(E_MUX1_PIN, OUTPUT);
pinMode(E_MUX2_PIN, OUTPUT);
delay(100); delay(100);
SERIAL_ECHO_START; SERIAL_ECHO_START;
@ -5639,25 +5749,21 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
case 1: case 1:
WRITE(E_MUX0_PIN, HIGH); WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, LOW); WRITE(E_MUX1_PIN, LOW);
WRITE(E_MUX2_PIN, LOW);
break; break;
case 2: case 2:
WRITE(E_MUX0_PIN, LOW); WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, HIGH); WRITE(E_MUX1_PIN, HIGH);
WRITE(E_MUX2_PIN, LOW);
break; break;
case 3: case 3:
WRITE(E_MUX0_PIN, HIGH); WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, HIGH); WRITE(E_MUX1_PIN, HIGH);
WRITE(E_MUX2_PIN, LOW);
break; break;
default: default:
WRITE(E_MUX0_PIN, LOW); WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, LOW); WRITE(E_MUX1_PIN, LOW);
WRITE(E_MUX2_PIN, LOW);
break; break;
} }
@ -5770,6 +5876,8 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
SERIAL_ECHOLNPGM("\""); SERIAL_ECHOLNPGM("\"");
} }
KEEPALIVE_STATE(NOT_BUSY);
ClearToSend(); ClearToSend();
} }
@ -6013,7 +6121,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
static int killCount = 0; // make the inactivity button a bit less responsive static int killCount = 0; // make the inactivity button a bit less responsive
const int KILL_DELAY = 10000; const int KILL_DELAY = 10000;
#endif #endif
if(buflen < (BUFSIZE-1)){ if(buflen < (BUFSIZE-1)){
get_command(); get_command();
} }
@ -6289,7 +6397,7 @@ void calculate_volumetric_multipliers() {
void delay_keep_alive(unsigned int ms) void delay_keep_alive(unsigned int ms)
{ {
for (;;) { for (;;) {
manage_heater(); manage_heater();
// Manage inactivity, but don't disable steppers on timeout. // Manage inactivity, but don't disable steppers on timeout.
manage_inactivity(true); manage_inactivity(true);

View File

@ -706,6 +706,7 @@ void CardReader::getfilename_sorted(const uint16_t nr) {
*/ */
void CardReader::presort() { void CardReader::presort() {
if (farm_mode) return; //sorting is not used in farm mode
uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT); uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
if (sdSort == SD_SORT_NONE) return; //sd sort is turned off if (sdSort == SD_SORT_NONE) return; //sd sort is turned off

View File

@ -67,7 +67,6 @@
#define E_MUX0_PIN 17 #define E_MUX0_PIN 17
#define E_MUX1_PIN 16 #define E_MUX1_PIN 16
#define E_MUX2_PIN 84
#endif #endif
@ -229,7 +228,6 @@
#define E_MUX0_PIN 17 #define E_MUX0_PIN 17
#define E_MUX1_PIN 16 #define E_MUX1_PIN 16
#define E_MUX2_PIN 84
#endif #endif

View File

@ -220,7 +220,7 @@ unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
pid_cycle = 0; pid_cycle = 0;
return; return;
} }
SERIAL_ECHOLN("PID Autotune start"); SERIAL_ECHOLN("PID Autotune start");
disable_heater(); // switch off all heaters. disable_heater(); // switch off all heaters.
@ -336,13 +336,13 @@ unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
p=soft_pwm_bed; p=soft_pwm_bed;
SERIAL_PROTOCOLPGM("ok B:"); SERIAL_PROTOCOLPGM("ok B:");
}else{ }else{
p=soft_pwm[extruder]; p=soft_pwm[extruder];
SERIAL_PROTOCOLPGM("ok T:"); SERIAL_PROTOCOLPGM("ok T:");
} }
SERIAL_PROTOCOL(input); SERIAL_PROTOCOL(input);
SERIAL_PROTOCOLPGM(" @:"); SERIAL_PROTOCOLPGM(" @:");
SERIAL_PROTOCOLLN(p); SERIAL_PROTOCOLLN(p);
temp_millis = millis(); temp_millis = millis();
} }
@ -686,6 +686,7 @@ void manage_heater()
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01;
} }
#endif #endif
host_keepalive();
} }
#define PGM_RD_W(x) (short)pgm_read_word(&x) #define PGM_RD_W(x) (short)pgm_read_word(&x)

View File

@ -506,10 +506,10 @@ static void lcd_status_screen()
feedmultiply = 999; feedmultiply = 999;
#endif //ULTIPANEL #endif //ULTIPANEL
if (farm_mode && !printer_connected) { /*if (farm_mode && !printer_connected) {
lcd.setCursor(0, 3); lcd.setCursor(0, 3);
lcd_printPGM(MSG_PRINTER_DISCONNECTED); lcd_printPGM(MSG_PRINTER_DISCONNECTED);
} }*/
} }
@ -1283,13 +1283,14 @@ void lcd_menu_statistics()
lcd.print(itostr3(_days)); lcd.print(itostr3(_days));
KEEPALIVE_STATE(PAUSED_FOR_USER);
while (!lcd_clicked()) while (!lcd_clicked())
{ {
manage_heater(); manage_heater();
manage_inactivity(true); manage_inactivity(true);
delay(100); delay(100);
} }
KEEPALIVE_STATE(NOT_BUSY);
lcd_quick_feedback(); lcd_quick_feedback();
lcd_return_to_status(); lcd_return_to_status();
@ -1367,6 +1368,7 @@ void lcd_service_mode_show_result() {
} else lcd_print_at_PGM(11, i + 1, PSTR("N/A")); } else lcd_print_at_PGM(11, i + 1, PSTR("N/A"));
} }
delay_keep_alive(500); delay_keep_alive(500);
KEEPALIVE_STATE(PAUSED_FOR_USER);
while (!lcd_clicked()) { while (!lcd_clicked()) {
delay_keep_alive(100); delay_keep_alive(100);
} }
@ -1393,6 +1395,7 @@ void lcd_service_mode_show_result() {
while (!lcd_clicked()) { while (!lcd_clicked()) {
delay_keep_alive(100); delay_keep_alive(100);
} }
KEEPALIVE_STATE(NOT_BUSY);
delay_keep_alive(500); delay_keep_alive(500);
lcd_set_custom_characters_arrows(); lcd_set_custom_characters_arrows();
lcd_return_to_status(); lcd_return_to_status();
@ -1865,6 +1868,7 @@ void lcd_show_fullscreen_message_and_wait_P(const char *msg)
const char *msg_next = lcd_display_message_fullscreen_P(msg); const char *msg_next = lcd_display_message_fullscreen_P(msg);
bool multi_screen = msg_next != NULL; bool multi_screen = msg_next != NULL;
KEEPALIVE_STATE(PAUSED_FOR_USER);
// Until confirmed by a button click. // Until confirmed by a button click.
for (;;) { for (;;) {
// Wait for 5 seconds before displaying the next text. // Wait for 5 seconds before displaying the next text.
@ -1874,6 +1878,7 @@ void lcd_show_fullscreen_message_and_wait_P(const char *msg)
while (lcd_clicked()) ; while (lcd_clicked()) ;
delay(10); delay(10);
while (lcd_clicked()) ; while (lcd_clicked()) ;
KEEPALIVE_STATE(IN_HANDLER);
return; return;
} }
} }
@ -1887,6 +1892,7 @@ void lcd_show_fullscreen_message_and_wait_P(const char *msg)
void lcd_wait_for_click() void lcd_wait_for_click()
{ {
KEEPALIVE_STATE(PAUSED_FOR_USER);
for (;;) { for (;;) {
manage_heater(); manage_heater();
manage_inactivity(true); manage_inactivity(true);
@ -1894,6 +1900,7 @@ void lcd_wait_for_click()
while (lcd_clicked()) ; while (lcd_clicked()) ;
delay(10); delay(10);
while (lcd_clicked()) ; while (lcd_clicked()) ;
KEEPALIVE_STATE(IN_HANDLER);
return; return;
} }
} }
@ -1901,7 +1908,6 @@ void lcd_wait_for_click()
int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes) int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting, bool default_yes)
{ {
lcd_display_message_fullscreen_P(msg); lcd_display_message_fullscreen_P(msg);
if (default_yes) { if (default_yes) {
@ -1923,6 +1929,7 @@ int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow
// Wait for user confirmation or a timeout. // Wait for user confirmation or a timeout.
unsigned long previous_millis_cmd = millis(); unsigned long previous_millis_cmd = millis();
int8_t enc_dif = encoderDiff; int8_t enc_dif = encoderDiff;
KEEPALIVE_STATE(PAUSED_FOR_USER);
for (;;) { for (;;) {
if (allow_timeouting && millis() - previous_millis_cmd > LCD_TIMEOUT_TO_STATUS) if (allow_timeouting && millis() - previous_millis_cmd > LCD_TIMEOUT_TO_STATUS)
return -1; return -1;
@ -1948,6 +1955,7 @@ int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow
while (lcd_clicked()); while (lcd_clicked());
delay(10); delay(10);
while (lcd_clicked()); while (lcd_clicked());
KEEPALIVE_STATE(IN_HANDLER);
return yes; return yes;
} }
} }
@ -2133,14 +2141,14 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
farm_timer = 2; farm_timer = 2;
break; break;
case 6: // print done case 6: // print done
SERIAL_ECHOLN("{[PRN:8]"); SERIAL_ECHO("{[PRN:8]");
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
status_number = 8; status_number = 8;
farm_timer = 2; farm_timer = 2;
break; break;
case 7: // print done - stopped case 7: // print done - stopped
SERIAL_ECHOLN("{[PRN:9]"); SERIAL_ECHO("{[PRN:9]");
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
status_number = 9; status_number = 9;
@ -2154,7 +2162,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
farm_timer = 2; farm_timer = 2;
break; break;
case 20: // echo farm no case 20: // echo farm no
SERIAL_ECHOLN("{"); SERIAL_ECHO("{");
prusa_stat_printerstatus(status_number); prusa_stat_printerstatus(status_number);
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
@ -2168,19 +2176,19 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
break; break;
case 22: // waiting for filament change case 22: // waiting for filament change
SERIAL_ECHOLN("{[PRN:5]"); SERIAL_ECHO("{[PRN:5]");
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
status_number = 5; status_number = 5;
break; break;
case 90: // Error - Thermal Runaway case 90: // Error - Thermal Runaway
SERIAL_ECHOLN("{[ERR:1]"); SERIAL_ECHO("{[ERR:1]");
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
break; break;
case 91: // Error - Thermal Runaway Preheat case 91: // Error - Thermal Runaway Preheat
SERIAL_ECHOLN("{[ERR:2]"); SERIAL_ECHO("{[ERR:2]");
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
break; break;
@ -2190,7 +2198,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) {
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
break; break;
case 93: // Error - Max temp case 93: // Error - Max temp
SERIAL_ECHOLN("{[ERR:4]"); SERIAL_ECHO("{[ERR:4]");
prusa_stat_farm_number(); prusa_stat_farm_number();
SERIAL_ECHOLN("}"); SERIAL_ECHOLN("}");
break; break;
@ -3001,7 +3009,7 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be
lcd_print_at_PGM(1,3,MSG_CURRENT); lcd_print_at_PGM(1,3,MSG_CURRENT);
char cursor_pos = 1; char cursor_pos = 1;
int enc_dif = 0; int enc_dif = 0;
KEEPALIVE_STATE(PAUSED_FOR_USER);
while (1) { while (1) {
manage_heater(); manage_heater();
manage_inactivity(true); manage_inactivity(true);
@ -3029,10 +3037,10 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be
while (lcd_clicked()); while (lcd_clicked());
delay(10); delay(10);
while (lcd_clicked()); while (lcd_clicked());
KEEPALIVE_STATE(IN_HANDLER);
return(cursor_pos - 1); return(cursor_pos - 1);
} }
} }
} }
char choose_extruder_menu() { char choose_extruder_menu() {
@ -3051,7 +3059,7 @@ char choose_extruder_menu() {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
lcd_print_at_PGM(1, i + 1, MSG_EXTRUDER); lcd_print_at_PGM(1, i + 1, MSG_EXTRUDER);
} }
KEEPALIVE_STATE(PAUSED_FOR_USER);
while (1) { while (1) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -3115,6 +3123,7 @@ char choose_extruder_menu() {
while (lcd_clicked()); while (lcd_clicked());
delay(10); delay(10);
while (lcd_clicked()); while (lcd_clicked());
KEEPALIVE_STATE(IN_HANDLER);
return(cursor_pos + first - 1); return(cursor_pos + first - 1);
} }
@ -3264,31 +3273,26 @@ void change_extr(int extr) { //switches multiplexer for extruders
pinMode(E_MUX0_PIN, OUTPUT); pinMode(E_MUX0_PIN, OUTPUT);
pinMode(E_MUX1_PIN, OUTPUT); pinMode(E_MUX1_PIN, OUTPUT);
pinMode(E_MUX2_PIN, OUTPUT);
switch (extr) { switch (extr) {
case 1: case 1:
WRITE(E_MUX0_PIN, HIGH); WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, LOW); WRITE(E_MUX1_PIN, LOW);
WRITE(E_MUX2_PIN, LOW);
break; break;
case 2: case 2:
WRITE(E_MUX0_PIN, LOW); WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, HIGH); WRITE(E_MUX1_PIN, HIGH);
WRITE(E_MUX2_PIN, LOW);
break; break;
case 3: case 3:
WRITE(E_MUX0_PIN, HIGH); WRITE(E_MUX0_PIN, HIGH);
WRITE(E_MUX1_PIN, HIGH); WRITE(E_MUX1_PIN, HIGH);
WRITE(E_MUX2_PIN, LOW);
break; break;
default: default:
WRITE(E_MUX0_PIN, LOW); WRITE(E_MUX0_PIN, LOW);
WRITE(E_MUX1_PIN, LOW); WRITE(E_MUX1_PIN, LOW);
WRITE(E_MUX2_PIN, LOW);
break; break;
} }
@ -3296,7 +3300,7 @@ void change_extr(int extr) { //switches multiplexer for extruders
} }
static int get_ext_nr() { //reads multiplexer input pins and return current extruder number (counted from 0) static int get_ext_nr() { //reads multiplexer input pins and return current extruder number (counted from 0)
return(4 * READ(E_MUX2_PIN) + 2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN)); return(2 * READ(E_MUX1_PIN) + READ(E_MUX0_PIN));
} }
@ -3309,7 +3313,7 @@ void display_loading() {
} }
} }
static void extr_adj(int extruder) //loading filament for SNMM void extr_adj(int extruder) //loading filament for SNMM
{ {
bool correct; bool correct;
max_feedrate[E_AXIS] =80; max_feedrate[E_AXIS] =80;
@ -3323,13 +3327,13 @@ static void extr_adj(int extruder) //loading filament for SNMM
case 3: lcd_display_message_fullscreen_P(MSG_FILAMENT_LOADING_T3); break; case 3: lcd_display_message_fullscreen_P(MSG_FILAMENT_LOADING_T3); break;
default: lcd_display_message_fullscreen_P(MSG_FILAMENT_LOADING_T0); break; default: lcd_display_message_fullscreen_P(MSG_FILAMENT_LOADING_T0); break;
} }
KEEPALIVE_STATE(PAUSED_FOR_USER);
do{ do{
extr_mov(0.001,1000); extr_mov(0.001,1000);
delay_keep_alive(2); delay_keep_alive(2);
} while (!lcd_clicked()); } while (!lcd_clicked());
//delay_keep_alive(500); //delay_keep_alive(500);
KEEPALIVE_STATE(IN_HANDLER);
st_synchronize(); st_synchronize();
//correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false); //correct = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FIL_LOADED_CHECK, false);
//if (!correct) goto START; //if (!correct) goto START;
@ -3773,12 +3777,20 @@ void lcd_confirm_print()
_ret = 1; _ret = 1;
filament_type = lcd_choose_color(); filament_type = lcd_choose_color();
prusa_statistics(4, filament_type); prusa_statistics(4, filament_type);
no_response = true; //we need confirmation by recieving PRUSA thx
important_status = 4;
saved_filament_type = filament_type;
NcTime = millis();
} }
if (cursor_pos == 2) if (cursor_pos == 2)
{ {
_ret = 2; _ret = 2;
filament_type = lcd_choose_color(); filament_type = lcd_choose_color();
prusa_statistics(5, filament_type); prusa_statistics(5, filament_type);
no_response = true; //we need confirmation by recieving PRUSA thx
important_status = 5;
saved_filament_type = filament_type;
NcTime = millis();
} }
} }
@ -3849,7 +3861,7 @@ static void lcd_main_menu()
}*/ }*/
if ( ( IS_SD_PRINTING || is_usb_printing ) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag) if ( ( IS_SD_PRINTING || is_usb_printing ) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag)
{ {
MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_babystep_z);//8 MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_babystep_z);//8
@ -4109,7 +4121,7 @@ void lcd_sdcard_stop()
lcd_return_to_status(); lcd_return_to_status();
lcd_ignore_click(true); lcd_ignore_click(true);
lcd_commands_type = LCD_COMMAND_STOP_PRINT; lcd_commands_type = LCD_COMMAND_STOP_PRINT;
if (farm_mode) prusa_statistics(7);
// Turn off the print fan // Turn off the print fan
SET_OUTPUT(FAN_PIN); SET_OUTPUT(FAN_PIN);
WRITE(FAN_PIN, 0); WRITE(FAN_PIN, 0);
@ -4159,14 +4171,16 @@ void lcd_sdcard_menu()
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
if (!farm_mode) {
#ifdef SDCARD_SORT_ALPHA #ifdef SDCARD_SORT_ALPHA
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort)); EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch(sdSort){ switch (sdSort) {
case SD_SORT_TIME: MENU_ITEM(function, MSG_SORT_TIME, lcd_sort_type_set); break; case SD_SORT_TIME: MENU_ITEM(function, MSG_SORT_TIME, lcd_sort_type_set); break;
case SD_SORT_ALPHA: MENU_ITEM(function, MSG_SORT_ALPHA, lcd_sort_type_set); break; case SD_SORT_ALPHA: MENU_ITEM(function, MSG_SORT_ALPHA, lcd_sort_type_set); break;
default: MENU_ITEM(function, MSG_SORT_NONE, lcd_sort_type_set); default: MENU_ITEM(function, MSG_SORT_NONE, lcd_sort_type_set);
} }
#endif // SDCARD_SORT_ALPHA #endif // SDCARD_SORT_ALPHA
}
card.getWorkDirName(); card.getWorkDirName();
if (card.filename[0] == '/') if (card.filename[0] == '/')
{ {
@ -4181,7 +4195,8 @@ void lcd_sdcard_menu()
{ {
if (_menuItemNr == _lineNr) if (_menuItemNr == _lineNr)
{ {
const uint16_t nr = (sdSort == SD_SORT_NONE) ? (fileCnt - 1 - i) : i; const uint16_t nr = ((sdSort == SD_SORT_NONE) || farm_mode) ? (fileCnt - 1 - i) : i;
/* #ifdef SDCARD_RATHERRECENTFIRST /* #ifdef SDCARD_RATHERRECENTFIRST
#ifndef SDCARD_SORT_ALPHA #ifndef SDCARD_SORT_ALPHA
fileCnt - 1 - fileCnt - 1 -
@ -4800,6 +4815,7 @@ static bool lcd_selftest_fan_dialog(int _fan)
lcd.setCursor(1, 3); lcd_printPGM(MSG_SELFTEST_FAN_NO); lcd.setCursor(1, 3); lcd_printPGM(MSG_SELFTEST_FAN_NO);
int8_t enc_dif = 0; int8_t enc_dif = 0;
KEEPALIVE_STATE(PAUSED_FOR_USER);
do do
{ {
switch (_fan) switch (_fan)
@ -4840,7 +4856,7 @@ static bool lcd_selftest_fan_dialog(int _fan)
delay(100); delay(100);
} while (!lcd_clicked()); } while (!lcd_clicked());
KEEPALIVE_STATE(IN_HANDLER);
SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN); SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
WRITE(EXTRUDER_0_AUTO_FAN_PIN, 0); WRITE(EXTRUDER_0_AUTO_FAN_PIN, 0);
SET_OUTPUT(FAN_PIN); SET_OUTPUT(FAN_PIN);
@ -5202,12 +5218,56 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
} }
if (!SdFatUtil::test_stack_integrity()) stack_error(); if (!SdFatUtil::test_stack_integrity()) stack_error();
lcd_ping(); //check that we have received ping command if we are in farm mode lcd_ping(); //check that we have received ping command if we are in farm mode
lcd_send_status();
} }
void lcd_printer_connected() { void lcd_printer_connected() {
printer_connected = true; printer_connected = true;
} }
static void lcd_send_status() {
if (farm_mode && no_response && ((millis() - NcTime) > (NC_TIME * 1000))) {
//send important status messages periodicaly
prusa_statistics(important_status, saved_filament_type);
NcTime = millis();
lcd_connect_printer();
}
};
static void lcd_connect_printer() {
lcd_update_enable(false);
lcd_implementation_clear();
bool pressed = false;
int i = 0;
int t = 0;
lcd_set_custom_characters_progress();
lcd_implementation_print_at(0, 0, "Connect printer to");
lcd_implementation_print_at(0, 1, "monitoring or hold");
lcd_implementation_print_at(0, 2, "the knob to continue");
while (no_response) {
i++;
t++;
delay_keep_alive(100);
proc_commands();
if (t == 10) {
prusa_statistics(important_status, saved_filament_type);
t = 0;
}
if (READ(BTN_ENC)) { //if button is not pressed
i = 0;
lcd_implementation_print_at(0, 3, " ");
}
if (i!=0) lcd_implementation_print_at((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\x01");
if (i == NC_BUTTON_LONG_PRESS * 10) {
no_response = false;
}
}
lcd_set_custom_characters_degree();
lcd_update_enable(true);
lcd_update(2);
}
void lcd_ping() { //chceck if printer is connected to monitoring when in farm mode void lcd_ping() { //chceck if printer is connected to monitoring when in farm mode
if (farm_mode) { if (farm_mode) {
bool empty = is_buffer_empty(); bool empty = is_buffer_empty();

View File

@ -211,7 +211,7 @@ extern void lcd_implementation_print_at(uint8_t x, uint8_t y, const char *str);
void change_extr(int extr); void change_extr(int extr);
static void lcd_colorprint_change(); static void lcd_colorprint_change();
static int get_ext_nr(); static int get_ext_nr();
static void extr_adj(int extruder); void extr_adj(int extruder);
static void extr_adj_0(); static void extr_adj_0();
static void extr_adj_1(); static void extr_adj_1();
static void extr_adj_2(); static void extr_adj_2();
@ -266,4 +266,7 @@ void lcd_set_arrows();
void lcd_set_progress(); void lcd_set_progress();
#endif #endif
static void lcd_send_status();
static void lcd_connect_printer();
#endif //ULTRALCD_H #endif //ULTRALCD_H

View File

@ -830,50 +830,48 @@ static void lcd_implementation_status_screen()
// If heating in progress, set flag // If heating in progress, set flag
if (heating_status != 0) { custom_message = true; } if (heating_status != 0) { custom_message = true; }
// If printing from SD, show what we are printing if (IS_SD_PRINTING) {
if ((IS_SD_PRINTING) && !custom_message) if (strcmp(longFilenameOLD, card.longFilename) != 0)
{
if(strcmp(longFilenameOLD, card.longFilename) != 0)
{
memset(longFilenameOLD,'\0',strlen(longFilenameOLD));
sprintf_P(longFilenameOLD, PSTR("%s"), card.longFilename);
scrollstuff = 0;
}
if(strlen(card.longFilename) > LCD_WIDTH)
{
int inters = 0;
int gh = scrollstuff;
while( ((gh-scrollstuff)<LCD_WIDTH) && (inters == 0) )
{ {
memset(longFilenameOLD, '\0', strlen(longFilenameOLD));
if(card.longFilename[gh] == '\0') sprintf_P(longFilenameOLD, PSTR("%s"), card.longFilename);
scrollstuff = 0;
}
}
// If printing from SD, show what we are printing
if (IS_SD_PRINTING && !custom_message)
{
if (strlen(card.longFilename) > LCD_WIDTH)
{ {
lcd.setCursor(gh-scrollstuff, 3); int inters = 0;
lcd.print(card.longFilename[gh-1]); int gh = scrollstuff;
scrollstuff = 0; while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0))
gh = scrollstuff; {
inters = 1;
} if (card.longFilename[gh] == '\0')
{
lcd.setCursor(gh - scrollstuff, 3);
lcd.print(card.longFilename[gh - 1]);
scrollstuff = 0;
gh = scrollstuff;
inters = 1;
}
else
{
lcd.setCursor(gh - scrollstuff, 3);
lcd.print(card.longFilename[gh - 1]);
gh++;
}
}
scrollstuff++;
}
else else
{ {
lcd.setCursor(gh-scrollstuff, 3); lcd.print(longFilenameOLD);
lcd.print(card.longFilename[gh-1]); }
gh++;
}
}
scrollstuff++;
}
else
{
lcd.print(longFilenameOLD);
}
} }
// If not, check for other special events // If not, check for other special events
else else

View File

@ -391,6 +391,8 @@ THERMISTORS SETTINGS
#define PING_TIME 60 //time in s #define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s #define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press #define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release

View File

@ -391,6 +391,8 @@ THERMISTORS SETTINGS
#define PING_TIME 60 //time in s #define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s #define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press #define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release

View File

@ -386,6 +386,8 @@ THERMISTORS SETTINGS
#define PING_TIME 60 //time in s #define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s #define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press #define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release

View File

@ -388,6 +388,8 @@ THERMISTORS SETTINGS
#define PING_TIME 60 //time in s #define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s #define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press #define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release

View File

@ -386,6 +386,8 @@ THERMISTORS SETTINGS
#define PING_TIME 60 //time in s #define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s #define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press #define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release

View File

@ -388,6 +388,8 @@ THERMISTORS SETTINGS
#define PING_TIME 60 //time in s #define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s #define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press #define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release