From ec5e54de25ec8d0c08726b880f0c26be9b4dedf5 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Mon, 2 Mar 2020 17:52:25 +0100 Subject: [PATCH] state fixing --- Firmware/Marlin_main.cpp | 29 ++++++++++++++++++++++ Firmware/config.h | 4 ++-- Firmware/ultralcd.cpp | 52 ++++++++++++++++++++++++++++++++++++---- Firmware/ultralcd.h | 3 +++ 4 files changed, 81 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 211384f9..6f74d5a7 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9439,6 +9439,8 @@ static void handleSafetyTimer() } #endif //SAFETYTIMER +extern bool bMenuDetect; / -> .h +extern void lcd_status_screen(); / -> .h & 'static' void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { bool bInhibitFlag; @@ -9451,11 +9453,38 @@ bool bInhibitFlag; #endif // PAT9125 #ifdef IR_SENSOR bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active +//MYSERIAL.print("inhibit :: "); +//MYSERIAL.println(bInhibitFlag); +// & IR_SENSOR_ANALOG ??? +//bInhibitFlag|=(menu_menu==lcd_detect_IRsensor); // Settings::HWsetup::FSdetect menu active +//.bInhibitFlag=bInhibitFlag||(menu_menu==lcd_detect_IRsensor); // Settings::HWsetup::FSdetect menu active +bInhibitFlag=bInhibitFlag||bMenuDetect; // Settings::HWsetup::FSdetect menu active +//MYSERIAL.print(" :: "); +//MYSERIAL.println(bInhibitFlag); +//MYSERIAL.println(current_voltage_raw_IR); #endif // IR_SENSOR if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active { if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { +// ***** +// & IR_SENSOR_ANALOG ??? +bool bTemp; +bTemp=current_voltage_raw_IR>14000; // nahradit prumerem @ vicero hodnot +bTemp=bTemp&&(target_temperature[0]==0); // & bed (& dalsi extrudery) +bTemp=bTemp&&(menu_menu==lcd_status_screen); +bTemp=bTemp&&((oFsensorPCB==ClFsensorPCB::_Old)||(oFsensorPCB==ClFsensorPCB::_Undef)); +bTemp=bTemp&&fsensor_enabled; +if(bTemp) + { + MYSERIAL.println(current_voltage_raw_IR); + MYSERIAL.println("!!!!! -> 03b !!!!!"); + oFsensorPCB=ClFsensorPCB::_Rev03b; + //bTemp=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("?potvrdit?"),false,true); + //MYSERIAL.println(bTemp); + lcd_setstatuspgm(_i("!!! -> 03b !!!")); + } +// ***** if (fsensor_check_autoload()) { #ifdef PAT9125 diff --git a/Firmware/config.h b/Firmware/config.h index 241a2f20..e6d81fe9 100644 --- a/Firmware/config.h +++ b/Firmware/config.h @@ -55,8 +55,8 @@ #define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE) //LANG - Multi-language support -//define LANG_MODE 0 // primary language only -#define LANG_MODE 1 // sec. language support +#define LANG_MODE 0 // primary language only +//#define LANG_MODE 1 // sec. language support #define LANG_SIZE_RESERVED 0x3000 // reserved space for secondary language (12288 bytes) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 38471b81..6c5fc3e2 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -114,7 +114,8 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, // void copy_and_scalePID_d(); /* Different menus */ -static void lcd_status_screen(); +//-//static void lcd_status_screen(); + void lcd_status_screen(); #if (LANG_MODE != 0) static void lcd_language_menu(); #endif @@ -236,7 +237,8 @@ static bool lcd_selftest_fsensor(); #endif //PAT9125 static bool selftest_irsensor(); #if IR_SENSOR_ANALOG -static bool lcd_selftest_IRsensor(); +static bool lcd_selftest_IRsensor(bool bStandalone = false); +//-//static lcd_detect_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(); @@ -2146,6 +2148,23 @@ static void lcd_support_menu() MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 r=1 MENU_ITEM_BACK_P(PSTR(__DATE__)); + MENU_ITEM_BACK_P(STR_SEPARATOR); + MENU_ITEM_BACK_P(PSTR("Fil. sensor v.:")); + switch(oFsensorPCB) + { + case ClFsensorPCB::_Old: + MENU_ITEM_BACK_P(PSTR(" 03 or older")); + break; + case ClFsensorPCB::_Rev03b: + MENU_ITEM_BACK_P(PSTR(" 03b or newer")); + break; + case ClFsensorPCB::_Undef: + MENU_ITEM_BACK_P(PSTR(" N/A")); + break; + default: + MENU_ITEM_BACK_P(PSTR(" unknown")); + } + MENU_ITEM_BACK_P(STR_SEPARATOR); if (mmu_enabled) { @@ -5697,6 +5716,7 @@ void lcd_hw_setup_menu(void) // can not be "static" #if IR_SENSOR_ANALOG FSENSOR_ACTION_NA; + MENU_ITEM_FUNCTION_P(PSTR("FS Detect"), lcd_detect_IRsensor); #endif //IR_SENSOR_ANALOG MENU_END(); } @@ -7496,7 +7516,7 @@ void lcd_belttest() #endif //TMC2130 #if IR_SENSOR_ANALOG -static bool lcd_selftest_IRsensor() +static bool lcd_selftest_IRsensor(bool bStandalone) { bool bAction; bool bPCBrev03b; @@ -7509,7 +7529,8 @@ 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",""); + if(!bStandalone) + 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.")); @@ -7518,7 +7539,8 @@ 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",""); + if(!bStandalone) + lcd_selftest_error(TestError::FsensorLevel,"LOW",""); return(false); } if((bPCBrev03b?1:0)!=(uint8_t)oFsensorPCB) // safer then "(uint8_t)bPCBrev03b" @@ -7529,6 +7551,26 @@ if((bPCBrev03b?1:0)!=(uint8_t)oFsensorPCB) // safer then "(uint8_t)bPCBre } return(true); } + +bool bMenuDetect=false; +//static void lcd_detect_IRsensor() +void lcd_detect_IRsensor() +{ +bool bAction; + +bMenuDetect=true; +bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament unloaded?"),false,true); +if(!bAction) + { + lcd_show_fullscreen_message_and_wait_P(_i("... vyjmi & opakuj ...")); + return; + } +bAction=lcd_selftest_IRsensor(true); +if(bAction) + lcd_show_fullscreen_message_and_wait_P(_i("... povedlo se - VYJMI!!! ...")); +else lcd_show_fullscreen_message_and_wait_P(_i("... NEpovedlo se - VYJMI!!!...")); +bMenuDetect=false; +} #endif //IR_SENSOR_ANALOG static void lcd_selftest_v() diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 9e0c35b0..c9a9d65d 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -57,6 +57,9 @@ void lcd_menu_statistics(); void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") + + void lcd_detect_IRsensor(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") + #ifdef TMC2130 bool lcd_crash_detect_enabled(); void lcd_crash_detect_enable();