🎨 Apply F() to status message
This commit is contained in:
		
				
					committed by
					
						
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							433eedd50f
						
					
				
				
					commit
					360311f232
				
			@@ -4287,16 +4287,16 @@ void DWIN_CompletedLeveling() {
 | 
			
		||||
  if (checkkey == Leveling) Goto_MainMenu();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DWIN_StatusChanged(const char *text) {
 | 
			
		||||
void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) {
 | 
			
		||||
  DWIN_Draw_Rectangle(1, Color_Bg_Blue, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 24);
 | 
			
		||||
  const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(text) * MENU_CHR_W) / 2;
 | 
			
		||||
  DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 3, F(text));
 | 
			
		||||
  const int8_t x = _MAX(0U, DWIN_WIDTH - strlen(cstr) * MENU_CHR_W) / 2;
 | 
			
		||||
  DWIN_Draw_String(false, font8x16, Color_White, Color_Bg_Blue, x, STATUS_Y + 3, cstr);
 | 
			
		||||
  DWIN_UpdateLCD();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DWIN_StatusChanged_P(PGM_P const pstr) {
 | 
			
		||||
  char str[strlen_P((const char*)pstr) + 1];
 | 
			
		||||
  strcpy_P(str, (const char*)pstr);
 | 
			
		||||
void DWIN_StatusChanged(FSTR_P const fstr) {
 | 
			
		||||
  char str[strlen_P(FTOP(fstr)) + 1];
 | 
			
		||||
  strcpy_P(str, FTOP(fstr));
 | 
			
		||||
  DWIN_StatusChanged(str);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -244,8 +244,8 @@ void HMI_Init();
 | 
			
		||||
void DWIN_Update();
 | 
			
		||||
void EachMomentUpdate();
 | 
			
		||||
void DWIN_HandleScreen();
 | 
			
		||||
void DWIN_StatusChanged(const char *text);
 | 
			
		||||
void DWIN_StatusChanged_P(PGM_P const pstr);
 | 
			
		||||
void DWIN_StatusChanged(const char * const cstr=nullptr);
 | 
			
		||||
void DWIN_StatusChanged(FSTR_P const fstr);
 | 
			
		||||
 | 
			
		||||
inline void DWIN_StartHoming() { HMI_flag.home_flag = true; }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -713,7 +713,7 @@ void Draw_Main_Menu() {
 | 
			
		||||
 | 
			
		||||
void Goto_Main_Menu() {
 | 
			
		||||
  checkkey = MainMenu;
 | 
			
		||||
  DWIN_StatusChanged(nullptr);
 | 
			
		||||
  DWIN_StatusChanged();
 | 
			
		||||
  Draw_Main_Menu();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1758,20 +1758,20 @@ void DWIN_Startup() {
 | 
			
		||||
  HMI_SetLanguage();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text) {
 | 
			
		||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char * const text/*=nullptr*/) {
 | 
			
		||||
  DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20);
 | 
			
		||||
  if (text) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text);
 | 
			
		||||
  DWIN_UpdateLCD();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Update Status line
 | 
			
		||||
void DWIN_StatusChanged(const char *text) {
 | 
			
		||||
  DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text);
 | 
			
		||||
void DWIN_StatusChanged(const char * const cstr/*=nullptr*/) {
 | 
			
		||||
  DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, cstr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DWIN_StatusChanged_P(PGM_P const pstr) {
 | 
			
		||||
  char str[strlen_P((const char*)pstr) + 1];
 | 
			
		||||
  strcpy_P(str, (const char*)pstr);
 | 
			
		||||
void DWIN_StatusChanged(FSTR_P const fstr) {
 | 
			
		||||
  char str[strlen_P(FTOP(fstr)) + 1];
 | 
			
		||||
  strcpy_P(str, FTOP(fstr));
 | 
			
		||||
  DWIN_StatusChanged(str);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1806,7 +1806,7 @@ void DWIN_Progress_Update() {
 | 
			
		||||
 | 
			
		||||
#if HAS_FILAMENT_SENSOR
 | 
			
		||||
  // Filament Runout process
 | 
			
		||||
  void DWIN_FilamentRunout(const uint8_t extruder) { ui.set_status_P(GET_TEXT(MSG_RUNOUT_SENSOR)); }
 | 
			
		||||
  void DWIN_FilamentRunout(const uint8_t extruder) { LCD_MESSAGE(MSG_RUNOUT_SENSOR); }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void DWIN_SetColorDefaults() {
 | 
			
		||||
@@ -1891,7 +1891,7 @@ void DWIN_Redraw_screen() {
 | 
			
		||||
      case PAUSE_MESSAGE_OPTION:   DWIN_Popup_FilamentPurge(); break;
 | 
			
		||||
      case PAUSE_MESSAGE_RESUME:   DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break;
 | 
			
		||||
      case PAUSE_MESSAGE_HEAT:     DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), ICON_Continue_E);   break;
 | 
			
		||||
      case PAUSE_MESSAGE_HEATING:  ui.set_status_P(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); break;
 | 
			
		||||
      case PAUSE_MESSAGE_HEATING:  LCD_MESSAGE(MSG_FILAMENT_CHANGE_HEATING); break;
 | 
			
		||||
      case PAUSE_MESSAGE_STATUS:   HMI_ReturnScreen(); break;
 | 
			
		||||
      default: break;
 | 
			
		||||
    }
 | 
			
		||||
@@ -2183,7 +2183,7 @@ void SetMoveZto0() {
 | 
			
		||||
  );
 | 
			
		||||
  gcode.process_subcommands_now(cmd);
 | 
			
		||||
  planner.synchronize();
 | 
			
		||||
  ui.set_status_P(PSTR("Now adjust Z Offset"));
 | 
			
		||||
  LCD_MESSAGE_F("Now adjust Z Offset");
 | 
			
		||||
  HMI_AudioFeedback(true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -2240,7 +2240,7 @@ void Goto_LockScreen() { DWIN_LockScreen(true); }
 | 
			
		||||
  void SetProbeOffsetY() { SetPFloatOnClick(-50, 50, UNITFDIGITS); }
 | 
			
		||||
  void SetProbeOffsetZ() { SetPFloatOnClick(-10, 10, 2); }
 | 
			
		||||
  void ProbeTest() {
 | 
			
		||||
    ui.set_status_P(GET_TEXT(MSG_M48_TEST));
 | 
			
		||||
    LCD_MESSAGE(MSG_M48_TEST);
 | 
			
		||||
    queue.inject(F("G28O\nM48 P10"));
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
@@ -2297,7 +2297,7 @@ void DWIN_ApplyColor() {
 | 
			
		||||
  DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color);
 | 
			
		||||
  Draw_Status_Area(false);
 | 
			
		||||
  Draw_SelectColors_Menu();
 | 
			
		||||
  ui.set_status_P(PSTR("Colors applied"));
 | 
			
		||||
  LCD_MESSAGE_F("Colors applied");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); }
 | 
			
		||||
@@ -2325,18 +2325,18 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void ParkHead(){
 | 
			
		||||
    ui.set_status_P(GET_TEXT(MSG_FILAMENT_PARK_ENABLED));
 | 
			
		||||
    LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED);
 | 
			
		||||
    queue.inject(F("G28O\nG27"));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
 | 
			
		||||
    void UnloadFilament(){
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_FILAMENTUNLOAD));
 | 
			
		||||
      LCD_MESSAGE(MSG_FILAMENTUNLOAD);
 | 
			
		||||
      queue.inject(F("M702 Z20"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void LoadFilament(){
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_FILAMENTLOAD));
 | 
			
		||||
      LCD_MESSAGE(MSG_FILAMENTLOAD);
 | 
			
		||||
      queue.inject(F("M701 Z20"));
 | 
			
		||||
    }
 | 
			
		||||
  #endif
 | 
			
		||||
@@ -2362,23 +2362,23 @@ void LevBed(uint8_t point) {
 | 
			
		||||
 | 
			
		||||
  switch (point) {
 | 
			
		||||
    case 0:
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_LEVBED_FL));
 | 
			
		||||
      LCD_MESSAGE(MSG_LEVBED_FL);
 | 
			
		||||
      xpos = ypos = margin;
 | 
			
		||||
      break;
 | 
			
		||||
    case 1:
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_LEVBED_FR));
 | 
			
		||||
      LCD_MESSAGE(MSG_LEVBED_FR);
 | 
			
		||||
      xpos = X_BED_SIZE - margin; ypos = margin;
 | 
			
		||||
      break;
 | 
			
		||||
    case 2:
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_LEVBED_BR));
 | 
			
		||||
      LCD_MESSAGE(MSG_LEVBED_BR);
 | 
			
		||||
      xpos = X_BED_SIZE - margin; ypos = Y_BED_SIZE - margin;
 | 
			
		||||
      break;
 | 
			
		||||
    case 3:
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_LEVBED_BL));
 | 
			
		||||
      LCD_MESSAGE(MSG_LEVBED_BL);
 | 
			
		||||
      xpos = margin; ypos = Y_BED_SIZE - margin;
 | 
			
		||||
      break;
 | 
			
		||||
    case 4:
 | 
			
		||||
      ui.set_status_P(GET_TEXT(MSG_LEVBED_C));
 | 
			
		||||
      LCD_MESSAGE(MSG_LEVBED_C);
 | 
			
		||||
      xpos = X_BED_SIZE / 2; ypos = Y_BED_SIZE / 2;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
