🎨 Apply F() to G-code suite and queue

This commit is contained in:
Scott Lahteine
2021-09-25 21:11:31 -05:00
committed by Scott Lahteine
parent 2b9ae0cc33
commit 46c53f6730
39 changed files with 136 additions and 134 deletions

View File

@ -103,7 +103,7 @@ void GcodeSuite::G29() {
mbl.reset();
mbl_probe_index = 0;
if (!ui.wait_for_move) {
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2"));
queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2"));
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
return;
}

View File

@ -126,7 +126,7 @@ bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
* Enqueue with Serial Echo
* Return true if the command was consumed
*/
bool GCodeQueue::enqueue_one(const char *cmd) {
bool GCodeQueue::enqueue_one(const char * const cmd) {
//SERIAL_ECHOLNPGM("enqueue_one(\"", cmd, "\")");
if (*cmd == 0 || ISEOL(*cmd)) return true;
@ -195,15 +195,15 @@ bool GCodeQueue::process_injected_command() {
* Enqueue and return only when commands are actually enqueued.
* Never call this from a G-code handler!
*/
void GCodeQueue::enqueue_one_now(const char *cmd) { while (!enqueue_one(cmd)) idle(); }
void GCodeQueue::enqueue_one_now(const char * const 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) {
bool GCodeQueue::enqueue_one(FSTR_P const fgcode) {
size_t i = 0;
PGM_P p = pgcode;
PGM_P p = FTOP(fgcode);
char c;
while ((c = pgm_read_byte(&p[i])) && c != '\n') i++;
char cmd[i + 1];

View File

@ -127,6 +127,7 @@ public:
* Aborts the current PROGMEM queue so only use for one or two commands.
*/
static inline void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; }
static inline void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); }
/**
* Enqueue command(s) to run from SRAM. Drained by process_injected_command().
@ -139,18 +140,19 @@ public:
/**
* Enqueue and return only when commands are actually enqueued
*/
static void enqueue_one_now(const char *cmd);
static void enqueue_one_now(const char * const cmd);
/**
* Attempt to enqueue a single G-code command
* and return 'true' if successful.
*/
static bool enqueue_one_P(PGM_P const pgcode);
static bool enqueue_one(FSTR_P const fgcode);
/**
* Enqueue from program memory and return only when commands are actually enqueued
*/
static void enqueue_now_P(PGM_P const cmd);
static void enqueue_now_P(PGM_P const pcmd);
static inline void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); }
/**
* Check whether there are any commands yet to be executed