MCPcopy Create free account
hub / github.com/MarlinFirmware/Marlin / buffer_sync_block

Method buffer_sync_block

Marlin/src/module/planner.cpp:2811–2850  ·  view source on GitHub ↗

* @brief Add a block to the buffer that just updates the position. * @details Supports LASER_SYNCHRONOUS_M106_M107 and LASER_POWER_SYNC power sync block buffer queueing. * * @param sync_flag The sync flag to set, determining the type of sync the block will do */

Source from the content-addressed store, hash-verified

2809 * @param sync_flag The sync flag to set, determining the type of sync the block will do
2810 */
2811void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_POSITION*/) {
2812
2813 // Wait for the next available block
2814 uint8_t next_buffer_head;
2815 block_t * const block = get_next_free_block(next_buffer_head);
2816
2817 // Clear block
2818 block->reset();
2819 block->flag.apply(sync_flag);
2820
2821 block->position = position;
2822
2823 #if ENABLED(BACKLASH_COMPENSATION)
2824 LOOP_NUM_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis);
2825 #endif
2826
2827 #if ENABLED(LASER_SYNCHRONOUS_M106_M107)
2828 FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i];
2829 #endif
2830
2831 /**
2832 * M3-based power setting can be processed inline with a laser power sync block.
2833 * During active moves cutter.power is processed immediately, otherwise on the next move.
2834 */
2835 TERN_(LASER_POWER_SYNC, block->laser.power = cutter.power);
2836
2837 // If this is the first added movement, reload the delay, otherwise, cancel it.
2838 if (block_buffer_head == block_buffer_tail) {
2839 // If it was the first queued block, restart the 1st block delivery delay, to
2840 // give the planner an opportunity to queue more movements and plan them
2841 // As there are no queued movements, the Stepper ISR will not touch this
2842 // variable, so there is no risk setting this here (but it MUST be done
2843 // before the following line!!)
2844 delay_before_delivering = TERN0(FT_MOTION, ftMotion.cfg.active) ? BLOCK_DELAY_NONE : BLOCK_DELAY_FOR_1ST_MOVE;
2845 }
2846
2847 block_buffer_head = next_buffer_head;
2848
2849 stepper.wake_up();
2850} // buffer_sync_block()
2851
2852/**
2853 * @brief Add a single linear movement.

Callers 5

M106Method · 0.80
M107Method · 0.80
M3_M4Method · 0.80
on_fan_updateFunction · 0.80
touchMethod · 0.80

Calls 5

get_applied_stepsMethod · 0.80
wake_upMethod · 0.80
LOOP_NUM_AXESFunction · 0.70
FANS_LOOPFunction · 0.70
resetMethod · 0.45

Tested by

no test coverage detected