diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b386d2a0f..4dccdf648 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -205,10 +205,6 @@ static LongTimer crashDetTimer; bool mesh_bed_leveling_flag = false; -#ifdef PRUSA_M28 -bool prusa_sd_card_upload = false; -#endif - unsigned long total_filament_used; HeatingStatus heating_status; uint8_t heating_status_counter; @@ -1677,79 +1673,6 @@ void stack_error() { crash_and_burn(dump_crash_reason::stack_error); } -#ifdef PRUSA_M28 -void trace(); - -#define CHUNK_SIZE 64 // bytes -#define SAFETY_MARGIN 1 -char chunk[CHUNK_SIZE+SAFETY_MARGIN]; - -void serial_read_stream() { - - setAllTargetHotends(0); - setTargetBed(0); - - lcd_clear(); - lcd_puts_P(PSTR(" Upload in progress")); - - // first wait for how many bytes we will receive - uint32_t bytesToReceive; - - // receive the four bytes - char bytesToReceiveBuffer[4]; - for (int i=0; i<4; i++) { - int data; - while ((data = MYSERIAL.read()) == -1) {}; - bytesToReceiveBuffer[i] = data; - - } - - // make it a uint32 - memcpy(&bytesToReceive, &bytesToReceiveBuffer, 4); - - // we're ready, notify the sender - MYSERIAL.write('+'); - - // lock in the routine - uint32_t receivedBytes = 0; - while (prusa_sd_card_upload) { - int i; - for (i=0; i 0 to avoid 0 triggering when dealing with long gcodes -#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 @@ -22,11 +18,14 @@ uint8_t farm_mode = 0; static ShortTimer NcTime; static uint8_t farm_timer = 8; -static bool printer_connected = true; -static unsigned long PingTime = 0; static uint8_t status_number = 0; static bool no_response = false; -static uint8_t important_status; +#ifdef PRUSA_M28 +#define CHUNK_SIZE 64 // bytes +#define SAFETY_MARGIN 1 +bool prusa_sd_card_upload = false; +char chunk[CHUNK_SIZE+SAFETY_MARGIN]; +#endif static void prusa_statistics_err(char c); @@ -40,7 +39,9 @@ static void lcd_send_status(); static void proc_commands(); static void lcd_connect_printer(); #endif //FARM_CONNECT_MESSAGE -static void lcd_ping(); +#ifdef PRUSA_M28 +static void trace(); +#endif static void prusa_statistics_err(char c) { @@ -110,7 +111,7 @@ static void prusa_stat_printinfo() { static void lcd_send_status() { if (farm_mode && no_response && (NcTime.expired(NC_TIME * 1000))) { //send important status messages periodicaly - prusa_statistics(important_status); + prusa_statistics(8); NcTime.start(); #ifdef FARM_CONNECT_MESSAGE lcd_connect_printer(); @@ -143,7 +144,7 @@ static void lcd_connect_printer() { delay_keep_alive(100); proc_commands(); if (t == 10) { - prusa_statistics(important_status); + prusa_statistics(8); t = 0; } if (READ(BTN_ENC)) { //if button is not pressed @@ -160,23 +161,76 @@ static void lcd_connect_printer() { } #endif //FARM_CONNECT_MESSAGE -static void lcd_ping() { //chceck if printer is connected to monitoring when in farm mode - if (farm_mode) { - bool empty = cmd_buffer_empty(); - if ((_millis() - PingTime) * 0.001 > (empty ? PING_TIME : PING_TIME_LONG)) { - //if commands buffer is empty use shorter time period - //if there are comamnds in buffer, some long gcodes can delay execution of ping command - //therefore longer period is used - printer_connected = false; +#ifdef PRUSA_M28 +static void trace() { + Sound_MakeCustom(25,440,true); +} + +void serial_read_stream() { + + setAllTargetHotends(0); + setTargetBed(0); + + lcd_clear(); + lcd_puts_P(PSTR(" Upload in progress")); + + // first wait for how many bytes we will receive + uint32_t bytesToReceive; + + // receive the four bytes + char bytesToReceiveBuffer[4]; + for (int i=0; i<4; i++) { + int data; + while ((data = MYSERIAL.read()) == -1) {}; + bytesToReceiveBuffer[i] = data; + + } + + // make it a uint32 + memcpy(&bytesToReceive, &bytesToReceiveBuffer, 4); + + // we're ready, notify the sender + MYSERIAL.write('+'); + + // lock in the routine + uint32_t receivedBytes = 0; + while (prusa_sd_card_upload) { + int i; + for (i=0; i