Isolate all PAT9125-specific code, fix build on !MK3 variants
- Hide all prototypes related to PAT9125 to force all callers to check for the proper sensor, since the handling differences are substantial - Remove unneeded lenght accounting from the stepper isr as as consequence. - Keep detailed soft failure counts for the MK3 on the "last print failures" status screen, but fix build on variants without a PAT9125 by fixing the lcd stats function.
This commit is contained in:
parent
d47363d85a
commit
6fbd632c84
@ -634,13 +634,15 @@ void crashdet_cancel()
|
||||
|
||||
void failstats_reset_print()
|
||||
{
|
||||
fsensor_softfail = 0;
|
||||
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_X, 0);
|
||||
eeprom_update_byte((uint8_t *)EEPROM_CRASH_COUNT_Y, 0);
|
||||
eeprom_update_byte((uint8_t *)EEPROM_FERROR_COUNT, 0);
|
||||
eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0);
|
||||
eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0);
|
||||
eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
fsensor_softfail = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -6682,7 +6684,9 @@ Sigma_Exit:
|
||||
axis_steps_per_sqr_second[i] *= factor;
|
||||
}
|
||||
cs.axis_steps_per_unit[i] = value;
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
fsensor_set_axis_steps_per_unit(value);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
cs.axis_steps_per_unit[i] = code_value();
|
||||
@ -8446,8 +8450,10 @@ Sigma_Exit:
|
||||
cs.axis_steps_per_unit[i] /= fac;
|
||||
position[i] /= fac;
|
||||
}
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
if (i == E_AXIS)
|
||||
fsensor_set_axis_steps_per_unit(cs.axis_steps_per_unit[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,25 +47,32 @@ const char ERRMSG_PAT9125_NOT_RESP[] PROGMEM = "PAT9125 not responding (%d)!\n";
|
||||
#define FSENSOR_INT_PIN_PCMSK_BIT PCINT13 // PinChange Interrupt / PinChange Enable Mask @ PJ4
|
||||
#define FSENSOR_INT_PIN_PCICR_BIT PCIE1 // PinChange Interrupt Enable / Flag @ PJ4
|
||||
|
||||
//uint8_t fsensor_int_pin = FSENSOR_INT_PIN;
|
||||
uint8_t fsensor_int_pin_old = 0;
|
||||
int16_t fsensor_chunk_len = 0;
|
||||
|
||||
//! enabled = initialized and sampled every chunk event
|
||||
bool fsensor_enabled = true;
|
||||
//! runout watching is done in fsensor_update (called from main loop)
|
||||
bool fsensor_watch_runout = true;
|
||||
//! not responding - is set if any communication error occurred during initialization or readout
|
||||
bool fsensor_not_responding = false;
|
||||
|
||||
#ifdef PAT9125
|
||||
uint8_t fsensor_int_pin_old = 0;
|
||||
//! optical checking "chunk lenght" (already in steps)
|
||||
int16_t fsensor_chunk_len = 0;
|
||||
//! enable/disable quality meassurement
|
||||
bool fsensor_oq_meassure_enabled = false;
|
||||
|
||||
//! number of errors, updated in ISR
|
||||
uint8_t fsensor_err_cnt = 0;
|
||||
//! variable for accumulating step count (updated callbacks from stepper and ISR)
|
||||
int16_t fsensor_st_cnt = 0;
|
||||
//! last dy value from pat9125 sensor (used in ISR)
|
||||
int16_t fsensor_dy_old = 0;
|
||||
//! count of total sensor "soft" failures (filament status checks)
|
||||
uint8_t fsensor_softfail = 0;
|
||||
//! timestamp of last soft failure
|
||||
unsigned long fsensor_softfail_last = 0;
|
||||
//! count of soft failures within the configured time
|
||||
uint8_t fsensor_softfail_ccnt = 0;
|
||||
#endif
|
||||
|
||||
//! log flag: 0=log disabled, 1=log enabled
|
||||
uint8_t fsensor_log = 1;
|
||||
@ -78,6 +85,8 @@ uint8_t fsensor_log = 1;
|
||||
bool fsensor_autoload_enabled = true;
|
||||
//! autoload watching enable/disable flag
|
||||
bool fsensor_watch_autoload = false;
|
||||
|
||||
#ifdef PAT9125
|
||||
//
|
||||
uint16_t fsensor_autoload_y;
|
||||
//
|
||||
@ -86,11 +95,8 @@ uint8_t fsensor_autoload_c;
|
||||
uint32_t fsensor_autoload_last_millis;
|
||||
//
|
||||
uint8_t fsensor_autoload_sum;
|
||||
//
|
||||
uint8_t fsensor_softfail = 0;
|
||||
uint8_t fsensor_softfail_ccnt = 0;
|
||||
unsigned long fsensor_softfail_last = 0;
|
||||
//! @}
|
||||
#endif
|
||||
|
||||
|
||||
//! @name filament optical quality measurement variables
|
||||
@ -136,7 +142,9 @@ void fsensor_restore_print_and_continue(void)
|
||||
{
|
||||
printf_P(PSTR("fsensor_restore_print_and_continue\n"));
|
||||
fsensor_watch_runout = true;
|
||||
#ifdef PAT9125
|
||||
fsensor_err_cnt = 0;
|
||||
#endif
|
||||
restore_print_from_ram_and_continue(0);
|
||||
}
|
||||
|
||||
@ -368,6 +376,7 @@ bool fsensor_check_autoload(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef PAT9125
|
||||
void fsensor_oq_meassure_set(bool State)
|
||||
{
|
||||
fsensor_oq_meassure_enabled = State;
|
||||
@ -439,7 +448,7 @@ bool fsensor_oq_result(void)
|
||||
printf_P(_N("fsensor_oq_result %S\n"), (res?_OK:_NG));
|
||||
return res;
|
||||
}
|
||||
#ifdef PAT9125
|
||||
|
||||
ISR(FSENSOR_INT_PIN_VECT)
|
||||
{
|
||||
if (mmu_enabled || ir_sensor_detected) return;
|
||||
@ -538,8 +547,6 @@ void fsensor_setup_interrupt(void)
|
||||
PCICR |= bit(FSENSOR_INT_PIN_PCICR_BIT); // enable corresponding PinChangeInterrupt (set of pins)
|
||||
}
|
||||
|
||||
#endif //PAT9125
|
||||
|
||||
void fsensor_st_block_chunk(int cnt)
|
||||
{
|
||||
if (!fsensor_enabled) return;
|
||||
@ -551,6 +558,7 @@ void fsensor_st_block_chunk(int cnt)
|
||||
else {PIN_VAL(FSENSOR_INT_PIN, HIGH);}
|
||||
}
|
||||
}
|
||||
#endif //PAT9125
|
||||
|
||||
|
||||
//! Common code for enqueing M600 and supplemental codes into the command queue.
|
||||
|
@ -6,16 +6,16 @@
|
||||
#include "config.h"
|
||||
|
||||
|
||||
//! minimum meassured chunk length in steps
|
||||
extern int16_t fsensor_chunk_len;
|
||||
// enable/disable flag
|
||||
extern bool fsensor_enabled;
|
||||
// not responding flag
|
||||
extern bool fsensor_not_responding;
|
||||
//enable/disable quality meassurement
|
||||
extern bool fsensor_oq_meassure_enabled;
|
||||
#ifdef PAT9125
|
||||
// optical checking "chunk lenght" (already in steps)
|
||||
extern int16_t fsensor_chunk_len;
|
||||
// count of soft failures
|
||||
extern uint8_t fsensor_softfail;
|
||||
|
||||
#endif
|
||||
|
||||
//! @name save restore printing
|
||||
//! @{
|
||||
@ -29,8 +29,10 @@ extern void fsensor_checkpoint_print(void);
|
||||
//! initialize
|
||||
extern void fsensor_init(void);
|
||||
|
||||
#ifdef PAT9125
|
||||
//! update axis resolution
|
||||
extern void fsensor_set_axis_steps_per_unit(float u);
|
||||
#endif
|
||||
|
||||
//! @name enable/disable
|
||||
//! @{
|
||||
@ -56,8 +58,10 @@ extern void fsensor_autoload_check_stop(void);
|
||||
extern bool fsensor_check_autoload(void);
|
||||
//! @}
|
||||
|
||||
#ifdef PAT9125
|
||||
//! @name optical quality measurement support
|
||||
//! @{
|
||||
extern bool fsensor_oq_meassure_enabled;
|
||||
extern void fsensor_oq_meassure_set(bool State);
|
||||
extern void fsensor_oq_meassure_start(uint8_t skip);
|
||||
extern void fsensor_oq_meassure_stop(void);
|
||||
@ -74,6 +78,7 @@ extern void fsensor_st_block_chunk(int cnt);
|
||||
// to drain fsensor_st_cnt anyway at the beginning of the new block.
|
||||
#define fsensor_st_block_begin(rev) fsensor_st_block_chunk(0)
|
||||
//! @}
|
||||
#endif //PAT9125
|
||||
|
||||
|
||||
#if IR_SENSOR_ANALOG
|
||||
|
@ -36,9 +36,9 @@
|
||||
#include "tmc2130.h"
|
||||
#endif //TMC2130
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
#include "fsensor.h"
|
||||
int fsensor_counter = 0; //counter for e-steps
|
||||
int fsensor_counter; //counter for e-steps
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
#include "mmu.h"
|
||||
@ -421,9 +421,9 @@ FORCE_INLINE void stepper_next_block()
|
||||
#endif /* LIN_ADVANCE */
|
||||
count_direction[E_AXIS] = 1;
|
||||
}
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter = 0;
|
||||
fsensor_st_block_begin(count_direction[E_AXIS] < 0);
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
fsensor_counter = 0;
|
||||
fsensor_st_block_begin(count_direction[E_AXIS] < 0);
|
||||
#endif //FILAMENT_SENSOR
|
||||
}
|
||||
else {
|
||||
@ -973,13 +973,13 @@ FORCE_INLINE void advance_isr_scheduler() {
|
||||
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
e_steps += (rev? 1: -1);
|
||||
WRITE_NC(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
#ifdef FILAMENT_SENSOR
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
fsensor_counter += (rev? -1: 1);
|
||||
#endif
|
||||
}
|
||||
while(--max_ticks);
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
if (abs(fsensor_counter) >= fsensor_chunk_len)
|
||||
{
|
||||
fsensor_st_block_chunk(fsensor_counter);
|
||||
|
@ -1796,14 +1796,23 @@ static void lcd_menu_fails_stats_print()
|
||||
uint8_t crashX = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X);
|
||||
uint8_t crashY = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y);
|
||||
lcd_home();
|
||||
#ifndef PAT9125
|
||||
lcd_printf_P(failStatsFmt,
|
||||
_i("Last print failures"), ////c=20 r=1
|
||||
_i("Power failures"), power, ////c=14 r=1
|
||||
_i("Filam. runouts"), filam, ////c=14 r=1
|
||||
_i("Crash"), crashX, crashY); ////c=7 r=1
|
||||
#else
|
||||
// On the MK3 include detailed PAT9125 statistics about soft failures
|
||||
lcd_printf_P(PSTR("%S\n"
|
||||
" %S %-3d\n"
|
||||
" %S H %-3d S %-3d\n"
|
||||
" %S X %-3d Y %-3d"),
|
||||
_i("Last print failures"),
|
||||
_i("Power failures"), power,
|
||||
_i("Runouts"), filam, fsensor_softfail,
|
||||
_i("Crash"), crashX, crashY);
|
||||
" %-16.16S%-3d\n"
|
||||
" %-7.7S H %-3d S %-3d\n"
|
||||
" %-7.7S X %-3d Y %-3d"),
|
||||
_i("Last print failures"), ////c=20 r=1
|
||||
_i("Power failures"), power, ////c=14 r=1
|
||||
_i("Runouts"), filam, fsensor_softfail, //c=7 r=1
|
||||
_i("Crash"), crashX, crashY); ////c=7 r=1
|
||||
#endif
|
||||
menu_back_if_clicked_fb();
|
||||
}
|
||||
|
||||
@ -2234,10 +2243,12 @@ void lcd_set_filament_autoload() {
|
||||
fsensor_autoload_set(!fsensor_autoload_enabled);
|
||||
}
|
||||
|
||||
#if defined(FILAMENT_SENSOR) && defined(PAT9125)
|
||||
void lcd_set_filament_oq_meass()
|
||||
{
|
||||
fsensor_oq_meassure_set(!fsensor_oq_meassure_enabled);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
FilamentAction eFilamentAction=FilamentAction::None; // must be initialized as 'non-autoLoad'
|
||||
|
Loading…
Reference in New Issue
Block a user