Browse Source

Fix "Stop Print" function in the LCD menu

When one hit "Stop Print" option in LCD menu, the command buffer was not
cleared. The printer keep moving until the buffer has been emptied.
Actually I could not clear the command buffer as well.. I don't know
why, it doesnt work as expected.
I need to implement a routine inside Stepper ISR to handle such
situation.
alexborro 10 years ago
parent
commit
e650d4044e
3 changed files with 14 additions and 7 deletions
  1. 0
    1
      Marlin/cardreader.cpp
  2. 13
    0
      Marlin/stepper.cpp
  3. 1
    6
      Marlin/ultralcd.cpp

+ 0
- 1
Marlin/cardreader.cpp View File

504
     startFileprint();
504
     startFileprint();
505
   }
505
   }
506
   else {
506
   else {
507
-    quickStop();
508
     file.close();
507
     file.close();
509
     sdprinting = false;
508
     sdprinting = false;
510
     if (SD_FINISHED_STEPPERRELEASE) {
509
     if (SD_FINISHED_STEPPERRELEASE) {

+ 13
- 0
Marlin/stepper.cpp View File

46
 
46
 
47
 // Variables used by The Stepper Driver Interrupt
47
 // Variables used by The Stepper Driver Interrupt
48
 static unsigned char out_bits;        // The next stepping-bits to be output
48
 static unsigned char out_bits;        // The next stepping-bits to be output
49
+static unsigned int cleaning_buffer_counter;  
49
 
50
 
50
 // Counter variables for the bresenham line tracer
51
 // Counter variables for the bresenham line tracer
51
 static long counter_x, counter_y, counter_z, counter_e;
52
 static long counter_x, counter_y, counter_z, counter_e;
346
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
347
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
347
 // It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
348
 // It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
348
 ISR(TIMER1_COMPA_vect) {
349
 ISR(TIMER1_COMPA_vect) {
350
+
351
+  if(cleaning_buffer_counter)
352
+  {
353
+    current_block = NULL;
354
+    plan_discard_current_block();
355
+    if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
356
+    cleaning_buffer_counter--;
357
+    OCR1A = 200;
358
+    return;
359
+  }
360
+  
349
   // If there is no current block, attempt to pop one from the buffer
361
   // If there is no current block, attempt to pop one from the buffer
350
   if (!current_block) {
362
   if (!current_block) {
351
     // Anything in the buffer?
363
     // Anything in the buffer?
972
 }
984
 }
973
 
985
 
974
 void quickStop() {
986
 void quickStop() {
987
+  cleaning_buffer_counter = 5000;
975
   DISABLE_STEPPER_DRIVER_INTERRUPT();
988
   DISABLE_STEPPER_DRIVER_INTERRUPT();
976
   while (blocks_queued()) plan_discard_current_block();
989
   while (blocks_queued()) plan_discard_current_block();
977
   current_block = NULL;
990
   current_block = NULL;

+ 1
- 6
Marlin/ultralcd.cpp View File

349
 static void lcd_sdcard_resume() { card.startFileprint(); }
349
 static void lcd_sdcard_resume() { card.startFileprint(); }
350
 
350
 
351
 static void lcd_sdcard_stop() {
351
 static void lcd_sdcard_stop() {
352
+  quickStop();
352
   card.sdprinting = false;
353
   card.sdprinting = false;
353
   card.closefile();
354
   card.closefile();
354
-  quickStop();
355
-  if (SD_FINISHED_STEPPERRELEASE) {
356
-    enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
357
-  }
358
   autotempShutdown();
355
   autotempShutdown();
359
-
360
   cancel_heatup = true;
356
   cancel_heatup = true;
361
-
362
   lcd_setstatus(MSG_PRINT_ABORTED);
357
   lcd_setstatus(MSG_PRINT_ABORTED);
363
 }
358
 }
364
 
359
 

Loading…
Cancel
Save