Browse Source

planner optimization by inline functions

Bernhard 13 years ago
parent
commit
f8e170a44b
2 changed files with 31 additions and 21 deletions
  1. 7
    16
      Marlin/planner.cpp
  2. 24
    5
      Marlin/planner.h

+ 7
- 16
Marlin/planner.cpp View File

93
     bool autotemp_enabled=false;
93
     bool autotemp_enabled=false;
94
 #endif
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
 //=============================private variables ============================
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
 // Used for the frequency limit
108
 // Used for the frequency limit
105
 static unsigned char old_direction_bits = 0;               // Old direction bits. Used for speed calculations
109
 static unsigned char old_direction_bits = 0;               // Old direction bits. Used for speed calculations
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
 #ifdef AUTOTEMP
373
 #ifdef AUTOTEMP
383
 void getHighESpeed()
374
 void getHighESpeed()

+ 24
- 5
Marlin/planner.h View File

72
 void plan_set_position(const float &x, const float &y, const float &z, const float &e);
72
 void plan_set_position(const float &x, const float &y, const float &z, const float &e);
73
 void plan_set_e_position(const float &e);
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
 void check_axes_activity();
77
 void check_axes_activity();
83
 uint8_t movesplanned(); //return the nr of buffered moves
78
 uint8_t movesplanned(); //return the nr of buffered moves
102
     extern float autotemp_factor;
97
     extern float autotemp_factor;
103
 #endif
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
 #endif
124
 #endif

Loading…
Cancel
Save