7070
7171#if ENABLED(DIRECT_STEPPING)
7272 #include " ../feature/direct_stepping.h"
73- #define IS_PAGE (B ) TEST(B->flag, BLOCK_BIT_IS_PAGE)
74- #else
75- #define IS_PAGE (B ) false
7673#endif
7774
7875#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
9289 #define HAS_DIST_MM_ARG 1
9390#endif
9491
95- enum BlockFlagBit : char {
92+ #if ENABLED(LASER_POWER_INLINE)
93+
94+ typedef struct {
95+ bool isPlanned:1 ;
96+ bool isEnabled:1 ;
97+ bool dir:1 ;
98+ bool Reserved:6 ;
99+ } power_status_t ;
100+
101+ typedef struct {
102+ power_status_t status; // See planner settings for meaning
103+ uint8_t power; // Ditto; When in trapezoid mode this is nominal power
104+ #if ENABLED(LASER_POWER_INLINE_TRAPEZOID)
105+ uint8_t power_entry; // Entry power for the laser
106+ #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT)
107+ uint8_t power_exit; // Exit power for the laser
108+ uint32_t entry_per, // Steps per power increment (to avoid floats in stepper calcs)
109+ exit_per; // Steps per power decrement
110+ #endif
111+ #endif
112+ } block_laser_t ;
113+
114+ #endif
115+
116+ /* *
117+ * Planner block flags as boolean bit fields
118+ */
119+ enum BlockFlagBit {
96120 // Recalculate trapezoids on entry junction. For optimization.
97121 BLOCK_BIT_RECALCULATE,
98122
@@ -109,7 +133,7 @@ enum BlockFlagBit : char {
109133
110134 // Direct stepping page
111135 #if ENABLED(DIRECT_STEPPING)
112- , BLOCK_BIT_IS_PAGE
136+ , BLOCK_BIT_PAGE
113137 #endif
114138
115139 // Sync the fan speeds from the block
@@ -118,57 +142,55 @@ enum BlockFlagBit : char {
118142 #endif
119143};
120144
121- enum BlockFlag : char {
122- BLOCK_FLAG_RECALCULATE = _BV (BLOCK_BIT_RECALCULATE)
123- , BLOCK_FLAG_NOMINAL_LENGTH = _BV (BLOCK_BIT_NOMINAL_LENGTH)
124- , BLOCK_FLAG_CONTINUED = _BV (BLOCK_BIT_CONTINUED)
125- , BLOCK_FLAG_SYNC_POSITION = _BV (BLOCK_BIT_SYNC_POSITION)
126- #if ENABLED(DIRECT_STEPPING)
127- , BLOCK_FLAG_IS_PAGE = _BV (BLOCK_BIT_IS_PAGE)
128- #endif
129- #if ENABLED(LASER_SYNCHRONOUS_M106_M107)
130- , BLOCK_FLAG_SYNC_FANS = _BV (BLOCK_BIT_SYNC_FANS)
131- #endif
132- };
145+ /* *
146+ * Planner block flags as boolean bit fields
147+ */
148+ typedef struct {
149+ union {
150+ uint8_t bits;
133151
134- #define BLOCK_MASK_SYNC ( BLOCK_FLAG_SYNC_POSITION | TERN0(LASER_SYNCHRONOUS_M106_M107, BLOCK_FLAG_SYNC_FANS) )
152+ struct {
153+ bool recalculate:1 ;
135154
136- # if ENABLED(LASER_POWER_INLINE)
155+ bool nominal_length: 1 ;
137156
138- typedef struct {
139- bool isPlanned:1 ;
140- bool isEnabled:1 ;
141- bool dir:1 ;
142- bool Reserved:6 ;
143- } power_status_t ;
157+ bool continued:1 ;
144158
145- typedef struct {
146- power_status_t status; // See planner settings for meaning
147- uint8_t power; // Ditto; When in trapezoid mode this is nominal power
148- #if ENABLED(LASER_POWER_INLINE_TRAPEZOID)
149- uint8_t power_entry; // Entry power for the laser
150- #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT)
151- uint8_t power_exit; // Exit power for the laser
152- uint32_t entry_per, // Steps per power increment (to avoid floats in stepper calcs)
153- exit_per; // Steps per power decrement
159+ bool sync_position:1 ;
160+
161+ #if ENABLED(DIRECT_STEPPING)
162+ bool page:1 ;
154163 #endif
155- #endif
156- } block_laser_t ;
157164
158- #endif
165+ #if ENABLED(LASER_SYNCHRONOUS_M106_M107)
166+ bool sync_fans:1 ;
167+ #endif
168+ };
169+ };
170+
171+ void clear () volatile { bits = 0 ; }
172+ void apply (const uint8_t f) volatile { bits |= f; }
173+ void apply (const BlockFlagBit b) volatile { SBI (bits, b); }
174+ void reset (const BlockFlagBit b) volatile { bits = _BV (b); }
175+ void set_nominal (const bool n) volatile { recalculate = true ; if (n) nominal_length = true ; }
176+
177+ } block_flags_t ;
159178
160179/* *
161- * struct block_t
162- *
163- * A single entry in the planner buffer.
164- * Tracks linear movement over multiple axes.
180+ * A single entry in the planner buffer, used to set up and
181+ * track a coordinated linear motion for one or more axes.
165182 *
166183 * The "nominal" values are as-specified by G-code, and
167184 * may never actually be reached due to acceleration limits.
168185 */
169186typedef struct block_t {
170187
171- volatile uint8_t flag; // Block flags (See BlockFlag enum above) - Modified by ISR and main thread!
188+ volatile block_flags_t flag; // Block flags
189+
190+ volatile bool is_fan_sync () { return TERN0 (LASER_SYNCHRONOUS_M106_M107, flag.sync_fans ); }
191+ volatile bool is_sync () { return flag.sync_position || is_fan_sync (); }
192+ volatile bool is_page () { return TERN0 (DIRECT_STEPPING, flag.page ); }
193+ volatile bool is_move () { return !(is_sync () || is_page ()); }
172194
173195 // Fields used by the motion planner to manage acceleration
174196 float nominal_speed_sqr, // The nominal speed for this block in (mm/sec)^2
@@ -759,7 +781,7 @@ class Planner {
759781 * case of LASER_SYNCHRONOUS_M106_M107 the fan pwm
760782 */
761783 static void buffer_sync_block (
762- TERN_ (LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag=BLOCK_FLAG_SYNC_POSITION )
784+ TERN_ (LASER_SYNCHRONOUS_M106_M107, const BlockFlagBit flag=BLOCK_BIT_SYNC_POSITION )
763785 );
764786
765787 #if IS_KINEMATIC
0 commit comments