🔧 Allow arbitrary BLOCK_BUFFER_SIZE

This commit is contained in:
Scott Lahteine 2023-08-22 19:16:35 -05:00
parent fb74caebb5
commit ab8af7fa9c
3 changed files with 8 additions and 5 deletions

View file

@ -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

View file

@ -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;

View file

@ -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 {
@ -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)
@ -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