Skip to content

Commit

Permalink
style tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 7, 2023
1 parent ae934bf commit d1d2948
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 33 deletions.
22 changes: 11 additions & 11 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4042,17 +4042,17 @@
* Sample debug features
* If you add more debug displays, be careful to avoid conflicts!
*/
#define MAX7219_DEBUG_PRINTER_ALIVE // Blink corner LED of 8x8 matrix to show that the firmware is functioning
#define MAX7219_DEBUG_PLANNER_HEAD 2 // Show the planner queue head position on this and the next LED matrix row
#define MAX7219_DEBUG_PLANNER_TAIL 4 // Show the planner queue tail position on this and the next LED matrix row

#define MAX7219_DEBUG_PLANNER_QUEUE 0 // Show the current planner queue depth on this and the next LED matrix row
// If you experience stuttering, reboots, etc. this option can reveal how
// tweaks made to the configuration are affecting the printer in real-time.
#define MAX7219_DEBUG_PROFILE 6 // Display the fraction of CPU time spent in profiled code on this LED matrix
// row. By default idle() is profiled so this shows how "idle" the processor is.
// See class CodeProfiler.
//#define MAX7219_DEBUG_MULTISTEPPING 6// Show multistepping 1 to 128 on this LED matrix row.
#define MAX7219_DEBUG_PRINTER_ALIVE // Blink corner LED of 8x8 matrix to show that the firmware is functioning
#define MAX7219_DEBUG_PLANNER_HEAD 2 // Show the planner queue head position on this and the next LED matrix row
#define MAX7219_DEBUG_PLANNER_TAIL 4 // Show the planner queue tail position on this and the next LED matrix row

#define MAX7219_DEBUG_PLANNER_QUEUE 0 // Show the current planner queue depth on this and the next LED matrix row
// If you experience stuttering, reboots, etc. this option can reveal how
// tweaks made to the configuration are affecting the printer in real-time.
#define MAX7219_DEBUG_PROFILE 6 // Display the fraction of CPU time spent in profiled code on this LED matrix
// row. By default idle() is profiled so this shows how "idle" the processor is.
// See class CodeProfiler.
//#define MAX7219_DEBUG_MULTISTEPPING 6 // Show multistepping 1 to 128 on this LED matrix row.
#endif

/**
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/feature/max7219.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,11 @@ void Max7219::idle_tasks() {

#ifdef MAX7219_DEBUG_MULTISTEPPING
static uint8_t last_multistepping = 0;
uint8_t multistepping = Stepper::steps_per_isr;
if (last_multistepping != multistepping) {
const uint8_t multistepping = Stepper::steps_per_isr;
if (multistepping != last_multistepping) {
static uint8_t log2_old = 0;
uint8_t log2_new = 0;
for (uint8_t val = multistepping; val > 1; val >>= 1, log2_new++);
for (uint8_t val = multistepping; val > 1; val >>= 1) log2_new++;
mark16(MAX7219_DEBUG_MULTISTEPPING, log2_old, log2_new, &row_change_mask);
last_multistepping = multistepping;
log2_old = log2_new;
Expand Down
30 changes: 11 additions & 19 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ void Stepper::pulse_phase_isr() {
}while(0)

#define PAGE_PULSE_PREP(AXIS) do{ \
step_needed.set(_AXIS(AXIS), \
step_needed.set(_AXIS(AXIS), \
pgm_read_byte(&segment_table[page_step_state.sd[_AXIS(AXIS)]][page_step_state.segment_steps & 0x7])); \
}while(0)

Expand Down Expand Up @@ -1802,7 +1802,7 @@ void Stepper::pulse_phase_isr() {
page_step_state.bd[_AXIS(AXIS)] += VALUE;

#define PAGE_PULSE_PREP(AXIS) do{ \
step_needed.set(_AXIS(AXIS), \
step_needed.set(_AXIS(AXIS), \
pgm_read_byte(&segment_table[page_step_state.sd[_AXIS(AXIS)]][page_step_state.segment_steps & 0x3])); \
}while(0)

Expand Down Expand Up @@ -1890,7 +1890,7 @@ void Stepper::pulse_phase_isr() {
PULSE_PREP(E);

#if ENABLED(LIN_ADVANCE)
if (step_needed.e && la_active) {
if (la_active && step_needed.e) {
// don't actually step here, but do subtract movements steps
// from the linear advance step count
step_needed.e = false;
Expand Down Expand Up @@ -2070,17 +2070,9 @@ void Stepper::pulse_phase_isr() {
// Get the timer interval and the number of loops to perform per tick
hal_timer_t Stepper::calc_timer_interval(uint32_t step_rate, uint8_t loops) {
#if DISABLED(DISABLE_MULTI_STEPPING)
if (loops >= 16) {
step_rate >>= 4;
loops >>= 4;
}
if (loops >= 4) {
step_rate >>= 2;
loops >>= 2;
}
if (loops >= 2) {
step_rate >>= 1;
}
if (loops >= 16) { step_rate >>= 4; loops >>= 4; }
if (loops >= 4) { step_rate >>= 2; loops >>= 2; }
if (loops >= 2) { step_rate >>= 1; }
#else
NOMORE(step_rate, uint32_t(MAX_STEP_ISR_FREQUENCY_1X));
#endif
Expand Down Expand Up @@ -2110,7 +2102,7 @@ hal_timer_t Stepper::calc_timer_interval(uint32_t step_rate, uint8_t loops) {
}
else {
step_rate = 0;
uintptr_t table_address = (uintptr_t)&speed_lookuptable_slow[0][0];
const uintptr_t table_address = (uintptr_t)&speed_lookuptable_slow[0][0];
return uint16_t(pgm_read_word(table_address));
}
}
Expand Down Expand Up @@ -2591,7 +2583,7 @@ hal_timer_t Stepper::block_phase_isr() {
if (stepper_extruder != last_moved_extruder) la_advance_steps = 0;
#endif
if (la_active) {
// apply LA scaling and discount the effect of frequency scaling
// Apply LA scaling and discount the effect of frequency scaling
la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling_factor;
}
#endif
Expand Down Expand Up @@ -2671,8 +2663,8 @@ hal_timer_t Stepper::block_phase_isr() {
// the acceleration and speed values calculated in block_phase_isr().
// This helps keep LA in sync with, for example, S_CURVE_ACCELERATION.
la_delta_error += la_dividend;
const bool step_needed = la_delta_error >= 0;
if (step_needed) {
const bool e_step_needed = la_delta_error >= 0;
if (e_step_needed) {
count_position.e += count_direction.e;
la_advance_steps += count_direction.e;
la_delta_error -= advance_divisor;
Expand All @@ -2683,7 +2675,7 @@ hal_timer_t Stepper::block_phase_isr() {

TERN_(I2S_STEPPER_STREAM, i2s_push_sample());

if (step_needed) {
if (e_step_needed) {
// Enforce a minimum duration for STEP pulse ON
#if ISR_PULSE_CONTROL
USING_TIMED_PULSE();
Expand Down

0 comments on commit d1d2948

Please sign in to comment.