Skip to content

Commit

Permalink
🔧 Allow arbitrary BLOCK_BUFFER_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Aug 23, 2023
1 parent fb74cae commit ab8af7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,6 @@
// @section motion

// The number of linear moves that can be in the planner at once.
// The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g., 8, 16, 32)
#if ALL(HAS_MEDIA, DIRECT_STEPPING)
#define BLOCK_BUFFER_SIZE 8
#elif HAS_MEDIA
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/max7219.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ void Max7219::idle_tasks() {

#ifdef MAX7219_DEBUG_PLANNER_QUEUE
static int16_t last_depth = 0;
const int16_t current_depth = (head - tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1) & 0xF;
const int16_t current_depth = BLOCK_MOD(head - tail + (BLOCK_BUFFER_SIZE)) & 0xF;
if (current_depth != last_depth) {
quantity16(MAX7219_DEBUG_PLANNER_QUEUE, last_depth, current_depth, &row_change_mask);
last_depth = current_depth;
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/module/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ typedef struct PlannerBlock {
#define HAS_POSITION_FLOAT 1
#endif

#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
#if IS_POWER_OF_2(BLOCK_BUFFER_SIZE)
#define BLOCK_MOD(n) ((n)&((BLOCK_BUFFER_SIZE)-1))
#else
#define BLOCK_MOD(n) ((n)%(BLOCK_BUFFER_SIZE))
#endif

#if ENABLED(LASER_FEATURE)
typedef struct {
Expand Down Expand Up @@ -366,7 +370,7 @@ typedef struct {
#endif

#if ENABLED(DISABLE_OTHER_EXTRUDERS)
typedef uvalue_t(BLOCK_BUFFER_SIZE * 2) last_move_t;
typedef uvalue_t((BLOCK_BUFFER_SIZE) * 2) last_move_t;
#endif

#if ENABLED(ARC_SUPPORT)
Expand Down Expand Up @@ -780,7 +784,7 @@ class Planner {
FORCE_INLINE static bool is_full() { return block_buffer_tail == next_block_index(block_buffer_head); }

// Get count of movement slots free
FORCE_INLINE static uint8_t moves_free() { return BLOCK_BUFFER_SIZE - 1 - movesplanned(); }
FORCE_INLINE static uint8_t moves_free() { return (BLOCK_BUFFER_SIZE) - 1 - movesplanned(); }

/**
* Planner::get_next_free_block
Expand Down

0 comments on commit ab8af7f

Please sign in to comment.