From 1863819e39f405623724390d00d58732e8955580 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Tue, 28 Nov 2017 22:44:58 +0100 Subject: [PATCH] pat9125 reinit when fsensor enabled from menu. --- Firmware/Configuration_prusa.h | 7 +++++++ Firmware/Marlin_main.cpp | 10 +++++----- Firmware/fsensor.cpp | 15 +++++++++------ Firmware/fsensor.h | 2 +- Firmware/ultralcd.cpp | 5 +++-- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index a2c5f81e..fad1ecff 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -291,6 +291,13 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E} #endif +/*------------------------------------ + PAT9125 SETTINGS + *------------------------------------*/ + +#define PAT9125_XRES 200 +#define PAT9125_YRES 200 + /*------------------------------------ BED SETTINGS *------------------------------------*/ diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b8c6083c..3d7c653e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -905,20 +905,20 @@ void setup() #endif //TMC2130 #ifdef PAT9125 - MYSERIAL.print("PAT9125_init:"); - int pat9125 = pat9125_init(200, 200); - MYSERIAL.println(pat9125); + int pat9125 = pat9125_init(PAT9125_XRES, PAT9125_YRES); + printf_P(PSTR("PAT9125_init:%d\n"), pat9125); uint8_t fsensor = eeprom_read_byte((uint8_t*)EEPROM_FSENSOR); if (!pat9125) fsensor = 0; //disable sensor + puts_P(PSTR("FSensor ")); if (fsensor) { + puts_P(PSTR("ENABLED\n")); fsensor_enable(); - MYSERIAL.println("Filament Sensor ENABLED!"); } else { + puts_P(PSTR("DISABLED\n")); fsensor_disable(); - MYSERIAL.println("Filament Sensor DISABLED"); } #endif //PAT9125 diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 5d304a58..218b91cb 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -41,20 +41,23 @@ int16_t fsensor_st_cnt = 0; uint8_t fsensor_log = 1; -void fsensor_enable() +bool fsensor_enable() { - MYSERIAL.println("fsensor_enable"); - fsensor_enabled = true; + puts_P(PSTR("fsensor_enable\n")); + int pat9125 = pat9125_init(PAT9125_XRES, PAT9125_YRES); + printf_P(PSTR("PAT9125_init:%d\n"), pat9125); + fsensor_enabled = pat9125?true:false; // fsensor_ignore_error = true; fsensor_M600 = false; fsensor_err_cnt = 0; - eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0xFF); - FSensorStateMenu = 1; + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled?0xFF:0x00); + FSensorStateMenu = fsensor_enabled?true:false; + return fsensor_enabled; } void fsensor_disable() { - MYSERIAL.println("fsensor_disable"); + puts_P(PSTR("fsensor_disable\n")); fsensor_enabled = false; eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x00); FSensorStateMenu = 0; diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index c8c35e26..87d9836d 100644 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -8,7 +8,7 @@ extern void fsensor_stop_and_save_print(); extern void fsensor_restore_print_and_continue(); //enable/disable -extern void fsensor_enable(); +extern bool fsensor_enable(); extern void fsensor_disable(); //update (perform M600 on filament runout) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 160fa263..06162f6e 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -110,7 +110,7 @@ int8_t FSensorStateMenu = 1; int8_t CrashDetectMenu = 1; -extern void fsensor_enable(); +extern bool fsensor_enable(); extern void fsensor_disable(); extern void crashdet_enable(); @@ -3271,7 +3271,8 @@ static void lcd_fsensor_state_set() if (FSensorStateMenu==0) { fsensor_disable(); }else{ - fsensor_enable(); + if (!fsensor_enable()); + FSensorStateMenu = 0; } if (IS_SD_PRINTING || is_usb_printing) lcd_goto_menu(lcd_tune_menu, 7); else lcd_goto_menu(lcd_settings_menu, 7);