Factor-out some repetition into fsensor_step
This commit is contained in:
parent
124540a06f
commit
bf0c60dd45
@ -352,6 +352,30 @@ FORCE_INLINE unsigned short calc_timer(uint16_t step_rate) {
|
|||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FILAMENT_SENSOR
|
||||||
|
#define fsensor_step(cnt)
|
||||||
|
#else
|
||||||
|
FORCE_INLINE void fsensor_step(uint8_t cnt)
|
||||||
|
{
|
||||||
|
if (READ(E0_DIR_PIN) == INVERT_E0_DIR)
|
||||||
|
{
|
||||||
|
if (count_direction[E_AXIS] == 1)
|
||||||
|
fsensor_counter -= cnt;
|
||||||
|
else
|
||||||
|
fsensor_counter += cnt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (count_direction[E_AXIS] == 1)
|
||||||
|
fsensor_counter += cnt;
|
||||||
|
else
|
||||||
|
fsensor_counter -= cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
||||||
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
|
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
|
||||||
ISR(TIMER1_COMPA_vect) {
|
ISR(TIMER1_COMPA_vect) {
|
||||||
@ -372,22 +396,7 @@ ISR(TIMER1_COMPA_vect) {
|
|||||||
cnt++;
|
cnt++;
|
||||||
WRITE_NC(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
WRITE_NC(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||||
}
|
}
|
||||||
#ifdef FILAMENT_SENSOR
|
fsensor_step(cnt);
|
||||||
if (READ(E0_DIR_PIN) == INVERT_E0_DIR)
|
|
||||||
{
|
|
||||||
if (count_direction[E_AXIS] == 1)
|
|
||||||
fsensor_counter -= cnt;
|
|
||||||
else
|
|
||||||
fsensor_counter += cnt;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (count_direction[E_AXIS] == 1)
|
|
||||||
fsensor_counter += cnt;
|
|
||||||
else
|
|
||||||
fsensor_counter -= cnt;
|
|
||||||
}
|
|
||||||
#endif //FILAMENT_SENSOR
|
|
||||||
if (e_steps) {
|
if (e_steps) {
|
||||||
// Plan another Linear Advance tick.
|
// Plan another Linear Advance tick.
|
||||||
OCR1A = eISR_Rate;
|
OCR1A = eISR_Rate;
|
||||||
@ -916,22 +925,7 @@ FORCE_INLINE void isr() {
|
|||||||
estep_loops = (e_steps & 0x0ff00) ? 4 : e_steps;
|
estep_loops = (e_steps & 0x0ff00) ? 4 : e_steps;
|
||||||
if (step_loops < estep_loops)
|
if (step_loops < estep_loops)
|
||||||
estep_loops = step_loops;
|
estep_loops = step_loops;
|
||||||
#ifdef FILAMENT_SENSOR
|
fsensor_step(estep_loops);
|
||||||
if (READ(E0_DIR_PIN) == INVERT_E0_DIR)
|
|
||||||
{
|
|
||||||
if (count_direction[E_AXIS] == 1)
|
|
||||||
fsensor_counter -= estep_loops;
|
|
||||||
else
|
|
||||||
fsensor_counter += estep_loops;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (count_direction[E_AXIS] == 1)
|
|
||||||
fsensor_counter += estep_loops;
|
|
||||||
else
|
|
||||||
fsensor_counter -= estep_loops;
|
|
||||||
}
|
|
||||||
#endif //FILAMENT_SENSOR
|
|
||||||
do {
|
do {
|
||||||
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||||
-- e_steps;
|
-- e_steps;
|
||||||
@ -1056,22 +1050,7 @@ FORCE_INLINE void isr() {
|
|||||||
// There is not enough time to fit even a single additional tick.
|
// There is not enough time to fit even a single additional tick.
|
||||||
// Tick all the extruder ticks now.
|
// Tick all the extruder ticks now.
|
||||||
MSerial.checkRx(); // Check for serial chars.
|
MSerial.checkRx(); // Check for serial chars.
|
||||||
#ifdef FILAMENT_SENSOR
|
fsensor_step(e_steps);
|
||||||
if (READ(E0_DIR_PIN) == INVERT_E0_DIR)
|
|
||||||
{
|
|
||||||
if (count_direction[E_AXIS] == 1)
|
|
||||||
fsensor_counter -= e_steps;
|
|
||||||
else
|
|
||||||
fsensor_counter += e_steps;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (count_direction[E_AXIS] == 1)
|
|
||||||
fsensor_counter += e_steps;
|
|
||||||
else
|
|
||||||
fsensor_counter -= e_steps;
|
|
||||||
}
|
|
||||||
#endif //FILAMENT_SENSOR
|
|
||||||
do {
|
do {
|
||||||
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||||
-- e_steps;
|
-- e_steps;
|
||||||
|
Loading…
Reference in New Issue
Block a user