🎨 Apply F() to some ExtUI functions

This commit is contained in:
Scott Lahteine
2021-09-25 22:11:48 -05:00
parent 7626d859a6
commit c3ae221a10
37 changed files with 277 additions and 278 deletions

View File

@@ -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("<<");

View File

@@ -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);
@@ -244,7 +244,7 @@ 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;
@@ -252,7 +252,7 @@ void ChironTFT::StatusChange(const char * const msg) {
// 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;
@@ -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
@@ -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() {
@@ -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
@@ -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;
}
}
@@ -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;
}
@@ -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
@@ -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;
@@ -675,7 +676,7 @@ 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;
@@ -683,9 +684,9 @@ void ChironTFT::PanelAction(uint8_t req) {
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;
}
}
@@ -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
@@ -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;
}
}
@@ -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);
}
@@ -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())
@@ -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 {
@@ -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)) {
@@ -911,7 +912,7 @@ 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;
@@ -919,7 +920,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
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;
}

View File

@@ -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();

View File

@@ -57,46 +57,46 @@
#define AC_LOWEST_MESHPOINT_VAL -10 // The lowest value you can set for a single mesh point offset
// TFT panel commands
#define AC_msg_sd_card_inserted PSTR("J00")
#define AC_msg_sd_card_removed PSTR("J01")
#define AC_msg_no_sd_card PSTR("J02")
#define AC_msg_usb_connected PSTR("J03")
#define AC_msg_print_from_sd_card PSTR("J04")
#define AC_msg_pause PSTR("J05")
#define AC_msg_nozzle_heating PSTR("J06")
#define AC_msg_nozzle_heating_done PSTR("J07")
#define AC_msg_bed_heating PSTR("J08")
#define AC_msg_bed_heating_done PSTR("J09")
#define AC_msg_nozzle_temp_abnormal PSTR("J10")
#define AC_msg_kill_lcd PSTR("J11")
#define AC_msg_ready PSTR("J12")
#define AC_msg_low_nozzle_temp PSTR("J13")
#define AC_msg_print_complete PSTR("J14")
#define AC_msg_filament_out_alert PSTR("J15")
#define AC_msg_stop PSTR("J16")
#define AC_msg_main_board_has_reset PSTR("J17")
#define AC_msg_paused PSTR("J18")
#define AC_msg_j19_unknown PSTR("J19")
#define AC_msg_sd_file_open_success PSTR("J20")
#define AC_msg_sd_file_open_failed PSTR("J21")
#define AC_msg_level_monitor_finished PSTR("J22")
#define AC_msg_filament_out_block PSTR("J23")
#define AC_msg_probing_not_allowed PSTR("J24")
#define AC_msg_probing_complete PSTR("J25")
#define AC_msg_start_probing PSTR("J26")
#define AC_msg_version PSTR("J27")
#define AC_msg_mesh_changes_abandoned PSTR("Mesh changes abandoned, previous mesh restored.")
#define AC_msg_mesh_changes_saved PSTR("Mesh changes saved.")
#define AC_msg_old_panel_detected PSTR("Standard TFT panel detected!")
#define AC_msg_new_panel_detected PSTR("New TFT panel detected!")
#define AC_msg_powerloss_recovery PSTR("Resuming from power outage! select the same SD file then press resume")
#define AC_msg_sd_card_inserted F("J00")
#define AC_msg_sd_card_removed F("J01")
#define AC_msg_no_sd_card F("J02")
#define AC_msg_usb_connected F("J03")
#define AC_msg_print_from_sd_card F("J04")
#define AC_msg_pause F("J05")
#define AC_msg_nozzle_heating F("J06")
#define AC_msg_nozzle_heating_done F("J07")
#define AC_msg_bed_heating F("J08")
#define AC_msg_bed_heating_done F("J09")
#define AC_msg_nozzle_temp_abnormal F("J10")
#define AC_msg_kill_lcd F("J11")
#define AC_msg_ready F("J12")
#define AC_msg_low_nozzle_temp F("J13")
#define AC_msg_print_complete F("J14")
#define AC_msg_filament_out_alert F("J15")
#define AC_msg_stop F("J16")
#define AC_msg_main_board_has_reset F("J17")
#define AC_msg_paused F("J18")
#define AC_msg_j19_unknown F("J19")
#define AC_msg_sd_file_open_success F("J20")
#define AC_msg_sd_file_open_failed F("J21")
#define AC_msg_level_monitor_finished F("J22")
#define AC_msg_filament_out_block F("J23")
#define AC_msg_probing_not_allowed F("J24")
#define AC_msg_probing_complete F("J25")
#define AC_msg_start_probing F("J26")
#define AC_msg_version F("J27")
#define AC_msg_mesh_changes_abandoned F("Mesh changes abandoned, previous mesh restored.")
#define AC_msg_mesh_changes_saved F("Mesh changes saved.")
#define AC_msg_old_panel_detected F("Standard TFT panel detected!")
#define AC_msg_new_panel_detected F("New TFT panel detected!")
#define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume")
// Error messages must not contain spaces
#define AC_msg_error_bed_temp PSTR("Abnormal_bed_temp")
#define AC_msg_error_hotend_temp PSTR("Abnormal_hotend_temp")
#define AC_msg_error_sd_card PSTR("SD_card_error")
#define AC_msg_filament_out PSTR("Filament_runout")
#define AC_msg_power_loss PSTR("Power_failure")
#define AC_msg_eeprom_version PSTR("EEPROM_ver_wrong")
#define AC_msg_error_bed_temp F("Abnormal_bed_temp")
#define AC_msg_error_hotend_temp F("Abnormal_hotend_temp")
#define AC_msg_error_sd_card F("SD_card_error")
#define AC_msg_filament_out F("Filament_runout")
#define AC_msg_power_loss F("Power_failure")
#define AC_msg_eeprom_version F("EEPROM_ver_wrong")
#define MARLIN_msg_start_probing PSTR("Probing Point 1/25")
#define MARLIN_msg_probing_failed PSTR("Probing Failed")
@@ -113,16 +113,16 @@
#define MARLIN_msg_filament_purging PSTR("Filament Purging...")
#define MARLIN_msg_special_pause PSTR("PB")
#define AC_cmnd_auto_unload_filament PSTR("M701") // Use Marlin unload routine
#define AC_cmnd_auto_load_filament PSTR("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle
#define AC_cmnd_auto_unload_filament F("M701") // Use Marlin unload routine
#define AC_cmnd_auto_load_filament F("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle
#define AC_cmnd_manual_load_filament PSTR("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster
#define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82")
#define AC_cmnd_enable_leveling PSTR("M420SV")
#define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
#define AC_cmnd_manual_load_filament F("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster
#define AC_cmnd_manual_unload_filament F("M83\nG1 E-50 F1200\nM82")
#define AC_cmnd_enable_leveling F("M420SV")
#define AC_cmnd_power_loss_recovery F("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
#define AC_Test_for_OldPanel PSTR("SIZE") // An old panel will respond with 'SXY 480 320' a new panel wont respond.
#define AC_Test_for_NewPanel PSTR("J200") // A new panel will respond with '[0]=0 [1]=0' to '[19]=0 ' an old panel wont respond
#define AC_Test_for_OldPanel F("SIZE") // An old panel will respond with 'SXY 480 320' a new panel wont respond.
#define AC_Test_for_NewPanel F("J200") // A new panel will respond with '[0]=0 [1]=0' to '[19]=0 ' an old panel wont respond
namespace Anycubic {
enum heater_state_t : uint8_t {