Ver código fonte

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 anos atrás
pai
commit
e650d4044e
3 arquivos alterados com 14 adições e 7 exclusões
  1. 0
    1
      Marlin/cardreader.cpp
  2. 13
    0
      Marlin/stepper.cpp
  3. 1
    6
      Marlin/ultralcd.cpp

+ 0
- 1
Marlin/cardreader.cpp Ver arquivo

@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() {
504 504
     startFileprint();
505 505
   }
506 506
   else {
507
-    quickStop();
508 507
     file.close();
509 508
     sdprinting = false;
510 509
     if (SD_FINISHED_STEPPERRELEASE) {

+ 13
- 0
Marlin/stepper.cpp Ver arquivo

@@ -46,6 +46,7 @@ block_t *current_block;  // A pointer to the block currently being traced
46 46
 
47 47
 // Variables used by The Stepper Driver Interrupt
48 48
 static unsigned char out_bits;        // The next stepping-bits to be output
49
+static unsigned int cleaning_buffer_counter;  
49 50
 
50 51
 // Counter variables for the bresenham line tracer
51 52
 static long counter_x, counter_y, counter_z, counter_e;
@@ -346,6 +347,17 @@ FORCE_INLINE void trapezoid_generator_reset() {
346 347
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
347 348
 // It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
348 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 361
   // If there is no current block, attempt to pop one from the buffer
350 362
   if (!current_block) {
351 363
     // Anything in the buffer?
@@ -972,6 +984,7 @@ void finishAndDisableSteppers() {
972 984
 }
973 985
 
974 986
 void quickStop() {
987
+  cleaning_buffer_counter = 5000;
975 988
   DISABLE_STEPPER_DRIVER_INTERRUPT();
976 989
   while (blocks_queued()) plan_discard_current_block();
977 990
   current_block = NULL;

+ 1
- 6
Marlin/ultralcd.cpp Ver arquivo

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

Carregando…
Cancelar
Salvar