Merge pull request #118 from XPila/MK3

pat9125 reinit when fsensor enabled from menu.
This commit is contained in:
XPila 2017-11-28 22:45:42 +01:00 committed by GitHub
commit b488345681
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 14 deletions

View file

@ -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
*------------------------------------*/

View file

@ -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

View file

@ -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;

View file

@ -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)

View file

@ -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);