Ver código fonte

planner optimization by inline functions

Bernhard 12 anos atrás
pai
commit
f8e170a44b
2 arquivos alterados com 31 adições e 21 exclusões
  1. 7
    16
      Marlin/planner.cpp
  2. 24
    5
      Marlin/planner.h

+ 7
- 16
Marlin/planner.cpp Ver arquivo

@@ -93,13 +93,17 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
93 93
     bool autotemp_enabled=false;
94 94
 #endif
95 95
 
96
+    
97
+//===========================================================================
98
+//=================semi-private variables, used in inline  functions    =====
99
+//===========================================================================
100
+block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
101
+volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
102
+volatile unsigned char block_buffer_tail;           // Index of the block to process now
96 103
 
97 104
 //===========================================================================
98 105
 //=============================private variables ============================
99 106
 //===========================================================================
100
-static block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
101
-static volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
102
-static volatile unsigned char block_buffer_tail;           // Index of the block to process now
103 107
 
104 108
 // Used for the frequency limit
105 109
 static unsigned char old_direction_bits = 0;               // Old direction bits. Used for speed calculations
@@ -364,20 +368,7 @@ void plan_init() {
364 368
 }
365 369
 
366 370
 
367
-void plan_discard_current_block() {
368
-  if (block_buffer_head != block_buffer_tail) {
369
-    block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);  
370
-  }
371
-}
372 371
 
373
-block_t *plan_get_current_block() {
374
-  if (block_buffer_head == block_buffer_tail) { 
375
-    return(NULL); 
376
-  }
377
-  block_t *block = &block_buffer[block_buffer_tail];
378
-  block->busy = true;
379
-  return(block);
380
-}
381 372
 
382 373
 #ifdef AUTOTEMP
383 374
 void getHighESpeed()

+ 24
- 5
Marlin/planner.h Ver arquivo

@@ -72,12 +72,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
72 72
 void plan_set_position(const float &x, const float &y, const float &z, const float &e);
73 73
 void plan_set_e_position(const float &e);
74 74
 
75
-// Called when the current block is no longer needed. Discards the block and makes the memory
76
-// availible for new blocks.
77
-void plan_discard_current_block();
78 75
 
79
-// Gets the current block. Returns NULL if buffer empty
80
-block_t *plan_get_current_block();
81 76
 
82 77
 void check_axes_activity();
83 78
 uint8_t movesplanned(); //return the nr of buffered moves
@@ -102,4 +97,28 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
102 97
     extern float autotemp_factor;
103 98
 #endif
104 99
 
100
+    
101
+/////semi-private stuff
102
+#include <WProgram.h>
103
+
104
+extern block_t block_buffer[BLOCK_BUFFER_SIZE];            // A ring buffer for motion instfructions
105
+extern volatile unsigned char block_buffer_head;           // Index of the next block to be pushed
106
+extern volatile unsigned char block_buffer_tail; 
107
+// Called when the current block is no longer needed. Discards the block and makes the memory
108
+// availible for new blocks.    
109
+inline void plan_discard_current_block() {
110
+  if (block_buffer_head != block_buffer_tail) {
111
+    block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);  
112
+  }
113
+}
114
+
115
+// Gets the current block. Returns NULL if buffer empty
116
+inline block_t *plan_get_current_block() {
117
+  if (block_buffer_head == block_buffer_tail) { 
118
+    return(NULL); 
119
+  }
120
+  block_t *block = &block_buffer[block_buffer_tail];
121
+  block->busy = true;
122
+  return(block);
123
+}
105 124
 #endif

Carregando…
Cancelar
Salvar