Merge pull request #1221 from XPila/MK3

Update fsensor in Manage_inactivity instead of main loop.
This commit is contained in:
PavelSindler 2018-10-10 13:12:12 +02:00 committed by GitHub
commit bbd4f70f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 9 deletions

View File

@ -1964,10 +1964,6 @@ void loop()
isPrintPaused ? manage_inactivity(true) : manage_inactivity(false);
checkHitEndstops();
lcd_update(0);
#ifdef FILAMENT_SENSOR
if (mcode_in_progress != 600 && !mmu_enabled) //M600 not in progress
fsensor_update();
#endif //FILAMENT_SENSOR
#ifdef TMC2130
tmc2130_check_overtemp();
if (tmc2130_sg_crash)
@ -7368,7 +7364,10 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
}
}
else
{
fsensor_autoload_check_stop();
fsensor_update();
}
}
}
#endif //FILAMENT_SENSOR

View File

@ -146,6 +146,8 @@
#define EEPROM_SOUND_MODE (EEPROM_UVLO_TINY_Z_MICROSTEPS-1) // uint8
#define EEPROM_AUTO_DEPLETE (EEPROM_SOUND_MODE-1) //bool
#define EEPROM_FSENS_OQ_MEASS_ENABLED (EEPROM_AUTO_DEPLETE - 1) //bool
// !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
// !!!!!

View File

