From 011468598e2dc10c898e28ee48e6fdf53d2bbf45 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Mon, 16 Sep 2019 00:43:37 +0200 Subject: [PATCH 01/18] IR sensor gen. II disconnected PCB detection --- Firmware/adc.c | 5 +- Firmware/config.h | 17 ++++- Firmware/eeprom.h | 3 + Firmware/fsensor.cpp | 138 +++++++++++++++++++++++++++++----- Firmware/fsensor.h | 29 +++++++- Firmware/pins_Einsy_1_0.h | 3 +- Firmware/temperature.cpp | 11 ++- Firmware/temperature.h | 6 ++ Firmware/ultralcd.cpp | 152 ++++++++++++++++++++++++++++++++++---- Firmware/ultralcd.h | 10 +++ 10 files changed, 330 insertions(+), 44 deletions(-) diff --git a/Firmware/adc.c b/Firmware/adc.c index 26728cef..3144990d 100644 --- a/Firmware/adc.c +++ b/Firmware/adc.c @@ -4,6 +4,7 @@ #include #include #include +#include "pins.h" uint8_t adc_state; uint8_t adc_count; @@ -24,8 +25,8 @@ void adc_init(void) ADMUX |= (1 << REFS0); ADCSRA |= (1 << ADEN); // ADCSRA |= (1 << ADIF) | (1 << ADSC); - DIDR0 = (ADC_CHAN_MSK & 0xff); - DIDR2 = (ADC_CHAN_MSK >> 8); + DIDR0 = ((ADC_CHAN_MSK & ADC_DIDR_MSK) & 0xff); + DIDR2 = ((ADC_CHAN_MSK & ADC_DIDR_MSK) >> 8); adc_reset(); // adc_sim_mask = 0b0101; // adc_sim_mask = 0b100101; diff --git a/Firmware/config.h b/Firmware/config.h index a712839b..3242e47c 100644 --- a/Firmware/config.h +++ b/Firmware/config.h @@ -2,9 +2,21 @@ #define _CONFIG_H +#include "Configuration_prusa.h" +#include "pins.h" + +#define IR_SENSOR_ANALOG (defined(VOLT_IR_PIN) && defined(IR_SENSOR)) + //ADC configuration +#if !IR_SENSOR_ANALOG #define ADC_CHAN_MSK 0b0000001001011111 //used AD channels bit mask (0,1,2,3,4,6,9) +#define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input) #define ADC_CHAN_CNT 7 //number of used channels) +#else //!IR_SENSOR_ANALOG +#define ADC_CHAN_MSK 0b0000001101011111 //used AD channels bit mask (0,1,2,3,4,6,8,9) +#define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input) +#define ADC_CHAN_CNT 8 //number of used channels) +#endif //!IR_SENSOR_ANALOG #define ADC_OVRSAMPL 16 //oversampling multiplier #define ADC_CALLBACK adc_ready //callback function () @@ -42,11 +54,8 @@ #define W25X20CL_SPCR SPI_SPCR(W25X20CL_SPI_RATE, 1, 1, 1, 0) #define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE) -#include "boards.h" -#include "Configuration_prusa.h" - //LANG - Multi-language support -//#define LANG_MODE 0 // primary language only +//define LANG_MODE 0 // primary language only #define LANG_MODE 1 // sec. language support #define LANG_SIZE_RESERVED 0x2800 // reserved space for secondary language (10240 bytes) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index c41fb9ff..83fdfe39 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -203,6 +203,9 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_SHEETS_BASE (EEPROM_CHECK_GCODE - EEPROM_SHEETS_SIZEOF) // Sheets static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); +#define EEPROM_FSENSOR_PCB (EEPROM_SHEETS_BASE-1) // uint8 +#define EEPROM_FSENSOR_ACTION_NA (EEPROM_FSENSOR_PCB-1) // uint8 + //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. #define EEPROM_LAST_ITEM EEPROM_SHEETS_BASE diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index f20f647d..c01274fb 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -15,6 +15,10 @@ #include "mmu.h" #include "cardreader.h" +#include "adc.h" +#include "temperature.h" +#include "config.h" + //! @name Basic parameters //! @{ #define FSENSOR_CHUNK_LEN 0.64F //!< filament sensor chunk length 0.64mm @@ -117,6 +121,13 @@ int16_t fsensor_oq_yd_max; uint16_t fsensor_oq_sh_sum; //! @} +#if IR_SENSOR_ANALOG +ClFsensorPCB oFsensorPCB; +ClFsensorActionNA oFsensorActionNA; +bool bIRsensorStateFlag=false; +unsigned long nIRsensorLastTime; +#endif //IR_SENSOR_ANALOG + void fsensor_stop_and_save_print(void) { printf_P(PSTR("fsensor_stop_and_save_print\n")); @@ -136,10 +147,11 @@ void fsensor_init(void) { #ifdef PAT9125 uint8_t pat9125 = pat9125_init(); - printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); + printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); #endif //PAT9125 uint8_t fsensor = eeprom_read_byte((uint8_t*)EEPROM_FSENSOR); fsensor_autoload_enabled=eeprom_read_byte((uint8_t*)EEPROM_FSENS_AUTOLOAD_ENABLED); + fsensor_not_responding = false; #ifdef PAT9125 uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED); fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false; @@ -150,19 +162,27 @@ void fsensor_init(void) fsensor = 0; //disable sensor fsensor_not_responding = true; } - else - fsensor_not_responding = false; #endif //PAT9125 +#if IR_SENSOR_ANALOG + bIRsensorStateFlag=false; + oFsensorPCB=(ClFsensorPCB)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_PCB); + oFsensorActionNA=(ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA); +#endif //IR_SENSOR_ANALOG if (fsensor) - fsensor_enable(); + fsensor_enable(false); // (in this case) EEPROM update is not necessary else - fsensor_disable(); - printf_P(PSTR("FSensor %S\n"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED\n"))); + fsensor_disable(false); // (in this case) EEPROM update is not necessary + printf_P(PSTR("FSensor %S"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED"))); +#if IR_SENSOR_ANALOG + printf_P(PSTR(" (sensor board revision: %S)\n"),(oFsensorPCB==ClFsensorPCB::_Rev03b)?PSTR("03b or newer"):PSTR("03 or older")); +#else //IR_SENSOR_ANALOG + printf_P(PSTR("\n")); +#endif //IR_SENSOR_ANALOG if (check_for_ir_sensor()) ir_sensor_detected = true; } -bool fsensor_enable(void) +bool fsensor_enable(bool bUpdateEEPROM) { #ifdef PAT9125 if (mmu_enabled == false) { //filament sensor is pat9125, enable only if it is working @@ -187,18 +207,34 @@ bool fsensor_enable(void) FSensorStateMenu = 1; } #else // PAT9125 - fsensor_enabled = true; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x01); - FSensorStateMenu = 1; -#endif // PAT9125 +#if IR_SENSOR_ANALOG + if(!fsensor_IR_check()) + { + bUpdateEEPROM=true; + fsensor_enabled=false; + fsensor_not_responding=true; + FSensorStateMenu=0; + } + else { +#endif //IR_SENSOR_ANALOG + fsensor_enabled=true; + fsensor_not_responding=false; + FSensorStateMenu=1; +#if IR_SENSOR_ANALOG + } +#endif //IR_SENSOR_ANALOG + if(bUpdateEEPROM) + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, FSensorStateMenu); +#endif //PAT9125 return fsensor_enabled; } -void fsensor_disable(void) -{ +void fsensor_disable(bool bUpdateEEPROM) +{ fsensor_enabled = false; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x00); FSensorStateMenu = 0; + if(bUpdateEEPROM) + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x00); } void fsensor_autoload_set(bool State) @@ -589,10 +625,76 @@ void fsensor_update(void) fsensor_oq_meassure_enabled = oq_meassure_enabled_tmp; } #else //PAT9125 - if ((digitalRead(IR_SENSOR_PIN) == 1) && CHECK_FSENSOR && fsensor_enabled && ir_sensor_detected && ( ! fsensor_m600_enqueued) ) - { - fsensor_stop_and_save_print(); - fsensor_enque_M600(); + if (CHECK_FSENSOR && fsensor_enabled && ir_sensor_detected && ( ! fsensor_m600_enqueued) ) + { + if(digitalRead(IR_SENSOR_PIN)) + { // IR_SENSOR_PIN ~ H +#if IR_SENSOR_ANALOG + if(!bIRsensorStateFlag) + { + bIRsensorStateFlag=true; + nIRsensorLastTime=_millis(); + } + else + { + if((_millis()-nIRsensorLastTime)>IR_SENSOR_STEADY) + { + uint8_t nMUX1,nMUX2; + uint16_t nADC; + bIRsensorStateFlag=false; + // sequence for direct data reading from AD converter + DISABLE_TEMPERATURE_INTERRUPT(); + nMUX1=ADMUX; // ADMUX saving + nMUX2=ADCSRB; + adc_setmux(VOLT_IR_PIN); + ADCSRA|=(1<((int)IRsensor_Hopen_TRESHOLD))) + { + fsensor_disable(); + fsensor_not_responding = true; + printf_P(PSTR("IR sensor not responding (%d)!\n"),1); + if((ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA)==ClFsensorActionNA::_Pause) + if(oFsensorActionNA==ClFsensorActionNA::_Pause) + lcd_pause_print(); + } + else + { +#endif //IR_SENSOR_ANALOG + fsensor_stop_and_save_print(); + fsensor_enque_M600(); +#if IR_SENSOR_ANALOG + } + } + } + } + else + { // IR_SENSOR_PIN ~ L + bIRsensorStateFlag=false; +#endif //IR_SENSOR_ANALOG + } } #endif //PAT9125 } + +#if IR_SENSOR_ANALOG +bool fsensor_IR_check() +{ +uint16_t volt_IR_int; +bool bCheckResult; + +volt_IR_int=current_voltage_raw_IR; +bCheckResult=(volt_IR_int<((int)IRsensor_Lmax_TRESHOLD))||(volt_IR_int>((int)IRsensor_Hmin_TRESHOLD)); +bCheckResult=bCheckResult&&(!((oFsensorPCB==ClFsensorPCB::_Rev03b)&&(volt_IR_int>((int)IRsensor_Hopen_TRESHOLD)))); +return(bCheckResult); +} +#endif //IR_SENSOR_ANALOG diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index fa7ab585..48ad5fba 100755 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -3,6 +3,7 @@ #define FSENSOR_H #include +#include "config.h" //! minimum meassured chunk length in steps @@ -27,8 +28,8 @@ extern void fsensor_init(void); //! @name enable/disable //! @{ -extern bool fsensor_enable(void); -extern void fsensor_disable(void); +extern bool fsensor_enable(bool bUpdateEEPROM=true); +extern void fsensor_disable(bool bUpdateEEPROM=true); //! @} //autoload feature enabled @@ -65,4 +66,28 @@ extern void fsensor_st_block_begin(block_t* bl); extern void fsensor_st_block_chunk(block_t* bl, int cnt); //! @} + +#if IR_SENSOR_ANALOG +#define IR_SENSOR_STEADY 10 // [ms] + +enum class ClFsensorPCB:uint_least8_t +{ + _Old=0, + _Rev03b=1, + _Undef=EEPROM_EMPTY_VALUE +}; + +enum class ClFsensorActionNA:uint_least8_t +{ + _Continue=0, + _Pause=1, + _Undef=EEPROM_EMPTY_VALUE +}; + +extern ClFsensorPCB oFsensorPCB; +extern ClFsensorActionNA oFsensorActionNA; + +extern bool fsensor_IR_check(); +#endif //IR_SENSOR_ANALOG + #endif //FSENSOR_H diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h index 33363388..1ea69a40 100755 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -71,12 +71,13 @@ #define HEATER_2_PIN -1 #define TEMP_2_PIN -1 -#define TEMP_AMBIENT_PIN 5 //A5 +#define TEMP_AMBIENT_PIN 6 //A6 #define TEMP_PINDA_PIN 3 //A3 #define VOLT_PWR_PIN 4 //A4 #define VOLT_BED_PIN 9 //A9 +#define VOLT_IR_PIN 8 //A8 #define E0_TMC2130_CS 66 diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 391607e8..80497480 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -44,6 +44,8 @@ #include "Timer.h" #include "Configuration_prusa.h" +#include "config.h" + //=========================================================================== //=============================public variables============================ //=========================================================================== @@ -71,6 +73,10 @@ int current_voltage_raw_pwr = 0; int current_voltage_raw_bed = 0; #endif +#if IR_SENSOR_ANALOG +int current_voltage_raw_IR = 0; +#endif //IR_SENSOR_ANALOG + int current_temperature_bed_raw = 0; float current_temperature_bed = 0.0; #ifdef TEMP_SENSOR_1_AS_REDUNDANT @@ -1635,11 +1641,14 @@ void adc_ready(void) //callback from adc when sampling finished current_voltage_raw_pwr = adc_values[ADC_PIN_IDX(VOLT_PWR_PIN)]; #endif #ifdef AMBIENT_THERMISTOR - current_temperature_raw_ambient = adc_values[ADC_PIN_IDX(TEMP_AMBIENT_PIN)]; + current_temperature_raw_ambient = adc_values[ADC_PIN_IDX(TEMP_AMBIENT_PIN)]; // 5->6 #endif //AMBIENT_THERMISTOR #ifdef VOLT_BED_PIN current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9 #endif +#if IR_SENSOR_ANALOG + current_voltage_raw_IR = adc_values[ADC_PIN_IDX(VOLT_IR_PIN)]; +#endif //IR_SENSOR_ANALOG temp_meas_ready = true; } diff --git a/Firmware/temperature.h b/Firmware/temperature.h index e9ba11b4..7ece8927 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -27,6 +27,8 @@ #include "stepper.h" #endif +#include "config.h" + #ifdef SYSTEM_TIMER_2 @@ -74,6 +76,10 @@ extern int current_voltage_raw_pwr; extern int current_voltage_raw_bed; #endif +#if IR_SENSOR_ANALOG +extern int current_voltage_raw_IR; +#endif //IR_SENSOR_ANALOG + #ifdef TEMP_SENSOR_1_AS_REDUNDANT extern float redundant_temperature; #endif diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0d726769..ffc12c26 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -42,6 +42,10 @@ #include "io_atmega2560.h" #include "first_lay_cal.h" +#include "fsensor.h" +#include "adc.h" +#include "config.h" + int scrollstuff = 0; char longFilenameOLD[LONG_FILENAME_LENGTH]; @@ -61,9 +65,6 @@ int8_t FSensorStateMenu = 1; int8_t CrashDetectMenu = 1; -extern bool fsensor_enable(); -extern void fsensor_disable(); - #ifdef TMC2130 extern void crashdet_enable(); extern void crashdet_disable(); @@ -200,6 +201,7 @@ enum class TestError : uint_least8_t SwappedFan, WiringFsensor, TriggeringFsensor, + FsensorLevel }; static int lcd_selftest_screen(TestScreen screen, int _progress, int _progress_scale, bool _clear, int _delay); @@ -231,6 +233,9 @@ static FanCheck lcd_selftest_fan_auto(int _fan); static bool lcd_selftest_fsensor(); #endif //PAT9125 static bool selftest_irsensor(); +#if IR_SENSOR_ANALOG +static bool lcd_selftest_IRsensor(); +#endif //IR_SENSOR_ANALOG static void lcd_selftest_error(TestError error, const char *_error_1, const char *_error_2); static void lcd_colorprint_change(); #ifdef SNMM @@ -1984,21 +1989,28 @@ static void lcd_menu_temperatures() menu_back_if_clicked(); } -#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) +#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || IR_SENSOR_ANALOG #define VOLT_DIV_R1 10000 #define VOLT_DIV_R2 2370 #define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1)) -#define VOLT_DIV_REF 5 + static void lcd_menu_voltages() { lcd_timeoutToStatus.stop(); //infinite timeout float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC; float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC; lcd_home(); - lcd_printf_P(PSTR(" PWR: %d.%01dV\n" " BED: %d.%01dV"), (int)volt_pwr, (int)(10*fabs(volt_pwr - (int)volt_pwr)), (int)volt_bed, (int)(10*fabs(volt_bed - (int)volt_bed))); - menu_back_if_clicked(); +#if !IR_SENSOR_ANALOG + lcd_printf_P(PSTR("\n")); +#endif //!IR_SENSOR_ANALOG + lcd_printf_P(PSTR(" PWR: %4.1fV\n" " BED: %4.1fV"), volt_pwr, volt_bed); +#if IR_SENSOR_ANALOG + float volt_IR = VOLT_DIV_REF * ((float)current_voltage_raw_IR / (1023 * OVERSAMPLENR)); + lcd_printf_P(PSTR("\n IR : %3.1fV"),volt_IR); +#endif //IR_SENSOR_ANALOG + menu_back_if_clicked(); } -#endif //defined VOLT_BED_PIN || defined VOLT_PWR_PIN +#endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || IR_SENSOR_ANALOG #ifdef TMC2130 static void lcd_menu_belt_status() @@ -5505,6 +5517,41 @@ SETTINGS_VERSION; MENU_END(); } +#if IR_SENSOR_ANALOG +static void lcd_fsensor_actionNA_set(void) +{ +switch(oFsensorActionNA) + { + case ClFsensorActionNA::_Continue: + oFsensorActionNA=ClFsensorActionNA::_Pause; + break; + case ClFsensorActionNA::_Pause: + oFsensorActionNA=ClFsensorActionNA::_Continue; + break; + default: + oFsensorActionNA=ClFsensorActionNA::_Continue; + } +eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA,(uint8_t)oFsensorActionNA); +} + +#define FSENSOR_ACTION_NA \ +do\ +{\ + switch(oFsensorActionNA)\ + {\ + case ClFsensorActionNA::_Continue:\ + MENU_ITEM_FUNCTION_P(_i("FS Action [cont.]"),lcd_fsensor_actionNA_set);\ + break;\ + case ClFsensorActionNA::_Pause:\ + MENU_ITEM_FUNCTION_P(_i("FS Action [pause]"),lcd_fsensor_actionNA_set);\ + break;\ + default:\ + oFsensorActionNA=ClFsensorActionNA::_Continue;\ + }\ +}\ +while (0) +#endif //IR_SENSOR_ANALOG + void lcd_hw_setup_menu(void) // can not be "static" { MENU_BEGIN(); @@ -5536,6 +5583,11 @@ if(!farm_mode){ SETTINGS_NOZZLE; MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu); } + +#if IR_SENSOR_ANALOG +FSENSOR_ACTION_NA; +#endif //IR_SENSOR_ANALOG + MENU_END(); } @@ -6850,11 +6902,21 @@ static void lcd_tune_menu() #ifdef FILAMENT_SENSOR if (FSensorStateMenu == 0) { - MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set); + if (fsensor_not_responding && (mmu_enabled == false)) { + /* Filament sensor not working*/ + MENU_ITEM_FUNCTION_P(_i("Fil. sensor [N/A]"), lcd_fsensor_state_set); + } + else { + /* Filament sensor turned off, working, no problems*/ + MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set); + } } else { MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_ON), lcd_fsensor_state_set); } +#if IR_SENSOR_ANALOG + FSENSOR_ACTION_NA; +#endif //IR_SENSOR_ANALOG #endif //FILAMENT_SENSOR SETTINGS_AUTO_DEPLETE; @@ -7137,6 +7199,42 @@ void lcd_sdcard_menu() MENU_END(); } +#if IR_SENSOR_ANALOG +static bool lcd_selftest_IRsensor() +{ +bool bAction; +bool bPCBrev03b; +uint16_t volt_IR_int; +float volt_IR; + +volt_IR_int=current_voltage_raw_IR; +bPCBrev03b=(volt_IR_int<((int)IRsensor_Hopen_TRESHOLD)); +volt_IR=VOLT_DIV_REF*((float)volt_IR_int/(1023*OVERSAMPLENR)); +printf_P(PSTR("Measured filament sensor high level: %4.2fV\n"),volt_IR); +if(volt_IR_int<((int)IRsensor_Hmin_TRESHOLD)) + { + lcd_selftest_error(TestError::FsensorLevel,"HIGH",""); + return(false); + } +lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament (but not load them!) into extruder and then press the knob.")); +volt_IR_int=current_voltage_raw_IR; +volt_IR=VOLT_DIV_REF*((float)volt_IR_int/(1023*OVERSAMPLENR)); +printf_P(PSTR("Measured filament sensor low level: %4.2fV\n"),volt_IR); +if(volt_IR_int>((int)IRsensor_Lmax_TRESHOLD)) + { + lcd_selftest_error(TestError::FsensorLevel,"LOW",""); + return(false); + } +if((bPCBrev03b?1:0)!=(uint8_t)oFsensorPCB) // safer then "(uint8_t)bPCBrev03b" + { + printf_P(PSTR("Filament sensor board change detected: revision %S\n"),bPCBrev03b?PSTR("03b or newer"):PSTR("03 or older")); + oFsensorPCB=bPCBrev03b?ClFsensorPCB::_Rev03b:ClFsensorPCB::_Old; + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_PCB,(uint8_t)oFsensorPCB); + } +return(true); +} +#endif //IR_SENSOR_ANALOG + static void lcd_selftest_v() { (void)lcd_selftest(); @@ -7153,8 +7251,16 @@ bool lcd_selftest() #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif // TMC2130 - _delay(2000); +#if !IR_SENSOR_ANALOG + _delay(2000); +#endif //!IR_SENSOR_ANALOG KEEPALIVE_STATE(IN_HANDLER); +#if IR_SENSOR_ANALOG + bool bAction; + bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is filament unloaded?"),false,true); + if(!bAction) + return(false); +#endif //IR_SENSOR_ANALOG _progress = lcd_selftest_screen(TestScreen::ExtruderFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_0)) @@ -7340,12 +7446,20 @@ bool lcd_selftest() { #ifdef PAT9125 _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filaments sensor - _result = lcd_selftest_fsensor(); + _result = lcd_selftest_fsensor(); if (_result) { _progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK } #endif //PAT9125 +#if IR_SENSOR_ANALOG + _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filament sensor + _result = lcd_selftest_IRsensor(); + if (_result) + { + _progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //filament sensor OK + } +#endif //IR_SENSOR_ANALOG } } #endif //FILAMENT_SENSOR @@ -7881,11 +7995,17 @@ static void lcd_selftest_error(TestError testError, const char *_error_1, const lcd_puts_P(_T(MSG_SELFTEST_WIRINGERROR)); break; case TestError::TriggeringFsensor: - lcd_set_cursor(0, 2); - lcd_puts_P(_T(MSG_SELFTEST_FILAMENT_SENSOR)); - lcd_set_cursor(0, 3); - lcd_puts_P(_i("False triggering"));////c=20 - break; + lcd_set_cursor(0, 2); + lcd_puts_P(_T(MSG_SELFTEST_FILAMENT_SENSOR)); + lcd_set_cursor(0, 3); + lcd_puts_P(_i("False triggering"));////c=20 + break; + case TestError::FsensorLevel: + lcd_set_cursor(0, 2); + lcd_puts_P(_T(MSG_SELFTEST_FILAMENT_SENSOR)); + lcd_set_cursor(0, 3); + lcd_printf_P(_i("%s level expected"),_error_1);////c=20 + break; } _delay(1000); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 2c57c944..65e886c6 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -7,6 +7,8 @@ #include "menu.h" #include "mesh_bed_calibration.h" +#include "config.h" + extern void menu_lcd_longpress_func(void); extern void menu_lcd_charsetup_func(void); extern void menu_lcd_lcdupdate_func(void); @@ -234,4 +236,12 @@ enum class WizState : uint8_t void lcd_wizard(WizState state); +#define VOLT_DIV_REF 5 +#if IR_SENSOR_ANALOG +#define IRsensor_Hmin_TRESHOLD (3.0*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~3.0V (0.6*Vcc) +#define IRsensor_Lmax_TRESHOLD (1.5*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~1.5V (0.3*Vcc) +#define IRsensor_Hopen_TRESHOLD (4.6*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k) +#define IRsensor_Ldiode_TRESHOLD (0.3*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~0.3V +#endif //IR_SENSOR_ANALOG + #endif //ULTRALCD_H From d491a9801d2f5a6869db658283f380f7ca145ef3 Mon Sep 17 00:00:00 2001 From: MRprusa3d <38257799+MRprusa3d@users.noreply.github.com> Date: Mon, 16 Sep 2019 16:04:45 +0200 Subject: [PATCH 02/18] Update ultralcd.cpp --- Firmware/ultralcd.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5fe2e976..5a710ba3 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5392,7 +5392,6 @@ do\ while (0) #endif //IR_SENSOR_ANALOG -void lcd_hw_setup_menu(void) // can not be "static" template static void select_sheet_menu() { From 28edd5a80beed6740ab365b71b5232c290bd688a Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Mon, 23 Sep 2019 19:22:45 +0200 Subject: [PATCH 03/18] Prepare PF-build.sh for Prusa Arduino_Boards V1.0.2 As I am planning to add new Prusa Arduino_Boards definition version 1.0.2 which contains few changes which interfere withthe existing PF-build.sh using Arduino_Boards v1.0.1, i had to add an additional variable. I have tested PF-build.sh with Arduino_Boards v1.0.1 and v1.0.2 It creates identical firmware hex files, if I manage it to run in the same minute. If one of the runs is off by a minute compared to the other there is just one line in the hex code different, which is showing the compiling date, time and firmware version. --- PF-build.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index fb3b51a1..9bafed34 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_9 +# Version: 1.0.6-Build_10 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -112,7 +112,7 @@ # Changed Hex-files folder to PF-build-hex as requested in PR # 23 Jul 2019, 3d-gussner, Added Finding OS version routine so supporting new OS should get easier # 26 Jul 2019, 3d-gussner, Change JSON repository to prusa3d after PR https://github.com/prusa3d/Arduino_Boards/pull/1 was merged - +# 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for comming Prusa3d/Arduino_Boards version 1.0.2 Pull Request #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -211,7 +211,8 @@ fi #### Set build environment ARDUINO_ENV="1.8.5" BUILD_ENV="1.0.6" -BOARD="PrusaResearchRambo" +BOARD="rambo" +BOARD_PACKAGE_NAME="PrusaResearchRambo" BOARD_VERSION="1.0.1" BOARD_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json" BOARD_FILENAME="prusa3drambo" @@ -229,6 +230,7 @@ echo "" echo "Ardunio IDE :" $ARDUINO_ENV echo "Build env :" $BUILD_ENV echo "Board :" $BOARD +echo "Package name:" $BOARD_PACKAGE_NAME echo "Specific Lib:" $LIB echo "" @@ -317,7 +319,7 @@ if [ ! -e ../PF-build-env-$BUILD_ENV/Preferences-$TARGET_OS-$Processor.txt ]; th echo "update.check" sed -i 's/update.check = true/update.check = false/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt echo "board" - sed -i 's/board = uno/board = rambo/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt + sed -i 's/board = uno/board = $BOARD/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt echo "editor.linenumbers" sed -i 's/editor.linenumbers = false/editor.linenumbers = true/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt echo "boardsmanager.additional.urls" @@ -336,24 +338,24 @@ if [ ! -f "$BOARD_FILENAME-$BOARD_VERSION.tar.bz2" ]; then sleep 2 wget $BOARD_FILE_URL || exit 9 fi -if [[ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr/$BOARD_VERSION" || ! -e "../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then - echo "$(tput setaf 6)Unzipping $BOARD Arduino IDE portable...$(tput setaf 2)" +if [[ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION" || ! -e "../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then + echo "$(tput setaf 6)Unzipping $BOARD_PACKAGE_NAME Arduino IDE portable...$(tput setaf 2)" sleep 2 tar -xvf $BOARD_FILENAME-$BOARD_VERSION.tar.bz2 -C ../PF-build-env-$BUILD_ENV/ || exit 10 - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD + if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then + mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME fi - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD + if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then + mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME fi - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware + if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware ]; then + mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware fi - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr + if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr ]; then + mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr fi - mv ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr/$BOARD_VERSION + mv ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION echo "# $BOARD_FILENAME-$BOARD_VERSION" >> ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt echo "$(tput sgr 0)" fi @@ -634,8 +636,8 @@ do echo "Start to build Prusa Firmware ..." echo "Using variant $VARIANT$(tput setaf 3)" sleep 2 - #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD:avr:rambo -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 - $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD:avr:rambo -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 + #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 + $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 echo "$(tput sgr 0)" if [ $LANGUAGES == "ALL" ]; then From 2af43667c81fdde913bc8193e134b55021acf8a9 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 17 Oct 2019 14:05:51 +0200 Subject: [PATCH 04/18] Changed folder and check file names... to have seperated build enviroments depening on Arduino IDE versions and board-versions. Successfully tested with: - Arduino IDE 1.8.5 and board version 1.0.1 - Arduino IDE 1.8.5 and board version 1.0.2 - These two above generate identical hex files - Arduino IDE 1.8.7 and board version 1.0.2 - Arduino IDE 1.8.8 and board version 1.0.2 - Arduino IDE 1.8.9 and board version 1.0.2 - These three above generate identical hex files - Compared to the 1.8.5 hex files the code uses less resources (Multi language/EN_ONLY): ``` Sketch uses 240082 bytes (94%) of program storage space. Maximum is 253952 bytes. Global variables use 6002 bytes of dynamic memory. Sketch uses 222344 bytes (87%) of program storage space. Maximum is 253952 bytes. Global variables use 6019 bytes of dynamic memory. ``` vs. ``` Sketch uses 241526 bytes (95%) of program storage space. Maximum is 253952 bytes. Global variables use 6046 bytes of dynamic memory. Sketch uses 223828 bytes (88%) of program storage space. Maximum is 253952 bytes. Global variables use 6065 bytes of dynamic memory. ``` Failed tests: - Arduino IDE 1.8.6 and board version 1.0.2 - Arduino IDE 1.8.10 and board version 1.0.2 --- PF-build.sh | 107 +++++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index 9bafed34..7f538ea0 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -113,6 +113,8 @@ # 23 Jul 2019, 3d-gussner, Added Finding OS version routine so supporting new OS should get easier # 26 Jul 2019, 3d-gussner, Change JSON repository to prusa3d after PR https://github.com/prusa3d/Arduino_Boards/pull/1 was merged # 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for comming Prusa3d/Arduino_Boards version 1.0.2 Pull Request +# 17 Oct 2019, 3d-gussner, Changed folder and check file names to have seperated build enviroments depening on Arduino IDE version and +# board-versions. #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -261,12 +263,12 @@ if [ $TARGET_OS == "windows" ]; then wget https://downloads.arduino.cc/arduino-$ARDUINO_ENV-windows.zip || exit 7 echo "$(tput sgr 0)" fi - if [ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor" ]; then + if [[ ! -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" && ! -e "../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then echo "$(tput setaf 6)Unzipping Windows 32/64-bit Arduino IDE portable...$(tput setaf 2)" sleep 2 unzip arduino-$ARDUINO_ENV-windows.zip -d ../PF-build-env-$BUILD_ENV || exit 7 - mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor - echo "# arduino-$ARDUINO_ENV-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$TARGET_OS-$Processor + mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor + echo "# arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt echo "$(tput sgr0)" fi fi @@ -279,55 +281,55 @@ if [ $TARGET_OS == "linux" ]; then wget --no-check-certificate https://downloads.arduino.cc/arduino-$ARDUINO_ENV-linux$Processor.tar.xz || exit 8 echo "$(tput sgr 0)" fi - if [[ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor" && ! -e "../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$TARGET_OS-$Processor.txt" ]]; then + if [[ ! -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" && ! -e "../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then echo "$(tput setaf 6)Unzipping Linux $Processor Arduino IDE portable...$(tput setaf 2)" sleep 2 tar -xvf arduino-$ARDUINO_ENV-linux$Processor.tar.xz -C ../PF-build-env-$BUILD_ENV/ || exit 8 - mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor - echo "# arduino-$ARDUINO_ENV-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$TARGET_OS-$Processor.txt + mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor + echo "# arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt echo "$(tput sgr0)" fi fi # Make Arduino IDE portable -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/ +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/ fi -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable fi -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/output/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/output +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/output/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/output fi -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages fi -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook fi -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook/libraries/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook/libraries +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook/libraries/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/sketchbook/libraries fi -if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/staging/ ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/staging +if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/staging/ ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/staging fi # Change Arduino IDE preferences -if [ ! -e ../PF-build-env-$BUILD_ENV/Preferences-$TARGET_OS-$Processor.txt ]; then - echo "$(tput setaf 6)Setting $TARGET_OS-$Processor Arduino IDE preferences for portable GUI usage...$(tput setaf 2)" +if [ ! -e ../PF-build-env-$BUILD_ENV/Preferences-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt ]; then + echo "$(tput setaf 6)Setting $ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor Arduino IDE preferences for portable GUI usage...$(tput setaf 2)" sleep 2 echo "update.check" - sed -i 's/update.check = true/update.check = false/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt + sed -i 's/update.check = true/update.check = false/g' ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt echo "board" - sed -i 's/board = uno/board = $BOARD/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt + sed -i 's/board = uno/board = $BOARD/g' ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt echo "editor.linenumbers" - sed -i 's/editor.linenumbers = false/editor.linenumbers = true/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt + sed -i 's/editor.linenumbers = false/editor.linenumbers = true/g' ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt echo "boardsmanager.additional.urls" - echo "boardsmanager.additional.urls=$BOARD_URL" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt - echo "build.verbose=true" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt - echo "compiler.cache_core=false" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt - echo "compiler.warning_level=all" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt - echo "# Preferences-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/Preferences-$TARGET_OS-$Processor.txt + echo "boardsmanager.additional.urls=$BOARD_URL" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt + echo "build.verbose=true" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt + echo "compiler.cache_core=false" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt + echo "compiler.warning_level=all" >>../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/lib/preferences.txt + echo "# Preferences-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/Preferences-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt echo "$(tput sgr0)" fi @@ -338,25 +340,26 @@ if [ ! -f "$BOARD_FILENAME-$BOARD_VERSION.tar.bz2" ]; then sleep 2 wget $BOARD_FILE_URL || exit 9 fi -if [[ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION" || ! -e "../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then +if [[ ! -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION" || ! -e "../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then echo "$(tput setaf 6)Unzipping $BOARD_PACKAGE_NAME Arduino IDE portable...$(tput setaf 2)" sleep 2 tar -xvf $BOARD_FILENAME-$BOARD_VERSION.tar.bz2 -C ../PF-build-env-$BUILD_ENV/ || exit 10 - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME + if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME fi - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME + if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME fi - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware + if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware fi - if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr ]; then - mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr + if [ ! -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr ]; then + mkdir ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr fi - mv ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION - echo "# $BOARD_FILENAME-$BOARD_VERSION" >> ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt + mv ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/$BOARD_PACKAGE_NAME/hardware/avr/$BOARD_VERSION + echo "# $BOARD_FILENAME-$BOARD_VERSION" >> ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt + echo "$(tput sgr 0)" fi @@ -367,30 +370,30 @@ if [ ! -f "PF-build-env-$BUILD_ENV.zip" ]; then wget $PF_BUILD_FILE_URL || exit 11 echo "$(tput sgr 0)" fi -if [ ! -e "../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$TARGET_OS-$Processor.txt" ]; then +if [ ! -e "../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]; then echo "$(tput setaf 6)Unzipping Prusa Firmware build environment...$(tput setaf 2)" sleep 2 - unzip -o PF-build-env-$BUILD_ENV.zip -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor || exit 12 - echo "# PF-build-env-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$TARGET_OS-$Processor.txt + unzip -o PF-build-env-$BUILD_ENV.zip -d ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 12 + echo "# PF-build-env-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt echo "$(tput sgr0)" fi # Check if User updated Arduino IDE 1.8.5 boardsmanager and tools -if [ -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools" ]; then +if [ -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools" ]; then echo "$(tput setaf 6)Arduino IDE boards / tools have been manually updated...$" echo "Please don't update the 'Arduino AVR boards' as this will prevent running this script (tput setaf 2)" sleep 2 fi -if [ -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2" ]; then +if [ -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2" ]; then echo "$(tput setaf 6)PrusaReasearch compatible tools have been manually updated...$(tput setaf 2)" sleep 2 echo "$(tput setaf 6)Copying Prusa Firmware build environment to manually updated boards / tools...$(tput setaf 2)" sleep 2 - cp -f ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/hardware/tools/avr/avr/lib/ldscripts/avr6.xn ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/lib/ldscripts/avr6.xn - echo "# PF-build-env-portable-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-portable-$BUILD_ENV-$TARGET_OS-$Processor.txt + cp -f ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/hardware/tools/avr/avr/lib/ldscripts/avr6.xn ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/lib/ldscripts/avr6.xn + echo "# PF-build-env-portable-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-portable-$BUILD_ENV-$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor.txt echo "$(tput sgr0)" fi -if [ -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2" ]; then +if [ -d "../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2" ]; then echo "$(tput setaf 1)Arduino IDE tools have been updated manually to a non supported version!!!" echo "Delete ../PF-build-env-$BUILD_ENV and start the script again" echo "Script will not continue until this have been fixed $(tput setaf 2)" @@ -491,7 +494,7 @@ if [ ! -z "$3" ] ; then fi #Set BUILD_ENV_PATH -cd ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor || exit 24 +cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 24 BUILD_ENV_PATH="$( pwd -P )" cd ../.. @@ -636,8 +639,8 @@ do echo "Start to build Prusa Firmware ..." echo "Using variant $VARIANT$(tput setaf 3)" sleep 2 - #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 - $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 + #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 + $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 echo "$(tput sgr 0)" if [ $LANGUAGES == "ALL" ]; then From 23cf076242a7fdf5c43beb6a1684bff189761844 Mon Sep 17 00:00:00 2001 From: Panayiotis-git <32783577+Panayiotis-git@users.noreply.github.com> Date: Tue, 12 Nov 2019 21:32:39 +0200 Subject: [PATCH 05/18] =?UTF-8?q?Add=20oversighted=20=E2=80=98break?= =?UTF-8?q?=E2=80=99=20statement=20at=20the=20M603=20command's=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Firmware/Marlin_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d6bb77ef..aecb7e39 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7250,9 +7250,10 @@ Sigma_Exit: //! ### M603 - Stop print // ------------------------------- - case 603: { + case 603: { lcd_print_stop(); } + break; #ifdef PINDA_THERMISTOR //! ### M860 - Wait for extruder temperature (PINDA) From e66574ac5f547c766bb04a0c8bd9b4a8c28d7a2e Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 19 Nov 2019 13:51:10 +0200 Subject: [PATCH 06/18] Updated branch to use TOGGLE --- Firmware/messages.c | 3 +++ Firmware/messages.h | 3 +++ Firmware/ultralcd.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Firmware/messages.c b/Firmware/messages.c index f38c2939..bb2e9510 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -128,6 +128,9 @@ const char MSG_SOUND_BLIND[] PROGMEM_I1 = ISTR("Assist"); //// const char MSG_MESH[] PROGMEM_I1 = ISTR("Mesh"); //// const char MSG_Z_PROBE_NR[] PROGMEM_I1 = ISTR("Z-probe nr."); //// const char MSG_MAGNETS_COMP[] PROGMEM_I1 = ISTR("Magnets comp."); //// +const char MSG_FS_ACTION[] PROGMEM_I1 = ISTR("FS Action"); //// +const char MSG_FS_CONTINUE[] PROGMEM_I1 = ISTR("Cont."); //// +const char MSG_FS_PAUSE[] PROGMEM_I1 = ISTR("Pause"); //// //not internationalized messages const char MSG_SD_WORKDIR_FAIL[] PROGMEM_N1 = "workDir open failed"; //// diff --git a/Firmware/messages.h b/Firmware/messages.h index 30671533..60a4cc1c 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -128,6 +128,9 @@ extern const char MSG_SOUND_BLIND[]; extern const char MSG_MESH[]; extern const char MSG_Z_PROBE_NR[]; extern const char MSG_MAGNETS_COMP[]; +extern const char MSG_FS_ACTION[]; +extern const char MSG_FS_CONTINUE[]; +extern const char MSG_FS_PAUSE[]; //not internationalized messages extern const char MSG_BROWNOUT_RESET[]; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e2c82c03..68710ec3 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5726,10 +5726,10 @@ do\ switch(oFsensorActionNA)\ {\ case ClFsensorActionNA::_Continue:\ - MENU_ITEM_FUNCTION_P(_i("FS Action [cont.]"),lcd_fsensor_actionNA_set);\ + MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_FS_CONTINUE), lcd_fsensor_actionNA_set);\ break;\ case ClFsensorActionNA::_Pause:\ - MENU_ITEM_FUNCTION_P(_i("FS Action [pause]"),lcd_fsensor_actionNA_set);\ + MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_FS_PAUSE), lcd_fsensor_actionNA_set);\ break;\ default:\ oFsensorActionNA=ClFsensorActionNA::_Continue;\ @@ -7107,11 +7107,11 @@ static void lcd_tune_menu() if (FSensorStateMenu == 0) { if (fsensor_not_responding && (mmu_enabled == false)) { /* Filament sensor not working*/ - MENU_ITEM_FUNCTION_P(_i("Fil. sensor [N/A]"), lcd_fsensor_state_set); + MENU_ITEM_TOGGLE_P(_T(MSG_MSG_FSENSOR), _T(MSG_NA), lcd_fsensor_state_set); } else { /* Filament sensor turned off, working, no problems*/ - MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set); + MENU_ITEM_TOGGLE_P(_T(MSG_MSG_FSENSOR), _T(MSG_OFF), lcd_fsensor_state_set); } } else { From 45b89c5728f487a3c3a408f52b86aa31d2b04ae7 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 19 Nov 2019 13:55:37 +0200 Subject: [PATCH 07/18] Fix typo --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 68710ec3..465fde2b 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7107,11 +7107,11 @@ static void lcd_tune_menu() if (FSensorStateMenu == 0) { if (fsensor_not_responding && (mmu_enabled == false)) { /* Filament sensor not working*/ - MENU_ITEM_TOGGLE_P(_T(MSG_MSG_FSENSOR), _T(MSG_NA), lcd_fsensor_state_set); + MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), _T(MSG_NA), lcd_fsensor_state_set); } else { /* Filament sensor turned off, working, no problems*/ - MENU_ITEM_TOGGLE_P(_T(MSG_MSG_FSENSOR), _T(MSG_OFF), lcd_fsensor_state_set); + MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), _T(MSG_OFF), lcd_fsensor_state_set); } } else { From 404802b5e6e3ebd3a21f936691b7885f11966c26 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 13 Oct 2019 18:49:32 +0200 Subject: [PATCH 08/18] Clear "sdprinting" state only when all SD moves are complete Ensure card.printingHasFinished sees all the planned moves before clearing sdprinting. To do that, we need to ensure all SD commands exited the command queue. --- Firmware/cmdqueue.cpp | 55 +++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index 74a8b90a..e17db42a 100755 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -582,30 +582,8 @@ void get_command() ((serial_char == '#' || serial_char == ':') && comment_mode == false) || serial_count >= (MAX_CMD_SIZE - 1) || n==-1) { - if(card.eof()){ - SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED - stoptime=_millis(); - char time[30]; - unsigned long t=(stoptime-starttime-pause_time)/1000; - pause_time = 0; - int hours, minutes; - minutes=(t/60)%60; - hours=t/60/60; - save_statistics(total_filament_used, t); - sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes); - SERIAL_ECHO_START; - SERIAL_ECHOLN(time); - lcd_setstatus(time); - card.printingHasFinished(); - card.checkautostart(true); + if(card.eof()) break; - if (farm_mode) - { - prusa_statistics(6); - lcd_commands_type = LcdCommands::FarmModeConfirm; - } - - } if(serial_char=='#') stop_buffering=true; @@ -663,6 +641,37 @@ void get_command() else if(!comment_mode) cmdbuffer[bufindw+CMDHDRSIZE+serial_count++] = serial_char; } } + if(card.eof()) + { + // file was fully buffered, but commands might still need to be planned! + // do *not* clear sdprinting until all SD commands are consumed to ensure + // SD state can be resumed from a saved printing state. sdprinting is only + // cleared by printingHasFinished after peforming all remaining moves. + if(!cmdqueue_calc_sd_length()) + { + SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED + stoptime=_millis(); + char time[30]; + unsigned long t=(stoptime-starttime-pause_time)/1000; + pause_time = 0; + int hours, minutes; + minutes=(t/60)%60; + hours=t/60/60; + save_statistics(total_filament_used, t); + sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes); + SERIAL_ECHO_START; + SERIAL_ECHOLN(time); + lcd_setstatus(time); + card.printingHasFinished(); + card.checkautostart(true); + + if (farm_mode) + { + prusa_statistics(6); + lcd_commands_type = LcdCommands::FarmModeConfirm; + } + } + } #endif //SDSUPPORT } From 0f6b9b40512eca03abbc930ae337a87ddf9323d6 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 15 Oct 2019 21:09:28 +0200 Subject: [PATCH 09/18] Unroll the stack in restore_print_from_ram_and_continue While handling moves in a recursive plan, such a filament check, ensure restore_print_from_ram_and_continue unwinds the stack by aborting early from any call that waits on the planner. This currently only handles G1 moves, but hard-coded behavior that can trigger recursive behavior (such as filament change) will probably have to be checked too. --- Firmware/Marlin_main.cpp | 6 ++++++ Firmware/planner.cpp | 2 +- Firmware/planner.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 19d79953..46fef27a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8363,6 +8363,8 @@ void clamp_to_software_endstops(float target[3]) current_position[Z_AXIS] + t * dz, current_position[E_AXIS] + t * de, feed_rate, extruder); + if (waiting_inside_plan_buffer_line_print_aborted) + return; } } // The rest of the path. @@ -8390,6 +8392,8 @@ void prepare_move() plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply*(1./(60.f*100.f)), active_extruder); #endif } + if (waiting_inside_plan_buffer_line_print_aborted) + return; for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; @@ -10264,10 +10268,12 @@ void restore_print_from_ram_and_continue(float e_move) else { //not sd printing nor usb printing } + SERIAL_PROTOCOLLNRPGM(MSG_OK); //dummy response because of octoprint is waiting for this lcd_setstatuspgm(_T(WELCOME_MSG)); saved_printing_type = PRINTING_TYPE_NONE; saved_printing = false; + waiting_inside_plan_buffer_line_print_aborted = true; //unroll the stack } void print_world_coordinates() diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index 752d0725..63058d2c 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -666,8 +666,8 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. + waiting_inside_plan_buffer_line_print_aborted = false; if (block_buffer_tail == next_buffer_head) { - waiting_inside_plan_buffer_line_print_aborted = false; do { manage_heater(); // Vojtech: Don't disable motors inside the planner! diff --git a/Firmware/planner.h b/Firmware/planner.h index 7904c45a..4977265b 100644 --- a/Firmware/planner.h +++ b/Firmware/planner.h @@ -238,6 +238,7 @@ FORCE_INLINE bool planner_queue_full() { // wait for the steppers to stop, // update planner's current position and the current_position of the front end. extern void planner_abort_hard(); +extern bool waiting_inside_plan_buffer_line_print_aborted; #ifdef PREVENT_DANGEROUS_EXTRUDE void set_extrude_min_temp(float temp); From 5fa7c178b5fa2232c9c2f3e1939611e9ad453f1b Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 15 Oct 2019 21:14:28 +0200 Subject: [PATCH 10/18] Do not set current_position in mesh_plan_buffer_line This is a task which _has_ to be performed by the caller, such as prepare_move(). --- Firmware/Marlin_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 46fef27a..6686fba0 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8369,10 +8369,6 @@ void clamp_to_software_endstops(float target[3]) } // The rest of the path. plan_buffer_line(x, y, z, e, feed_rate, extruder); - current_position[X_AXIS] = x; - current_position[Y_AXIS] = y; - current_position[Z_AXIS] = z; - current_position[E_AXIS] = e; } #endif // MESH_BED_LEVELING From faa9e925fe38acfc3de13aae35e6227c68fedc1e Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 15 Oct 2019 21:20:18 +0200 Subject: [PATCH 11/18] Replace a few loops with set_current_to_destination() --- Firmware/Marlin_main.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6686fba0..3d1945ef 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8391,9 +8391,7 @@ void prepare_move() if (waiting_inside_plan_buffer_line_print_aborted) return; - for(int8_t i=0; i < NUM_AXIS; i++) { - current_position[i] = destination[i]; - } + set_current_to_destination(); } void prepare_arc_move(char isclockwise) { @@ -9114,10 +9112,8 @@ void bed_check(float x_dimension, float y_dimension, int x_points_num, int y_poi destination[X_AXIS] = ix * (x_dimension / (x_points_num - 1)) + shift_x; destination[Y_AXIS] = iy * (y_dimension / (y_points_num - 1)) + shift_y; - mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], XY_AXIS_FEEDRATE/6, active_extruder); - for(int8_t i=0; i < NUM_AXIS; i++) { - current_position[i] = destination[i]; - } + mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], XY_AXIS_FEEDRATE/6, active_extruder); + set_current_to_destination(); st_synchronize(); // printf_P(PSTR("X = %f; Y= %f \n"), current_position[X_AXIS], current_position[Y_AXIS]); From 4268c2fdae35c97d732fa4318a60c342e5547065 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 15 Oct 2019 21:23:50 +0200 Subject: [PATCH 12/18] Fix recovery from relative/chunked moves When starting to replay existing USB/SD commands from a recovery state, an immediate relative move needs to compensate for a previously interrupted move. This is almost the norm for the E axis. Instead of saving the relative status of the move (which needs to account for the world2machine conversion and is not always available on a chunked move split by MBL) save directly the calculated target position for the move in the original plan, which is easy to replay. --- Firmware/Marlin_main.cpp | 61 ++++++++++++++++++++++++++++++++++------ Firmware/eeprom.h | 3 +- Firmware/planner.cpp | 31 +++++++++++++------- Firmware/planner.h | 5 ++-- 4 files changed, 78 insertions(+), 22 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3d1945ef..4877f7a8 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -309,6 +309,8 @@ bool no_response = false; uint8_t important_status; uint8_t saved_filament_type; +#define SAVED_TARGET_UNSET (X_MIN_POS-1) +float saved_target[NUM_AXIS] = {SAVED_TARGET_UNSET, 0, 0, 0}; // save/restore printing in case that mmu was not responding bool mmu_print_saved = false; @@ -4043,8 +4045,19 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) #endif + get_coordinates(); // For X Y Z E F + + // When recovering from a previous print move, restore the originally + // calculated target position on the first USB/SD command. This accounts + // properly for relative moves + if ((saved_target[0] != SAVED_TARGET_UNSET) && + ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_SDCARD) || + (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR))) + { + memcpy(destination, saved_target, sizeof(destination)); + saved_target[0] = SAVED_TARGET_UNSET; + } - get_coordinates(); // For X Y Z E F if (total_filament_used > ((current_position[E_AXIS] - destination[E_AXIS]) * 100)) { //protection against total_filament_used overflow total_filament_used = total_filament_used + ((destination[E_AXIS] - current_position[E_AXIS]) * 100); } @@ -8339,30 +8352,37 @@ void clamp_to_software_endstops(float target[3]) } #ifdef MESH_BED_LEVELING - void mesh_plan_buffer_line(const float &x, const float &y, const float &z, const float &e, const float &feed_rate, const uint8_t extruder) { +void mesh_plan_buffer_line(const float &x, const float &y, const float &z, const float &e, const float &feed_rate, const uint8_t extruder) { float dx = x - current_position[X_AXIS]; float dy = y - current_position[Y_AXIS]; - float dz = z - current_position[Z_AXIS]; int n_segments = 0; - + if (mbl.active) { float len = abs(dx) + abs(dy); if (len > 0) // Split to 3cm segments or shorter. n_segments = int(ceil(len / 30.f)); } - + if (n_segments > 1) { + // In a multi-segment move explicitly set the final target in the plan + // as the move will be recalculated in it's entirety + float gcode_target[NUM_AXIS]; + gcode_target[X_AXIS] = x; + gcode_target[Y_AXIS] = y; + gcode_target[Z_AXIS] = z; + gcode_target[E_AXIS] = e; + + float dz = z - current_position[Z_AXIS]; float de = e - current_position[E_AXIS]; + for (int i = 1; i < n_segments; ++ i) { float t = float(i) / float(n_segments); - if (saved_printing || (mbl.active == false)) return; - plan_buffer_line( - current_position[X_AXIS] + t * dx, + plan_buffer_line(current_position[X_AXIS] + t * dx, current_position[Y_AXIS] + t * dy, current_position[Z_AXIS] + t * dz, current_position[E_AXIS] + t * de, - feed_rate, extruder); + feed_rate, extruder, gcode_target); if (waiting_inside_plan_buffer_line_print_aborted) return; } @@ -9602,6 +9622,12 @@ void uvlo_() // Backup the feedrate in mm/min. int feedrate_bckp = blocks_queued() ? (block_buffer[block_buffer_tail].nominal_speed * 60.f) : feedrate; + // save the original target position of the current move + if (blocks_queued()) + memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); + else + saved_target[0] = SAVED_TARGET_UNSET; + // After this call, the planner queue is emptied and the current_position is set to a current logical coordinate. // The logical coordinate will likely differ from the machine coordinate if the skew calibration and mesh bed leveling // are in action. @@ -9679,6 +9705,11 @@ void uvlo_() #endif #endif eeprom_update_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY), (uint16_t)extrudemultiply); + // Store the saved target + eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+0*4), saved_target[X_AXIS]); + eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+1*4), saved_target[Y_AXIS]); + eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+2*4), saved_target[Z_AXIS]); + eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+3*4), saved_target[E_AXIS]); // Finaly store the "power outage" flag. if(sd_print) eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1); @@ -9927,6 +9958,12 @@ void recover_machine_state_after_power_panic(bool bTiny) #endif #endif extrudemultiply = (int)eeprom_read_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY)); + + // 9) Recover the saved target + saved_target[X_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+0*4)); + saved_target[Y_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+1*4)); + saved_target[Z_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+2*4)); + saved_target[E_AXIS] = eeprom_read_float((float*)(EEPROM_UVLO_SAVED_TARGET+3*4)); } void restore_print_from_eeprom() { @@ -10143,6 +10180,12 @@ void stop_and_save_print_to_ram(float z_move, float e_move) saved_feedrate2 = blocks_queued() ? (block_buffer[block_buffer_tail].nominal_speed * 60.f) : feedrate; #endif + // save the original target position of the current move + if (blocks_queued()) + memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); + else + saved_target[0] = SAVED_TARGET_UNSET; + planner_abort_hard(); //abort printing memcpy(saved_pos, current_position, sizeof(saved_pos)); saved_active_extruder = active_extruder; //save active_extruder diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 0949e411..82852220 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -204,9 +204,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_FSENSOR_PCB (EEPROM_SHEETS_BASE-1) // uint8 #define EEPROM_FSENSOR_ACTION_NA (EEPROM_FSENSOR_PCB-1) // uint8 +#define EEPROM_UVLO_SAVED_TARGET (EEPROM_FSENSOR_ACTION_NA - 4*4) // 4 x float for saved target for all axes //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_SHEETS_BASE +#define EEPROM_LAST_ITEM EEPROM_UVLO_SAVED_TARGET // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index 63058d2c..c1285aed 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -659,7 +659,7 @@ float junction_deviation = 0.1; // Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. -void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder) +void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder, const float* gcode_target) { // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); @@ -687,6 +687,26 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate planner_update_queue_min_counter(); #endif /* PLANNER_DIAGNOSTICS */ + // Prepare to set up new block + block_t *block = &block_buffer[block_buffer_head]; + + // Set sdlen for calculating sd position + block->sdlen = 0; + + // Mark block as not busy (Not executed by the stepper interrupt, could be still tinkered with.) + block->busy = false; + + // Save original destination of the move + if (gcode_target) + memcpy(block->gcode_target, gcode_target, sizeof(block_t::gcode_target)); + else + { + block->gcode_target[X_AXIS] = x; + block->gcode_target[Y_AXIS] = y; + block->gcode_target[Z_AXIS] = z; + block->gcode_target[E_AXIS] = e; + } + #ifdef ENABLE_AUTO_BED_LEVELING apply_rotation_xyz(plan_bed_level_matrix, x, y, z); #endif // ENABLE_AUTO_BED_LEVELING @@ -786,15 +806,6 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate } #endif - // Prepare to set up new block - block_t *block = &block_buffer[block_buffer_head]; - - // Set sdlen for calculating sd position - block->sdlen = 0; - - // Mark block as not busy (Not executed by the stepper interrupt, could be still tinkered with.) - block->busy = false; - // Number of steps for each axis #ifndef COREXY // default non-h-bot planning diff --git a/Firmware/planner.h b/Firmware/planner.h index 4977265b..d4c6bc2b 100644 --- a/Firmware/planner.h +++ b/Firmware/planner.h @@ -116,7 +116,8 @@ typedef struct { unsigned long abs_adv_steps_multiplier8; // Factorised by 2^8 to avoid float #endif - uint16_t sdlen; + float gcode_target[NUM_AXIS]; // Target (abs mm) of the original Gcode instruction + uint16_t sdlen; // Length of the Gcode instruction } block_t; #ifdef LIN_ADVANCE @@ -147,7 +148,7 @@ vector_3 plan_get_position(); /// The performance penalty is negligible, since these planned lines are usually maintenance moves with the extruder. void plan_buffer_line_curposXYZE(float feed_rate, uint8_t extruder); -void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder); +void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder, const float* gcode_target = NULL); //void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder); #endif // ENABLE_AUTO_BED_LEVELING From 6ecff003b78e276ae775e47279559b45b8584d75 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 16 Oct 2019 18:47:18 +0200 Subject: [PATCH 13/18] Fix M600 insertion by the filament sensor Remove incorrect usage of stop_and_save_print combined with the fsensor_recovert internal instruction which would result in a broken sequence of events and/or broken stack. Re-use the now safe stop/recover functions in the same spot (fsensor_checkpoint_stream) to effectively cut a hole in the current gcode stream to insert an M600 instruction, which removes all recursive behavior without the need of extra state variables. --- Firmware/Marlin_main.cpp | 9 +------- Firmware/fsensor.cpp | 46 +++++++++++++++++----------------------- Firmware/fsensor.h | 2 ++ Firmware/mmu.cpp | 3 +-- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4877f7a8..5afeb525 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3657,7 +3657,7 @@ void process_commands() Set of internal PRUSA commands - PRUSA [ Ping | PRN | FAN | fn | thx | uvlo | fsensor_recover | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | Beat | FR ] + PRUSA [ Ping | PRN | FAN | fn | thx | uvlo | MMURES | RESET | fv | M28 | SN | Fir | Rev | Lang | Lz | Beat | FR ] - `Ping` - `PRN` - Prints revision of the printer @@ -3665,7 +3665,6 @@ void process_commands() - `fn` - Prints farm no. - `thx` - `uvlo` - - `fsensor_recover` - Filament sensor recover - restore print and continue - `MMURES` - Reset MMU - `RESET` - (Careful!) - `fv` - ? @@ -3715,12 +3714,6 @@ void process_commands() eeprom_update_byte((uint8_t*)EEPROM_UVLO,0); enquecommand_P(PSTR("M24")); } -#ifdef FILAMENT_SENSOR - else if (code_seen("fsensor_recover")) // PRUSA fsensor_recover - { - fsensor_restore_print_and_continue(); - } -#endif //FILAMENT_SENSOR else if (code_seen("MMURES")) // PRUSA MMURES { mmu_reset(); diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index c01274fb..1c28d025 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -57,15 +57,8 @@ bool fsensor_enabled = true; bool fsensor_watch_runout = true; //! not responding - is set if any communication error occurred during initialization or readout bool fsensor_not_responding = false; -//! printing saved -bool fsensor_printing_saved = false; //! enable/disable quality meassurement bool fsensor_oq_meassure_enabled = false; -//! as explained in the CHECK_FSENSOR macro: this flag is set to true when fsensor posts -//! the M600 into the command queue, which elliminates the hazard of having posted multiple M600's -//! before the first one gets read and started processing. -//! Btw., the IR fsensor could do up to 6 posts before the command queue managed to start processing the first M600 ;) -static bool fsensor_m600_enqueued = false; //! number of errors, updated in ISR uint8_t fsensor_err_cnt = 0; @@ -137,12 +130,19 @@ void fsensor_stop_and_save_print(void) void fsensor_restore_print_and_continue(void) { printf_P(PSTR("fsensor_restore_print_and_continue\n")); - fsensor_watch_runout = true; fsensor_err_cnt = 0; - fsensor_m600_enqueued = false; restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change } +// fsensor_checkpoint_print cuts the current print job at the current position, +// allowing new instructions to be inserted in the middle +void fsensor_checkpoint_print(void) +{ + printf_P(PSTR("fsensor_checkpoint_print\n")); + stop_and_save_print_to_ram(0, 0); + restore_print_from_ram_and_continue(0); +} + void fsensor_init(void) { #ifdef PAT9125 @@ -565,8 +565,6 @@ void fsensor_enque_M600(){ printf_P(PSTR("fsensor_update - M600\n")); eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1); eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1); - enquecommand_front_P(PSTR("PRUSA fsensor_recover")); - fsensor_m600_enqueued = true; enquecommand_front_P((PSTR("M600"))); } @@ -578,7 +576,7 @@ void fsensor_enque_M600(){ void fsensor_update(void) { #ifdef PAT9125 - if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX) && ( ! fsensor_m600_enqueued) ) + if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX)) { bool autoload_enabled_tmp = fsensor_autoload_enabled; fsensor_autoload_enabled = false; @@ -611,22 +609,18 @@ void fsensor_update(void) err |= (fsensor_oq_er_sum > 2); err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD)); - if (!err) - { - printf_P(PSTR("fsensor_err_cnt = 0\n")); - fsensor_restore_print_and_continue(); - } - else - { - fsensor_enque_M600(); - fsensor_watch_runout = false; - } + fsensor_restore_print_and_continue(); fsensor_autoload_enabled = autoload_enabled_tmp; fsensor_oq_meassure_enabled = oq_meassure_enabled_tmp; + + if (!err) + printf_P(PSTR("fsensor_err_cnt = 0\n")); + else + fsensor_enque_M600(); } #else //PAT9125 - if (CHECK_FSENSOR && fsensor_enabled && ir_sensor_detected && ( ! fsensor_m600_enqueued) ) - { + if (CHECK_FSENSOR && fsensor_enabled && ir_sensor_detected) + { if(digitalRead(IR_SENSOR_PIN)) { // IR_SENSOR_PIN ~ H #if IR_SENSOR_ANALOG @@ -670,8 +664,8 @@ void fsensor_update(void) else { #endif //IR_SENSOR_ANALOG - fsensor_stop_and_save_print(); - fsensor_enque_M600(); + fsensor_checkpoint_print(); + fsensor_enque_M600(); #if IR_SENSOR_ANALOG } } diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index 48ad5fba..aa4963af 100755 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -21,6 +21,8 @@ extern bool fsensor_oq_meassure_enabled; extern void fsensor_stop_and_save_print(void); //! restore print - restore position and heatup to original temperature extern void fsensor_restore_print_and_continue(void); +//! split the current gcode stream to insert new instructions +extern void fsensor_checkpoint_print(void); //! @} //! initialize diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index c9ca9cb6..f1515d98 100755 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -382,8 +382,7 @@ void mmu_loop(void) FDEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_finda); //printf_P(PSTR("Eact: %d\n"), int(e_active())); if (!mmu_finda && CHECK_FSENSOR && fsensor_enabled) { - fsensor_stop_and_save_print(); - enquecommand_front_P(PSTR("PRUSA fsensor_recover")); //then recover + fsensor_checkpoint_print(); ad_markDepleted(mmu_extruder); if (lcd_autoDepleteEnabled() && !ad_allDepleted()) { From 4f0af648fb95903942d0ebf1cad9d1d214048084 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 19 Oct 2019 18:48:02 +0200 Subject: [PATCH 14/18] Save/restore feedmultiply independently of the feedrate --- Firmware/Marlin_main.cpp | 34 ++++++++++++++++++---------------- Firmware/eeprom.h | 3 ++- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5afeb525..00e0ae99 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -375,8 +375,8 @@ bool saved_printing = false; //!< Print is paused and saved in RAM static uint32_t saved_sdpos = 0; //!< SD card position, or line number in case of USB printing uint8_t saved_printing_type = PRINTING_TYPE_SD; static float saved_pos[4] = { 0, 0, 0, 0 }; -//! Feedrate hopefully derived from an active block of the planner at the time the print has been canceled, in mm/min. static float saved_feedrate2 = 0; +static int saved_feedmultiply2 = 0; static uint8_t saved_active_extruder = 0; static float saved_extruder_temperature = 0.0; //!< Active extruder temperature static bool saved_extruder_under_pressure = false; @@ -9612,9 +9612,6 @@ void uvlo_() if (sd_position < 0) sd_position = 0; } - // Backup the feedrate in mm/min. - int feedrate_bckp = blocks_queued() ? (block_buffer[block_buffer_tail].nominal_speed * 60.f) : feedrate; - // save the original target position of the current move if (blocks_queued()) memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); @@ -9686,7 +9683,9 @@ void uvlo_() eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]); eeprom_update_float((float*)EEPROM_UVLO_CURRENT_POSITION_Z , current_position[Z_AXIS]); // Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates) - EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &feedrate_bckp); + int i_feedrate = feedrate; + EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &i_feedrate); + EEPROM_save_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed); eeprom_update_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED, fanSpeed); @@ -9961,6 +9960,7 @@ void recover_machine_state_after_power_panic(bool bTiny) void restore_print_from_eeprom() { int feedrate_rec; + int feedmultiply_rec; uint8_t fan_speed_rec; char cmd[30]; char filename[13]; @@ -9969,8 +9969,11 @@ void restore_print_from_eeprom() { fan_speed_rec = eeprom_read_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED); EEPROM_read_B(EEPROM_UVLO_FEEDRATE, &feedrate_rec); + EEPROM_read_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply_rec); SERIAL_ECHOPGM("Feedrate:"); - MYSERIAL.println(feedrate_rec); + MYSERIAL.print(feedrate_rec); + SERIAL_ECHOPGM(", feedmultiply:"); + MYSERIAL.println(feedmultiply_rec); depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH); @@ -10011,9 +10014,11 @@ void restore_print_from_eeprom() { enquecommand(cmd); // Unretract. enquecommand_P(PSTR("G1 E" STRINGIFY(2*default_retraction)" F480")); - // Set the feedrate saved at the power panic. + // Set the feedrates saved at the power panic. sprintf_P(cmd, PSTR("G1 F%d"), feedrate_rec); enquecommand(cmd); + sprintf_P(cmd, PSTR("M220 S%d"), feedmultiply_rec); + enquecommand(cmd); if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_E_ABS)) { enquecommand_P(PSTR("M82")); //E axis abslute mode @@ -10165,14 +10170,6 @@ void stop_and_save_print_to_ram(float z_move, float e_move) } #endif -#if 0 - saved_feedrate2 = feedrate; //save feedrate -#else - // Try to deduce the feedrate from the first block of the planner. - // Speed is in mm/min. - saved_feedrate2 = blocks_queued() ? (block_buffer[block_buffer_tail].nominal_speed * 60.f) : feedrate; -#endif - // save the original target position of the current move if (blocks_queued()) memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); @@ -10181,6 +10178,8 @@ void stop_and_save_print_to_ram(float z_move, float e_move) planner_abort_hard(); //abort printing memcpy(saved_pos, current_position, sizeof(saved_pos)); + saved_feedrate2 = feedrate; //save feedrate + saved_feedmultiply2 = feedmultiply; //save feedmultiply saved_active_extruder = active_extruder; //save active_extruder saved_extruder_temperature = degTargetHotend(active_extruder); @@ -10258,7 +10257,6 @@ void restore_print_from_ram_and_continue(float e_move) wait_for_heater(_millis(), saved_active_extruder); heating_status = 2; } - feedrate = saved_feedrate2; //restore feedrate axis_relative_modes[E_AXIS] = saved_extruder_relative_mode; float e = saved_pos[E_AXIS] - e_move; plan_set_e_position(e); @@ -10281,6 +10279,10 @@ void restore_print_from_ram_and_continue(float e_move) fans_check_enabled = true; #endif + // restore original feedrate/feedmultiply _after_ restoring the extruder position + feedrate = saved_feedrate2; + feedmultiply = saved_feedmultiply2; + memcpy(current_position, saved_pos, sizeof(saved_pos)); memcpy(destination, current_position, sizeof(destination)); if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 82852220..3f1e6141 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -205,9 +205,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_FSENSOR_ACTION_NA (EEPROM_FSENSOR_PCB-1) // uint8 #define EEPROM_UVLO_SAVED_TARGET (EEPROM_FSENSOR_ACTION_NA - 4*4) // 4 x float for saved target for all axes +#define EEPROM_UVLO_FEEDMULTIPLY (EEPROM_UVLO_SAVED_TARGET - 2) // uint16_t for feedmultiply //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_UVLO_SAVED_TARGET +#define EEPROM_LAST_ITEM EEPROM_UVLO_FEEDMULTIPLY // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! From 17176c1df21574c53c2fefc0b1455f9eb3f5e625 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 19 Oct 2019 21:20:38 +0200 Subject: [PATCH 15/18] Save/restore the default feedrate correctly Since the global feedrate can be similarly modified for moves ahead of time, save the original feedrate in the planner as we do for gcode_target. This avoids having to undo feedmultiply (and machine limits!) from "nominal_speed" as previously done. Thanks @leptun --- Firmware/Marlin.h | 1 + Firmware/Marlin_main.cpp | 31 +++++++++++++++++++++++++------ Firmware/planner.cpp | 9 ++++++--- Firmware/planner.h | 2 ++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 8a396dac..d9078ada 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -296,6 +296,7 @@ void setPwmFrequency(uint8_t pin, int val); extern bool fans_check_enabled; extern float homing_feedrate[]; extern bool axis_relative_modes[]; +extern float feedrate; extern int feedmultiply; extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all extruders extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 00e0ae99..6e33a397 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -331,7 +331,15 @@ float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0}; // For tracing an arc static float offset[3] = {0.0, 0.0, 0.0}; -static float feedrate = 1500.0, next_feedrate, saved_feedrate; + +// Current feedrate +float feedrate = 1500.0; + +// Feedrate for the next move +static float next_feedrate; + +// Original feedrate saved during homing moves +static float saved_feedrate; // Determines Absolute or Relative Coordinates. // Also there is bool axis_relative_modes[] per axis flag. @@ -9612,11 +9620,18 @@ void uvlo_() if (sd_position < 0) sd_position = 0; } - // save the original target position of the current move + // save the global state at planning time + int feedrate_bckp; if (blocks_queued()) + { memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); + feedrate_bckp = current_block->gcode_feedrate; + } else + { saved_target[0] = SAVED_TARGET_UNSET; + feedrate_bckp = feedrate; + } // After this call, the planner queue is emptied and the current_position is set to a current logical coordinate. // The logical coordinate will likely differ from the machine coordinate if the skew calibration and mesh bed leveling @@ -9683,8 +9698,7 @@ void uvlo_() eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]); eeprom_update_float((float*)EEPROM_UVLO_CURRENT_POSITION_Z , current_position[Z_AXIS]); // Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates) - int i_feedrate = feedrate; - EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &i_feedrate); + EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &feedrate_bckp); EEPROM_save_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed); @@ -10170,15 +10184,20 @@ void stop_and_save_print_to_ram(float z_move, float e_move) } #endif - // save the original target position of the current move + // save the global state at planning time if (blocks_queued()) + { memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); + saved_feedrate2 = current_block->gcode_feedrate; + } else + { saved_target[0] = SAVED_TARGET_UNSET; + saved_feedrate2 = feedrate; + } planner_abort_hard(); //abort printing memcpy(saved_pos, current_position, sizeof(saved_pos)); - saved_feedrate2 = feedrate; //save feedrate saved_feedmultiply2 = feedmultiply; //save feedmultiply saved_active_extruder = active_extruder; //save active_extruder saved_extruder_temperature = degTargetHotend(active_extruder); diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index c1285aed..0ccf54f8 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -690,12 +690,12 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate // Prepare to set up new block block_t *block = &block_buffer[block_buffer_head]; - // Set sdlen for calculating sd position - block->sdlen = 0; - // Mark block as not busy (Not executed by the stepper interrupt, could be still tinkered with.) block->busy = false; + // Set sdlen for calculating sd position + block->sdlen = 0; + // Save original destination of the move if (gcode_target) memcpy(block->gcode_target, gcode_target, sizeof(block_t::gcode_target)); @@ -707,6 +707,9 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate block->gcode_target[E_AXIS] = e; } + // Save the global feedrate at scheduling time + block->gcode_feedrate = feedrate; + #ifdef ENABLE_AUTO_BED_LEVELING apply_rotation_xyz(plan_bed_level_matrix, x, y, z); #endif // ENABLE_AUTO_BED_LEVELING diff --git a/Firmware/planner.h b/Firmware/planner.h index d4c6bc2b..27541e5f 100644 --- a/Firmware/planner.h +++ b/Firmware/planner.h @@ -116,7 +116,9 @@ typedef struct { unsigned long abs_adv_steps_multiplier8; // Factorised by 2^8 to avoid float #endif + // Save/recovery state data float gcode_target[NUM_AXIS]; // Target (abs mm) of the original Gcode instruction + float gcode_feedrate; // Original feedrate uint16_t sdlen; // Length of the Gcode instruction } block_t; From 18eaf21baf38ec6bff47882af4b1c664f4b9e935 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 19 Oct 2019 21:45:50 +0200 Subject: [PATCH 16/18] Halve memory usage of saved feedrate Truncate the saved feedrate to an uint16_t. This is more than sufficient for recovery. --- Firmware/Marlin_main.cpp | 8 ++++---- Firmware/eeprom.h | 2 +- Firmware/planner.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6e33a397..a312f3e5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -383,7 +383,7 @@ bool saved_printing = false; //!< Print is paused and saved in RAM static uint32_t saved_sdpos = 0; //!< SD card position, or line number in case of USB printing uint8_t saved_printing_type = PRINTING_TYPE_SD; static float saved_pos[4] = { 0, 0, 0, 0 }; -static float saved_feedrate2 = 0; +static uint16_t saved_feedrate2 = 0; //!< Default feedrate (truncated from float) static int saved_feedmultiply2 = 0; static uint8_t saved_active_extruder = 0; static float saved_extruder_temperature = 0.0; //!< Active extruder temperature @@ -9621,7 +9621,7 @@ void uvlo_() } // save the global state at planning time - int feedrate_bckp; + uint16_t feedrate_bckp; if (blocks_queued()) { memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); @@ -9698,7 +9698,7 @@ void uvlo_() eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]); eeprom_update_float((float*)EEPROM_UVLO_CURRENT_POSITION_Z , current_position[Z_AXIS]); // Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates) - EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &feedrate_bckp); + eeprom_update_word((uint16_t*)EEPROM_UVLO_FEEDRATE, feedrate_bckp); EEPROM_save_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]); eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed); @@ -9982,7 +9982,7 @@ void restore_print_from_eeprom() { char dir_name[9]; fan_speed_rec = eeprom_read_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED); - EEPROM_read_B(EEPROM_UVLO_FEEDRATE, &feedrate_rec); + feedrate_rec = eeprom_read_word((uint16_t*)EEPROM_UVLO_FEEDRATE); EEPROM_read_B(EEPROM_UVLO_FEEDMULTIPLY, &feedmultiply_rec); SERIAL_ECHOPGM("Feedrate:"); MYSERIAL.print(feedrate_rec); diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 3f1e6141..12a31d3c 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -74,7 +74,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_UVLO_CURRENT_POSITION_Z (EEPROM_FILE_POSITION - 4) //float for current position in Z #define EEPROM_UVLO_TARGET_HOTEND (EEPROM_UVLO_CURRENT_POSITION_Z - 1) #define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_TARGET_HOTEND - 1) -#define EEPROM_UVLO_FEEDRATE (EEPROM_UVLO_TARGET_BED - 2) +#define EEPROM_UVLO_FEEDRATE (EEPROM_UVLO_TARGET_BED - 2) //uint16_t #define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1) #define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1) #define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2) diff --git a/Firmware/planner.h b/Firmware/planner.h index 27541e5f..0d0cb41a 100644 --- a/Firmware/planner.h +++ b/Firmware/planner.h @@ -118,7 +118,7 @@ typedef struct { // Save/recovery state data float gcode_target[NUM_AXIS]; // Target (abs mm) of the original Gcode instruction - float gcode_feedrate; // Original feedrate + uint16_t gcode_feedrate; // Default and/or move feedrate uint16_t sdlen; // Length of the Gcode instruction } block_t; From dbe2ed41500863b6948f5a0154700feb76dafdb7 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 20 Oct 2019 17:34:54 +0200 Subject: [PATCH 17/18] Fix pause/resume when using M25/M601 Remove the conflicting and mostly useless card.paused flag (the printing is either paused, or not) and switch to isPrintPaused only which accounts for both cases (SD/USB) correctly. Fix M27/getStatus to show the current real status of the SD print. Synchronize the queue on M601, as required to precisely pause the print at the correct instruction. Alias M25 to M601, which when combined with PR #1899 fixes issue #1614. Guard against incorrect usage in M601, M602 and M603. --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 36 ++++++++++++--------- Firmware/cardreader.cpp | 57 ++++++++++++++-------------------- Firmware/cardreader.h | 2 -- Firmware/ultralcd.cpp | 2 +- Tests/PrusaStatistics_test.cpp | 5 ++- 6 files changed, 48 insertions(+), 56 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index d9078ada..7dedc8a4 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -396,7 +396,7 @@ extern uint16_t gcode_in_progress; extern LongTimer safetyTimer; #define PRINT_PERCENT_DONE_INIT 0xff -#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved) +#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || mmu_print_saved) //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a312f3e5..fe94fab5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5377,21 +5377,19 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) card.openFile(strchr_pointer + 4,true); break; - //! ### M24 - Start SD print + //! ### M24 - Start/resume SD print // ---------------------------------- case 24: - if (!card.paused) - failstats_reset_print(); - card.startFileprint(); - starttime=_millis(); + if (isPrintPaused) + lcd_resume_print(); + else + { + failstats_reset_print(); + card.startFileprint(); + starttime=_millis(); + } break; - //! ### M25 - Pause SD print - // ---------------------------------- - case 25: - card.pauseSDPrint(); - break; - //! ### M26 S\ - Set SD index //! Set position in SD card file to index in bytes. //! This command is expected to be called after M23 and before M24. @@ -7246,26 +7244,34 @@ Sigma_Exit: break; #endif //FILAMENTCHANGEENABLE + //! ### M25 - Pause SD print //! ### M601 - Pause print + //! ### M125 - Pause print (TODO: not implemented) // ------------------------------- + case 25: case 601: { - cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore - lcd_pause_print(); + if (!isPrintPaused) + { + st_synchronize(); + cmdqueue_pop_front(); //trick because we want skip this command (M601) after restore + lcd_pause_print(); + } } break; //! ### M602 - Resume print // ------------------------------- case 602: { - lcd_resume_print(); + if (isPrintPaused) + lcd_resume_print(); } break; //! ### M603 - Stop print // ------------------------------- case 603: { - lcd_print_stop(); + Stop(); } break; diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 3c01bf84..047a2c76 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -25,7 +25,6 @@ CardReader::CardReader() sdpos = 0; sdprinting = false; cardOK = false; - paused = false; saving = false; logging = false; autostart_atmillis=0; @@ -242,24 +241,13 @@ void CardReader::startFileprint() if(cardOK) { sdprinting = true; - paused = false; - Stopped = false; + Stopped = false; #ifdef SDCARD_SORT_ALPHA //flush_presort(); #endif } } -void CardReader::pauseSDPrint() -{ - if(sdprinting) - { - sdprinting = false; - paused = true; - } -} - - void CardReader::openLogFile(const char* name) { logging = true; @@ -408,9 +396,7 @@ void CardReader::openFile(const char* name,bool read, bool replace_current/*=tru SERIAL_ECHOLN(name); } sdprinting = false; - paused = false; - - + SdFile myDir; const char *fname=name; diveSubfolder(fname,myDir); @@ -492,24 +478,27 @@ uint32_t CardReader::getFileSize() void CardReader::getStatus() { - if(sdprinting){ - SERIAL_PROTOCOL(longFilename); - SERIAL_PROTOCOLPGM("\n"); - SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE - SERIAL_PROTOCOL(sdpos); - SERIAL_PROTOCOLPGM("/"); - SERIAL_PROTOCOLLN(filesize); - uint16_t time = _millis()/60000 - starttime/60000; - SERIAL_PROTOCOL(itostr2(time/60)); - SERIAL_PROTOCOL(':'); - SERIAL_PROTOCOL(itostr2(time%60)); - SERIAL_PROTOCOLPGM("\n"); - } - else if (paused) { - SERIAL_PROTOCOLLNPGM("SD print paused"); - } - else if (saved_printing) { - SERIAL_PROTOCOLLNPGM("Print saved"); + if(sdprinting) + { + if (isPrintPaused) { + SERIAL_PROTOCOLLNPGM("SD print paused"); + } + else if (saved_printing) { + SERIAL_PROTOCOLLNPGM("Print saved"); + } + else { + SERIAL_PROTOCOL(longFilename); + SERIAL_PROTOCOLPGM("\n"); + SERIAL_PROTOCOLRPGM(_N("SD printing byte "));////MSG_SD_PRINTING_BYTE + SERIAL_PROTOCOL(sdpos); + SERIAL_PROTOCOLPGM("/"); + SERIAL_PROTOCOLLN(filesize); + uint16_t time = _millis()/60000 - starttime/60000; + SERIAL_PROTOCOL(itostr2(time/60)); + SERIAL_PROTOCOL(':'); + SERIAL_PROTOCOL(itostr2(time%60)); + SERIAL_PROTOCOLPGM("\n"); + } } else { SERIAL_PROTOCOLLNPGM("Not SD printing"); diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index b7df8ff4..9a7d0f69 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -25,7 +25,6 @@ public: void closefile(bool store_location=false); void release(); void startFileprint(); - void pauseSDPrint(); uint32_t getFileSize(); void getStatus(); void printingHasFinished(); @@ -75,7 +74,6 @@ public: bool logging; bool sdprinting ; bool cardOK ; - bool paused ; char filename[13]; uint16_t modificationTime, modificationDate; uint32_t cluster, position; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 465fde2b..cbfe017f 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4108,7 +4108,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { { prusa_statistics_case0(15); } - else if (isPrintPaused || card.paused) + else if (isPrintPaused) { prusa_statistics_case0(14); } diff --git a/Tests/PrusaStatistics_test.cpp b/Tests/PrusaStatistics_test.cpp index 3c15899a..261a4dc6 100644 --- a/Tests/PrusaStatistics_test.cpp +++ b/Tests/PrusaStatistics_test.cpp @@ -198,7 +198,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { SERIAL_ECHOLN("}"); status_number = 15; } - else if (isPrintPaused || card.paused) + else if (isPrintPaused) { SERIAL_ECHO("{"); prusa_stat_printerstatus(14); @@ -490,7 +490,7 @@ void prusa_statistics(int _message, uint8_t _fil_nr) { { prusa_statistics_case0(15); } - else if (isPrintPaused || card.paused) + else if (isPrintPaused) { prusa_statistics_case0(14); } @@ -753,7 +753,6 @@ TEST_CASE("Prusa_statistics test", "[prusa_stats]") SERIALS_RESET(); isPrintPaused = 0; - card.paused = 0; IS_SD_PRINTING = 1; old_code::prusa_statistics(test_codes[i],0); new_code::prusa_statistics(test_codes[i],0); From 779423f0e71b700f941d1c5e6b8ac1114f05adc5 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Fri, 29 Nov 2019 15:06:54 +0200 Subject: [PATCH 18/18] Move hardcoded values to variants --- Firmware/tmc2130.cpp | 4 ++-- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 4 +++- Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 6a79f51a..dca50ac7 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -24,7 +24,7 @@ uint8_t tmc2130_current_h[4] = TMC2130_CURRENTS_H; uint8_t tmc2130_current_r[4] = TMC2130_CURRENTS_R; //running currents for homing -uint8_t tmc2130_current_r_home[4] = {8, 10, 20, 18}; +uint8_t tmc2130_current_r_home[4] = TMC2130_CURRENTS_R_HOME; //pwm_ampl @@ -40,7 +40,7 @@ uint8_t tmc2130_mres[4] = {0, 0, 0, 0}; //will be filed at begin of init uint8_t tmc2130_sg_thr[4] = {TMC2130_SG_THRS_X, TMC2130_SG_THRS_Y, TMC2130_SG_THRS_Z, TMC2130_SG_THRS_E}; -uint8_t tmc2130_sg_thr_home[4] = {3, 3, TMC2130_SG_THRS_Z, TMC2130_SG_THRS_E}; +uint8_t tmc2130_sg_thr_home[4] = TMC2130_SG_THRS_HOME; uint8_t tmc2130_sg_homing_axes_mask = 0x00; diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 54f0c469..685d77c6 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -260,11 +260,13 @@ #define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis #define TMC2130_SG_THRS_Z 4 // stallguard sensitivity for Z axis #define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis +#define TMC2130_SG_THRS_HOME {3, 3, TMC2130_SG_THRS_Z, TMC2130_SG_THRS_E} //new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) #define TMC2130_CURRENTS_H {16, 20, 35, 30} // default holding currents for all axes #define TMC2130_CURRENTS_R {16, 20, 35, 30} // default running currents for all axes -#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor +#define TMC2130_CURRENTS_R_HOME {8, 10, 20, 18} // homing running currents for all axes +// #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 62dae6ac..5ee149e7 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -262,11 +262,13 @@ #define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis #define TMC2130_SG_THRS_Z 4 // stallguard sensitivity for Z axis #define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis +#define TMC2130_SG_THRS_HOME {3, 3, TMC2130_SG_THRS_Z, TMC2130_SG_THRS_E} //new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) #define TMC2130_CURRENTS_H {16, 20, 35, 30} // default holding currents for all axes #define TMC2130_CURRENTS_R {16, 20, 35, 30} // default running currents for all axes -#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor +#define TMC2130_CURRENTS_R_HOME {8, 10, 20, 18} // homing running currents for all axes +// #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z