Add SRAM command injection (#17459)

This commit is contained in:
Scott Lahteine 2020-04-09 20:05:58 -05:00 committed by GitHub
parent 7af0da7f93
commit 48919c54fb
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 120 additions and 109 deletions

View file

@ -86,11 +86,15 @@ static int serial_count[NUM_SERIAL] = { 0 };
bool send_ok[BUFSIZE];
/**
* Next Injected Command pointer. nullptr if no commands are being injected.
* Used by Marlin internally to ensure that commands initiated from within
* are enqueued ahead of any pending serial or sd card commands.
* Next Injected PROGMEM Command pointer. (nullptr == empty)
* Internal commands are enqueued ahead of serial / SD commands.
*/
static PGM_P injected_commands_P = nullptr;
PGM_P GCodeQueue::injected_commands_P; // = nullptr
/**
* Injected SRAM Commands
*/
char GCodeQueue::injected_commands[64]; // = { 0 }
GCodeQueue::GCodeQueue() {
// Send "ok" after commands by default
@ -101,7 +105,7 @@ GCodeQueue::GCodeQueue() {
* Check whether there are any commands yet to be executed
*/
bool GCodeQueue::has_commands_queued() {
return queue.length || injected_commands_P;
return queue.length || injected_commands_P || injected_commands[0];
}
/**
@ -172,11 +176,10 @@ bool GCodeQueue::enqueue_one(const char* cmd) {
}
/**
* Process the next "immediate" command.
* Return 'true' if any commands were processed,
* or remain to process.
* Process the next "immediate" command from PROGMEM.
* Return 'true' if any commands were processed.
*/
bool GCodeQueue::process_injected_command() {
bool GCodeQueue::process_injected_command_P() {
if (injected_commands_P == nullptr) return false;
char c;
@ -198,12 +201,27 @@ bool GCodeQueue::process_injected_command() {
}
/**
* Enqueue one or many commands to run from program memory.
* Do not inject a comment or use leading spaces!
* Aborts the current queue, if any.
* Note: process_injected_command() will be called to drain any commands afterwards
* Process the next "immediate" command from SRAM.
* Return 'true' if any commands were processed.
*/
void GCodeQueue::inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; }
bool GCodeQueue::process_injected_command() {
if (injected_commands[0] == '\0') return false;
char c;
size_t i = 0;
while ((c = injected_commands[i]) && c != '\n') i++;
// Execute a non-blank command
if (i) {
injected_commands[i] = '\0';
parser.parse(injected_commands);
gcode.process_parsed_command();
}
// Copy the next command into place
strcpy(injected_commands, &injected_commands[i + (c != '\0')]);
return true;
}
/**
* Enqueue and return only when commands are actually enqueued.
@ -575,7 +593,7 @@ void GCodeQueue::get_serial_commands() {
/**
* Add to the circular command queue the next command from:
* - The command-injection queue (injected_commands_P)
* - The command-injection queues (injected_commands_P, injected_commands)
* - The active serial input (usually USB)
* - The SD card file being actively printed
*/
@ -594,7 +612,7 @@ void GCodeQueue::get_available_commands() {
void GCodeQueue::advance() {
// Process immediate commands
if (process_injected_command()) return;
if (process_injected_command_P() || process_injected_command()) return;
// Return if the G-code buffer is empty
if (!length) return;

View file

@ -66,11 +66,30 @@ public:
static void clear();
/**
* Enqueue one or many commands to run from program memory.
* Aborts the current queue, if any.
* Note: process_injected_command() will process them.
* Next Injected Command (PROGMEM) pointer. (nullptr == empty)
* Internal commands are enqueued ahead of serial / SD commands.
*/
static void inject_P(PGM_P const pgcode);
static PGM_P injected_commands_P;
/**
* Injected Commands (SRAM)
*/
static char injected_commands[64];
/**
* Enqueue command(s) to run from PROGMEM. Drained by process_injected_command_P().
* Don't inject comments or use leading spaces!
* 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; }
/**
* Enqueue command(s) to run from SRAM. Drained by process_injected_command().
* Aborts the current SRAM queue so only use for one or two commands.
*/
static inline void inject(char * const gcode) {
strncpy(injected_commands, gcode, sizeof(injected_commands) - 1);
}
/**
* Enqueue and return only when commands are actually enqueued
@ -145,7 +164,10 @@ private:
#endif
);
// Process the next "immediate" command
// Process the next "immediate" command (PROGMEM)
static bool process_injected_command_P();
// Process the next "immediate" command (SRAM)
static bool process_injected_command();
/**

View file

@ -197,8 +197,8 @@ namespace Language_cz {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Paměťový slot");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Načíst síť bodů");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Uložit síť bodů");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Síť %i načtena");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Síť %i uložena");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Síť %i načtena");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Síť %i uložena");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Nedostatek místa");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Ch.: Uložit UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Ch.: Obnovit UBL");

View file

@ -179,8 +179,8 @@ namespace Language_de {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Speicherort");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Bettnetz laden");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Bettnetz speichern");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Netz %i geladen");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Netz %i gespeichert");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Netz %i geladen");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Netz %i gespeichert");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Kein Speicher");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Err:UBL speichern");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Err:UBL wiederherst.");

View file

@ -190,8 +190,8 @@ namespace Language_en {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Memory Slot");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Load Bed Mesh");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Save Bed Mesh");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Mesh %i Loaded");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Mesh %i Saved");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Mesh %i Loaded");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Mesh %i Saved");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("No Storage");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Err: UBL Save");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Err: UBL Restore");

View file

@ -186,8 +186,8 @@ namespace Language_es {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Huecos de memoria");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Cargar Mallado cama");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Guardar Mallado cama");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Mall. %i Carga.");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Mall. %i Guard.");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Mall. %i Carga.");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Mall. %i Guard.");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Sin guardar");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Error: Guardar UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Error: Restaurar UBL");

View file

@ -189,8 +189,8 @@ namespace Language_gl {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Rañura Memoria");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Cargar Malla Cama");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Gardar Malla Cama");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Malla %i Cargada");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Malla %i Gardada");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Malla %i Cargada");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Malla %i Gardada");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Sen Gardar");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Erro: Gardadado UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Erro: Recuperación UBL");

View file

@ -188,8 +188,8 @@ namespace Language_it {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Slot di memoria");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Carica Mesh Piatto");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Salva Mesh Piatto");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Mesh %i caricata");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Mesh %i salvata");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Mesh %i caricata");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Mesh %i salvata");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Nessuna memoria");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Err: Salvataggio UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Err: Ripristino UBL");

View file

@ -186,8 +186,8 @@ namespace Language_pl {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Slot Pamięci");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Załaduj siatke stołu");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Zapisz siatke stołu");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Siatka %i załadowana");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Siatka %i Zapisana");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Siatka %i załadowana");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Siatka %i Zapisana");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Brak magazynu");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Błąd: Zapis UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Bład: Odczyt UBL");

View file

@ -156,8 +156,8 @@ namespace Language_pt_br {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Slot de Memória");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Ler Malha");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Salvar Malha");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Malha %i carregada");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Malha %i salva");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Malha %i carregada");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Malha %i salva");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Sem armazenamento");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Erro ao salvar UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Erro no restauro UBL");

View file

@ -167,8 +167,8 @@ namespace Language_ru {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Слот памяти");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Загрузить сетку стола");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Сохранить сетку стола");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Сетка %i загружена");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Сетка %i сохранена");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Сетка %i загружена");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Сетка %i сохранена");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Нет хранилища");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Ошибка: Сохран. UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Ошибка: Восстан. UBL");

View file

@ -189,8 +189,8 @@ namespace Language_sk {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Pamäťový slot");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Načítať sieť bodov");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Uložiť sieť bodov");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Sieť %i načítaná");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Sieť %i uložená");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Sieť %i načítaná");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Sieť %i uložená");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Nedostatok miesta");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Chyba: Ukladanie UBL");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Chyba: Obnovenie UBL");

View file

@ -191,8 +191,8 @@ namespace Language_tr {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Bellek Yuvası");
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Yatak Mesh Yükle");
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Yatak Mesh Kayıt Et");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 Mesh %i yüklendi");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 Mesh %i kayıtlandı");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("Mesh %i yüklendi");
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("Mesh %i kayıtlandı");
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("Depolama Yok");
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Hata: UBL Kayıt");
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Hata: UBL Yenileme");

View file

@ -159,8 +159,8 @@ namespace Language_vi {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("Khe nhớ"); // Memory Slot
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("Tải lưới bàn"); // Load Bed Mesh
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("Lưu lưới bàn"); // Save Bed Mesh
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 %i lưới được nạp"); // Mesh %i loaded
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 %i lưới đã lưu");
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("%i lưới được nạp"); // Mesh %i loaded
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("%i lưới đã lưu");
PROGMEM Language_Str MSG_NO_STORAGE = _UxGT("Không lưu trữ"); // No Storage
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("Điều sai: Lưu UBL"); // Err: UBL Save
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("Điều Sai: Khôi Phục UBL"); // Err: UBL Restore

View file

@ -136,8 +136,8 @@ namespace Language_zh_CN {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("存储槽"); // "Memory Slot"
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("装载热床网格"); // "Load Bed Mesh"
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("保存热床网格"); // "Save Bed Mesh"
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 网格 %i 已装载"); // "Mesh %i loaded"
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 网格 %i 已保存"); // "Mesh %i saved"
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("网格 %i 已装载"); // "Mesh %i loaded"
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("网格 %i 已保存"); // "Mesh %i saved"
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("没有存储"); // "No storage"
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("错误: UBL保存"); // "Err: UBL Save"
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("错误: UBL还原"); // "Err: UBL Restore"

View file

@ -184,8 +184,8 @@ namespace Language_zh_TW {
PROGMEM Language_Str MSG_UBL_STORAGE_SLOT = _UxGT("存儲槽"); // "Memory Slot"
PROGMEM Language_Str MSG_UBL_LOAD_MESH = _UxGT("裝載熱床網格"); // "Load Bed Mesh"
PROGMEM Language_Str MSG_UBL_SAVE_MESH = _UxGT("保存熱床網格"); // "Save Bed Mesh"
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("M117 網格 %i 已裝載"); // "Mesh %i loaded"
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("M117 網格 %i 已保存"); // "Mesh %i saved"
PROGMEM Language_Str MSG_MESH_LOADED = _UxGT("網格 %i 已裝載"); // "Mesh %i loaded"
PROGMEM Language_Str MSG_MESH_SAVED = _UxGT("網格 %i 已保存"); // "Mesh %i saved"
PROGMEM Language_Str MSG_UBL_NO_STORAGE = _UxGT("沒有存儲"); // "No storage"
PROGMEM Language_Str MSG_UBL_SAVE_ERROR = _UxGT("錯誤: UBL保存"); // "Err: UBL Save"
PROGMEM Language_Str MSG_UBL_RESTORE_ERROR = _UxGT("錯誤: UBL還原"); // "Err: UBL Restore"

View file

@ -438,22 +438,6 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#endif // BABYSTEP_ZPROBE_OFFSET
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
void lcd_enqueue_one_now(const char * const cmd) {
no_reentry = true;
queue.enqueue_one_now(cmd);
no_reentry = false;
}
void lcd_enqueue_one_now_P(PGM_P const cmd) {
no_reentry = true;
queue.enqueue_now_P(cmd);
no_reentry = false;
}
#endif
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings() {
const bool saved = settings.save();

View file

@ -547,11 +547,6 @@ void _lcd_draw_homing();
void line_to_z(const float &z);
#endif
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
void lcd_enqueue_one_now(const char * const cmd);
void lcd_enqueue_one_now_P(PGM_P const cmd);
#endif
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const float zvalue);
#endif

View file

@ -178,18 +178,18 @@ void menu_cancelobject();
int16_t autotune_temp_bed = 70;
#endif
#include "../../gcode/queue.h"
void _lcd_autotune(const int16_t e) {
char cmd[30];
sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
#if HAS_PID_FOR_BOTH
e < 0 ? autotune_temp_bed : autotune_temp[e]
#elif ENABLED(PIDTEMPBED)
autotune_temp_bed
#else
autotune_temp[e]
TERN(PIDTEMPBED, autotune_temp_bed, autotune_temp[e])
#endif
);
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
}
#endif // PID_AUTOTUNE_MENU

View file

@ -31,6 +31,7 @@
#include "menu.h"
#include "../../module/temperature.h"
#include "../../feature/pause.h"
#include "../../gcode/queue.h"
#if HAS_FILAMENT_SENSOR
#include "../../feature/runout.h"
#endif
@ -60,7 +61,7 @@ static void _change_filament_temp(const uint16_t temperature) {
char cmd[11];
sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
}
//
@ -121,7 +122,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
ACTION_ITEM_N_P(s, msg, []{
char cmd[13];
sprintf_P(cmd, PSTR("M600 B0 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
});
}
}
@ -145,7 +146,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
ACTION_ITEM_N_P(s, msg_load, []{
char cmd[12];
sprintf_P(cmd, PSTR("M701 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
});
}
}
@ -181,7 +182,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
ACTION_ITEM_N_P(s, msg_unload, []{
char cmd[12];
sprintf_P(cmd, PSTR("M702 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
queue.inject(cmd);
});
}
}

View file

@ -29,6 +29,8 @@
#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
#include "menu.h"
#include "../../gcode/gcode.h"
#include "../../gcode/queue.h"
#include "../../module/planner.h"
#include "../../module/configuration_store.h"
#include "../../feature/bedlevel/bedlevel.h"
@ -106,15 +108,13 @@ void lcd_z_offset_edit_setup(const float &initial) {
* UBL Build Custom Mesh Command
*/
void _lcd_ubl_build_custom_mesh() {
char ubl_lcd_gcode[20];
queue.inject_P(G28_STR);
char ubl_lcd_gcode[64];
#if HAS_HEATED_BED
sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, PSTR("G28\nM190 S%i\nM109 S%i\nG29 P1"), custom_bed_temp, custom_hotend_temp);
#else
sprintf_P(ubl_lcd_gcode, PSTR("G28\nM109 S%i\nG29 P1"), custom_hotend_temp);
#endif
sprintf_P(ubl_lcd_gcode, PSTR("M109 S%i"), custom_hotend_temp);
lcd_enqueue_one_now(ubl_lcd_gcode);
queue.inject_P(PSTR("G29 P1"));
queue.inject(ubl_lcd_gcode);
}
/**
@ -144,7 +144,7 @@ void _lcd_ubl_adjust_height_cmd() {
const int ind = ubl_height_amount > 0 ? 9 : 10;
strcpy_P(ubl_lcd_gcode, PSTR("G29 P6 C -"));
sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount));
lcd_enqueue_one_now(ubl_lcd_gcode);
queue.inject(ubl_lcd_gcode);
}
/**
@ -187,16 +187,9 @@ void _lcd_ubl_edit_mesh() {
*/
void _lcd_ubl_validate_custom_mesh() {
char ubl_lcd_gcode[24];
const int temp =
#if HAS_HEATED_BED
custom_bed_temp
#else
0
#endif
;
sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
lcd_enqueue_one_now_P(G28_STR);
lcd_enqueue_one_now(ubl_lcd_gcode);
const int temp = TERN(HAS_HEATED_BED, custom_bed_temp, 0);
sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26 C B%i H%i P"), temp, custom_hotend_temp);
queue.inject(ubl_lcd_gcode);
}
/**
@ -237,7 +230,7 @@ void _lcd_ubl_grid_level() {
ACTION_ITEM(MSG_UBL_MESH_LEVEL, []{
char ubl_lcd_gcode[12];
sprintf_P(ubl_lcd_gcode, PSTR("G29 J%i"), side_points);
lcd_enqueue_one_now(ubl_lcd_gcode);
queue.inject(ubl_lcd_gcode);
});
END_MENU();
}
@ -265,7 +258,7 @@ void _lcd_ubl_mesh_leveling() {
void _lcd_ubl_fillin_amount_cmd() {
char ubl_lcd_gcode[18];
sprintf_P(ubl_lcd_gcode, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
lcd_enqueue_one_now(ubl_lcd_gcode);
gcode.process_subcommands_now(ubl_lcd_gcode);
}
/**
@ -355,22 +348,20 @@ void _lcd_ubl_build_mesh() {
* UBL Load Mesh Command
*/
void _lcd_ubl_load_mesh_cmd() {
char ubl_lcd_gcode[25];
sprintf_P(ubl_lcd_gcode, PSTR("G29 L%i"), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, GET_TEXT(MSG_MESH_LOADED), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
char ubl_lcd_gcode[40];
sprintf_P(ubl_lcd_gcode, PSTR("G29 L%i\nM117 "), ubl_storage_slot);
sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], GET_TEXT(MSG_MESH_LOADED), ubl_storage_slot);
gcode.process_subcommands_now(ubl_lcd_gcode);
}
/**
* UBL Save Mesh Command
*/
void _lcd_ubl_save_mesh_cmd() {
char ubl_lcd_gcode[25];
sprintf_P(ubl_lcd_gcode, PSTR("G29 S%i"), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
sprintf_P(ubl_lcd_gcode, GET_TEXT(MSG_MESH_SAVED), ubl_storage_slot);
lcd_enqueue_one_now(ubl_lcd_gcode);
char ubl_lcd_gcode[40];
sprintf_P(ubl_lcd_gcode, PSTR("G29 S%i\nM117 "), ubl_storage_slot);
sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], GET_TEXT(MSG_MESH_SAVED), ubl_storage_slot);
gcode.process_subcommands_now(ubl_lcd_gcode);
}
/**
@ -418,7 +409,7 @@ void _lcd_ubl_map_lcd_edit_cmd() {
dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2);
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
lcd_enqueue_one_now(ubl_lcd_gcode);
queue.inject(ubl_lcd_gcode);
}
/**