Browse Source

Fixed crashes when one moved the axes from the menu many times
up/down, left/right until the planner queue got full.

bubnikv 8 years ago
parent
commit
4c6ea5af94
2 changed files with 23 additions and 11 deletions
  1. 7 0
      Firmware/planner.h
  2. 16 11
      Firmware/ultralcd.cpp

+ 7 - 0
Firmware/planner.h

@@ -178,6 +178,13 @@ 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;
+}
+
 #ifdef PREVENT_DANGEROUS_EXTRUDE
 void set_extrude_min_temp(float temp);
 #endif

+ 16 - 11
Firmware/ultralcd.cpp

@@ -1150,13 +1150,15 @@ static void lcd_menu_statistics()
 static void _lcd_move(const char *name, int axis, int min, int max) {
   if (encoderPosition != 0) {
     refresh_cmd_timeout();
-    current_position[axis] += float((int)encoderPosition) * move_menu_scale;
-    if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
-    if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
-    encoderPosition = 0;
-    world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
-    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis] / 60, active_extruder);
-    lcdDrawUpdate = 1;
+    if (! planner_queue_full()) {
+      current_position[axis] += float((int)encoderPosition) * move_menu_scale;
+      if (min_software_endstops && current_position[axis] < min) current_position[axis] = min;
+      if (max_software_endstops && current_position[axis] > max) current_position[axis] = max;
+      encoderPosition = 0;
+      world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]);
+      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis] / 60, active_extruder);
+      lcdDrawUpdate = 1;
+    }
   }
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
   if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis);
@@ -1167,10 +1169,13 @@ static void lcd_move_e()
 {
   if (encoderPosition != 0)
   {
-    current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
-    encoderPosition = 0;
-    plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS] / 60, active_extruder);
-    lcdDrawUpdate = 1;
+    refresh_cmd_timeout();
+    if (! planner_queue_full()) {
+      current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
+      encoderPosition = 0;
+      plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[E_AXIS] / 60, active_extruder);
+      lcdDrawUpdate = 1;
+    }
   }
   if (lcdDrawUpdate)
   {