Skip to content

Commit

Permalink
🎨 Apply F() to some ExtUI functions
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 4, 2021
1 parent 008bf1b commit 12b5d99
Show file tree
Hide file tree
Showing 37 changed files with 277 additions and 278 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/feature/mmu/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER);
BUZZ(200, 404);
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover")));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover")));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
BUZZ(200, 404);
BUZZ(200, 404);
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Load Filament")));

#if ENABLED(HOST_PROMPT_SUPPORT)
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
Expand Down Expand Up @@ -252,7 +252,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load

if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE);

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)));
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR)));
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR));
wait_for_user = true; // A click or M108 breaks the purge_length loop
Expand Down Expand Up @@ -513,7 +513,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
// Wait for filament insert by user and press button
KEEPALIVE_STATE(PAUSED_FOR_USER);
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_NOZZLE_PARKED), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_NOZZLE_PARKED)));
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) {
impatient_beep(max_beep_count);
Expand All @@ -530,13 +530,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep

TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_HEATER_TIMEOUT), GET_TEXT_F(MSG_REHEAT)));

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_HEATER_TIMEOUT)));

TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(0, true)); // Wait for LCD click or M108

TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING)));

TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));
TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING)));

TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATING));

Expand All @@ -555,7 +555,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);

TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE)));
TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE));

IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M43.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void GcodeSuite::M43() {
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called")));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("M43 Wait Called")));
#endif

for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/lcd/M0_M1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void GcodeSuite::M0_M1() {
if (parser.string_arg)
ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
else
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT));
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
if (parser.string_arg)
DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT));
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void GcodeSuite::M1001() {
#if HAS_LEDS_OFF_FLAG
if (long_print) {
printerEventLEDs.onPrintCompleted();
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE)));
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR)));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30))));
printerEventLEDs.onResumeAfterWait();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
// The new panel ignores entries that don't end in .GCO or .gcode so add and pad them.
if (paneltype == AC_panel_new) {
TFTSer.println("<<.GCO");
Chiron.SendtoTFTLN(PSTR(".. .gcode"));
Chiron.SendtoTFTLN(F(".. .gcode"));
}
else {
TFTSer.println("<<");
Expand Down
85 changes: 43 additions & 42 deletions Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void ChironTFT::Startup() {

// Enable leveling and Disable end stops during print
// as Z home places nozzle above the bed so we need to allow it past the end stops
injectCommands_P(AC_cmnd_enable_leveling);
injectCommands(AC_cmnd_enable_leveling);

// Startup tunes are defined in Tunes.h
PlayTune(BEEPER_PIN, TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn), 1);
Expand Down Expand Up @@ -244,15 +244,15 @@ void ChironTFT::StatusChange(const char * const msg) {
// If probing completes ok save the mesh and park
// Ignore the custom machine name
if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) {
injectCommands_P(PSTR("M500\nG27"));
injectCommands(F("M500\nG27"));
SendtoTFTLN(AC_msg_probing_complete);
printer_state = AC_printer_idle;
msg_matched = true;
}
// If probing fails don't save the mesh raise the probe above the bad point
if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) {
PlayTune(BEEPER_PIN, BeepBeepBeeep, 1);
injectCommands_P(PSTR("G1 Z50 F500"));
injectCommands(F("G1 Z50 F500"));
SendtoTFTLN(AC_msg_probing_complete);
printer_state = AC_printer_idle;
msg_matched = true;
Expand Down Expand Up @@ -315,19 +315,20 @@ void ChironTFT::PrintComplete() {
setSoftEndstopState(true); // enable endstops
}

void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel
void ChironTFT::SendtoTFT(FSTR_P const fstr) { // A helper to print PROGMEM string to the panel
#if ACDEBUG(AC_SOME)
SERIAL_ECHOPGM_P(str);
SERIAL_ECHOF(fstr);
#endif
PGM_P str = FTOP(fstr);
while (const char c = pgm_read_byte(str++)) TFTSer.write(c);
}

void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) {
if (str) {
void ChironTFT::SendtoTFTLN(FSTR_P const fstr) {
if (fstr) {
#if ACDEBUG(AC_SOME)
SERIAL_ECHOPGM("> ");
#endif
SendtoTFT(str);
SendtoTFT(fstr);
#if ACDEBUG(AC_SOME)
SERIAL_EOL();
#endif
Expand Down Expand Up @@ -426,9 +427,9 @@ void ChironTFT::SendFileList(int8_t startindex) {
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("## SendFileList ## ", startindex);
#endif
SendtoTFTLN(PSTR("FN "));
SendtoTFTLN(F("FN "));
filenavigator.getFiles(startindex, panel_type, 4);
SendtoTFTLN(PSTR("END"));
SendtoTFTLN(F("END"));
}

void ChironTFT::SelectFile() {
Expand Down Expand Up @@ -512,55 +513,55 @@ void ChironTFT::PanelInfo(uint8_t req) {
// information requests A0-A8 and A33
switch (req) {
case 0: // A0 Get HOTEND Temp
SendtoTFT(PSTR("A0V "));
SendtoTFT(F("A0V "));
TFTSer.println(getActualTemp_celsius(E0));
break;

case 1: // A1 Get HOTEND Target Temp
SendtoTFT(PSTR("A1V "));
SendtoTFT(F("A1V "));
TFTSer.println(getTargetTemp_celsius(E0));
break;

case 2: // A2 Get BED Temp
SendtoTFT(PSTR("A2V "));
SendtoTFT(F("A2V "));
TFTSer.println(getActualTemp_celsius(BED));
break;

case 3: // A3 Get BED Target Temp
SendtoTFT(PSTR("A3V "));
SendtoTFT(F("A3V "));
TFTSer.println(getTargetTemp_celsius(BED));
break;

case 4: // A4 Get FAN Speed
SendtoTFT(PSTR("A4V "));
SendtoTFT(F("A4V "));
TFTSer.println(getActualFan_percent(FAN0));
break;

case 5: // A5 Get Current Coordinates
SendtoTFT(PSTR("A5V X: "));
SendtoTFT(F("A5V X: "));
TFTSer.print(getAxisPosition_mm(X));
SendtoTFT(PSTR(" Y: "));
SendtoTFT(F(" Y: "));
TFTSer.print(getAxisPosition_mm(Y));
SendtoTFT(PSTR(" Z: "));
SendtoTFT(F(" Z: "));
TFTSer.println(getAxisPosition_mm(Z));
break;

case 6: // A6 Get printing progress
if (isPrintingFromMedia()) {
SendtoTFT(PSTR("A6V "));
SendtoTFT(F("A6V "));
TFTSer.println(ui8tostr2(getProgress_percent()));
}
else
SendtoTFTLN(PSTR("A6V ---"));
SendtoTFTLN(F("A6V ---"));
break;

case 7: { // A7 Get Printing Time
uint32_t time = getProgress_seconds_elapsed() / 60;
SendtoTFT(PSTR("A7V "));
SendtoTFT(F("A7V "));
TFTSer.print(ui8tostr2(time / 60));
SendtoTFT(PSTR(" H "));
SendtoTFT(F(" H "));
TFTSer.print(ui8tostr2(time % 60));
SendtoTFT(PSTR(" M"));
SendtoTFT(F(" M"));
#if ACDEBUG(AC_ALL)
SERIAL_ECHOLNPGM("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60));
#endif
Expand All @@ -575,9 +576,9 @@ void ChironTFT::PanelInfo(uint8_t req) {
break;

case 33: // A33 Get firmware info
SendtoTFT(PSTR("J33 "));
SendtoTFT(F("J33 "));
// If there is an error recorded, show that instead of the FW version
if (!GetLastError()) SendtoTFTLN(PSTR(SHORT_BUILD_VERSION));
if (!GetLastError()) SendtoTFTLN(F(SHORT_BUILD_VERSION));
break;
}
}
Expand Down Expand Up @@ -608,7 +609,7 @@ void ChironTFT::PanelAction(uint8_t req) {
}
else {
if (printer_state == AC_printer_resuming_from_power_outage)
injectCommands_P(PSTR("M1000 C")); // Cancel recovery
injectCommands(F("M1000 C")); // Cancel recovery
SendtoTFTLN(AC_msg_stop);
printer_state = AC_printer_idle;
}
Expand All @@ -625,7 +626,7 @@ void ChironTFT::PanelAction(uint8_t req) {
case 14: { // A14 Start Printing
// Allows printer to restart the job if we don't want to recover
if (printer_state == AC_printer_resuming_from_power_outage) {
injectCommands_P(PSTR("M1000 C")); // Cancel recovery
injectCommands(F("M1000 C")); // Cancel recovery
printer_state = AC_printer_idle;
}
#if ACDebugLevel >= 1
Expand All @@ -638,8 +639,8 @@ void ChironTFT::PanelAction(uint8_t req) {
case 15: // A15 Resuming from outage
if (printer_state == AC_printer_resuming_from_power_outage) {
// Need to home here to restore the Z position
injectCommands_P(AC_cmnd_power_loss_recovery);
injectCommands_P(PSTR("M1000")); // home and start recovery
injectCommands(AC_cmnd_power_loss_recovery);
injectCommands(F("M1000")); // home and start recovery
}
break;

Expand Down Expand Up @@ -675,17 +676,17 @@ void ChironTFT::PanelAction(uint8_t req) {
if (panel_command[4] == 'S')
setFeedrate_percent(atoi(&panel_command[5]));
else {
SendtoTFT(PSTR("A20V "));
SendtoTFT(F("A20V "));
TFTSer.println(getFeedrate_percent());
}
break;

case 21: // A21 Home Axis A21 X
if (!isPrinting()) {
switch ((char)panel_command[4]) {
case 'X': injectCommands_P(PSTR("G28X")); break;
case 'Y': injectCommands_P(PSTR("G28Y")); break;
case 'Z': injectCommands_P(PSTR("G28Z")); break;
case 'X': injectCommands(F("G28X")); break;
case 'Y': injectCommands(F("G28Y")); break;
case 'Z': injectCommands(F("G28Z")); break;
case 'C': injectCommands_P(G28_STR); break;
}
}
Expand Down Expand Up @@ -771,7 +772,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
pos.y = atoi(&panel_command[FindToken('Y')+1]);
pos_z = getMeshPoint(pos);

SendtoTFT(PSTR("A29V "));
SendtoTFT(F("A29V "));
TFTSer.println(pos_z * 100);
if (!isPrinting()) {
setSoftEndstopState(true); // disable endstops
Expand Down Expand Up @@ -809,7 +810,7 @@ void ChironTFT::PanelProcess(uint8_t req) {


SendtoTFTLN(AC_msg_start_probing);
injectCommands_P(PSTR("G28\nG29"));
injectCommands(F("G28\nG29"));
printer_state = AC_printer_probing;
}
}
Expand All @@ -823,7 +824,7 @@ void ChironTFT::PanelProcess(uint8_t req) {

if (FindToken('C') != -1) { // Restore and apply original offsets
if (!isPrinting()) {
injectCommands_P(PSTR("M501\nM420 S1"));
injectCommands(F("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99;
SERIAL_ECHOLNF(AC_msg_mesh_changes_abandoned);
}
Expand All @@ -832,14 +833,14 @@ void ChironTFT::PanelProcess(uint8_t req) {
else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state
if (!isPrinting()) {
setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
injectCommands_P(PSTR("M500"));
injectCommands(F("M500"));
SERIAL_ECHOLNF(AC_msg_mesh_changes_saved);
selectedmeshpoint.x = selectedmeshpoint.y = 99;
}
}

else if (FindToken('G') != -1) { // Get current offset
SendtoTFT(PSTR("A31V "));
SendtoTFT(F("A31V "));
// When printing use the live z Offset position
// we will use babystepping to move the print head
if (isPrinting())
Expand Down Expand Up @@ -874,7 +875,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
babystepAxis_steps(steps, Z);
live_Zoffset += Zshift;
}
SendtoTFT(PSTR("A31V "));
SendtoTFT(F("A31V "));
TFTSer.println(live_Zoffset);
}
else {
Expand All @@ -892,7 +893,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
#endif

setZOffset_mm(currZOffset + Zshift);
SendtoTFT(PSTR("A31V "));
SendtoTFT(F("A31V "));
TFTSer.println(getZOffset_mm());

if (isAxisPositionKnown(Z)) {
Expand All @@ -911,15 +912,15 @@ void ChironTFT::PanelProcess(uint8_t req) {
case 32: { // A32 clean leveling beep flag
// Ignore request if printing
//if (isPrinting()) break;
//injectCommands_P(PSTR("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000"));
//injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000"));
//TFTSer.println();
} break;

// A33 firmware info request see PanelInfo()

case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123
if (panel_command[3] == 'C') { // Restore original offsets
injectCommands_P(PSTR("M501\nM420 S1"));
injectCommands(F("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99;
//printer_state = AC_printer_idle;
}
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ class ChironTFT {
public:
static void Startup();
static void IdleLoop();
static void PrinterKilled(PGM_P,PGM_P);
static void PrinterKilled(PGM_P, PGM_P);
static void MediaEvent(media_event_t);
static void TimerEvent(timer_event_t);
static void FilamentRunout();
static void ConfirmationRequest(const char * const );
static void StatusChange(const char * const );
static void ConfirmationRequest(const char * const);
static void StatusChange(const char * const);
static void PowerLossRecovery();
static void PrintComplete();
static void SendtoTFT(PGM_P);
static void SendtoTFTLN(PGM_P);
static void SendtoTFT(FSTR_P const);
static void SendtoTFTLN(FSTR_P const);
private:
static void DetectPanelType();
static bool ReadTFTCommand();
Expand Down
Loading

0 comments on commit 12b5d99

Please sign in to comment.