From 2a9504b20a5a6db30550e8c22cd1b28fe1eed3d6 Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Mon, 2 Mar 2020 19:07:23 +0100 Subject: [PATCH] !!! for testing only !!! filament sensor auto-detection --- Firmware/Marlin_main.cpp | 49 ++++++++++++++++------------------------ Firmware/config.h | 4 ++-- Firmware/ultralcd.cpp | 27 +++++++++++----------- Firmware/ultralcd.h | 7 ++++-- 4 files changed, 40 insertions(+), 47 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6f74d5a7e..7ecbe0e9e 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9439,12 +9439,11 @@ 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; #ifdef FILAMENT_SENSOR +bool bInhibitFlag; + if (mmu_enabled == false) { //-// if (mcode_in_progress != 600) //M600 not in progress @@ -9453,38 +9452,28 @@ 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); +#ifdef IR_SENSOR_ANALOG + bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Settings::HWsetup::FSdetect menu active +#endif // IR_SENSOR_ANALOG #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 !!!")); - } -// ***** +#ifdef IR_SENSOR_ANALOG + bool 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) + { + oFsensorPCB=ClFsensorPCB::_Rev03b; +// eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_PCB,(uint8_t)oFsensorPCB); + printf_P(PSTR("Filament sensor board change detected: revision 03b or newer\n")); + lcd_setstatuspgm(_i("FS rev. 03b or newer")); + } +#endif // IR_SENSOR_ANALOG if (fsensor_check_autoload()) { #ifdef PAT9125 diff --git a/Firmware/config.h b/Firmware/config.h index e6d81fe9b..ab93d798b 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 6c5fc3e2e..a2acd1b99 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -68,6 +68,10 @@ uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode int8_t FSensorStateMenu = 1; +#if IR_SENSOR_ANALOG +bool bMenuFSDetect=false; +#endif //IR_SENSOR_ANALOG + #ifdef SDCARD_SORT_ALPHA bool presort_flag = false; @@ -114,8 +118,7 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, // void copy_and_scalePID_d(); /* Different menus */ -//-//static void lcd_status_screen(); - void lcd_status_screen(); +//static void lcd_status_screen(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") #if (LANG_MODE != 0) static void lcd_language_menu(); #endif @@ -237,8 +240,8 @@ static bool lcd_selftest_fsensor(); #endif //PAT9125 static bool selftest_irsensor(); #if IR_SENSOR_ANALOG -static bool lcd_selftest_IRsensor(bool bStandalone = false); -//-//static lcd_detect_IRsensor(); +static bool lcd_selftest_IRsensor(bool bStandalone=false); +static void 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(); @@ -977,7 +980,7 @@ void lcdui_print_status_screen(void) } // Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent -static void lcd_status_screen() +void lcd_status_screen() // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") { if (firstrun == 1) { @@ -7552,24 +7555,22 @@ 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() +static void lcd_detect_IRsensor() { bool bAction; -bMenuDetect=true; +bMenuFSDetect=true; // inhibits some code inside "manage_inactivity()" 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 ...")); + lcd_show_fullscreen_message_and_wait_P(_i("... so unload the filament and repeat action!")); 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; + lcd_show_fullscreen_message_and_wait_P(_i("PCB check successful - withdraw the filament now!")); +else lcd_show_fullscreen_message_and_wait_P(_i("PCB check unsuccessful - withdraw the filament now!")); +bMenuFSDetect=false; // de-inhibits some code inside "manage_inactivity()" } #endif //IR_SENSOR_ANALOG diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index c9a9d65d1..ca64659ae 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -55,11 +55,10 @@ extern bool lcd_selftest(); void lcd_menu_statistics(); +void lcd_status_screen(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") 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(); @@ -141,6 +140,10 @@ extern uint8_t farm_status; #define SILENT_MODE_OFF SILENT_MODE_POWER #endif +#if IR_SENSOR_ANALOG +extern bool bMenuFSDetect; +#endif //IR_SENSOR_ANALOG + extern int8_t SilentModeMenu; extern uint8_t SilentModeMenu_MMU;