From 87864cce19c36096f27eb5431c2bc2f4deba24f5 Mon Sep 17 00:00:00 2001
From: Jens Geisler <jens.geisler@web.de>
Date: Wed, 20 Feb 2013 15:04:26 +0100
Subject: [PATCH] added counter for planner steps

---
 planner.c       | 4 ++++
 planner.h       | 2 ++
 sim/simulator.c | 3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/planner.c b/planner.c
index 2234ef5..43fa937 100644
--- a/planner.c
+++ b/planner.c
@@ -34,6 +34,8 @@
 #include "protocol.h"
 #include "motion_control.h"
 
+uint32_t planner_steps_counter;
+
 #define SOME_LARGE_VALUE 1.0E+38 // Used by rapids and acceleration maximization calculations. Just needs
                                  // to be larger than any feasible (mm/min)^2 or mm/sec^2 value.
 
@@ -210,6 +212,7 @@ static uint8_t planner_recalculate()
   block_t *curr_block = &block_buffer[current_block_idx];
   uint8_t plan_unchanged= 1;
   
+  planner_steps_counter= 0;
   if(current_block_idx!=block_buffer_tail) { // we cannot do anything to only one block
     float max_entry_speed_sqr;
     float next_entry_speed_sqr= 0.0;
@@ -219,6 +222,7 @@ static uint8_t planner_recalculate()
         planned_block_tail= current_block_idx;
         break;
       }
+      planner_steps_counter++;
 
       // TODO: Determine maximum entry speed at junction for feedrate overrides, since they can alter
       // the planner nominal speeds at any time. This calc could be done in the override handler, but
diff --git a/planner.h b/planner.h
index a16c8c9..7d065cd 100644
--- a/planner.h
+++ b/planner.h
@@ -22,6 +22,8 @@
 #ifndef planner_h
 #define planner_h
                  
+extern uint32_t planner_steps_counter;
+
 // The number of linear motions that can be in the plan at any give time
 #ifndef BLOCK_BUFFER_SIZE
   #define BLOCK_BUFFER_SIZE 18
diff --git a/sim/simulator.c b/sim/simulator.c
index 73c1405..bbdb624 100644
--- a/sim/simulator.c
+++ b/sim/simulator.c
@@ -157,7 +157,8 @@ void printBlock() {
     else block_position[2]+= b->steps_z;
     fprintf(block_out_file,"%d, ", block_position[2]);
 
-    fprintf(block_out_file,"%f", b->entry_speed_sqr);
+    fprintf(block_out_file,"%f, ", b->entry_speed_sqr);
+    fprintf(block_out_file,"%d", planner_steps_counter);
     fprintf(block_out_file,"\n");
 
     last_block= b;