123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- #ifndef planner_h
- #define planner_h
- #include "Marlin.h"
- #ifdef ENABLE_AUTO_BED_LEVELING
- #include "vector_3.h"
- #endif
- enum BlockFlag {
-
-
- BLOCK_FLAG_RECALCULATE = 1,
-
-
- BLOCK_FLAG_NOMINAL_LENGTH = 2,
-
-
- BLOCK_FLAG_START_FROM_FULL_HALT = 4,
-
-
-
- BLOCK_FLAG_DDA_LOWRES = 8,
- };
- union dda_isteps_t
- {
- int32_t wide;
- struct {
- int16_t lo;
- int16_t hi;
- };
- };
- union dda_usteps_t
- {
- uint32_t wide;
- struct {
- uint16_t lo;
- uint16_t hi;
- };
- };
- typedef struct {
-
-
- dda_isteps_t steps_x, steps_y, steps_z, steps_e;
- dda_usteps_t step_event_count;
- long acceleration_rate;
- unsigned char direction_bits;
- unsigned char active_extruder;
-
- long accelerate_until;
- long decelerate_after;
-
-
-
- float nominal_speed;
-
-
- float entry_speed;
-
- float max_entry_speed;
-
- float millimeters;
-
- float acceleration;
-
- uint8_t flag;
-
-
-
- unsigned long nominal_rate;
- unsigned long initial_rate;
- unsigned long final_rate;
- unsigned long acceleration_st;
-
- unsigned long fan_speed;
- volatile char busy;
-
- float speed_factor;
-
- #ifdef LIN_ADVANCE
- bool use_advance_lead;
- unsigned long abs_adv_steps_multiplier8;
- #endif
- uint16_t sdlen;
- } block_t;
- #ifdef LIN_ADVANCE
- extern float extruder_advance_k, advance_ed_ratio;
- #endif
- #ifdef ENABLE_AUTO_BED_LEVELING
- extern matrix_3x3 plan_bed_level_matrix;
- #endif
- void plan_init();
- #ifdef ENABLE_AUTO_BED_LEVELING
- void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder);
- vector_3 plan_get_position();
- #else
- void plan_buffer_line_curposXYZE(float feed_rate, uint8_t extruder);
- void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, uint8_t extruder);
- #endif
- void plan_set_position(float x, float y, float z, const float &e);
- void plan_set_z_position(const float &z);
- void plan_set_e_position(const float &e);
- extern bool e_active();
- void check_axes_activity();
- extern float* max_feedrate;
- extern unsigned long* max_acceleration_units_per_sq_second;
- extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
- extern long position[NUM_AXIS];
- extern uint8_t maxlimit_status;
- #ifdef AUTOTEMP
- extern bool autotemp_enabled;
- extern float autotemp_max;
- extern float autotemp_min;
- extern float autotemp_factor;
- #endif
-
- extern block_t block_buffer[BLOCK_BUFFER_SIZE];
- extern volatile unsigned char block_buffer_head;
- extern volatile unsigned char block_buffer_tail;
- FORCE_INLINE void plan_discard_current_block()
- {
- if (block_buffer_head != block_buffer_tail) {
- block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
- }
- }
- FORCE_INLINE block_t *plan_get_current_block()
- {
- if (block_buffer_head == block_buffer_tail) {
- return(NULL);
- }
- block_t *block = &block_buffer[block_buffer_tail];
- block->busy = true;
- return(block);
- }
- FORCE_INLINE bool blocks_queued() {
- return (block_buffer_head != block_buffer_tail);
- }
- FORCE_INLINE uint8_t moves_planned() {
- return (block_buffer_head + BLOCK_BUFFER_SIZE - block_buffer_tail) & (BLOCK_BUFFER_SIZE - 1);
- }
- FORCE_INLINE bool planner_queue_full() {
- unsigned char next_block_index = block_buffer_head;
- if (++ next_block_index == BLOCK_BUFFER_SIZE)
- next_block_index = 0;
- return block_buffer_tail == next_block_index;
- }
- extern void planner_abort_hard();
- #ifdef PREVENT_DANGEROUS_EXTRUDE
- void set_extrude_min_temp(float temp);
- #endif
- void reset_acceleration_rates();
- #endif
- void update_mode_profile();
- unsigned char number_of_blocks();
- #ifdef PLANNER_DIAGNOSTICS
- extern uint8_t planner_queue_min();
- extern void planner_queue_min_reset();
- #endif
- extern void planner_add_sd_length(uint16_t sdlen);
- extern uint16_t planner_calc_sd_length();
|