@ -42,6 +42,8 @@ bool fsensor_enabled = true;
bool fsensor_watch_runout = true;
//not responding - is set if any communication error occured durring initialization or readout
bool fsensor_not_responding = false;
//enable/disable quality meassurement
bool fsensor_oq_meassure_enabled = false;
//number of errors, updated in ISR
uint8_t fsensor_err_cnt = 0;
@ -114,6 +116,8 @@ void fsensor_init(void)
printf_P(PSTR("PAT9125_init:%hhu\n"), pat9125);
uint8_t fsensor = eeprom_read_byte((uint8_t*)EEPROM_FSENSOR);
fsensor_autoload_enabled=eeprom_read_byte((uint8_t*)EEPROM_FSENS_AUTOLOAD_ENABLED);
uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED);
fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false;
fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * axis_steps_per_unit[E_AXIS]);
if (!pat9125)
@ -255,9 +259,16 @@ bool fsensor_check_autoload(void)
return false;
}
void fsensor_oq_meassure_set(bool State)
{
fsensor_oq_meassure_enabled = State;
eeprom_update_byte((unsigned char *)EEPROM_FSENS_OQ_MEASS_ENABLED, fsensor_oq_meassure_enabled);
}
void fsensor_oq_meassure_start(uint8_t skip)
{
if (!fsensor_enabled) return;
if (!fsensor_oq_meassure_enabled) return;
printf_P(PSTR("fsensor_oq_meassure_start\n"));
fsensor_oq_skipchunk = skip;
fsensor_oq_samples = 0;
@ -277,6 +288,7 @@ void fsensor_oq_meassure_start(uint8_t skip)
void fsensor_oq_meassure_stop(void)
{
if (!fsensor_enabled) return;
if (!fsensor_oq_meassure_enabled) return;
printf_P(PSTR("fsensor_oq_meassure_stop, %hhu samples\n"), fsensor_oq_samples);
printf_P(_N(" st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max);
printf_P(_N(" yd_min=%u yd_max=%u yd_avg=%u sh_avg=%u\n"), fsensor_oq_yd_min, fsensor_oq_yd_max, (uint16_t)((uint32_t)fsensor_oq_yd_sum * fsensor_chunk_len / fsensor_oq_st_sum), (uint16_t)(fsensor_oq_sh_sum / fsensor_oq_samples));
@ -291,6 +303,7 @@ const char _NG[] PROGMEM = "NG!";
bool fsensor_oq_result(void)
{
if (!fsensor_enabled) return true;
if (!fsensor_oq_meassure_enabled) return true;
printf_P(_N("fsensor_oq_result\n"));
bool res_er_sum = (fsensor_oq_er_sum <= FSENSOR_OQ_MAX_ES);
printf_P(_N(" er_sum = %u %S\n"), fsensor_oq_er_sum, (res_er_sum?_OK:_NG));
@ -305,9 +318,10 @@ bool fsensor_oq_result(void)
printf_P(_N(" yd_min = %u %S\n"), fsensor_oq_yd_min, (res_yd_min?_OK:_NG));
uint16_t yd_dev = (fsensor_oq_yd_max - yd_avg) + (yd_avg - fsensor_oq_yd_min);
uint16_t yd_qua = 10 * yd_avg / (yd_dev + 1);
printf_P(_N(" yd_dev = %u\n"), yd_dev);
printf_P(_N(" yd_qua = %u\n"), yd_qua);
uint16_t yd_qua = 10 * yd_avg / (yd_dev + 1);
printf_P(_N(" yd_qua = %u %S\n"), yd_qua, ((yd_qua >= 8)?_OK:_NG));
uint8_t sh_avg = (fsensor_oq_sh_sum / fsensor_oq_samples);
bool res_sh_avg = (sh_avg <= FSENSOR_OQ_MAX_SH);
@ -432,6 +446,8 @@ void fsensor_update(void)
{
bool autoload_enabled_tmp = fsensor_autoload_enabled;
fsensor_autoload_enabled = false;
bool oq_meassure_enabled_tmp = fsensor_oq_meassure_enabled;
fsensor_oq_meassure_enabled = true;
fsensor_stop_and_save_print();
@ -467,10 +483,12 @@ void fsensor_update(void)
fsensor_oq_meassure_stop();
bool err = false;
err |= (fsensor_oq_er_sum > 2);
err |= (err_cnt > 1);
err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD));
if (!err)
err |= (fsensor_oq_er_sum > 2);
err |= (fsensor_oq_yd_sum < (4 * FSENSOR_OQ_MIN_YD));
if (!err)
{
printf_P(PSTR("fsensor_err_cnt = 0\n"));
fsensor_restore_print_and_continue();
@ -485,6 +503,7 @@ void fsensor_update(void)
fsensor_watch_runout = false;
}
fsensor_autoload_enabled = autoload_enabled_tmp;
fsensor_oq_meassure_enabled = oq_meassure_enabled_tmp;
}
}

View File

@ -10,6 +10,8 @@ extern int16_t fsensor_chunk_len;
extern bool fsensor_enabled;
//not responding flag
extern bool fsensor_not_responding;
//enable/disable quality meassurement
extern bool fsensor_oq_meassure_enabled;
//save restore printing
@ -39,6 +41,7 @@ extern void fsensor_autoload_check_stop(void);
extern bool fsensor_check_autoload(void);
//optical quality meassurement support
extern void fsensor_oq_meassure_set(bool State);
extern void fsensor_oq_meassure_start(uint8_t skip);
extern void fsensor_oq_meassure_stop(void);
extern bool fsensor_oq_result(void);

View File

@ -2209,6 +2209,12 @@ void lcd_set_filament_autoload() {
fsensor_autoload_set(!fsensor_autoload_enabled);
}
void lcd_set_filament_oq_meass()
{
fsensor_oq_meassure_set(!fsensor_oq_meassure_enabled);
}
void lcd_unLoadFilament()
{
@ -4594,6 +4600,10 @@ do\
MENU_ITEM_FUNCTION_P(_i("F. autoload [on]"), lcd_set_filament_autoload);/*////MSG_FSENS_AUTOLOAD_ON c=17 r=1*/\
else\
MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);/*////MSG_FSENS_AUTOLOAD_OFF c=17 r=1*/\
if (fsensor_oq_meassure_enabled)\
MENU_ITEM_FUNCTION_P(_i("F. OQ meass. [on]"), lcd_set_filament_oq_meass);/*////MSG_FSENS_OQMEASS_ON c=17 r=1*/\
else\
MENU_ITEM_FUNCTION_P(_i("F. OQ meass.[off]"), lcd_set_filament_oq_meass);/*////MSG_FSENS_OQMEASS_OFF c=17 r=1*/\
}\
}\
}\

View File

@ -145,6 +145,8 @@
//#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */
#define FSENSOR_QUALITY
/*------------------------------------
EXTRUDER SETTINGS

View File

@ -146,6 +146,8 @@
//#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */
#define FSENSOR_QUALITY
/*------------------------------------
EXTRUDER SETTINGS

View File

@ -183,6 +183,9 @@
#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */
#define FSENSOR_QUALITY
#define LINEARITY_CORRECTION
#define TMC2130_LINEARITY_CORRECTION
#define TMC2130_LINEARITY_CORRECTION_XYZ