Browse Source

Fix broken enqueue_P

vanilla_fb_2.0.x
Scott Lahteine 5 years ago
parent
commit
4e3a793f1e
  1. 4
      Marlin/src/MarlinCore.cpp
  2. 15
      Marlin/src/gcode/queue.cpp
  3. 12
      Marlin/src/gcode/queue.h

4
Marlin/src/MarlinCore.cpp

@ -423,14 +423,14 @@ void startOrResumeJob() {
#if HAS_RESUME_CONTINUE // Display "Click to Continue..." #if HAS_RESUME_CONTINUE // Display "Click to Continue..."
case 1: // 30 min timeout with LCD, 1 min without case 1: // 30 min timeout with LCD, 1 min without
did_state = queue.enqueue_P(PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60"))); did_state = queue.enqueue_one_P(PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60")));
break; break;
#endif #endif
case 2: print_job_timer.stop(); break; case 2: print_job_timer.stop(); break;
case 3: case 3:
did_state = print_job_timer.duration() < 60 || queue.enqueue_P(PSTR("M31")); did_state = print_job_timer.duration() < 60 || queue.enqueue_one_P(PSTR("M31"));
break; break;
case 4: case 4:

15
Marlin/src/gcode/queue.cpp

@ -209,6 +209,21 @@ void GCodeQueue::inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; }
*/ */
void GCodeQueue::enqueue_one_now(const char* cmd) { while (!enqueue_one(cmd)) idle(); } void GCodeQueue::enqueue_one_now(const char* cmd) { while (!enqueue_one(cmd)) idle(); }
/**
* Attempt to enqueue a single G-code command
* and return 'true' if successful.
*/
bool GCodeQueue::enqueue_one_P(PGM_P const pgcode) {
size_t i = 0;
PGM_P p = pgcode;
char c;
while ((c = pgm_read_byte(&p[i])) && c != '\n') i++;
char cmd[i + 1];
memcpy_P(cmd, p, i);
cmd[i] = '\0';
return _enqueue(cmd);
}
/** /**
* Enqueue from program memory and return only when commands are actually enqueued * Enqueue from program memory and return only when commands are actually enqueued
* Never call this from a G-code handler! * Never call this from a G-code handler!

12
Marlin/src/gcode/queue.h

@ -77,6 +77,12 @@ public:
*/ */
static void enqueue_one_now(const char* cmd); static void enqueue_one_now(const char* cmd);
/**
* Attempt to enqueue a single G-code command
* and return 'true' if successful.
*/
static bool enqueue_one_P(PGM_P const pgcode);
/** /**
* Enqueue from program memory and return only when commands are actually enqueued * Enqueue from program memory and return only when commands are actually enqueued
*/ */
@ -117,12 +123,6 @@ public:
*/ */
static void flush_and_request_resend(); static void flush_and_request_resend();
/**
* Attempt to enqueue a single G-code command
* and return 'true' if successful.
*/
FORCE_INLINE static bool enqueue_P(const char* cmd) { return _enqueue(cmd); }
private: private:
static uint8_t index_w; // Ring buffer write position static uint8_t index_w; // Ring buffer write position

Loading…
Cancel
Save