@@ -2393,7 +2393,7 @@ void LevBed(uint8_t point) {
 | 
			
		||||
      dtostrf(ypos, 1, 1, str_2),
 | 
			
		||||
      dtostrf(zval, 1, 2, str_3)
 | 
			
		||||
    );
 | 
			
		||||
    ui.set_status_P(cmd);
 | 
			
		||||
    ui.set_status(cmd);
 | 
			
		||||
  #else
 | 
			
		||||
    planner.synchronize();
 | 
			
		||||
    sprintf_P(cmd, PSTR(fmt), xpos, ypos);
 | 
			
		||||
@@ -2410,7 +2410,7 @@ void LevBedC () { LevBed(4); }
 | 
			
		||||
#if ENABLED(MESH_BED_LEVELING)
 | 
			
		||||
 | 
			
		||||
  void ManualMeshStart(){
 | 
			
		||||
    ui.set_status_P(GET_TEXT(MSG_UBL_BUILD_MESH_MENU));
 | 
			
		||||
    LCD_MESSAGE(MSG_UBL_BUILD_MESH_MENU);
 | 
			
		||||
    gcode.process_subcommands_now(F("G28 XYO\nG28 Z\nM211 S0\nG29S1"));
 | 
			
		||||
    planner.synchronize();
 | 
			
		||||
    #ifdef MANUAL_PROBE_START_Z
 | 
			
		||||
@@ -2435,7 +2435,7 @@ void LevBedC () { LevBed(4); }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void ManualMeshSave(){
 | 
			
		||||
    ui.set_status_P(GET_TEXT(MSG_UBL_STORAGE_MESH_MENU));
 | 
			
		||||
    LCD_MESSAGE(MSG_UBL_STORAGE_MESH_MENU);
 | 
			
		||||
    queue.inject(F("M211 S1\nM500"));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -3092,11 +3092,11 @@ void HMI_SetPFloat() {
 | 
			
		||||
 | 
			
		||||
// Menu Creation and Drawing functions ======================================================
 | 
			
		||||
 | 
			
		||||
void SetMenuTitle(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* text) {
 | 
			
		||||
void SetMenuTitle(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* fstr) {
 | 
			
		||||
  if (HMI_IsChinese() && (cn.w != 0))
 | 
			
		||||
    CurrentMenu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h);
 | 
			
		||||
  else
 | 
			
		||||
    CurrentMenu->MenuTitle.SetCaption(text);
 | 
			
		||||
    CurrentMenu->MenuTitle.SetCaption(fstr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Draw_Prepare_Menu() {
 | 
			
		||||
@@ -3234,7 +3234,7 @@ void Draw_Move_Menu() {
 | 
			
		||||
    #endif
 | 
			
		||||
  }
 | 
			
		||||
  CurrentMenu->draw();
 | 
			
		||||
  if (!all_axes_trusted()) ui.set_status_P(PSTR("WARNING: position is unknow"));
 | 
			
		||||
  if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: position is unknown");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if HAS_HOME_OFFSET
 | 
			
		||||
@@ -3440,11 +3440,11 @@ void Draw_Motion_Menu() {
 | 
			
		||||
 | 
			
		||||
#if HAS_PREHEAT
 | 
			
		||||
 | 
			
		||||
  void Draw_Preheat_Menu(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* text) {
 | 
			
		||||
  void Draw_Preheat_Menu(frame_rect_t cn, frame_rect_t en, const __FlashStringHelper* fstr) {
 | 
			
		||||
    checkkey = Menu;
 | 
			
		||||
    if (CurrentMenu != PreheatMenu) {
 | 
			
		||||
      CurrentMenu = PreheatMenu;
 | 
			
		||||
      SetMenuTitle(cn, en, text);
 | 
			
		||||
      SetMenuTitle(cn, en, fstr);
 | 
			
		||||
      DWINUI::MenuItemsPrepare(5);
 | 
			
		||||
      ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Temperature_Menu);
 | 
			
		||||
      #if HAS_HOTEND
 | 
			
		||||
@@ -3648,7 +3648,7 @@ void Draw_Steps_Menu() {
 | 
			
		||||
      ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR);
 | 
			
		||||
    }
 | 
			
		||||
    CurrentMenu->draw();
 | 
			
		||||
    if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home"));
 | 
			
		||||
    if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home");
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -179,9 +179,9 @@ void EachMomentUpdate();
 | 
			
		||||
void update_variable();
 | 
			
		||||
void DWIN_HandleScreen();
 | 
			
		||||
void DWIN_Update();
 | 
			
		||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
 | 
			
		||||
void DWIN_StatusChanged(const char * const text);
 | 
			
		||||
void DWIN_StatusChanged_P(PGM_P const text);
 | 
			
		||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text=nullptr);
 | 
			
		||||
void DWIN_StatusChanged(const char * const cstr=nullptr);
 | 
			
		||||
void DWIN_StatusChanged(FSTR_P const fstr);
 | 
			
		||||
void DWIN_StartHoming();
 | 
			
		||||
void DWIN_CompletedHoming();
 | 
			
		||||
#if HAS_MESH
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ void MeshViewerClass::Draw() {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  char str_1[6], str_2[6] = "";
 | 
			
		||||
  ui.status_printf_P(0, PSTR("Mesh minZ: %s, maxZ: %s"),
 | 
			
		||||
  ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),
 | 
			
		||||
    dtostrf((float)minz / 100, 1, 2, str_1),
 | 
			
		||||
    dtostrf((float)maxz / 100, 1, 2, str_2)
 | 
			
		||||
  );
 | 
			
		||||
 
 | 
			
		||||
@@ -2018,7 +2018,7 @@ void get_wifi_commands() {
 | 
			
		||||
                TERN_(ARC_SUPPORT, case 2 ... 3:)
 | 
			
		||||
                TERN_(BEZIER_CURVE_SUPPORT, case 5:)
 | 
			
		||||
                SERIAL_ECHOLNPGM(STR_ERR_STOPPED);
 | 
			
		||||
                LCD_MESSAGEPGM(MSG_STOPPED);
 | 
			
		||||
                LCD_MESSAGE(MSG_STOPPED);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
 
 | 
			
		||||
@@ -665,7 +665,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
 | 
			
		||||
  void MarlinUI::kill_screen(PGM_P lcd_error, PGM_P lcd_component) {
 | 
			
		||||
    init();
 | 
			
		||||
    status_printf_P(1, PSTR(S_FMT ": " S_FMT), lcd_error, lcd_component);
 | 
			
		||||
    status_printf(1, F(S_FMT ": " S_FMT), lcd_error, lcd_component);
 | 
			
		||||
    TERN_(HAS_LCD_MENU, return_to_status());
 | 
			
		||||
 | 
			
		||||
    // RED ALERT. RED ALERT.
 | 
			
		||||
@@ -1393,76 +1393,77 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
    #if SERVICE_INTERVAL_3 > 0
 | 
			
		||||
      static PGMSTR(service3, "> " SERVICE_NAME_3 "!");
 | 
			
		||||
    #endif
 | 
			
		||||
    PGM_P msg;
 | 
			
		||||
    FSTR_P msg;
 | 
			
		||||
    if (printingIsPaused())
 | 
			
		||||
      msg = GET_TEXT(MSG_PRINT_PAUSED);
 | 
			
		||||
      msg = GET_TEXT_F(MSG_PRINT_PAUSED);
 | 
			
		||||
    #if ENABLED(SDSUPPORT)
 | 
			
		||||
      else if (IS_SD_PRINTING())
 | 
			
		||||
        return set_status(card.longest_filename(), true);
 | 
			
		||||
    #endif
 | 
			
		||||
    else if (print_job_timer.isRunning())
 | 
			
		||||
      msg = GET_TEXT(MSG_PRINTING);
 | 
			
		||||
      msg = GET_TEXT_F(MSG_PRINTING);
 | 
			
		||||
 | 
			
		||||
    #if SERVICE_INTERVAL_1 > 0
 | 
			
		||||
      else if (print_job_timer.needsService(1)) msg = service1;
 | 
			
		||||
      else if (print_job_timer.needsService(1)) msg = FPSTR(service1);
 | 
			
		||||
    #endif
 | 
			
		||||
    #if SERVICE_INTERVAL_2 > 0
 | 
			
		||||
      else if (print_job_timer.needsService(2)) msg = service2;
 | 
			
		||||
      else if (print_job_timer.needsService(2)) msg = FPSTR(service2);
 | 
			
		||||
    #endif
 | 
			
		||||
    #if SERVICE_INTERVAL_3 > 0
 | 
			
		||||
      else if (print_job_timer.needsService(3)) msg = service3;
 | 
			
		||||
      else if (print_job_timer.needsService(3)) msg = FPSTR(service3);
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
    else if (!no_welcome)
 | 
			
		||||
      msg = GET_TEXT(WELCOME_MSG);
 | 
			
		||||
      msg = GET_TEXT_F(WELCOME_MSG);
 | 
			
		||||
    else
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    set_status_P(msg, -1);
 | 
			
		||||
    set_status(msg, -1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
 | 
			
		||||
  void MarlinUI::set_status(FSTR_P const fstr, int8_t level) {
 | 
			
		||||
    PGM_P const pstr = FTOP(fstr);
 | 
			
		||||
    if (level < 0) level = alert_level = 0;
 | 
			
		||||
    if (level < alert_level) return;
 | 
			
		||||
    alert_level = level;
 | 
			
		||||
 | 
			
		||||
    TERN_(HOST_PROMPT_SUPPORT, host_action_notify_P(message));
 | 
			
		||||
    TERN_(HOST_PROMPT_SUPPORT, host_action_notify_P(pstr));
 | 
			
		||||
 | 
			
		||||
    // Since the message is encoded in UTF8 it must
 | 
			
		||||
    // only be cut on a character boundary.
 | 
			
		||||
 | 
			
		||||
    // Get a pointer to the null terminator
 | 
			
		||||
    PGM_P pend = message + strlen_P(message);
 | 
			
		||||
    PGM_P pend = pstr + strlen_P(pstr);
 | 
			
		||||
 | 
			
		||||
    // If length of supplied UTF8 string is greater than
 | 
			
		||||
    // the buffer size, start cutting whole UTF8 chars
 | 
			
		||||
    while ((pend - message) > MAX_MESSAGE_LENGTH) {
 | 
			
		||||
    while ((pend - pstr) > MAX_MESSAGE_LENGTH) {
 | 
			
		||||
      --pend;
 | 
			
		||||
      while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // At this point, we have the proper cut point. Use it
 | 
			
		||||
    uint8_t maxLen = pend - message;
 | 
			
		||||
    strncpy_P(status_message, message, maxLen);
 | 
			
		||||
    uint8_t maxLen = pend - pstr;
 | 
			
		||||
    strncpy_P(status_message, pstr, maxLen);
 | 
			
		||||
    status_message[maxLen] = '\0';
 | 
			
		||||
 | 
			
		||||
    finish_status(level > 0);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void MarlinUI::set_alert_status_P(PGM_P const message) {
 | 
			
		||||
    set_status_P(message, 1);
 | 
			
		||||
  void MarlinUI::set_alert_status(FSTR_P const fstr) {
 | 
			
		||||
    set_status(fstr, 1);
 | 
			
		||||
    TERN_(HAS_TOUCH_SLEEP, wakeup_screen());
 | 
			
		||||
    TERN_(HAS_LCD_MENU, return_to_status());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  #include <stdarg.h>
 | 
			
		||||
 | 
			
		||||
  void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
 | 
			
		||||
  void MarlinUI::status_printf(const uint8_t level, FSTR_P const fmt, ...) {
 | 
			
		||||
    if (level < alert_level) return;
 | 
			
		||||
    alert_level = level;
 | 
			
		||||
    va_list args;
 | 
			
		||||
    va_start(args, fmt);
 | 
			
		||||
    vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
 | 
			
		||||
    va_start(args, FTOP(fmt));
 | 
			
		||||
    vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args);
 | 
			
		||||
    va_end(args);
 | 
			
		||||
    finish_status(level > 0);
 | 
			
		||||
  }
 | 
			
		||||
@@ -1536,7 +1537,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
    #endif
 | 
			
		||||
    IF_DISABLED(SDSUPPORT, print_job_timer.stop());
 | 
			
		||||
    TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("UI Aborted"), DISMISS_STR));
 | 
			
		||||
    LCD_MESSAGEPGM(MSG_PRINT_ABORTED);
 | 
			
		||||
    LCD_MESSAGE(MSG_PRINT_ABORTED);
 | 
			
		||||
    TERN_(HAS_LCD_MENU, return_to_status());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -1548,7 +1549,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  void MarlinUI::flow_fault() {
 | 
			
		||||
    LCD_ALERTMESSAGEPGM(MSG_FLOWMETER_FAULT);
 | 
			
		||||
    LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT);
 | 
			
		||||
    TERN_(HAS_BUZZER, buzz(1000, 440));
 | 
			
		||||
    TERN_(HAS_LCD_MENU, return_to_status());
 | 
			
		||||
  }
 | 
			
		||||
@@ -1566,7 +1567,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
    TERN_(HAS_TOUCH_SLEEP, wakeup_screen());
 | 
			
		||||
    TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume")));
 | 
			
		||||
 | 
			
		||||
    LCD_MESSAGEPGM(MSG_PRINT_PAUSED);
 | 
			
		||||
    LCD_MESSAGE(MSG_PRINT_PAUSED);
 | 
			
		||||
 | 
			
		||||
    #if ENABLED(PARK_HEAD_ON_PAUSE)
 | 
			
		||||
      pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress
 | 
			
		||||
@@ -1637,14 +1638,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
  //
 | 
			
		||||
  // Send the status line as a host notification
 | 
			
		||||
  //
 | 
			
		||||
  void MarlinUI::set_status(const char * const message, const bool) {
 | 
			
		||||
    TERN(HOST_PROMPT_SUPPORT, host_action_notify(message), UNUSED(message));
 | 
			
		||||
  void MarlinUI::set_status(const char * const cstr, const bool) {
 | 
			
		||||
    TERN(HOST_PROMPT_SUPPORT, host_action_notify(cstr), UNUSED(cstr));
 | 
			
		||||
  }
 | 
			
		||||
  void MarlinUI::set_status_P(PGM_P message, const int8_t) {
 | 
			
		||||
    TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message));
 | 
			
		||||
  void MarlinUI::set_status(FSTR_P const fstr, const int8_t) {
 | 
			
		||||
    TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(FTOP(fstr)), UNUSED(fstr));
 | 
			
		||||
  }
 | 
			
		||||
  void MarlinUI::status_printf_P(const uint8_t, PGM_P const message, ...) {
 | 
			
		||||
    TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(message), UNUSED(message));
 | 
			
		||||
  void MarlinUI::status_printf(const uint8_t, FSTR_P const fstr, ...) {
 | 
			
		||||
    TERN(HOST_PROMPT_SUPPORT, host_action_notify_P(FPSTR(fstr)), UNUSED(fstr));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE
 | 
			
		||||
@@ -1670,7 +1671,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
          quick_feedback();
 | 
			
		||||
          goto_screen(MEDIA_MENU_GATEWAY);
 | 
			
		||||
        #else
 | 
			
		||||
          LCD_MESSAGEPGM(MSG_MEDIA_INSERTED);
 | 
			
		||||
          LCD_MESSAGE(MSG_MEDIA_INSERTED);
 | 
			
		||||
        #endif
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@@ -1679,7 +1680,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
        #if ENABLED(EXTENSIBLE_UI)
 | 
			
		||||
          ExtUI::onMediaRemoved();
 | 
			
		||||
        #elif PIN_EXISTS(SD_DETECT)
 | 
			
		||||
          LCD_MESSAGEPGM(MSG_MEDIA_REMOVED);
 | 
			
		||||
          LCD_MESSAGE(MSG_MEDIA_REMOVED);
 | 
			
		||||
          #if HAS_LCD_MENU
 | 
			
		||||
            if (!defer_return_to_status) return_to_status();
 | 
			
		||||
          #endif
 | 
			
		||||
@@ -1802,7 +1803,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
 | 
			
		||||
          );
 | 
			
		||||
        });
 | 
			
		||||
      #else
 | 
			
		||||
        set_status_P(eeprom_err(msgid));
 | 
			
		||||
        set_status(FPSTR(eeprom_err(msgid)));
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -342,21 +342,19 @@ public:
 | 
			
		||||
 | 
			
		||||
    static bool has_status();
 | 
			
		||||
    static void reset_status(const bool no_welcome=false);
 | 
			
		||||
    static void set_status(const char * const message, const bool persist=false);
 | 
			
		||||
    static void set_status_P(PGM_P const message, const int8_t level=0);
 | 
			
		||||
    static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
 | 
			
		||||
    static void set_alert_status_P(PGM_P const message);
 | 
			
		||||
    static void set_alert_status(FSTR_P const fstr);
 | 
			
		||||
    static inline void reset_alert_level() { alert_level = 0; }
 | 
			
		||||
  #else
 | 
			
		||||
    static constexpr bool has_status() { return false; }
 | 
			
		||||
    static inline void reset_status(const bool=false) {}
 | 
			
		||||
    static void set_status(const char *message, const bool=false);
 | 
			
		||||
    static void set_status_P(PGM_P message, const int8_t=0);
 | 
			
		||||
    static void status_printf_P(const uint8_t, PGM_P message, ...);
 | 
			
		||||
    static inline void set_alert_status_P(PGM_P const) {}
 | 
			
		||||
    static inline void set_alert_status(FSTR_P const) {}
 | 
			
		||||
    static inline void reset_alert_level() {}
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  static void set_status(const char * const cstr, const bool persist=false);
 | 
			
		||||
  static void set_status(FSTR_P const fstr, const int8_t level=0);
 | 
			
		||||
  static void status_printf(const uint8_t level, FSTR_P const fmt, ...);
 | 
			
		||||
 | 
			
		||||
  #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
 | 
			
		||||
    static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
 | 
			
		||||
  #else
 | 
			
		||||
@@ -740,8 +738,7 @@ private:
 | 
			
		||||
 | 
			
		||||
extern MarlinUI ui;
 | 
			
		||||
 | 
			
		||||
#define LCD_MESSAGEPGM_P(x)      ui.set_status_P(x)
 | 
			
		||||
#define LCD_ALERTMESSAGEPGM_P(x) ui.set_alert_status_P(x)
 | 
			
		||||
 | 
			
		||||
#define LCD_MESSAGEPGM(x)        LCD_MESSAGEPGM_P(GET_TEXT(x))
 | 
			
		||||
#define LCD_ALERTMESSAGEPGM(x)   LCD_ALERTMESSAGEPGM_P(GET_TEXT(x))
 | 
			
		||||
#define LCD_MESSAGE_F(S)       ui.set_status(F(S))
 | 
			
		||||
#define LCD_MESSAGE(M)         ui.set_status(GET_TEXT_F(M))
 | 
			
		||||
#define LCD_ALERTMESSAGE_F(S)  ui.set_alert_status(F(S))
 | 
			
		||||
#define LCD_ALERTMESSAGE(M)    ui.set_alert_status(GET_TEXT_F(M))
 | 
			
		||||
 
 | 
			
		||||
@@ -630,7 +630,7 @@ void menu_advanced_settings() {
 | 
			
		||||
                 didset = settings.set_sd_update_status(new_state);
 | 
			
		||||
      ui.completion_feedback(didset);
 | 
			
		||||
      ui.return_to_status();
 | 
			
		||||
      if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
 | 
			
		||||
      if (new_state) LCD_MESSAGE(MSG_RESET_PRINTER); else ui.reset_status();
 | 
			
		||||
    });
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -253,7 +253,7 @@ void menu_mixer() {
 | 
			
		||||
    MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
 | 
			
		||||
    []{
 | 
			
		||||
      mixer.reset_vtools();
 | 
			
		||||
      LCD_MESSAGEPGM(MSG_VTOOLS_RESET);
 | 
			
		||||
      LCD_MESSAGE(MSG_VTOOLS_RESET);
 | 
			
		||||
      ui.return_to_status();
 | 
			
		||||
    },
 | 
			
		||||
    nullptr,
 | 
			
		||||
 
 | 
			
		||||
@@ -36,14 +36,14 @@
 | 
			
		||||
inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) {
 | 
			
		||||
  ui.reset_status();
 | 
			
		||||
  ui.return_to_status();
 | 
			
		||||
  ui.status_printf_P(0,  GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(tool + 1));
 | 
			
		||||
  ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(tool + 1));
 | 
			
		||||
  if (mmu2.load_filament_to_nozzle(tool)) ui.reset_status();
 | 
			
		||||
  ui.return_to_status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void _mmu2_load_filament(uint8_t index) {
 | 
			
		||||
  ui.return_to_status();
 | 
			
		||||
  ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
 | 
			
		||||
  ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
 | 
			
		||||
  mmu2.load_filament(index);
 | 
			
		||||
  ui.reset_status();
 | 
			
		||||
}
 | 
			
		||||
@@ -74,14 +74,14 @@ void menu_mmu2_load_to_nozzle() {
 | 
			
		||||
void _mmu2_eject_filament(uint8_t index) {
 | 
			
		||||
  ui.reset_status();
 | 
			
		||||
  ui.return_to_status();
 | 
			
		||||
  ui.status_printf_P(0, GET_TEXT(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
 | 
			
		||||
  ui.status_printf(0, GET_TEXT_F(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
 | 
			
		||||
  if (mmu2.eject_filament(index, true)) ui.reset_status();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void action_mmu2_unload_filament() {
 | 
			
		||||
  ui.reset_status();
 | 
			
		||||
  ui.return_to_status();
 | 
			
		||||
  LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
 | 
			
		||||
  LCD_MESSAGE(MSG_MMU2_UNLOADING_FILAMENT);
 | 
			
		||||
  idle();
 | 
			
		||||
  if (mmu2.unload()) ui.reset_status();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user