From a6a81c6ea6620d062b56f9bd980f3982e94b82df Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 25 Oct 2018 18:26:26 +0200 Subject: [PATCH] mmu2: filament senor (FINDA) can be switched ON/OFF from menu without dependency on pat9125 state --- Firmware/fsensor.cpp | 37 ++++++++++++++++++++++--------------- Firmware/ultralcd.cpp | 4 ++-- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 2891b770..f4321f99 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -7,6 +7,7 @@ #include "planner.h" #include "fastio.h" #include "cmdqueue.h" +#include "mmu.h" //Basic params #define FSENSOR_CHUNK_LEN 0.64F //filament sensor chunk length 0.64mm @@ -136,21 +137,27 @@ void fsensor_init(void) bool fsensor_enable(void) { - uint8_t pat9125 = pat9125_init(); - printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); - if (pat9125) - fsensor_not_responding = false; - else - fsensor_not_responding = true; - fsensor_enabled = pat9125?true:false; - fsensor_watch_runout = true; - fsensor_oq_meassure = false; - fsensor_err_cnt = 0; - fsensor_dy_old = 0; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled?0x01:0x00); - FSensorStateMenu = fsensor_enabled?1:0; - - + if (mmu_enabled == false) { //filament sensor is pat9125, enable only if it is working + uint8_t pat9125 = pat9125_init(); + printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125); + if (pat9125) + fsensor_not_responding = false; + else + fsensor_not_responding = true; + fsensor_enabled = pat9125 ? true : false; + fsensor_watch_runout = true; + fsensor_oq_meassure = false; + fsensor_err_cnt = 0; + fsensor_dy_old = 0; + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled ? 0x01 : 0x00); + FSensorStateMenu = fsensor_enabled ? 1 : 0; + } + else //filament sensor is FINDA, always enable + { + fsensor_enabled = true; + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x01); + FSensorStateMenu = 1; + } return fsensor_enabled; } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 2a4cf0f0..5ffe3383 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4574,7 +4574,7 @@ do\ {\ if (FSensorStateMenu == 0)\ {\ - if (fsensor_not_responding)\ + if (fsensor_not_responding && (mmu_enabled == false))\ {\ /* Filament sensor not working*/\ MENU_ITEM_FUNCTION_P(_i("Fil. sensor [N/A]"), lcd_fsensor_state_set);/*////MSG_FSENSOR_NA c=0 r=0*/\ @@ -4584,7 +4584,7 @@ do\ {\ /* Filament sensor turned off, working, no problems*/\ MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set);\ - if (mmu_enabled == false)if (mmu_enabled == false)\ + if (mmu_enabled == false)\ {\ MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);\ }\