planner optimization by inline functions
This commit is contained in:
parent
a0dc66f7bf
commit
f8e170a44b
@ -93,13 +93,17 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
|
|||||||
bool autotemp_enabled=false;
|
bool autotemp_enabled=false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//=================semi-private variables, used in inline functions =====
|
||||||
|
//===========================================================================
|
||||||
|
block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||||
|
volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||||
|
volatile unsigned char block_buffer_tail; // Index of the block to process now
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//=============================private variables ============================
|
//=============================private variables ============================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
|
||||||
static volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
|
||||||
static volatile unsigned char block_buffer_tail; // Index of the block to process now
|
|
||||||
|
|
||||||
// Used for the frequency limit
|
// Used for the frequency limit
|
||||||
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
||||||
@ -364,20 +368,7 @@ void plan_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void plan_discard_current_block() {
|
|
||||||
if (block_buffer_head != block_buffer_tail) {
|
|
||||||
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
void getHighESpeed()
|
void getHighESpeed()
|
||||||
|
@ -72,12 +72,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
|||||||
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
|
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
|
||||||
void plan_set_e_position(const float &e);
|
void plan_set_e_position(const float &e);
|
||||||
|
|
||||||
// Called when the current block is no longer needed. Discards the block and makes the memory
|
|
||||||
// availible for new blocks.
|
|
||||||
void plan_discard_current_block();
|
|
||||||
|
|
||||||
// Gets the current block. Returns NULL if buffer empty
|
|
||||||
block_t *plan_get_current_block();
|
|
||||||
|
|
||||||
void check_axes_activity();
|
void check_axes_activity();
|
||||||
uint8_t movesplanned(); //return the nr of buffered moves
|
uint8_t movesplanned(); //return the nr of buffered moves
|
||||||
@ -102,4 +97,28 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
|||||||
extern float autotemp_factor;
|
extern float autotemp_factor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/////semi-private stuff
|
||||||
|
#include <WProgram.h>
|
||||||
|
|
||||||
|
extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||||
|
extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||||
|
extern volatile unsigned char block_buffer_tail;
|
||||||
|
// Called when the current block is no longer needed. Discards the block and makes the memory
|
||||||
|
// availible for new blocks.
|
||||||
|
inline void plan_discard_current_block() {
|
||||||
|
if (block_buffer_head != block_buffer_tail) {
|
||||||
|
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets the current block. Returns NULL if buffer empty
|
||||||
|
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);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user