Browse Source

Fix broken enqueue_P

Scott Lahteine 4 years ago
parent
commit
4e3a793f1e
3 changed files with 23 additions and 8 deletions
  1. 2
    2
      Marlin/src/MarlinCore.cpp
  2. 15
    0
      Marlin/src/gcode/queue.cpp
  3. 6
    6
      Marlin/src/gcode/queue.h

+ 2
- 2
Marlin/src/MarlinCore.cpp View File

423
 
423
 
424
       #if HAS_RESUME_CONTINUE                   // Display "Click to Continue..."
424
       #if HAS_RESUME_CONTINUE                   // Display "Click to Continue..."
425
         case 1:                                 // 30 min timeout with LCD, 1 min without
425
         case 1:                                 // 30 min timeout with LCD, 1 min without
426
-          did_state = queue.enqueue_P(PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60")));
426
+          did_state = queue.enqueue_one_P(PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60")));
427
           break;
427
           break;
428
       #endif
428
       #endif
429
 
429
 
430
       case 2: print_job_timer.stop(); break;
430
       case 2: print_job_timer.stop(); break;
431
 
431
 
432
       case 3:
432
       case 3:
433
-        did_state = print_job_timer.duration() < 60 || queue.enqueue_P(PSTR("M31"));
433
+        did_state = print_job_timer.duration() < 60 || queue.enqueue_one_P(PSTR("M31"));
434
         break;
434
         break;
435
 
435
 
436
       case 4:
436
       case 4:

+ 15
- 0
Marlin/src/gcode/queue.cpp View File

210
 void GCodeQueue::enqueue_one_now(const char* cmd) { while (!enqueue_one(cmd)) idle(); }
210
 void GCodeQueue::enqueue_one_now(const char* cmd) { while (!enqueue_one(cmd)) idle(); }
211
 
211
 
212
 /**
212
 /**
213
+ * Attempt to enqueue a single G-code command
214
+ * and return 'true' if successful.
215
+ */
216
+bool GCodeQueue::enqueue_one_P(PGM_P const pgcode) {
217
+  size_t i = 0;
218
+  PGM_P p = pgcode;
219
+  char c;
220
+  while ((c = pgm_read_byte(&p[i])) && c != '\n') i++;
221
+  char cmd[i + 1];
222
+  memcpy_P(cmd, p, i);
223
+  cmd[i] = '\0';
224
+  return _enqueue(cmd);
225
+}
226
+
227
+/**
213
  * Enqueue from program memory and return only when commands are actually enqueued
228
  * Enqueue from program memory and return only when commands are actually enqueued
214
  * Never call this from a G-code handler!
229
  * Never call this from a G-code handler!
215
  */
230
  */

+ 6
- 6
Marlin/src/gcode/queue.h View File

78
   static void enqueue_one_now(const char* cmd);
78
   static void enqueue_one_now(const char* cmd);
79
 
79
 
80
   /**
80
   /**
81
+   * Attempt to enqueue a single G-code command
82
+   * and return 'true' if successful.
83
+   */
84
+  static bool enqueue_one_P(PGM_P const pgcode);
85
+
86
+  /**
81
    * Enqueue from program memory and return only when commands are actually enqueued
87
    * Enqueue from program memory and return only when commands are actually enqueued
82
    */
88
    */
83
   static void enqueue_now_P(PGM_P const cmd);
89
   static void enqueue_now_P(PGM_P const cmd);
117
    */
123
    */
118
   static void flush_and_request_resend();
124
   static void flush_and_request_resend();
119
 
125
 
120
-  /**
121
-   * Attempt to enqueue a single G-code command
122
-   * and return 'true' if successful.
123
-   */
124
-  FORCE_INLINE static bool enqueue_P(const char* cmd) { return _enqueue(cmd); }
125
-
126
 private:
126
 private:
127
 
127
 
128
   static uint8_t index_w;  // Ring buffer write position
128
   static uint8_t index_w;  // Ring buffer write position

Loading…
Cancel
Save