Advertisement
Guest User

Ender3 Marlin Firmware Patch (Dec 8 2018)

a guest
Feb 4th, 2019
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 95.80 KB | None | 0 0
  1. diff --git a/Configuration.h b/Configuration.h
  2. index 8fd1749..b1899f5 100644
  3. --- a/Configuration.h
  4. +++ b/Configuration.h
  5. @@ -74,10 +74,10 @@
  6.  // User-specified version info of this build to display in [Pronterface, etc] terminal window during
  7.  // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
  8.  // build by the user have been successfully uploaded into firmware.
  9. -#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
  10. +#define STRING_CONFIG_H_AUTHOR "(Ender-3)" // Who made the changes.
  11.  #define SHOW_BOOTSCREEN
  12. -#define STRING_SPLASH_LINE1 SHORT_BUILD_VERSION // will be shown during bootup in line 1
  13. -#define STRING_SPLASH_LINE2 WEBSITE_URL         // will be shown during bootup in line 2
  14. +// #define STRING_SPLASH_LINE1 DETAILED_BUILD_VERSION // will be shown during bootup in line 1
  15. +// #define STRING_SPLASH_LINE2 WEBSITE_URL            // will be shown during bootup in line 2
  16.  
  17.  //
  18.  // *** VENDORS PLEASE READ *****************************************************
  19. @@ -111,7 +111,7 @@
  20.   *
  21.   * :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000]
  22.   */
  23. -#define BAUDRATE 250000
  24. +#define BAUDRATE 115200
  25.  
  26.  // Enable the Bluetooth serial interface on AT90USB devices
  27.  //#define BLUETOOTH
  28. @@ -119,12 +119,12 @@
  29.  // The following define selects which electronics board you have.
  30.  // Please choose the name from boards.h that matches your setup
  31.  #ifndef MOTHERBOARD
  32. -  #define MOTHERBOARD BOARD_RAMPS_14_EFB
  33. +  #define MOTHERBOARD BOARD_MELZI_CREALITY
  34.  #endif
  35.  
  36.  // Optional custom name for your RepStrap or other custom machine
  37.  // Displayed in the LCD "Ready" message
  38. -//#define CUSTOM_MACHINE_NAME "3D Printer"
  39. +#define CUSTOM_MACHINE_NAME "Ender-3"
  40.  
  41.  // Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
  42.  // You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
  43. @@ -223,7 +223,7 @@
  44.   *
  45.   * :{ 0:'No power switch', 1:'ATX', 2:'X-Box 360' }
  46.   */
  47. -#define POWER_SUPPLY 0
  48. +//#define POWER_SUPPLY 0
  49.  
  50.  #if POWER_SUPPLY > 0
  51.    // Enable this option to leave the PSU off at startup.
  52. @@ -288,7 +288,7 @@
  53.  #define TEMP_SENSOR_2 0
  54.  #define TEMP_SENSOR_3 0
  55.  #define TEMP_SENSOR_4 0
  56. -#define TEMP_SENSOR_BED 0
  57. +#define TEMP_SENSOR_BED 1
  58.  
  59.  // Dummy thermistor constant temperature readings, for use with 998 and 999
  60.  #define DUMMY_THERMISTOR_998_VALUE 25
  61. @@ -352,9 +352,10 @@
  62.    // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
  63.  
  64.    // Ultimaker
  65. -  #define  DEFAULT_Kp 22.2
  66. -  #define  DEFAULT_Ki 1.08
  67. -  #define  DEFAULT_Kd 114
  68. +  // Stock CR-10S Hotend fan 100%
  69. +  #define  DEFAULT_Kp 20.84
  70. +  #define  DEFAULT_Ki 1.96
  71. +  #define  DEFAULT_Kd 55.47
  72.  
  73.    // MakerGear
  74.    //#define  DEFAULT_Kp 7.0
  75. @@ -396,6 +397,7 @@
  76.  
  77.    //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
  78.    //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
  79. +  // Stock bed tuned for 50C
  80.    #define  DEFAULT_bedKp 10.00
  81.    #define  DEFAULT_bedKi .023
  82.    #define  DEFAULT_bedKd 305.4
  83. @@ -525,14 +527,14 @@
  84.   * Override with M92
  85.   *                                      X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]]
  86.   */
  87. -#define DEFAULT_AXIS_STEPS_PER_UNIT   { 80, 80, 4000, 500 }
  88. +#define DEFAULT_AXIS_STEPS_PER_UNIT   { 80.00, 80.00, 400.00, 93.00 }
  89.  
  90.  /**
  91.   * Default Max Feed Rate (mm/s)
  92.   * Override with M203
  93.   *                                      X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]]
  94.   */
  95. -#define DEFAULT_MAX_FEEDRATE          { 300, 300, 5, 25 }
  96. +#define DEFAULT_MAX_FEEDRATE          { 500, 500, 5, 25 }
  97.  
  98.  /**
  99.   * Default Max Acceleration (change/s) change = mm/s
  100. @@ -540,7 +542,7 @@
  101.   * Override with M201
  102.   *                                      X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]]
  103.   */
  104. -#define DEFAULT_MAX_ACCELERATION      { 3000, 3000, 100, 10000 }
  105. +#define DEFAULT_MAX_ACCELERATION      { 500, 500, 100, 1000 }
  106.  
  107.  /**
  108.   * Default Acceleration (change/s) change = mm/s
  109. @@ -550,9 +552,9 @@
  110.   *   M204 R    Retract Acceleration
  111.   *   M204 T    Travel Acceleration
  112.   */
  113. -#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E acceleration for printing moves
  114. -#define DEFAULT_RETRACT_ACCELERATION  3000    // E acceleration for retracts
  115. -#define DEFAULT_TRAVEL_ACCELERATION   3000    // X, Y, Z acceleration for travel (non printing) moves
  116. +#define DEFAULT_ACCELERATION          500    // X, Y, Z and E acceleration for printing moves
  117. +#define DEFAULT_RETRACT_ACCELERATION  500    // E acceleration for retracts
  118. +#define DEFAULT_TRAVEL_ACCELERATION   1000    // X, Y, Z acceleration for travel (non printing) moves
  119.  
  120.  /**
  121.   * Default Jerk (mm/s)
  122. @@ -562,8 +564,8 @@
  123.   * When changing speed and direction, if the difference is less than the
  124.   * value set here, it may happen instantaneously.
  125.   */
  126. -#define DEFAULT_XJERK                 20.0
  127. -#define DEFAULT_YJERK                 20.0
  128. +#define DEFAULT_XJERK                 10.0
  129. +#define DEFAULT_YJERK                 10.0
  130.  #define DEFAULT_ZJERK                  0.4
  131.  #define DEFAULT_EJERK                  5.0
  132.  
  133. @@ -679,12 +681,12 @@
  134.   *      O-- FRONT --+
  135.   *    (0,0)
  136.   */
  137. -#define X_PROBE_OFFSET_FROM_EXTRUDER 10  // X offset: -left  +right  [of the nozzle]
  138. -#define Y_PROBE_OFFSET_FROM_EXTRUDER 10  // Y offset: -front +behind [the nozzle]
  139. -#define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]
  140. +#define X_PROBE_OFFSET_FROM_EXTRUDER 0  // X offset: -left  +right  [of the nozzle]
  141. +#define Y_PROBE_OFFSET_FROM_EXTRUDER 0  // Y offset: -front +behind [the nozzle]
  142. +#define Z_PROBE_OFFSET_FROM_EXTRUDER 0  // Z offset: -below +above  [the nozzle]
  143.  
  144.  // X and Y axis travel speed (mm/m) between probes
  145. -#define XY_PROBE_SPEED 8000
  146. +#define XY_PROBE_SPEED 3000
  147.  
  148.  // Speed for the first approach when double-probing (with PROBE_DOUBLE_TOUCH)
  149.  #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
  150. @@ -742,7 +744,7 @@
  151.  // @section machine
  152.  
  153.  // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way.
  154. -#define INVERT_X_DIR false
  155. +#define INVERT_X_DIR true
  156.  #define INVERT_Y_DIR true
  157.  #define INVERT_Z_DIR false
  158.  
  159. @@ -752,7 +754,7 @@
  160.  // @section extruder
  161.  
  162.  // For direct drive extruder v9 set to true, for geared extruder set to false.
  163. -#define INVERT_E0_DIR false
  164. +#define INVERT_E0_DIR true
  165.  #define INVERT_E1_DIR false
  166.  #define INVERT_E2_DIR false
  167.  #define INVERT_E3_DIR false
  168. @@ -774,8 +776,8 @@
  169.  // @section machine
  170.  
  171.  // The size of the print bed
  172. -#define X_BED_SIZE 200
  173. -#define Y_BED_SIZE 200
  174. +#define X_BED_SIZE 235
  175. +#define Y_BED_SIZE 235
  176.  
  177.  // Travel limits (mm) after homing, corresponding to endstop positions.
  178.  #define X_MIN_POS 0
  179. @@ -783,7 +785,7 @@
  180.  #define Z_MIN_POS 0
  181.  #define X_MAX_POS X_BED_SIZE
  182.  #define Y_MAX_POS Y_BED_SIZE
  183. -#define Z_MAX_POS 200
  184. +#define Z_MAX_POS 250
  185.  
  186.  // If enabled, axes won't move below MIN_POS in response to movement commands.
  187.  #define MIN_SOFTWARE_ENDSTOPS
  188. @@ -875,10 +877,10 @@
  189.    #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
  190.  
  191.    // Set the boundaries for probing (where the probe can reach).
  192. -  #define LEFT_PROBE_BED_POSITION 15
  193. -  #define RIGHT_PROBE_BED_POSITION 170
  194. -  #define FRONT_PROBE_BED_POSITION 20
  195. -  #define BACK_PROBE_BED_POSITION 170
  196. +  #define LEFT_PROBE_BED_POSITION 50
  197. +  #define RIGHT_PROBE_BED_POSITION 210
  198. +  #define FRONT_PROBE_BED_POSITION 50
  199. +  #define BACK_PROBE_BED_POSITION 210
  200.  
  201.    // The Z probe minimum outer margin (to validate G29 parameters).
  202.    #define MIN_PROBE_EDGE 10
  203. @@ -1015,9 +1017,9 @@
  204.  // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
  205.  // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
  206.  //
  207. -//#define EEPROM_SETTINGS // Enable for M500 and M501 commands
  208. +#define EEPROM_SETTINGS // Enable for M500 and M501 commands
  209.  //#define DISABLE_M503    // Saves ~2700 bytes of PROGMEM. Disable for release!
  210. -#define EEPROM_CHITCHAT   // Give feedback on EEPROM commands. Disable to save PROGMEM.
  211. +//#define EEPROM_CHITCHAT   // Give feedback on EEPROM commands. Disable to save PROGMEM.
  212.  
  213.  //
  214.  // Host Keepalive
  215. @@ -1047,12 +1049,12 @@
  216.  // @section temperature
  217.  
  218.  // Preheat Constants
  219. -#define PREHEAT_1_TEMP_HOTEND 180
  220. -#define PREHEAT_1_TEMP_BED     70
  221. +#define PREHEAT_1_TEMP_HOTEND 185
  222. +#define PREHEAT_1_TEMP_BED     45
  223.  #define PREHEAT_1_FAN_SPEED     0 // Value from 0 to 255
  224.  
  225.  #define PREHEAT_2_TEMP_HOTEND 240
  226. -#define PREHEAT_2_TEMP_BED    110
  227. +#define PREHEAT_2_TEMP_BED     70
  228.  #define PREHEAT_2_FAN_SPEED     0 // Value from 0 to 255
  229.  
  230.  /**
  231. @@ -1229,7 +1231,10 @@
  232.   * you must uncomment the following option or it won't work.
  233.   *
  234.   */
  235. -//#define SDSUPPORT
  236. +#define SDSUPPORT
  237. +
  238. +// If power off, after power on, the printing can be resumed.
  239. +#define POWEROFF_SAVE_SD_FILE
  240.  
  241.  /**
  242.   * SD CARD: SPI SPEED
  243. @@ -1522,7 +1527,7 @@
  244.  // This is RAMPS-compatible using a single 10-pin connector.
  245.  // (For CR-10 owners who want to replace the Melzi Creality board but retain the display)
  246.  //
  247. -//#define CR10_STOCKDISPLAY
  248. +#define CR10_STOCKDISPLAY
  249.  
  250.  //
  251.  // MKS OLED 1.3" 128 β”œΓΉ 64 FULL GRAPHICS CONTROLLER
  252. @@ -1681,7 +1686,7 @@
  253.   */
  254.  //#define FILAMENT_WIDTH_SENSOR
  255.  
  256. -#define DEFAULT_NOMINAL_FILAMENT_DIA 3.00   // (mm) Diameter of the filament generally used (3.0 or 1.75mm), also used in the slicer. Used to validate sensor reading.
  257. +#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75   // (mm) Diameter of the filament generally used (3.0 or 1.75mm), also used in the slicer. Used to validate sensor reading.
  258.  
  259.  #if ENABLED(FILAMENT_WIDTH_SENSOR)
  260.    #define FILAMENT_SENSOR_EXTRUDER_NUM 0    // Index of the extruder that has the filament sensor (0,1,2,3)
  261. diff --git a/Configuration_adv.h b/Configuration_adv.h
  262. index 3ed2a44..d7c75eb 100644
  263. --- a/Configuration_adv.h
  264. +++ b/Configuration_adv.h
  265. @@ -455,7 +455,7 @@
  266.  // @section lcd
  267.  
  268.  // Include a page of printer information in the LCD Main Menu
  269. -//#define LCD_INFO_MENU
  270. +#define LCD_INFO_MENU
  271.  
  272.  // Scroll a longer status message into view
  273.  //#define STATUS_MESSAGE_SCROLLING
  274. @@ -599,7 +599,7 @@
  275.   *
  276.   * Warning: Does not respect endstops!
  277.   */
  278. -//#define BABYSTEPPING
  279. +#define BABYSTEPPING
  280.  #if ENABLED(BABYSTEPPING)
  281.    //#define BABYSTEP_XY              // Also enable X/Y Babystepping. Not supported on DELTA!
  282.    #define BABYSTEP_INVERT_Z false    // Change if Z babysteps should go the other way
  283. @@ -816,11 +816,11 @@
  284.   * Requires an LCD display.
  285.   * This feature is required for the default FILAMENT_RUNOUT_SCRIPT.
  286.   */
  287. -//#define ADVANCED_PAUSE_FEATURE
  288. +#define ADVANCED_PAUSE_FEATURE
  289.  #if ENABLED(ADVANCED_PAUSE_FEATURE)
  290. -  #define PAUSE_PARK_X_POS 3                  // X position of hotend
  291. -  #define PAUSE_PARK_Y_POS 3                  // Y position of hotend
  292. -  #define PAUSE_PARK_Z_ADD 10                 // Z addition of hotend (lift)
  293. +  #define PAUSE_PARK_X_POS 0                  // X position of hotend
  294. +  #define PAUSE_PARK_Y_POS 0                  // Y position of hotend
  295. +  #define PAUSE_PARK_Z_ADD 0                  // Z addition of hotend (lift)
  296.    #define PAUSE_PARK_XY_FEEDRATE 100          // X and Y axes feedrate in mm/s (also used for delta printers Z axis)
  297.    #define PAUSE_PARK_Z_FEEDRATE 5             // Z axis feedrate in mm/s (not used for delta printers)
  298.    #define PAUSE_PARK_RETRACT_FEEDRATE 60      // Initial retract feedrate in mm/s
  299. diff --git a/Marlin.h b/Marlin.h
  300. index c341d98..b51747b 100644
  301. --- a/Marlin.h
  302. +++ b/Marlin.h
  303. @@ -414,6 +414,10 @@ extern uint8_t active_extruder;
  304.  
  305.  void calculate_volumetric_multipliers();
  306.  
  307. +#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  308. +  void init_power_off_info();
  309. +#endif
  310. +
  311.  /**
  312.   * Blocking movement and shorthand functions
  313.   */
  314. diff --git a/Marlin_main.cpp b/Marlin_main.cpp
  315. index 3ac0433..4ce1a92 100644
  316. --- a/Marlin_main.cpp
  317. +++ b/Marlin_main.cpp
  318. @@ -665,6 +665,19 @@ float cartes[XYZ] = { 0 };
  319.  #endif
  320.  
  321.  static bool send_ok[BUFSIZE];
  322. +#if ENABLED(SDSUPPORT)
  323. +  #if ENABLED(POWEROFF_SAVE_SD_FILE)
  324. +    #define SAVE_INFO_INTERVAL (1000 * 10)
  325. +    #define APPEND_CMD_COUNT 5
  326. +    // #define SAVE_EACH_CMD_MODE
  327. +    struct power_off_info_t power_off_info;
  328. +    static char power_off_commands[BUFSIZE + APPEND_CMD_COUNT][MAX_CMD_SIZE];
  329. +    int power_off_commands_count = 0;
  330. +    int power_off_type_yes = 0;
  331. +    static int power_off_commands_index = 0;
  332. +  #endif
  333. +#endif
  334. +bool drain_power_off_commands();
  335.  
  336.  #if HAS_SERVOS
  337.    Servo servo[NUM_SERVOS];
  338. @@ -1254,6 +1267,11 @@ inline void get_serial_commands() {
  339.  
  340.      if (commands_in_queue == 0) stop_buffering = false;
  341.  
  342. +    #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  343. +      /* translation: Priority reads the power-off saved command. */
  344. +      if (drain_power_off_commands()) return;
  345. +    #endif
  346. +
  347.      uint16_t sd_count = 0;
  348.      bool card_eof = card.eof();
  349.      while (commands_in_queue < BUFSIZE && !card_eof && !stop_buffering) {
  350. @@ -5943,14 +5961,17 @@ void home_all_axes() { gcode_G28(true); }
  351.  /**
  352.   * G92: Set current position to given X Y Z E
  353.   */
  354. -inline void gcode_G92() {
  355. +inline void gcode_G92()
  356. +{
  357.    bool didXYZ = false,
  358.         didE = parser.seenval('E');
  359.  
  360.    if (!didE) stepper.synchronize();
  361.  
  362. -  LOOP_XYZE(i) {
  363. -    if (parser.seenval(axis_codes[i])) {
  364. +  LOOP_XYZE(i)
  365. +  {
  366. +    if (parser.seenval(axis_codes[i]))
  367. +    {
  368.        #if IS_SCARA
  369.          current_position[i] = parser.value_axis_units((AxisEnum)i);
  370.          if (i != E_AXIS) didXYZ = true;
  371. @@ -5962,8 +5983,13 @@ inline void gcode_G92() {
  372.  
  373.          current_position[i] = v;
  374.  
  375. -        if (i != E_AXIS) {
  376. +        if (i != E_AXIS)
  377. +        {
  378.            didXYZ = true;
  379. +          if (i == Z_AXIS)
  380. +          {
  381. +            axis_known_position[Z_AXIS] = true;
  382. +          }
  383.            #if HAS_POSITION_SHIFT
  384.              position_shift[i] += v - p; // Offset the coordinate space
  385.              update_software_endstops((AxisEnum)i);
  386. @@ -6512,7 +6538,12 @@ inline void gcode_M17() {
  387.    /**
  388.     * M24: Start or Resume SD Print
  389.     */
  390. -  inline void gcode_M24() {
  391. +  inline void gcode_M24()
  392. +  {
  393. +    #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  394. +      card.removePowerOffFile();
  395. +    #endif
  396. +
  397.      #if ENABLED(PARK_HEAD_ON_PAUSE)
  398.        resume_print();
  399.      #endif
  400. @@ -7289,7 +7320,8 @@ inline void gcode_M77() { print_job_timer.stop(); }
  401.  /**
  402.   * M104: Set hot end temperature
  403.   */
  404. -inline void gcode_M104() {
  405. +inline void gcode_M104()
  406. +{
  407.    if (get_target_extruder_from_command(104)) return;
  408.    if (DEBUGGING(DRYRUN)) return;
  409.  
  410. @@ -7297,7 +7329,8 @@ inline void gcode_M104() {
  411.      if (target_extruder != active_extruder) return;
  412.    #endif
  413.  
  414. -  if (parser.seenval('S')) {
  415. +  if (parser.seenval('S'))
  416. +  {
  417.      const int16_t temp = parser.value_celsius();
  418.      thermalManager.setTargetHotend(temp, target_extruder);
  419.  
  420. @@ -7313,14 +7346,18 @@ inline void gcode_M104() {
  421.         * standby mode, for instance in a dual extruder setup, without affecting
  422.         * the running print timer.
  423.         */
  424. -      if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
  425. +      if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2)
  426. +      {
  427.          print_job_timer.stop();
  428.          LCD_MESSAGEPGM(WELCOME_MSG);
  429.        }
  430.      #endif
  431.  
  432.      if (parser.value_celsius() > thermalManager.degHotend(target_extruder))
  433. -      lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
  434. +    {
  435. +      // lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
  436. +     lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING);
  437. +    }
  438.    }
  439.  
  440.    #if ENABLED(AUTOTEMP)
  441. @@ -7506,8 +7543,8 @@ inline void gcode_M105() {
  442.    #define MIN_COOLING_SLOPE_TIME 60
  443.  #endif
  444.  
  445. -inline void gcode_M109() {
  446. -
  447. +inline void gcode_M109()
  448. +{
  449.    if (get_target_extruder_from_command(109)) return;
  450.    if (DEBUGGING(DRYRUN)) return;
  451.  
  452. @@ -7516,7 +7553,8 @@ inline void gcode_M109() {
  453.    #endif
  454.  
  455.    const bool no_wait_for_cooling = parser.seenval('S');
  456. -  if (no_wait_for_cooling || parser.seenval('R')) {
  457. +  if (no_wait_for_cooling || parser.seenval('R'))
  458. +  {
  459.      const int16_t temp = parser.value_celsius();
  460.      thermalManager.setTargetHotend(temp, target_extruder);
  461.  
  462. @@ -7531,7 +7569,8 @@ inline void gcode_M109() {
  463.         * standby mode, (e.g., in a dual extruder setup) without affecting
  464.         * the running print timer.
  465.         */
  466. -      if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
  467. +      if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2)
  468. +      {
  469.          print_job_timer.stop();
  470.          LCD_MESSAGEPGM(WELCOME_MSG);
  471.        }
  472. @@ -7539,7 +7578,11 @@ inline void gcode_M109() {
  473.          print_job_timer.start();
  474.      #endif
  475.  
  476. -    if (thermalManager.isHeatingHotend(target_extruder)) lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
  477. +    if (thermalManager.isHeatingHotend(target_extruder))
  478. +    {
  479. +      // lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
  480. +      lcd_status_printf_P(0, PSTR("Extruder %s"), MSG_HEATING);
  481. +    }
  482.    }
  483.    else return;
  484.  
  485. @@ -7570,9 +7613,11 @@ inline void gcode_M109() {
  486.      uint8_t old_blue = 0;
  487.    #endif
  488.  
  489. -  do {
  490. +  do
  491. +  {
  492.      // Target temperature might be changed during the loop
  493. -    if (target_temp != thermalManager.degTargetHotend(target_extruder)) {
  494. +    if (target_temp != thermalManager.degTargetHotend(target_extruder))
  495. +   {
  496.        wants_to_cool = thermalManager.isCoolingHotend(target_extruder);
  497.        target_temp = thermalManager.degTargetHotend(target_extruder);
  498.  
  499. @@ -7581,7 +7626,9 @@ inline void gcode_M109() {
  500.      }
  501.  
  502.      now = millis();
  503. -    if (ELAPSED(now, next_temp_ms)) { //Print temp & remaining time every 1s while waiting
  504. +    if (ELAPSED(now, next_temp_ms))
  505. +   {
  506. +     // Print temp & remaining time every 1s while waiting
  507.        next_temp_ms = now + 1000UL;
  508.        print_heaterstates();
  509.        #if TEMP_RESIDENCY_TIME > 0
  510. @@ -7601,9 +7648,11 @@ inline void gcode_M109() {
  511.  
  512.      #if ENABLED(PRINTER_EVENT_LEDS)
  513.        // Gradually change LED strip from violet to red as nozzle heats up
  514. -      if (!wants_to_cool) {
  515. +      if (!wants_to_cool)
  516. +     {
  517.          const uint8_t blue = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 255, 0);
  518. -        if (blue != old_blue) {
  519. +        if (blue != old_blue)
  520. +       {
  521.            old_blue = blue;
  522.            set_led_color(255, 0, blue
  523.            #if ENABLED(NEOPIXEL_LED)
  524. @@ -7622,11 +7671,13 @@ inline void gcode_M109() {
  525.  
  526.        const float temp_diff = FABS(target_temp - temp);
  527.  
  528. -      if (!residency_start_ms) {
  529. +      if (!residency_start_ms)
  530. +     {
  531.          // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
  532.          if (temp_diff < TEMP_WINDOW) residency_start_ms = now;
  533.        }
  534. -      else if (temp_diff > TEMP_HYSTERESIS) {
  535. +      else if (temp_diff > TEMP_HYSTERESIS)
  536. +     {
  537.          // Restart the timer whenever the temperature falls outside the hysteresis.
  538.          residency_start_ms = now;
  539.        }
  540. @@ -7634,10 +7685,12 @@ inline void gcode_M109() {
  541.      #endif
  542.  
  543.      // Prevent a wait-forever situation if R is misused i.e. M109 R0
  544. -    if (wants_to_cool) {
  545. +    if (wants_to_cool)
  546. +   {
  547.        // break after MIN_COOLING_SLOPE_TIME seconds
  548.        // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG
  549. -      if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
  550. +      if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms))
  551. +     {
  552.          if (old_temp - temp < MIN_COOLING_SLOPE_DEG) break;
  553.          next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME;
  554.          old_temp = temp;
  555. @@ -7646,7 +7699,8 @@ inline void gcode_M109() {
  556.  
  557.    } while (wait_for_heatup && TEMP_CONDITIONS);
  558.  
  559. -  if (wait_for_heatup) {
  560. +  if (wait_for_heatup)
  561. +  {
  562.      LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
  563.      #if ENABLED(PRINTER_EVENT_LEDS)
  564.        #if ENABLED(RGB_LED) || ENABLED(BLINKM) || ENABLED(PCA9632) || ENABLED(RGBW_LED)
  565. @@ -7676,12 +7730,14 @@ inline void gcode_M109() {
  566.     * M190: Sxxx Wait for bed current temp to reach target temp. Waits only when heating
  567.     *       Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
  568.     */
  569. -  inline void gcode_M190() {
  570. +  inline void gcode_M190()
  571. +  {
  572.      if (DEBUGGING(DRYRUN)) return;
  573.  
  574.      LCD_MESSAGEPGM(MSG_BED_HEATING);
  575.      const bool no_wait_for_cooling = parser.seenval('S');
  576. -    if (no_wait_for_cooling || parser.seenval('R')) {
  577. +    if (no_wait_for_cooling || parser.seenval('R'))
  578. +   {
  579.        thermalManager.setTargetBed(parser.value_celsius());
  580.        #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
  581.          if (parser.value_celsius() > BED_MINTEMP)
  582. @@ -7726,7 +7782,9 @@ inline void gcode_M109() {
  583.        }
  584.  
  585.        now = millis();
  586. -      if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
  587. +      if (ELAPSED(now, next_temp_ms))
  588. +     {
  589. +       // Print Temp Reading every 1 second while heating up.
  590.          next_temp_ms = now + 1000UL;
  591.          print_heaterstates();
  592.          #if TEMP_BED_RESIDENCY_TIME > 0
  593. @@ -7746,9 +7804,11 @@ inline void gcode_M109() {
  594.  
  595.        #if ENABLED(PRINTER_EVENT_LEDS)
  596.          // Gradually change LED strip from blue to violet as bed heats up
  597. -        if (!wants_to_cool) {
  598. +        if (!wants_to_cool)
  599. +       {
  600.            const uint8_t red = map(constrain(temp, start_temp, target_temp), start_temp, target_temp, 0, 255);
  601. -          if (red != old_red) {
  602. +          if (red != old_red)
  603. +         {
  604.              old_red = red;
  605.              set_led_color(red, 0, 255
  606.                #if ENABLED(NEOPIXEL_LED)
  607. @@ -7766,11 +7826,13 @@ inline void gcode_M109() {
  608.  
  609.          const float temp_diff = FABS(target_temp - temp);
  610.  
  611. -        if (!residency_start_ms) {
  612. +        if (!residency_start_ms)
  613. +       {
  614.            // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
  615.            if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = now;
  616.          }
  617. -        else if (temp_diff > TEMP_BED_HYSTERESIS) {
  618. +        else if (temp_diff > TEMP_BED_HYSTERESIS)
  619. +       {
  620.            // Restart the timer whenever the temperature falls outside the hysteresis.
  621.            residency_start_ms = now;
  622.          }
  623. @@ -7778,10 +7840,12 @@ inline void gcode_M109() {
  624.        #endif // TEMP_BED_RESIDENCY_TIME > 0
  625.  
  626.        // Prevent a wait-forever situation if R is misused i.e. M190 R0
  627. -      if (wants_to_cool) {
  628. +      if (wants_to_cool)
  629. +     {
  630.          // Break after MIN_COOLING_SLOPE_TIME_BED seconds
  631.          // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_BED
  632. -        if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
  633. +        if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms))
  634. +       {
  635.            if (old_temp - temp < MIN_COOLING_SLOPE_DEG_BED) break;
  636.            next_cool_check_ms = now + 1000UL * MIN_COOLING_SLOPE_TIME_BED;
  637.            old_temp = temp;
  638. @@ -8002,6 +8066,10 @@ inline void gcode_M81() {
  639.        ZERO(paused_fanSpeeds);
  640.      #endif
  641.    #endif
  642. +  #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  643. +    card.removePowerOffFile();
  644. +    power_off_commands_count = 0;
  645. +  #endif
  646.  
  647.    safe_delay(1000); // Wait 1 second before switching off
  648.  
  649. @@ -13366,6 +13434,232 @@ void stop() {
  650.    }
  651.  }
  652.  
  653. +/**
  654. + * Add about power off init information and confirm power off continue print
  655. + */
  656. +#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  657. +void init_power_off_info ()
  658. +{
  659. +   int i = 0;
  660. +   // if (power_off_commands_count > 0) return;
  661. +   memset(&power_off_info, 0, sizeof(power_off_info));
  662. +   memset(power_off_commands, 0, sizeof(power_off_commands));
  663. +   if (!card.cardOK)
  664. +   {
  665. +       card.initsd();
  666. +   }
  667. +   if (card.cardOK)
  668. +   {
  669. +       SERIAL_PROTOCOLLN("Init power off infomation.");
  670. +       SERIAL_PROTOCOLLN("size: ");
  671. +       SERIAL_PROTOCOLLN(sizeof(power_off_info));
  672. +       strncpy_P(power_off_info.power_off_filename, PSTR("bin"), sizeof(power_off_info.power_off_filename) - 1);
  673. +       if (card.existPowerOffFile(power_off_info.power_off_filename))
  674. +       {
  675. +           card.openPowerOffFile(power_off_info.power_off_filename, O_READ);
  676. +           card.getPowerOffInfo(&power_off_info, sizeof(power_off_info));
  677. +           card.closePowerOffFile();
  678. +           // card.removePowerOffFile();  
  679. +           SERIAL_PROTOCOLLN("init valid: ");
  680. +           SERIAL_PROTOCOLLN((unsigned long)power_off_info.valid_head);
  681. +           SERIAL_PROTOCOLLN((unsigned long)power_off_info.valid_foot);
  682. +           if ((power_off_info.valid_head != 0) && (power_off_info.valid_head == power_off_info.valid_foot))
  683. +           {
  684. +               /* --------------------------------------------------------------------- */
  685. +               enable_Z();
  686. +               SERIAL_PROTOCOLLN("current_position(X,Y,Z,E,F,T1..T4,B): ");
  687. +               for (i = 0; i < NUM_AXIS; i++)
  688. +               {
  689. +                   // current_position[i] = power_off_info.current_position[i];
  690. +                   SERIAL_PROTOCOLLN(power_off_info.current_position[i]);
  691. +               }
  692. +               feedrate_mm_s = power_off_info.feedrate;
  693. +               SERIAL_PROTOCOLLN(power_off_info.feedrate);
  694. +               for (i = 0; i < 4; i++)
  695. +               {
  696. +                   // target_temperature[i] = power_off_info.target_temperature[i];
  697. +                   SERIAL_PROTOCOLLN(power_off_info.target_temperature[i]);
  698. +               }
  699. +               SERIAL_PROTOCOLLN(power_off_info.target_temperature_bed);
  700. +
  701. +               // SERIAL_PROTOCOLLN(power_off_info.saved_extruder);
  702. +               // SERIAL_PROTOCOLLN("power off info T number");
  703. +               /* --------------------------------------------------------------------- */
  704. +               SERIAL_PROTOCOLLN("cmd_queue(R,W,C,Q): ");
  705. +               // cmd_queue_index_r = power_off_info.cmd_queue_index_r;
  706. +               SERIAL_PROTOCOLLN(power_off_info.cmd_queue_index_r);
  707. +               // cmd_queue_index_w = power_off_info.cmd_queue_index_w;
  708. +               SERIAL_PROTOCOLLN(power_off_info.cmd_queue_index_w);
  709. +               // commands_in_queue = power_off_info.commands_in_queue;
  710. +               SERIAL_PROTOCOLLN(power_off_info.commands_in_queue);
  711. +               // memcpy(command_queue, power_off_info.command_queue, sizeof(command_queue));
  712. +               for (i = 0; i < BUFSIZE; i++)
  713. +               {
  714. +                   SERIAL_PROTOCOLLN(power_off_info.command_queue[i]);
  715. +               }
  716. +               char str_X[16];
  717. +               char str_Y[16];
  718. +               char str_Z[16];
  719. +               char str_E[16];
  720. +               char str_Z_up[16];
  721. +               memset(str_Z, 0, sizeof(str_X));
  722. +               memset(str_Z, 0, sizeof(str_Y));
  723. +               memset(str_Z, 0, sizeof(str_Z));
  724. +               memset(str_E, 0, sizeof(str_E));
  725. +               memset(str_Z_up, 0, sizeof(str_Z_up));
  726. +               dtostrf(power_off_info.current_position[0], 1, 3, str_X);
  727. +               dtostrf(power_off_info.current_position[1], 1, 3, str_Y);
  728. +               dtostrf(power_off_info.current_position[2], 1, 3, str_Z);
  729. +               dtostrf(power_off_info.current_position[2] + 5, 1, 3, str_Z_up);
  730. +               #if ENABLED(SAVE_EACH_CMD_MODE)
  731. +               dtostrf(power_off_info.current_position[3] - 5, 1, 3, str_E);
  732. +               #else
  733. +               dtostrf(power_off_info.current_position[3], 1, 3, str_E);
  734. +               #endif
  735. +              
  736. +               // sprintf_P(power_off_commands[0], PSTR("G0 Z%s"), tmp);
  737. +               sprintf_P(power_off_commands[0], PSTR("G92 Z%s E%s"), str_Z, str_E);
  738. +               enqueue_and_echo_command(power_off_commands[0]);
  739. +               sprintf_P(power_off_commands[1], PSTR("G0 Z%s"), str_Z_up);
  740. +               enqueue_and_echo_command(power_off_commands[1]);
  741. +               sprintf_P(power_off_commands[2], PSTR("G28 X0 Y0"));
  742. +               enqueue_and_echo_command(power_off_commands[2]);
  743. +               sprintf_P(power_off_commands[3], PSTR("G0 Z%s"), str_Z);
  744. +               enqueue_and_echo_command(power_off_commands[3]);
  745. +               sprintf_P(power_off_commands[4], PSTR("M117 Printing..."));
  746. +               enqueue_and_echo_command(power_off_commands[4]);
  747. +
  748. +               power_off_commands_count = APPEND_CMD_COUNT;
  749. +               i = APPEND_CMD_COUNT;
  750. +               while (power_off_info.commands_in_queue > 0)
  751. +               {
  752. +                   strcpy(power_off_commands[i++], power_off_info.command_queue[power_off_info.cmd_queue_index_r]);
  753. +                   power_off_commands_count++;
  754. +                   power_off_info.commands_in_queue--;
  755. +                   power_off_info.cmd_queue_index_r = (power_off_info.cmd_queue_index_r + 1) % BUFSIZE;
  756. +               }
  757. +               for (i = 0; i < power_off_commands_count; i++)
  758. +               {
  759. +                   SERIAL_PROTOCOLLN(power_off_commands[i]);
  760. +               }
  761. +               /* --------------------------------------------------------------------- */
  762. +               SERIAL_PROTOCOLLN("sd file(start_time,file_name,sd_pos): ");
  763. +               SERIAL_PROTOCOLLN(power_off_info.print_job_start_ms);
  764. +               SERIAL_PROTOCOLLN(power_off_info.sd_filename);
  765. +               SERIAL_PROTOCOLLN(power_off_info.sdpos);
  766. +               previous_cmd_ms = power_off_info.print_job_start_ms;
  767. +               card.openFile(power_off_info.sd_filename, true);
  768. +               card.setIndex(power_off_info.sdpos);
  769. +               /* --------------------------------------------------------------------- */
  770. +           }          
  771. +           else
  772. +           {
  773. +               if ((power_off_info.valid_head != 0) && (power_off_info.valid_head != power_off_info.valid_foot))
  774. +               {
  775. +                   enqueue_and_echo_commands_P(PSTR("M117 INVALID DATA."));
  776. +               }
  777. +               memset(&power_off_info, 0, sizeof(power_off_info));
  778. +               strncpy_P(power_off_info.power_off_filename, PSTR("bin"), sizeof(power_off_info.power_off_filename) - 1);
  779. +           }
  780. +       }
  781. +   }
  782. +}
  783. +
  784. +bool drain_power_off_commands()
  785. +{
  786. +   if (power_off_commands_count > 0)
  787. +   {
  788. +       if(enqueue_and_echo_command(power_off_commands[power_off_commands_index]))
  789. +       {
  790. +           power_off_commands_index++;
  791. +           power_off_commands_count--;
  792. +       }
  793. +       return true;
  794. +   }
  795. +   else
  796. +   {
  797. +       return false;
  798. +   }
  799. +}
  800. +
  801. +void save_power_off_info ()
  802. +{
  803. +   int i = 0;
  804. +   // static millis_t pre_time = millis();
  805. +   // static millis_t cur_time = millis();
  806. +   if (card.cardOK && card.sdprinting)
  807. +   {
  808. +       // cur_time = millis();
  809. +       if (
  810. +       #if ENABLED(SAVE_EACH_CMD_MODE)
  811. +           (true)
  812. +       #else
  813. +           ((current_position[2] > 0) && (power_off_info.saved_z != current_position[2]))
  814. +       #endif
  815. +           // || ((cur_time - pre_time) > SAVE_INFO_INTERVAL)
  816. +       )
  817. +       {
  818. +           // pre_time = cur_time;
  819. +           // SERIAL_PROTOCOLLN("Z : ");
  820. +           // SERIAL_PROTOCOLLN(current_position[2]);
  821. +           // SERIAL_PROTOCOLLN(power_off_info.saved_z);
  822. +           power_off_info.valid_head = random(1,256);
  823. +           power_off_info.valid_foot = power_off_info.valid_head;
  824. +           // SERIAL_PROTOCOLLN("save valid: ");
  825. +           // SERIAL_PROTOCOLLN((unsigned long)power_off_info.valid_head);
  826. +           // SERIAL_PROTOCOLLN((unsigned long)power_off_info.valid_foot);
  827. +           /* --------------------------------------------------------------------- */
  828. +           // SERIAL_PROTOCOLLN("current_position(X,Y,Z,SZ,E,F,T1..T4,B): ");
  829. +           for (i = 0; i < NUM_AXIS; i++)
  830. +           {
  831. +               power_off_info.current_position[i] = current_position[i];
  832. +               // SERIAL_PROTOCOLLN(current_position[i]);
  833. +           }
  834. +           power_off_info.saved_z = current_position[2];
  835. +           // SERIAL_PROTOCOLLN(power_off_info.saved_z);
  836. +           power_off_info.feedrate = feedrate_mm_s;
  837. +           // SERIAL_PROTOCOLLN(power_off_info.feedrate);
  838. +           for (i = 0; i < 4; i++)
  839. +           {
  840. +               power_off_info.target_temperature[i] = thermalManager.degTargetHotend(i);
  841. +               // SERIAL_PROTOCOLLN(thermalManager.setTargetHotend[i]);
  842. +           }
  843. +           power_off_info.target_temperature_bed = thermalManager.degTargetBed();
  844. +           // power_off_info.saved_extruder = active_extruder;
  845. +           // SERIAL_PROTOCOLLN(power_off_info.target_temperature_bed);
  846. +           /* --------------------------------------------------------------------- */
  847. +           // SERIAL_PROTOCOLLN("cmd_queue(R,W,C,Q): ");
  848. +           power_off_info.cmd_queue_index_r = cmd_queue_index_r;
  849. +           // SERIAL_PROTOCOLLN(power_off_info.cmd_queue_index_r);
  850. +           power_off_info.cmd_queue_index_w = cmd_queue_index_w;
  851. +           // SERIAL_PROTOCOLLN(power_off_info.cmd_queue_index_w);
  852. +           power_off_info.commands_in_queue = commands_in_queue;
  853. +           // SERIAL_PROTOCOLLN(power_off_info.commands_in_queue);
  854. +           memcpy(power_off_info.command_queue, command_queue, sizeof(power_off_info.command_queue));
  855. +           // for (i = 0; i < BUFSIZE; i++)
  856. +           // {
  857. +           //  SERIAL_PROTOCOLLN(power_off_info.command_queue[i]);
  858. +           // }
  859. +           /* --------------------------------------------------------------------- */
  860. +           // SERIAL_PROTOCOLLN("sd file(start_time,file_name,sd_pos): ");
  861. +           power_off_info.print_job_start_ms = previous_cmd_ms;
  862. +           // SERIAL_PROTOCOLLN(power_off_info.print_job_start_ms);
  863. +           // strcpy(power_off_info.sd_filename,
  864. +           card.getAbsFilename(power_off_info.sd_filename);
  865. +           // SERIAL_PROTOCOLLN(power_off_info.sd_filename);
  866. +           power_off_info.sdpos = card.getIndex();
  867. +           // SERIAL_PROTOCOLLN(power_off_info.sdpos);
  868. +           /* --------------------------------------------------------------------- */
  869. +           card.openPowerOffFile(power_off_info.power_off_filename, O_CREAT | O_WRITE | O_TRUNC | O_SYNC);
  870. +           if (card.savePowerOffInfo(&power_off_info, sizeof(power_off_info)) == -1)
  871. +           {
  872. +               SERIAL_PROTOCOLLN("Write power off file failed.");
  873. +           }
  874. +       }
  875. +   }
  876. +}
  877. +#endif
  878. +
  879.  /**
  880.   * Marlin entry-point: Set up before the program loop
  881.   *  - Set up the kill pin, filament runout, power hold
  882. @@ -13619,6 +13913,11 @@ void setup() {
  883.      delay(1000);
  884.      WRITE(LCD_PINS_RS, HIGH);
  885.    #endif
  886. +
  887. +  // init power off information
  888. +  #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  889. +   init_power_off_info();
  890. +  #endif
  891.  }
  892.  
  893.  /**
  894. @@ -13631,20 +13930,22 @@ void setup() {
  895.   *  - Call endstop manager
  896.   *  - Call LCD update
  897.   */
  898. -void loop() {
  899. +void loop()
  900. +{
  901.    if (commands_in_queue < BUFSIZE) get_available_commands();
  902.  
  903.    #if ENABLED(SDSUPPORT)
  904.      card.checkautostart(false);
  905.    #endif
  906.  
  907. -  if (commands_in_queue) {
  908. -
  909. +  if (commands_in_queue)
  910. +  {
  911.      #if ENABLED(SDSUPPORT)
  912. -
  913. -      if (card.saving) {
  914. +      if (card.saving)
  915. +      {
  916.          char* command = command_queue[cmd_queue_index_r];
  917. -        if (strstr_P(command, PSTR("M29"))) {
  918. +        if (strstr_P(command, PSTR("M29")))
  919. +        {
  920.            // M29 closes the file
  921.            card.closefile();
  922.            SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
  923. @@ -13659,7 +13960,8 @@ void loop() {
  924.  
  925.            ok_to_send();
  926.          }
  927. -        else {
  928. +        else
  929. +        {
  930.            // Write the string from the read buffer to SD
  931.            card.write_command(command);
  932.            if (card.logging)
  933. @@ -13669,7 +13971,12 @@ void loop() {
  934.          }
  935.        }
  936.        else
  937. +      {
  938.          process_next_command();
  939. +        #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  940. +          save_power_off_info();
  941. +        #endif
  942. +      }
  943.  
  944.      #else
  945.  
  946. @@ -13678,9 +13985,13 @@ void loop() {
  947.      #endif // SDSUPPORT
  948.  
  949.      // The queue may be reset by a command handler or by code invoked by idle() within a handler
  950. -    if (commands_in_queue) {
  951. +    if (commands_in_queue)
  952. +    {
  953.        --commands_in_queue;
  954. -      if (++cmd_queue_index_r >= BUFSIZE) cmd_queue_index_r = 0;
  955. +      if (++cmd_queue_index_r >= BUFSIZE)
  956. +      {
  957. +        cmd_queue_index_r = 0;
  958. +      }
  959.      }
  960.    }
  961.    endstops.report_state();
  962. diff --git a/Version.h b/Version.h
  963. index 3039da5..71521bd 100644
  964. --- a/Version.h
  965. +++ b/Version.h
  966. @@ -35,20 +35,20 @@
  967.    /**
  968.     * Marlin release version identifier
  969.     */
  970. -  #define SHORT_BUILD_VERSION "1.1.6"
  971. +  #define SHORT_BUILD_VERSION "Marlin 1.1.6"
  972.  
  973.    /**
  974.     * Verbose version identifier which should contain a reference to the location
  975.     * from where the binary was downloaded or the source code was compiled.
  976.     */
  977. -  #define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (Github)"
  978. +  #define DETAILED_BUILD_VERSION "Creality 3D"
  979.  
  980.    /**
  981.     * The STRING_DISTRIBUTION_DATE represents when the binary file was built,
  982.     * here we define this default string as the date where the latest release
  983.     * version was tagged.
  984.     */
  985. -  #define STRING_DISTRIBUTION_DATE "2017-10-10 12:00"
  986. +  #define STRING_DISTRIBUTION_DATE "2018-11-28"
  987.  
  988.    /**
  989.     * Required minimum Configuration.h and Configuration_adv.h file versions.
  990. @@ -89,6 +89,6 @@
  991.     * The WEBSITE_URL is the location where users can get more information such as
  992.     * documentation about a specific Marlin release.
  993.     */
  994. -  #define WEBSITE_URL "http://marlinfw.org"
  995. +  #define WEBSITE_URL "www.creality3d.cn"
  996.  
  997.  #endif // USE_AUTOMATIC_VERSIONING
  998. diff --git a/cardreader.cpp b/cardreader.cpp
  999. index 89147d9..5871170 100644
  1000. --- a/cardreader.cpp
  1001. +++ b/cardreader.cpp
  1002. @@ -310,6 +310,64 @@ void CardReader::openLogFile(char* name) {
  1003.    openFile(name, false);
  1004.  }
  1005.  
  1006. +#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1007. +  void CardReader::openPowerOffFile(char* name, uint8_t oflag)
  1008. +  {
  1009. +    if (!cardOK) return;
  1010. +    if (powerOffFile.isOpen()) return;
  1011. +    if (!powerOffFile.open(&root, name, oflag))
  1012. +    {
  1013. +      SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
  1014. +      SERIAL_PROTOCOL(name);
  1015. +      SERIAL_PROTOCOLPGM(".\n");
  1016. +    }
  1017. +    else
  1018. +    {
  1019. +      SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
  1020. +      SERIAL_PROTOCOLLN(name);
  1021. +    }
  1022. +  }
  1023. +
  1024. +  void CardReader::closePowerOffFile()
  1025. +  {
  1026. +    powerOffFile.close();
  1027. +  }
  1028. +
  1029. +  bool CardReader::existPowerOffFile(char* name)
  1030. +  {
  1031. +    bool ret = powerOffFile.open(&root, name, O_READ);
  1032. +    // if (ret)
  1033. +    // {
  1034. +    // powerOffFile.close();
  1035. +    // }
  1036. +   return ret;
  1037. +  }
  1038. +
  1039. +  int16_t CardReader::savePowerOffInfo(const void* data, uint16_t size)
  1040. +  {
  1041. +    powerOffFile.seekSet(0);
  1042. +    return powerOffFile.write(data, size);
  1043. +  }
  1044. +
  1045. +  int16_t CardReader::getPowerOffInfo(void* data, uint16_t size)
  1046. +  {
  1047. +    return powerOffFile.read(data, size);
  1048. +  }
  1049. +
  1050. +  void CardReader::removePowerOffFile()
  1051. +  {
  1052. +    if (powerOffFile.remove(&root, power_off_info.power_off_filename))
  1053. +    {
  1054. +      SERIAL_PROTOCOLPGM("File(bin) deleted");
  1055. +    }
  1056. +    else
  1057. +    {
  1058. +    SERIAL_PROTOCOLPGM("Deletion(bin) failed");
  1059. +    }
  1060. +    SERIAL_PROTOCOLPGM(".\n");
  1061. +  }
  1062. +#endif
  1063. +
  1064.  void CardReader::getAbsFilename(char *t) {
  1065.    uint8_t cnt = 0;
  1066.    *t = '/'; t++; cnt++;
  1067. @@ -860,17 +918,32 @@ void CardReader::updir() {
  1068.  
  1069.  #endif // SDCARD_SORT_ALPHA
  1070.  
  1071. -void CardReader::printingHasFinished() {
  1072. +void CardReader::printingHasFinished()
  1073. +{
  1074.    stepper.synchronize();
  1075.    file.close();
  1076. -  if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
  1077. +  if (file_subcall_ctr > 0)
  1078. +  {
  1079. +    // Heading up to a parent file that called current as a procedure.
  1080.      file_subcall_ctr--;
  1081.      openFile(proc_filenames[file_subcall_ctr], true, true);
  1082.      setIndex(filespos[file_subcall_ctr]);
  1083.      startFileprint();
  1084.    }
  1085. -  else {
  1086. +  else
  1087. +  {
  1088.      sdprinting = false;
  1089. +    #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1090. +      openPowerOffFile(power_off_info.power_off_filename, O_CREAT | O_WRITE | O_TRUNC | O_SYNC);
  1091. +      power_off_info.valid_head = 0;
  1092. +      power_off_info.valid_foot = 0;
  1093. +      if (savePowerOffInfo(&power_off_info, sizeof(power_off_info)) == -1)
  1094. +      {
  1095. +        SERIAL_PROTOCOLLN("Stop to Write power off file failed.");
  1096. +      }
  1097. +      closePowerOffFile();
  1098. +      power_off_commands_count = 0;
  1099. +    #endif
  1100.      if (SD_FINISHED_STEPPERRELEASE)
  1101.        enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
  1102.      print_job_timer.stop();
  1103. diff --git a/cardreader.h b/cardreader.h
  1104. index 75674a8..d276f12 100644
  1105. --- a/cardreader.h
  1106. +++ b/cardreader.h
  1107. @@ -46,6 +46,14 @@ public:
  1108.    void checkautostart(bool x);
  1109.    void openFile(char* name, bool read, bool push_current=false);
  1110.    void openLogFile(char* name);
  1111. +  #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1112. +    void openPowerOffFile(char* name, uint8_t oflag);
  1113. +    void closePowerOffFile();
  1114. +    bool existPowerOffFile(char* name);
  1115. +    int16_t savePowerOffInfo(const void* data, uint16_t size);
  1116. +    int16_t getPowerOffInfo(void* data, uint16_t size);
  1117. +    void removePowerOffFile();
  1118. +  #endif
  1119.    void removeFile(char* name);
  1120.    void closefile(bool store_location=false);
  1121.    void release();
  1122. @@ -84,6 +92,8 @@ public:
  1123.    FORCE_INLINE bool eof() { return sdpos >= filesize; }
  1124.    FORCE_INLINE int16_t get() { sdpos = file.curPosition(); return (int16_t)file.read(); }
  1125.    FORCE_INLINE void setIndex(long index) { sdpos = index; file.seekSet(index); }
  1126. +  FORCE_INLINE uint32_t getIndex() { return sdpos; }
  1127. +  // FORCE_INLINE char* getCurrentPrintFileName() { return filenames[file_subcall_ctr]; }
  1128.    FORCE_INLINE uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
  1129.    FORCE_INLINE char* getWorkDirName() { workDir.getFilename(filename); return filename; }
  1130.  
  1131. @@ -142,6 +152,9 @@ private:
  1132.    Sd2Card card;
  1133.    SdVolume volume;
  1134.    SdFile file;
  1135. +  #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1136. +    SdFile powerOffFile;
  1137. +  #endif
  1138.  
  1139.    #define SD_PROCEDURE_DEPTH 1
  1140.    #define MAXPATHNAMELENGTH (FILENAME_LENGTH*MAX_DIR_DEPTH + MAX_DIR_DEPTH + 1)
  1141. @@ -165,6 +178,38 @@ private:
  1142.  };
  1143.  
  1144.  extern CardReader card;
  1145. +#if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1146. +struct power_off_info_t
  1147. +{
  1148. +  /* header (1B + 7B = 8B) */
  1149. +  uint8_t valid_head;
  1150. +  // uint8_t reserved1[8-1];
  1151. +  /* Gcode related information. (44B + 20B = 64B) */
  1152. +  float current_position[NUM_AXIS];
  1153. +  float feedrate;
  1154. +  float saved_z;
  1155. +  int target_temperature[4];
  1156. +  int target_temperature_bed;
  1157. +  // uint8_t reserved2[64-44];
  1158. +  /* print queue related information. (396B + 116B = 512B) */
  1159. +  int cmd_queue_index_r;
  1160. +  int cmd_queue_index_w;
  1161. +  int commands_in_queue;
  1162. +  char command_queue[BUFSIZE][MAX_CMD_SIZE];
  1163. +  // uint8_t reserved3[512-396];
  1164. +  /* SD card related information. (165B + 91B = 256B)*/
  1165. +  uint32_t sdpos;
  1166. +  millis_t print_job_start_ms;
  1167. +  char sd_filename[MAXPATHNAMELENGTH];
  1168. +  char power_off_filename[16];
  1169. +  // uint8_t reserved4[256-166];
  1170. +  uint8_t valid_foot;
  1171. +};
  1172. +
  1173. +extern struct power_off_info_t power_off_info;
  1174. +extern int power_off_commands_count;
  1175. +extern int power_off_type_yes;
  1176. +#endif
  1177.  
  1178.  #define IS_SD_PRINTING (card.sdprinting)
  1179.  #define IS_SD_FILE_OPEN (card.isFileOpen())
  1180. diff --git a/configuration_store.cpp b/configuration_store.cpp
  1181. index 4fa9db9..955d54a 100644
  1182. --- a/configuration_store.cpp
  1183. +++ b/configuration_store.cpp
  1184. @@ -545,7 +545,8 @@ void MarlinSettings::postprocess() {
  1185.      EEPROM_WRITE(volumetric_enabled);
  1186.  
  1187.      // Save filament sizes
  1188. -    for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  1189. +    for (uint8_t q = 0; q < MAX_EXTRUDERS; q++)
  1190. +   {
  1191.        if (q < COUNT(filament_size)) dummy = filament_size[q];
  1192.        EEPROM_WRITE(dummy);
  1193.      }
  1194. @@ -930,7 +931,8 @@ void MarlinSettings::postprocess() {
  1195.  
  1196.        EEPROM_READ(volumetric_enabled);
  1197.  
  1198. -      for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
  1199. +      for (uint8_t q = 0; q < MAX_EXTRUDERS; q++)
  1200. +     {
  1201.          EEPROM_READ(dummy);
  1202.          if (q < COUNT(filament_size)) filament_size[q] = dummy;
  1203.        }
  1204. diff --git a/dogm_bitmaps.h b/dogm_bitmaps.h
  1205. index 9a77ff7..ff11c54 100644
  1206. --- a/dogm_bitmaps.h
  1207. +++ b/dogm_bitmaps.h
  1208. @@ -32,16 +32,17 @@
  1209.   * Please note that using the high-res version takes 402Bytes of PROGMEM.
  1210.   */
  1211.  
  1212. -//#define START_BMPHIGH
  1213. +#define START_BMPHIGH
  1214.  
  1215.  #if ENABLED(SHOW_BOOTSCREEN)
  1216.    #if ENABLED(START_BMPHIGH)
  1217. -    #define START_BMPWIDTH      112
  1218. -    #define START_BMPHEIGHT      38
  1219. -    #define START_BMPBYTEWIDTH   14
  1220. -    #define START_BMPBYTES      532 // START_BMPWIDTH * START_BMPHEIGHT / 8
  1221. +    #define START_BMPWIDTH      128
  1222. +    #define START_BMPHEIGHT      64
  1223. +    #define START_BMPBYTEWIDTH   16
  1224. +    #define START_BMPBYTES     1024 // START_BMPWIDTH * START_BMPHEIGHT / 8
  1225.  
  1226.      const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
  1227. +      /*
  1228.        0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  1229.        0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  1230.        0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF,
  1231. @@ -79,14 +80,121 @@
  1232.        0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C,
  1233.        0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78,
  1234.        0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0,
  1235. -      0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80 };
  1236. +      0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80
  1237. +      */
  1238. +  
  1239. +      // Creality 3D
  1240. +      /*
  1241. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1242. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
  1243. +      0x08,0x08,0x00,0x00,0x00,0x04,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x08,0x08,
  1244. +      0xF8,0x00,0x00,0x04,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x08,0x08,0x88,0x3F,
  1245. +      0xFE,0x08,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x48,0x7E,0x88,0x00,0x00,0x09,
  1246. +      0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x42,0x48,0x08,0xF8,0x00,0x00,0x11,0x44,0x00,
  1247. +      0x00,0x00,0x00,0x00,0x00,0x81,0x48,0x18,0x88,0x00,0x00,0x3E,0xC4,0x00,0x00,0x00,
  1248. +      0x00,0x00,0x01,0x7C,0x48,0x1C,0xF8,0x00,0x00,0x05,0x7F,0x00,0x00,0x00,0x00,0x00,
  1249. +      0x00,0x44,0x48,0x2A,0x88,0x1F,0xFC,0x08,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x44,
  1250. +      0x48,0x48,0x88,0x00,0x00,0x10,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x48,0x08,
  1251. +      0xF8,0x00,0x00,0x3F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x48,0x01,0x00,0x00,
  1252. +      0x00,0x10,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x48,0x08,0x84,0x00,0x00,0x00,
  1253. +      0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x08,0x48,0x92,0x00,0x00,0x07,0x44,0x00,
  1254. +      0x00,0x00,0x00,0x00,0x00,0x41,0x08,0x48,0x12,0x7F,0xFF,0x38,0x7F,0x80,0x00,0x00,
  1255. +      0x00,0x00,0x00,0x3F,0x28,0x87,0xF0,0x00,0x00,0x10,0x40,0x00,0x00,0x00,0x00,0x00,
  1256. +      0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1257. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1258. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1259. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1260. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1261. +      0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x07,0x01,0x80,0x00,0x00,0x00,0x3C,0x7E,0x00,
  1262. +      0x00,0x42,0x00,0x00,0x00,0x01,0x01,0x80,0x80,0x00,0x00,0x42,0x21,0x00,0x00,0x42,
  1263. +      0x00,0x00,0x00,0x01,0x00,0x00,0x80,0x00,0x00,0x42,0x20,0x80,0x00,0x80,0x00,0x00,
  1264. +      0x00,0x01,0x00,0x00,0x80,0x00,0x00,0x04,0x20,0x80,0x00,0x80,0xEE,0x1E,0x0F,0x01,
  1265. +      0x03,0x83,0xE1,0xDC,0x00,0x18,0x20,0x80,0x00,0x80,0x32,0x21,0x10,0x81,0x00,0x80,
  1266. +      0x80,0x88,0x00,0x04,0x20,0x80,0x00,0x80,0x20,0x3F,0x07,0x81,0x00,0x80,0x80,0x90,
  1267. +      0x00,0x02,0x20,0x80,0x00,0x80,0x20,0x20,0x08,0x81,0x00,0x80,0x80,0x50,0x00,0x02,
  1268. +      0x20,0x80,0x00,0x82,0x20,0x20,0x10,0x81,0x00,0x80,0x80,0x50,0x00,0x42,0x20,0x80,
  1269. +      0x00,0x44,0x20,0x21,0x10,0x81,0x00,0x80,0x90,0x20,0x00,0x42,0x21,0x00,0x00,0x38,
  1270. +      0xF8,0x1E,0x0F,0xC7,0xC3,0xE0,0xE0,0x20,0x00,0x3C,0x7E,0x00,0x00,0x00,0x00,0x00,
  1271. +      0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1272. +      0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1273. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  1274. +      */
  1275. +
  1276. +      // ENDER
  1277. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1278. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1279. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1280. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1281. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1282. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1283. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1284. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE3,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1285. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xCF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1286. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0xE1,0xCF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1287. +      0xFF,0xFF,0xFF,0xFF,0xFE,0x78,0x00,0x00,0x03,0xDD,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1288. +      0xFF,0xFF,0xFF,0xFE,0xFF,0x80,0x7E,0x00,0x01,0xEE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1289. +      0xFF,0xFF,0xFF,0xFE,0x7D,0xCF,0xFC,0x00,0x00,0xF7,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1290. +      0xFF,0xFF,0xFF,0xFF,0x8E,0x06,0x00,0x00,0x00,0x7B,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1291. +      0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x7D,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1292. +      0xFF,0xFF,0xFF,0xFF,0xFC,0x01,0xFE,0x00,0x00,0x3E,0xE7,0xFF,0xFF,0xFF,0xFF,0xFF,
  1293. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x03,0x1F,0x73,0xFF,0xFF,0xFF,0xFF,0xFF,
  1294. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x01,0x8F,0x81,0xFF,0xFF,0xFF,0xFF,0xFF,
  1295. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x83,0xF9,0xFF,0xFF,0xFF,0xFF,0xFF,
  1296. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xFC,0x00,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,
  1297. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x0F,0xFF,0xC0,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,
  1298. +      0xFF,0xFF,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xC0,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,
  1299. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF9,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,
  1300. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x07,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,
  1301. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x07,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,
  1302. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x07,0xF1,0xFF,0xFF,0xFF,0xFF,0xFF,
  1303. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x07,0xF9,0xFF,0xFF,0xFF,0xFF,0xFF,
  1304. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0xF9,0xFF,0xFF,0xFF,0xFF,0xFF,
  1305. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x83,0xF9,0xFF,0xFF,0xFF,0xFF,0xFF,
  1306. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC3,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1307. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1308. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1309. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFB,0xF8,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1310. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF9,0xF8,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1311. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7E,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1312. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1313. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1314. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1315. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1316. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1317. +      0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x7F,0xFF,0xFF,0xF8,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1318. +      0xFF,0xFF,0xFF,0xFF,0x80,0x00,0x7F,0xFF,0xFF,0xE0,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1319. +      0xFF,0xFF,0xFF,0xFF,0xC3,0xFC,0xFF,0xFF,0xFF,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1320. +      0xFF,0xFF,0xFF,0xFF,0xC3,0xFC,0xFF,0xFF,0xFF,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1321. +      0xFF,0xFF,0xFF,0xFF,0x87,0xFD,0xFF,0xFF,0xFF,0xF1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1322. +      0xFF,0xFF,0xFF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF,0xF1,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1323. +      0xFF,0xFF,0xFF,0xFF,0x0F,0xE7,0xF3,0x0F,0xFC,0x23,0xFC,0x3F,0xFF,0xFF,0xFF,0xFF,
  1324. +      0xFF,0xFF,0xFF,0xFF,0x0F,0xEF,0x80,0x07,0xF0,0x03,0xF0,0x1E,0x00,0x7F,0xFF,0xFF,
  1325. +      0xFF,0xFF,0xFF,0xFE,0x1F,0xCF,0x81,0x87,0xC7,0x87,0xC7,0x0C,0x00,0x7F,0xFF,0xFF,
  1326. +      0xFF,0xFF,0xFF,0xFE,0x00,0x1F,0xC7,0xC7,0x8F,0xC7,0x9F,0x0F,0x0C,0xFF,0xFF,0xFF,
  1327. +      0xFF,0xFF,0xFF,0xFE,0x00,0x1F,0x87,0x8F,0x1F,0x8F,0x1F,0x0F,0x1F,0xFF,0xFF,0xFF,
  1328. +      0xFF,0xFF,0xFF,0xFC,0x3F,0x9F,0x8F,0x8F,0x1F,0x8E,0x00,0x1E,0x3F,0xFF,0xFF,0xFF,
  1329. +      0xFF,0xFF,0xFF,0xFC,0x7F,0x3F,0x0F,0x1E,0x3F,0x1E,0x3F,0xFE,0x3F,0xFF,0xFF,0xFF,
  1330. +      0xFF,0xFF,0xFF,0xF8,0x7F,0xFF,0x1F,0x1C,0x3F,0x1C,0x7F,0xFC,0x7F,0xFF,0xFF,0xFF,
  1331. +      0xFF,0xFF,0xFF,0xF8,0xFF,0xFF,0x1E,0x1C,0x7E,0x1C,0x7F,0xFC,0x7F,0xFF,0xFF,0xFF,
  1332. +      0xFF,0xFF,0xFF,0xF0,0xFF,0xCE,0x3E,0x3C,0x7E,0x3C,0x7F,0xB8,0xFF,0xFF,0xFF,0xFF,
  1333. +      0xFF,0xFF,0xFF,0xF0,0xFF,0x9E,0x3C,0x38,0x7C,0x38,0x7E,0x78,0xFF,0xFF,0xFF,0xFF,
  1334. +      0xFF,0xFF,0xFF,0xE1,0xFF,0x3C,0x7C,0x78,0x7C,0x78,0x3C,0xF1,0xFF,0xFF,0xFF,0xFF,
  1335. +      0xFF,0xFF,0xFF,0xE1,0xF8,0x38,0x78,0x78,0x10,0x18,0x01,0xF1,0xFF,0xFF,0xFF,0xFF,
  1336. +      0xFF,0xFF,0xFF,0x00,0x00,0x60,0x20,0x3C,0x00,0x7C,0x07,0x80,0x7F,0xFF,0xFF,0xFF,
  1337. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x1F,0xFE,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,
  1338. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1339. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1340. +      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  1341. +
  1342. +     };
  1343.    #else
  1344.      #define START_BMPWIDTH      56
  1345.      #define START_BMPHEIGHT     19
  1346.      #define START_BMPBYTEWIDTH  7
  1347.      #define START_BMPBYTES      133 // START_BMPWIDTH * START_BMPHEIGHT / 8
  1348.  
  1349. -    const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
  1350. +    const unsigned char start_bmp[START_BMPBYTES] PROGMEM =
  1351. +   {
  1352.        0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  1353.        0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF,
  1354.        0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
  1355. @@ -105,7 +213,9 @@
  1356.        0x8C, 0x30, 0xC7, 0x7C, 0x03, 0x8F, 0x19,
  1357.        0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
  1358.        0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
  1359. -      0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8 };
  1360. +      0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8
  1361. +    
  1362. +   };
  1363.    #endif
  1364.  #endif
  1365.  
  1366. @@ -117,6 +227,7 @@
  1367.  
  1368.  #if HAS_TEMP_BED
  1369.    #if HOTENDS == 1
  1370. +    /*
  1371.      #define STATUS_SCREENWIDTH     115 //Width in pixels
  1372.      #define STATUS_SCREENHEIGHT     19 //Height in pixels
  1373.      #define STATUS_SCREENBYTEWIDTH  15 //Width in bytes
  1374. @@ -166,6 +277,110 @@
  1375.        0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
  1376.        0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
  1377.      };
  1378. +    */
  1379. +    #define STATUS_SCREENWIDTH         125 //Width in pixels
  1380. +    #define STATUS_SCREENHEIGHT    19  //Height in pixels
  1381. +    #define STATUS_SCREENBYTEWIDTH     15  //Width in bytes
  1382. +    const unsigned char status_screen0_bmp[] PROGMEM =
  1383. +   {
  1384. +      // AVR-GCC, WinAVR
  1385. +      // chuangxiang 3D
  1386. +      /*
  1387. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,
  1388. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1389. +      0x00,0x80,0x81,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x87,0x30,
  1390. +      0x00,0xC0,0x81,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0x87,0x90,
  1391. +      0x01,0x20,0x81,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2F,0x87,0xD0,
  1392. +      0x02,0x14,0x8F,0xDF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2F,0x87,0xD0,
  1393. +      0x04,0x04,0x81,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2F,0x03,0xD0,
  1394. +      0x0B,0xE4,0x83,0x9F,0x80,0x1F,0xE0,0x00,0x00,0x08,0x20,0x80,0x00,0x20,0x30,0x10,
  1395. +      0x02,0x24,0x85,0x50,0x80,0x3F,0xF0,0x00,0x00,0x04,0x10,0x40,0x00,0x20,0x78,0x10,
  1396. +      0x02,0x24,0x89,0x1F,0x80,0x3F,0xF0,0x00,0x00,0x04,0x10,0x40,0x00,0x20,0x78,0x10,
  1397. +      0x02,0x24,0x81,0x10,0x00,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x20,0x30,0x10,
  1398. +      0x02,0xC4,0x80,0xA1,0x00,0x1F,0xE0,0x00,0x00,0x10,0x41,0x00,0x00,0x2F,0x03,0xD0,
  1399. +      0x02,0x00,0x82,0x90,0x80,0x1F,0xE0,0x00,0x00,0x20,0x82,0x00,0x00,0x2F,0x87,0xD0,
  1400. +      0x02,0x10,0x82,0x8A,0x40,0x3F,0xF0,0x00,0x00,0x20,0x82,0x00,0x00,0x2F,0x87,0xD0,
  1401. +      0x02,0x12,0x84,0x82,0x00,0x3F,0xF0,0x00,0x00,0x10,0x41,0x00,0x00,0x27,0x87,0x90,
  1402. +      0x01,0xF1,0x00,0x7E,0x00,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x33,0x87,0x30,
  1403. +      0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1404. +      0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x3F,0xFF,0xF0,
  1405. +      0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,
  1406. +      */
  1407. +
  1408. +      // ENDER-3
  1409. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,
  1410. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1411. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x87,0x30,
  1412. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0x87,0x90,
  1413. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2F,0x87,0xD0,
  1414. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2F,0x87,0xD0,
  1415. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2F,0x03,0xD0,
  1416. +      0xF8,0x01,0x80,0x00,0x0C,0x1F,0xE0,0x00,0x00,0x08,0x20,0x80,0x00,0x20,0x30,0x10,
  1417. +      0x48,0x00,0x80,0x00,0x12,0x3F,0xF0,0x00,0x00,0x04,0x10,0x40,0x00,0x20,0x78,0x10,
  1418. +      0x43,0xC3,0x8C,0xD0,0x02,0x3F,0xF0,0x00,0x00,0x04,0x10,0x40,0x00,0x20,0x78,0x10,
  1419. +      0x71,0x24,0x92,0x67,0xCC,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x20,0x30,0x10,
  1420. +      0x41,0x24,0x9E,0x40,0x02,0x1F,0xE0,0x00,0x00,0x10,0x41,0x00,0x00,0x2F,0x03,0xD0,
  1421. +      0x49,0x24,0x90,0x40,0x12,0x1F,0xE0,0x00,0x00,0x20,0x82,0x00,0x00,0x2F,0x87,0xD0,
  1422. +      0xFB,0xB3,0xCE,0xE0,0x0C,0x3F,0xF0,0x00,0x00,0x20,0x82,0x00,0x00,0x2F,0x87,0xD0,
  1423. +      0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x00,0x00,0x10,0x41,0x00,0x00,0x27,0x87,0x90,
  1424. +      0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x33,0x87,0x30,
  1425. +      0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1426. +      0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x3F,0xFF,0xF0,
  1427. +      0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00
  1428. +
  1429. +   };
  1430. +
  1431. +    #define STATUS_SCREENWIDTH         125 //Width in pixels
  1432. +    #define STATUS_SCREENHEIGHT    19  //Height in pixels
  1433. +    #define STATUS_SCREENBYTEWIDTH     16  //Width in bytes
  1434. +    const unsigned char status_screen1_bmp[] PROGMEM =
  1435. +    {
  1436. +      // AVR-GCC, WinAVR
  1437. +      // chuangxiang 3D
  1438. +      /*
  1439. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,
  1440. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1441. +      0x00,0x80,0x81,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xFC,0x30,
  1442. +      0x00,0xC0,0x81,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xFC,0x10,
  1443. +      0x01,0x20,0x81,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x78,0x10,
  1444. +      0x02,0x14,0x8F,0xDF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x30,0x10,
  1445. +      0x04,0x04,0x81,0x10,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0xD0,
  1446. +      0x0B,0xE4,0x83,0x9F,0x80,0x1F,0xE0,0x00,0x00,0x10,0x41,0x00,0x00,0x2E,0x31,0xD0,
  1447. +      0x02,0x24,0x85,0x50,0x80,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x2F,0x7B,0xD0,
  1448. +      0x02,0x24,0x89,0x1F,0x80,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x2F,0x7B,0xD0,
  1449. +      0x02,0x24,0x81,0x10,0x00,0x3F,0xF0,0x00,0x00,0x10,0x41,0x00,0x00,0x2E,0x31,0xD0,
  1450. +      0x02,0xC4,0x80,0xA1,0x00,0x1F,0xE0,0x00,0x00,0x20,0x82,0x00,0x00,0x2C,0x00,0xD0,
  1451. +      0x02,0x00,0x82,0x90,0x80,0x1F,0xE0,0x00,0x00,0x41,0x04,0x00,0x00,0x20,0x30,0x10,
  1452. +      0x02,0x10,0x82,0x8A,0x40,0x3F,0xF0,0x00,0x00,0x41,0x04,0x00,0x00,0x20,0x78,0x10,
  1453. +      0x02,0x12,0x84,0x82,0x00,0x3F,0xF0,0x00,0x00,0x20,0x82,0x00,0x00,0x20,0xFC,0x10,
  1454. +      0x01,0xF1,0x00,0x7E,0x00,0x3F,0xF0,0x00,0x00,0x10,0x41,0x00,0x00,0x30,0xFC,0x30,
  1455. +      0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1456. +      0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x3F,0xFF,0xF0,
  1457. +      0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,
  1458. +      */
  1459. +
  1460. +      // ENDER-3
  1461. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,
  1462. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1463. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xFC,0x30,
  1464. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xFC,0x10,
  1465. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x78,0x10,
  1466. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x30,0x10,
  1467. +      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0xD0,
  1468. +      0xF8,0x01,0x80,0x00,0x0C,0x1F,0xE0,0x00,0x00,0x10,0x41,0x00,0x00,0x2E,0x31,0xD0,
  1469. +      0x48,0x00,0x80,0x00,0x12,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x2F,0x7B,0xD0,
  1470. +      0x43,0xC3,0x8C,0xD0,0x02,0x3F,0xF0,0x00,0x00,0x08,0x20,0x80,0x00,0x2F,0x7B,0xD0,
  1471. +      0x71,0x24,0x92,0x67,0xCC,0x3F,0xF0,0x00,0x00,0x10,0x41,0x00,0x00,0x2E,0x31,0xD0,
  1472. +      0x41,0x24,0x9E,0x40,0x02,0x1F,0xE0,0x00,0x00,0x20,0x82,0x00,0x00,0x2C,0x00,0xD0,
  1473. +      0x49,0x24,0x90,0x40,0x12,0x1F,0xE0,0x00,0x00,0x41,0x04,0x00,0x00,0x20,0x30,0x10,
  1474. +      0xFB,0xB3,0xCE,0xE0,0x0C,0x3F,0xF0,0x00,0x00,0x41,0x04,0x00,0x00,0x20,0x78,0x10,
  1475. +      0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x00,0x00,0x20,0x82,0x00,0x00,0x20,0xFC,0x10,
  1476. +      0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x00,0x00,0x10,0x41,0x00,0x00,0x30,0xFC,0x30,
  1477. +      0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,
  1478. +      0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x3F,0xFF,0xF0,
  1479. +      0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00
  1480. +
  1481. +   };
  1482.    #elif HOTENDS == 2
  1483.      #define STATUS_SCREENWIDTH     115 //Width in pixels
  1484.      #define STATUS_SCREENHEIGHT     19 //Height in pixels
  1485. diff --git a/language.h b/language.h
  1486. index 0ff6bad..e68ca79 100644
  1487. --- a/language.h
  1488. +++ b/language.h
  1489. @@ -177,20 +177,20 @@
  1490.  #define MSG_SOFT_MAX                        "  Max: "
  1491.  
  1492.  #define MSG_SD_CANT_OPEN_SUBDIR             "Cannot open subdir "
  1493. -#define MSG_SD_INIT_FAIL                    "SD init fail"
  1494. +#define MSG_SD_INIT_FAIL                    "TF init fail"
  1495.  #define MSG_SD_VOL_INIT_FAIL                "volume.init failed"
  1496.  #define MSG_SD_OPENROOT_FAIL                "openRoot failed"
  1497. -#define MSG_SD_CARD_OK                      "SD card ok"
  1498. +#define MSG_SD_CARD_OK                      "TF card ok"
  1499.  #define MSG_SD_WORKDIR_FAIL                 "workDir open failed"
  1500.  #define MSG_SD_OPEN_FILE_FAIL               "open failed, File: "
  1501.  #define MSG_SD_FILE_OPENED                  "File opened: "
  1502.  #define MSG_SD_SIZE                         " Size: "
  1503.  #define MSG_SD_FILE_SELECTED                "File selected"
  1504.  #define MSG_SD_WRITE_TO_FILE                "Writing to file: "
  1505. -#define MSG_SD_PRINTING_BYTE                "SD printing byte "
  1506. -#define MSG_SD_NOT_PRINTING                 "Not SD printing"
  1507. +#define MSG_SD_PRINTING_BYTE                "TF printing byte "
  1508. +#define MSG_SD_NOT_PRINTING                 "Not TF printing"
  1509.  #define MSG_SD_ERR_WRITE_TO_FILE            "error writing to file"
  1510. -#define MSG_SD_ERR_READ                     "SD read error"
  1511. +#define MSG_SD_ERR_READ                     "TF read error"
  1512.  #define MSG_SD_CANT_ENTER_SUBDIR            "Cannot enter subdir: "
  1513.  
  1514.  #define MSG_STEPPER_TOO_HIGH                "Steprate too high: "
  1515. diff --git a/language_cn.h b/language_cn.h
  1516. index f6230a0..f06a477 100644
  1517. --- a/language_cn.h
  1518. +++ b/language_cn.h
  1519. @@ -53,7 +53,7 @@
  1520.  #define MSG_PREHEAT_2                       "\xc3\xc4 ABS"
  1521.  #define MSG_PREHEAT_2_N                     MSG_PREHEAT_2 " "
  1522.  #define MSG_PREHEAT_2_ALL                   MSG_PREHEAT_2 " \xc5\xc6"
  1523. -#define MSG_PREHEAT_2_BEDONLY               MSG_PREHEAT_2 " \xbe\xc6"
  1524. +#define MSG_PREHEAT_2_BEDONLY               MSG_PREHEAT_2 " \xc4\xc7"
  1525.  #define MSG_PREHEAT_2_SETTINGS              MSG_PREHEAT_2 " \xbe\xbf"
  1526.  #define MSG_COOLDOWN                        "\xc8\xc9"
  1527.  #define MSG_SWITCH_PS_ON                    "\xb9\xcb\xca\xb3"
  1528. @@ -61,7 +61,7 @@
  1529.  #define MSG_EXTRUDE                         "\xcc\xad"
  1530.  #define MSG_RETRACT                         "\xbb\xcd"
  1531.  #define MSG_MOVE_AXIS                       "\xc1\xb2\xce"
  1532. -#define MSG_BED_LEVELING                    "\xcf\xe0\xc4\xc7"
  1533. +#define MSG_BED_LEVELING                    "\xb1\xb2\xcf\xd0"
  1534.  #define MSG_LEVEL_BED                       "\xcf\xe0\xc4\xc7"
  1535.  #define MSG_MOVE_X                          "\xc1\xb2 X"
  1536.  #define MSG_MOVE_Y                          "\xc1\xb2 Y"
  1537. @@ -80,8 +80,8 @@
  1538.  #define MSG_MAX                             LCD_STR_THERMOMETER " \xda\xdc"
  1539.  #define MSG_FACTOR                          LCD_STR_THERMOMETER " \xdd\xde"
  1540.  #define MSG_AUTOTEMP                        "\xb1\xb2\xd8\xc9"
  1541. -#define MSG_ON                              "\xb3 "  // intentional space to shift wide symbol to the left
  1542. -#define MSG_OFF                             "\xb5 "  // intentional space to shift wide symbol to the left
  1543. +#define MSG_ON                              "On"   // intentional space to shift wide symbol to the left
  1544. +#define MSG_OFF                             "Off"  // intentional space to shift wide symbol to the left
  1545.  #define MSG_PID_P                           "PID-P"
  1546.  #define MSG_PID_I                           "PID-I"
  1547.  #define MSG_PID_D                           "PID-D"
  1548. @@ -142,8 +142,8 @@
  1549.  #define MSG_CONTROL_RETRACT_RECOVERF        "UnRet  V"
  1550.  #define MSG_AUTORETRACT                     "AutoRetr."
  1551.  #define MSG_FILAMENTCHANGE                  "Change filament"
  1552. -#define MSG_INIT_SDCARD                     "Init. SD card"
  1553. -#define MSG_CNG_SDCARD                      "Change SD card"
  1554. +#define MSG_INIT_SDCARD                     "Init. TF card"
  1555. +#define MSG_CNG_SDCARD                      "Change TF card"
  1556.  #define MSG_ZPROBE_OUT                      "Z probe out. bed"
  1557.  #define MSG_HOME                            "Home"  // Used as MSG_HOME " " MSG_X MSG_Y MSG_Z " " MSG_FIRST
  1558.  #define MSG_FIRST                           "first"
  1559. @@ -163,5 +163,5 @@
  1560.  #define MSG_DELTA_CALIBRATE_Y               "Calibrate Y"
  1561.  #define MSG_DELTA_CALIBRATE_Z               "Calibrate Z"
  1562.  #define MSG_DELTA_CALIBRATE_CENTER          "Calibrate Center"
  1563. -
  1564. +#define MSG_POWER_LOSS_RECOVERY             "\xa4\xa5\xf4\xf5\xca\xf3 ?"
  1565.  #endif // LANGUAGE_CN_H
  1566. diff --git a/language_en.h b/language_en.h
  1567. index 811b132..17eadef 100644
  1568. --- a/language_en.h
  1569. +++ b/language_en.h
  1570. @@ -564,10 +564,10 @@
  1571.    #define MSG_STOP_PRINT                      _UxGT("Stop print")
  1572.  #endif
  1573.  #ifndef MSG_CARD_MENU
  1574. -  #define MSG_CARD_MENU                       _UxGT("Print from SD")
  1575. +  #define MSG_CARD_MENU                       _UxGT("Print from TF")
  1576.  #endif
  1577.  #ifndef MSG_NO_CARD
  1578. -  #define MSG_NO_CARD                         _UxGT("No SD card")
  1579. +  #define MSG_NO_CARD                         _UxGT("No TF card")
  1580.  #endif
  1581.  #ifndef MSG_DWELL
  1582.    #define MSG_DWELL                           _UxGT("Sleep...")
  1583. @@ -621,10 +621,10 @@
  1584.    #define MSG_FILAMENTCHANGE                  _UxGT("Change filament")
  1585.  #endif
  1586.  #ifndef MSG_INIT_SDCARD
  1587. -  #define MSG_INIT_SDCARD                     _UxGT("Init. SD card")
  1588. +  #define MSG_INIT_SDCARD                     _UxGT("Init. TF card")
  1589.  #endif
  1590.  #ifndef MSG_CNG_SDCARD
  1591. -  #define MSG_CNG_SDCARD                      _UxGT("Change SD card")
  1592. +  #define MSG_CNG_SDCARD                      _UxGT("Change TF card")
  1593.  #endif
  1594.  #ifndef MSG_ZPROBE_OUT
  1595.    #define MSG_ZPROBE_OUT                      _UxGT("Z probe out. bed")
  1596. @@ -870,6 +870,9 @@
  1597.  #ifndef MSG_ERR_PROBING_FAILED
  1598.    #define MSG_ERR_PROBING_FAILED              _UxGT("Probing failed")
  1599.  #endif
  1600. +#ifndef MSG_POWER_LOSS_RECOVERY
  1601. +  #define MSG_POWER_LOSS_RECOVERY             _UxGT("Power-Loss Recovery")
  1602. +#endif
  1603.  
  1604.  //
  1605.  // Filament Change screens show up to 3 lines on a 4-line display
  1606. diff --git a/pins_MELZI_CREALITY.h b/pins_MELZI_CREALITY.h
  1607. index 7981e4a..07f7d71 100644
  1608. --- a/pins_MELZI_CREALITY.h
  1609. +++ b/pins_MELZI_CREALITY.h
  1610. @@ -59,6 +59,9 @@
  1611.  #define ST7920_DELAY_2 DELAY_2_NOP
  1612.  #define ST7920_DELAY_3 DELAY_2_NOP
  1613.  
  1614. +// BLTouch mappings: (Creality 3D)
  1615. +#define SERVO0_PIN      27
  1616. +
  1617.  /**
  1618.    PIN:   0   Port: B0        E0_DIR_PIN                  protected
  1619.    PIN:   1   Port: B1        E0_STEP_PIN                 protected
  1620. diff --git a/pins_SANGUINOLOLU_11.h b/pins_SANGUINOLOLU_11.h
  1621. index 0506d78..a14cb78 100644
  1622. --- a/pins_SANGUINOLOLU_11.h
  1623. +++ b/pins_SANGUINOLOLU_11.h
  1624. @@ -170,7 +170,7 @@
  1625.          // Pin 27 is taken by LED_PIN, but Melzi LED does nothing with
  1626.          // Marlin so this can be used for BEEPER_PIN. You can use this pin
  1627.          // with M42 instead of BEEPER_PIN.
  1628. -        #define BEEPER_PIN      27
  1629. +        #define BEEPER_PIN      -1 // 27
  1630.        #else        // Sanguinololu >=1.3
  1631.          #define LCD_PINS_RS      4
  1632.          #define LCD_PINS_ENABLE 17
  1633. diff --git a/temperature.cpp b/temperature.cpp
  1634. index e2ea537..9bd2d8c 100644
  1635. --- a/temperature.cpp
  1636. +++ b/temperature.cpp
  1637. @@ -506,22 +506,36 @@ int Temperature::getHeaterPower(int heater) {
  1638.  //
  1639.  // Temperature Error Handlers
  1640.  //
  1641. -void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg) {
  1642. +void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg)
  1643. +{
  1644.    static bool killed = false;
  1645. -  if (IsRunning()) {
  1646. +  if (IsRunning())
  1647. +  {
  1648.      SERIAL_ERROR_START();
  1649.      serialprintPGM(serial_msg);
  1650.      SERIAL_ERRORPGM(MSG_STOPPED_HEATER);
  1651. -    if (e >= 0) SERIAL_ERRORLN((int)e); else SERIAL_ERRORLNPGM(MSG_HEATER_BED);
  1652. +    if (e >= 0)
  1653. +    {
  1654. +      SERIAL_ERRORLN((int)e);
  1655. +    }
  1656. +    else
  1657. +    {
  1658. +      SERIAL_ERRORLNPGM(MSG_HEATER_BED);
  1659. +    }
  1660.    }
  1661.    #if DISABLED(BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE)
  1662. -    if (!killed) {
  1663. -      Running = false;
  1664. -      killed = true;
  1665. -      kill(lcd_msg);
  1666. +    if (!killed)
  1667. +    { 
  1668. +      // Generate error temperature, close firmware.          
  1669. +      // Running = false;
  1670. +      // killed = true;
  1671. +      // Diabale lcd message display
  1672. +      // kill(lcd_msg);
  1673.      }
  1674.      else
  1675. -      disable_all_heaters(); // paranoia
  1676. +    {
  1677. +      disable_all_heaters(); // paranoia prohibits all heating.
  1678. +    }
  1679.    #endif
  1680.  }
  1681.  
  1682. diff --git a/ultralcd.cpp b/ultralcd.cpp
  1683. index 83ce9d2..39000f2 100644
  1684. --- a/ultralcd.cpp
  1685. +++ b/ultralcd.cpp
  1686. @@ -157,14 +157,19 @@ uint16_t max_display_update_time = 0;
  1687.    void lcd_control_temperature_preheat_material2_settings_menu();
  1688.    void lcd_control_motion_menu();
  1689.    void lcd_control_filament_menu();
  1690. +  // Add power off cotinue print function.
  1691. +  #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1692. +    static void lcd_resume_ok_menu();
  1693. +  #endif
  1694.  
  1695.    #if ENABLED(LCD_INFO_MENU)
  1696.      #if ENABLED(PRINTCOUNTER)
  1697.        void lcd_info_stats_menu();
  1698.      #endif
  1699. -    void lcd_info_thermistors_menu();
  1700. -    void lcd_info_board_menu();
  1701. -    void lcd_info_menu();
  1702. +    // void lcd_info_thermistors_menu();
  1703. +    // void lcd_info_board_menu();
  1704. +    // void lcd_info_menu();
  1705. +    void lcd_info_printer_menu();
  1706.    #endif // LCD_INFO_MENU
  1707.  
  1708.    #if ENABLED(ADVANCED_PAUSE_FEATURE)
  1709. @@ -750,8 +755,22 @@ void kill_screen(const char* lcd_msg) {
  1710.  
  1711.    #if ENABLED(SDSUPPORT)
  1712.  
  1713. -    void lcd_sdcard_pause() {
  1714. +    int mytemphot = 0;
  1715. +    int mytempbed = 0;
  1716. +    float pause_z = 0;
  1717. +    void lcd_sdcard_pause()
  1718. +    {
  1719.        card.pauseSDPrint();
  1720. +      pause_z = current_position[Z_AXIS];
  1721. +
  1722. +      mytemphot = thermalManager.degTargetHotend(0);
  1723. +      mytempbed = thermalManager.degTargetBed();
  1724. +
  1725. +      thermalManager.setTargetHotend(0, 0);
  1726. +      thermalManager.setTargetBed(0);
  1727. +
  1728. +      enqueue_and_echo_commands_P(PSTR("G1 F1200 X0 Y0"));
  1729. +
  1730.        print_job_timer.pause();
  1731.        #if ENABLED(PARK_HEAD_ON_PAUSE)
  1732.          enqueue_and_echo_commands_P(PSTR("M125"));
  1733. @@ -759,7 +778,46 @@ void kill_screen(const char* lcd_msg) {
  1734.        lcd_setstatusPGM(PSTR(MSG_PRINT_PAUSED), -1);
  1735.      }
  1736.  
  1737. -    void lcd_sdcard_resume() {
  1738. +    void lcd_sdcard_resume()
  1739. +    {
  1740. +      char cmd1[30];
  1741. +      char pause_str_Z[16];
  1742. +
  1743. +      memset(pause_str_Z, 0, sizeof(pause_str_Z));
  1744. +      dtostrf(pause_z, 3, 2, pause_str_Z);
  1745. +      SERIAL_PROTOCOLLN(pause_str_Z);
  1746. +      SERIAL_PROTOCOLLN("lcd_sdcard_resume() pause_str_Z");
  1747. +      #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1748. +        if (power_off_commands_count > 0)
  1749. +        {
  1750. +          sprintf_P(cmd1, PSTR("M190 S%i"), power_off_info.target_temperature_bed);
  1751. +          enqueue_and_echo_command(cmd1);
  1752. +          sprintf_P(cmd1, PSTR("M109 S%i"), power_off_info.target_temperature[0]);
  1753. +          enqueue_and_echo_command(cmd1);
  1754. +          enqueue_and_echo_commands_P(PSTR("M106 S255"));
  1755. +          // sprintf_P(cmd1, PSTR("T%i"), power_off_info.saved_extruder);
  1756. +          // enqueue_and_echo_command(cmd1);
  1757. +          power_off_type_yes = 1;
  1758. +        }
  1759. +        else
  1760. +        {
  1761. +          sprintf_P(cmd1, PSTR("M140 S%i"), mytempbed);
  1762. +          enqueue_and_echo_command(cmd1);
  1763. +          sprintf_P(cmd1, PSTR("M109 S%i"), mytemphot);
  1764. +          enqueue_and_echo_command(cmd1);
  1765. +          // enqueue_and_echo_commands_P(PSTR("G28 X0 Y0"));
  1766. +          sprintf_P(cmd1, PSTR("G0 Z%s"), pause_str_Z);
  1767. +          enqueue_and_echo_command(cmd1);
  1768. +        }
  1769. +      #else
  1770. +        sprintf_P(cmd1, PSTR("M140 S%i"), mytempbed);
  1771. +        enqueue_and_echo_command(cmd1);
  1772. +        sprintf_P(cmd1, PSTR("M109 S%i"), mytemphot);
  1773. +        enqueue_and_echo_command(cmd1);
  1774. +        // enqueue_and_echo_commands_P(PSTR("G28 X0 Y0"));
  1775. +        sprintf_P(cmd1, PSTR("G0 Z%s"), pause_str_Z);
  1776. +        enqueue_and_echo_command(cmd1);
  1777. +      #endif
  1778.        #if ENABLED(PARK_HEAD_ON_PAUSE)
  1779.          enqueue_and_echo_commands_P(PSTR("M24"));
  1780.        #else
  1781. @@ -769,12 +827,25 @@ void kill_screen(const char* lcd_msg) {
  1782.        lcd_reset_status();
  1783.      }
  1784.  
  1785. -    void lcd_sdcard_stop() {
  1786. +    void lcd_sdcard_stop()
  1787. +    {
  1788.        card.stopSDPrint();
  1789.        clear_command_queue();
  1790.        quickstop_stepper();
  1791.        print_job_timer.stop();
  1792.        thermalManager.disable_all_heaters();
  1793. +      #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1794. +        card.openPowerOffFile(power_off_info.power_off_filename, O_CREAT | O_WRITE | O_TRUNC | O_SYNC);
  1795. +        power_off_info.valid_head = 0;
  1796. +        power_off_info.valid_foot = 0;
  1797. +        if (card.savePowerOffInfo(&power_off_info, sizeof(power_off_info)) == -1)
  1798. +        {
  1799. +          SERIAL_PROTOCOLLN("Stop to Write power off file failed.");
  1800. +        }
  1801. +        card.closePowerOffFile();
  1802. +        power_off_commands_count = 0;
  1803. +      #endif
  1804. +
  1805.        #if FAN_COUNT > 0
  1806.          for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
  1807.        #endif
  1808. @@ -783,8 +854,39 @@ void kill_screen(const char* lcd_msg) {
  1809.        lcd_return_to_status();
  1810.      }
  1811.  
  1812. +    static void lcd_sdcard_resume_return()
  1813. +    {
  1814. +      lcd_sdcard_resume();
  1815. +      lcd_return_to_status();
  1816. +    }
  1817. +
  1818. +    static void lcd_sdcard_stop_return()
  1819. +    {
  1820. +      lcd_sdcard_stop();
  1821. +      lcd_return_to_status();
  1822. +    }
  1823. +
  1824. +    static void msg_resume_print_ok_title()
  1825. +    {
  1826. +      return;
  1827. +    }
  1828. +
  1829.    #endif // SDSUPPORT
  1830.  
  1831. +  /**
  1832. +   * "Resume yes or no" menu
  1833. +   */
  1834. +  #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1835. +    static void lcd_resume_ok_menu()
  1836. +    {
  1837. +      START_MENU();
  1838. +      MENU_ITEM(function, MSG_POWER_LOSS_RECOVERY, msg_resume_print_ok_title);
  1839. +      MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume_return);
  1840. +      MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop_return);
  1841. +      END_MENU();
  1842. +    }
  1843. +  #endif
  1844. +
  1845.    #if ENABLED(MENU_ITEM_CASE_LIGHT)
  1846.  
  1847.      extern uint8_t case_light_brightness;
  1848. @@ -929,7 +1031,8 @@ void kill_screen(const char* lcd_msg) {
  1849.     *
  1850.     */
  1851.  
  1852. -  void lcd_main_menu() {
  1853. +  void lcd_main_menu()
  1854. +  {
  1855.      START_MENU();
  1856.      MENU_BACK(MSG_WATCH);
  1857.  
  1858. @@ -948,38 +1051,71 @@ void kill_screen(const char* lcd_msg) {
  1859.      // Set Case light on/off/brightness
  1860.      //
  1861.      #if ENABLED(MENU_ITEM_CASE_LIGHT)
  1862. -      if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
  1863. +      if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN))
  1864. +      {
  1865.          MENU_ITEM(submenu, MSG_CASE_LIGHT, case_light_menu);
  1866.        }
  1867.        else
  1868. +      {
  1869.          MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
  1870. +      }
  1871.      #endif
  1872.  
  1873. -    if (planner.movesplanned() || IS_SD_PRINTING) {
  1874. +    if (planner.movesplanned() || IS_SD_PRINTING)
  1875. +    {
  1876.        MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
  1877.      }
  1878. -    else {
  1879. +    else
  1880. +    {
  1881.        MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
  1882.      }
  1883.      MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
  1884.  
  1885.      #if ENABLED(SDSUPPORT)
  1886. -      if (card.cardOK) {
  1887. -        if (card.isFileOpen()) {
  1888. -          if (card.sdprinting)
  1889. -            MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
  1890. -          else
  1891. -            MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
  1892. -          MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
  1893. +      if (card.cardOK)
  1894. +      {
  1895. +        if (card.isFileOpen())
  1896. +        {
  1897. +          #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1898. +            if (power_off_commands_count > 0)
  1899. +            {
  1900. +              // MENU_ITEM(submenu, MSG_RESUME_PRINT_OK, lcd_resume_ok_menu);
  1901. +              if (card.sdprinting)
  1902. +              {
  1903. +                MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
  1904. +              }
  1905. +              else
  1906. +              {
  1907. +                MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
  1908. +              }
  1909. +              MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
  1910. +            }
  1911. +            else
  1912. +            {
  1913. +          #endif
  1914. +              if (card.sdprinting)
  1915. +              {
  1916. +                MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
  1917. +              }
  1918. +              else
  1919. +              {
  1920. +                MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
  1921. +              }
  1922. +              MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
  1923. +          #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  1924. +            }
  1925. +          #endif
  1926.          }
  1927. -        else {
  1928. +        else
  1929. +        {
  1930.            MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
  1931.            #if !PIN_EXISTS(SD_DETECT)
  1932.              MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));  // SD-card changed by user
  1933.            #endif
  1934.          }
  1935.        }
  1936. -      else {
  1937. +      else
  1938. +      {
  1939.          MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
  1940.          #if !PIN_EXISTS(SD_DETECT)
  1941.            MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
  1942. @@ -988,7 +1124,7 @@ void kill_screen(const char* lcd_msg) {
  1943.      #endif // SDSUPPORT
  1944.  
  1945.      #if ENABLED(LCD_INFO_MENU)
  1946. -      MENU_ITEM(submenu, MSG_INFO_MENU, lcd_info_menu);
  1947. +      MENU_ITEM(submenu, MSG_INFO_MENU, lcd_info_printer_menu);
  1948.      #endif
  1949.  
  1950.      END_MENU();
  1951. @@ -2501,6 +2637,15 @@ void kill_screen(const char* lcd_msg) {
  1952.  
  1953.    #endif // AUTO_BED_LEVELING_UBL
  1954.  
  1955. +// lcd auto home
  1956. +static void lcd_autohome()
  1957. +{
  1958. +  enqueue_and_echo_commands_P(PSTR("G28")); // move all axis home
  1959. +
  1960. +  disable_X();
  1961. +  disable_Y();
  1962. +}
  1963. +
  1964.    /**
  1965.     *
  1966.     * "Prepare" submenu
  1967. @@ -2526,7 +2671,8 @@ void kill_screen(const char* lcd_msg) {
  1968.      //
  1969.      // Auto Home
  1970.      //
  1971. -    MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
  1972. +    // MENU_ITEM(gcode, msg_auto_home(), PSTR("G28"));
  1973. +     MENU_ITEM(function, MSG_AUTO_HOME, lcd_autohome);
  1974.      #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
  1975.        MENU_ITEM(gcode, MSG_AUTO_HOME_X, PSTR("G28 X"));
  1976.        MENU_ITEM(gcode, MSG_AUTO_HOME_Y, PSTR("G28 Y"));
  1977. @@ -2602,11 +2748,13 @@ void kill_screen(const char* lcd_msg) {
  1978.      //
  1979.      // BLTouch Self-Test and Reset
  1980.      //
  1981. +/*
  1982.      #if ENABLED(BLTOUCH)
  1983.        MENU_ITEM(gcode, MSG_BLTOUCH_SELFTEST, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_SELFTEST)));
  1984.        if (!endstops.z_probe_enabled && TEST_BLTOUCH())
  1985.          MENU_ITEM(gcode, MSG_BLTOUCH_RESET, PSTR("M280 P" STRINGIFY(Z_ENDSTOP_SERVO_NR) " S" STRINGIFY(BLTOUCH_RESET)));
  1986.      #endif
  1987. +*/
  1988.  
  1989.      //
  1990.      // Switch power on/off
  1991. @@ -3132,9 +3280,9 @@ void kill_screen(const char* lcd_msg) {
  1992.        MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
  1993.        MENU_ITEM(function, MSG_LOAD_EEPROM, lcd_load_settings);
  1994.      #endif
  1995. -    MENU_ITEM(function, MSG_RESTORE_FAILSAFE, lcd_factory_settings);
  1996. +    // MENU_ITEM(function, MSG_RESTORE_FAILSAFE, lcd_factory_settings);
  1997.      #if ENABLED(EEPROM_SETTINGS)
  1998. -      MENU_ITEM(submenu, MSG_INIT_EEPROM, lcd_init_eeprom_confirm);
  1999. +      MENU_ITEM(submenu, MSG_INIT_EEPROM, lcd_init_eeprom);
  2000.      #endif
  2001.  
  2002.      END_MENU();
  2003. @@ -3283,6 +3431,7 @@ void kill_screen(const char* lcd_msg) {
  2004.      //
  2005.      // Autotemp, Min, Max, Fact
  2006.      //
  2007. +/*
  2008.      #if ENABLED(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
  2009.        MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
  2010.        MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
  2011. @@ -3340,7 +3489,7 @@ void kill_screen(const char* lcd_msg) {
  2012.        #endif // !PID_PARAMS_PER_HOTEND || HOTENDS == 1
  2013.  
  2014.      #endif // PIDTEMP
  2015. -
  2016. +*/
  2017.      //
  2018.      // Preheat Material 1 conf
  2019.      //
  2020. @@ -3850,11 +3999,15 @@ void kill_screen(const char* lcd_msg) {
  2021.        if (lcd_clicked) { return lcd_goto_previous_menu(); }
  2022.        START_SCREEN();
  2023.        STATIC_ITEM(MSG_MARLIN, true, true);                             // Marlin
  2024. +      STATIC_ITEM(DETAILED_BUILD_VERSION, true);                       // Creality 3D
  2025.        STATIC_ITEM(SHORT_BUILD_VERSION, true);                          // x.x.x-Branch
  2026. -      STATIC_ITEM(STRING_DISTRIBUTION_DATE, true);                     // YYYY-MM-DD HH:MM
  2027. -      STATIC_ITEM(MACHINE_NAME, true);                                 // My3DPrinter
  2028. -      STATIC_ITEM(WEBSITE_URL, true);                                  // www.my3dprinter.com
  2029. -      STATIC_ITEM(MSG_INFO_EXTRUDERS ": " STRINGIFY(EXTRUDERS), true); // Extruders: 2
  2030. +      // STATIC_ITEM(STRING_DISTRIBUTION_DATE, true);                  // YYYY-MM-DD HH:MM
  2031. +      STATIC_ITEM(MACHINE_NAME, true);                                 // Ender-3
  2032. +      STATIC_ITEM(WEBSITE_URL, true);                                  // www.cxsw3d.com
  2033. +      STATIC_ITEM(MSG_INFO_EXTRUDERS ": " STRINGIFY(EXTRUDERS), true); // Extruders: 1
  2034. +      STATIC_ITEM(BOARD_NAME, true);                                   // MyPrinterController
  2035. +      STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true);   // Baud: 115200
  2036. +      /*
  2037.        #if ENABLED(AUTO_BED_LEVELING_3POINT)
  2038.          STATIC_ITEM(MSG_3POINT_LEVELING, true);                        // 3-Point Leveling
  2039.        #elif ENABLED(AUTO_BED_LEVELING_LINEAR)
  2040. @@ -3866,6 +4019,7 @@ void kill_screen(const char* lcd_msg) {
  2041.        #elif ENABLED(MESH_BED_LEVELING)
  2042.          STATIC_ITEM(MSG_MESH_LEVELING, true);                          // Mesh Leveling
  2043.        #endif
  2044. +      */
  2045.        END_SCREEN();
  2046.      }
  2047.  
  2048. @@ -4491,6 +4645,13 @@ void lcd_update() {
  2049.  
  2050.      lcd_buttons_update();
  2051.  
  2052. +    #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  2053. +      if ((power_off_type_yes == 0) && (power_off_commands_count > 0))
  2054. +      {
  2055. +        currentScreen = lcd_resume_ok_menu;
  2056. +      }
  2057. +    #endif
  2058. +
  2059.      #if ENABLED(AUTO_BED_LEVELING_UBL)
  2060.        const bool UBL_CONDITION = !ubl.has_control_of_lcd_panel;
  2061.      #else
  2062. @@ -4498,34 +4659,51 @@ void lcd_update() {
  2063.      #endif
  2064.  
  2065.      // If the action button is pressed...
  2066. -    if (UBL_CONDITION && LCD_CLICKED) {
  2067. -      if (!wait_for_unclick) {           // If not waiting for a debounce release:
  2068. -        wait_for_unclick = true;         //  Set debounce flag to ignore continous clicks
  2069. -        lcd_clicked = !wait_for_user;    //  Keep the click if not waiting for a user-click
  2070. -        wait_for_user = false;           //  Any click clears wait for user
  2071. -        lcd_quick_feedback();            //  Always make a click sound
  2072. +    if (UBL_CONDITION && LCD_CLICKED)
  2073. +    {
  2074. +      if (!wait_for_unclick)
  2075. +      {
  2076. +        // If not waiting for a debounce release:
  2077. +        wait_for_unclick = true;        // Set debounce flag to ignore continous clicks
  2078. +        lcd_clicked = !wait_for_user;   // Keep the click if not waiting for a user-click
  2079. +        wait_for_user = false;          // Any click clears wait for user
  2080. +        lcd_quick_feedback();           // Always make a click sound
  2081.        }
  2082.      }
  2083. -    else wait_for_unclick = false;
  2084. +    else
  2085. +    {
  2086. +      wait_for_unclick = false;
  2087. +    }
  2088.    #endif
  2089.  
  2090.    #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
  2091.  
  2092.      const bool sd_status = IS_SD_INSERTED;
  2093. -    if (sd_status != lcd_sd_status && lcd_detected()) {
  2094. -
  2095. -      if (sd_status) {
  2096. +    if (sd_status != lcd_sd_status && lcd_detected())
  2097. +    {
  2098. +      if (sd_status)
  2099. +      {
  2100.          card.initsd();
  2101. -        if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED);
  2102. +        if (lcd_sd_status != 2)
  2103. +        {
  2104. +          LCD_MESSAGEPGM(MSG_SD_INSERTED);
  2105. +        }
  2106. +        #if ENABLED(SDSUPPORT) && ENABLED(POWEROFF_SAVE_SD_FILE)
  2107. +          init_power_off_info();
  2108. +        #endif
  2109.        }
  2110.        else {
  2111.          card.release();
  2112. -        if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
  2113. +        if (lcd_sd_status != 2)
  2114. +        {
  2115. +          LCD_MESSAGEPGM(MSG_SD_REMOVED);
  2116. +        }
  2117.        }
  2118.  
  2119.        lcd_sd_status = sd_status;
  2120.        lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
  2121. -      lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
  2122. +      // to maybe revive the LCD if static electricity killed it.
  2123. +      lcd_implementation_init(
  2124.          #if ENABLED(LCD_PROGRESS_BAR)
  2125.            currentScreen == lcd_status_screen
  2126.          #endif
  2127. @@ -4556,7 +4734,9 @@ void lcd_update() {
  2128.        #if ENABLED(ADC_KEYPAD)
  2129.  
  2130.          if (handle_adc_keypad())
  2131. +        {
  2132.            return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
  2133. +        }
  2134.  
  2135.        #elif ENABLED(REPRAPWORLD_KEYPAD)
  2136.  
  2137. @@ -4565,22 +4745,32 @@ void lcd_update() {
  2138.        #endif
  2139.  
  2140.        bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
  2141. -      if (encoderPastThreshold || lcd_clicked) {
  2142. -        if (encoderPastThreshold) {
  2143. +      if (encoderPastThreshold || lcd_clicked)
  2144. +      {
  2145. +        if (encoderPastThreshold)
  2146. +        {
  2147.            int32_t encoderMultiplier = 1;
  2148.  
  2149.            #if ENABLED(ENCODER_RATE_MULTIPLIER)
  2150.  
  2151. -            if (encoderRateMultiplierEnabled) {
  2152. +            if (encoderRateMultiplierEnabled)
  2153. +            {
  2154.                int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
  2155.  
  2156. -              if (lastEncoderMovementMillis) {
  2157. +              if (lastEncoderMovementMillis)
  2158. +              {
  2159.                  // Note that the rate is always calculated between two passes through the
  2160.                  // loop and that the abs of the encoderDiff value is tracked.
  2161.                  float encoderStepRate = float(encoderMovementSteps) / float(ms - lastEncoderMovementMillis) * 1000.0;
  2162.  
  2163. -                if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)     encoderMultiplier = 100;
  2164. -                else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
  2165. +                if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)
  2166. +                {
  2167. +                  encoderMultiplier = 100;
  2168. +                }
  2169. +                else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)
  2170. +                {
  2171. +                  encoderMultiplier = 10;
  2172. +                }
  2173.  
  2174.                  #if ENABLED(ENCODER_RATE_MULTIPLIER_DEBUG)
  2175.                    SERIAL_ECHO_START();
  2176. @@ -4612,7 +4802,8 @@ void lcd_update() {
  2177.          currentScreen == lcd_status_screen &&
  2178.        #endif
  2179.        !lcd_status_update_delay--
  2180. -    ) {
  2181. +    )
  2182. +    {
  2183.        lcd_status_update_delay = 9
  2184.          #if ENABLED(DOGLCD)
  2185.            + 3
  2186. @@ -4635,7 +4826,8 @@ void lcd_update() {
  2187.          if (!drawing_screen)
  2188.        #endif
  2189.          {
  2190. -          switch (lcdDrawUpdate) {
  2191. +          switch (lcdDrawUpdate)
  2192. +          {
  2193.              case LCDVIEW_CALL_NO_REDRAW:
  2194.                lcdDrawUpdate = LCDVIEW_NONE;
  2195.                break;
  2196. @@ -4659,14 +4851,16 @@ void lcd_update() {
  2197.        #endif
  2198.  
  2199.        #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
  2200. -        if (!drawing_screen) {
  2201. +        if (!drawing_screen)
  2202. +        {
  2203.            u8g.firstPage();
  2204.            drawing_screen = 1;
  2205.          }
  2206.          lcd_setFont(FONT_MENU);
  2207.          u8g.setColorIndex(1);
  2208.          CURRENTSCREEN();
  2209. -        if (drawing_screen && (drawing_screen = u8g.nextPage())) {
  2210. +        if (drawing_screen && (drawing_screen = u8g.nextPage()))
  2211. +        {
  2212.            NOLESS(max_display_update_time, millis() - ms);
  2213.            return;
  2214.          }
  2215. @@ -4680,9 +4874,13 @@ void lcd_update() {
  2216.  
  2217.        // Return to Status Screen after a timeout
  2218.        if (currentScreen == lcd_status_screen || defer_return_to_status)
  2219. +      {
  2220.          return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
  2221. +      }
  2222.        else if (ELAPSED(ms, return_to_status_ms))
  2223. +      {
  2224.          lcd_return_to_status();
  2225. +      }
  2226.  
  2227.      #endif // ULTIPANEL
  2228.  
  2229. @@ -4690,7 +4888,8 @@ void lcd_update() {
  2230.        if (!drawing_screen)
  2231.      #endif
  2232.        {
  2233. -        switch (lcdDrawUpdate) {
  2234. +        switch (lcdDrawUpdate)
  2235. +        {
  2236.            case LCDVIEW_CLEAR_CALL_REDRAW:
  2237.              lcd_implementation_clear();
  2238.            case LCDVIEW_CALL_REDRAW_NEXT:
  2239. diff --git a/ultralcd_impl_DOGM.h b/ultralcd_impl_DOGM.h
  2240. index 6f75143..e0911fc 100644
  2241. --- a/ultralcd_impl_DOGM.h
  2242. +++ b/ultralcd_impl_DOGM.h
  2243. @@ -291,11 +291,12 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
  2244.  
  2245.    #endif // SHOW_CUSTOM_BOOTSCREEN
  2246.  
  2247. -  void lcd_bootscreen() {
  2248. -
  2249. +  void lcd_bootscreen()
  2250. +  {
  2251.      static bool show_bootscreen = true;
  2252.  
  2253. -    if (show_bootscreen) {
  2254. +    if (show_bootscreen)
  2255. +    {
  2256.        show_bootscreen = false;
  2257.  
  2258.        #if ENABLED(START_BMPHIGH)
  2259. @@ -304,15 +305,15 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
  2260.          constexpr uint8_t offy = DOG_CHAR_HEIGHT;
  2261.        #endif
  2262.  
  2263. -      const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2,
  2264. -                    txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
  2265. +      const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2;
  2266. +                    // txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
  2267.  
  2268.        u8g.firstPage();
  2269.        do {
  2270.          u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
  2271.          lcd_setFont(FONT_MENU);
  2272.          #ifndef STRING_SPLASH_LINE2
  2273. -          u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
  2274. +          // u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
  2275.          #else
  2276.            const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
  2277.            u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
  2278. @@ -325,8 +326,8 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
  2279.  #endif // SHOW_BOOTSCREEN
  2280.  
  2281.  // Initialize or re-initialize the LCD
  2282. -static void lcd_implementation_init() {
  2283. -
  2284. +static void lcd_implementation_init()
  2285. +{
  2286.    #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
  2287.      OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
  2288.    #endif
  2289. @@ -478,9 +479,10 @@ inline void lcd_implementation_status_message(const bool blink) {
  2290.    #endif
  2291.  }
  2292.  
  2293. -//#define DOGM_SD_PERCENT
  2294. +// #define DOGM_SD_PERCENT
  2295.  
  2296. -static void lcd_implementation_status_screen() {
  2297. +static void lcd_implementation_status_screen()
  2298. +{
  2299.  
  2300.    const bool blink = lcd_blink();
  2301.  
  2302. @@ -491,9 +493,10 @@ static void lcd_implementation_status_screen() {
  2303.    // Fan Animation
  2304.    //
  2305.  
  2306. -  if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) {
  2307. -
  2308. -    u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT,
  2309. +  if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1))
  2310. +  {
  2311. +    // u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT,
  2312. +    u8g.drawBitmapP(0, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT,
  2313.        #if HAS_FAN0
  2314.          blink && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp
  2315.        #else
  2316. @@ -507,20 +510,24 @@ static void lcd_implementation_status_screen() {
  2317.    // Temperature Graphics and Info
  2318.    //
  2319.  
  2320. -  if (PAGE_UNDER(28)) {
  2321. +  if (PAGE_UNDER(28))
  2322. +  {
  2323.      // Extruders
  2324. -    HOTEND_LOOP() _draw_heater_status(5 + e * 25, e, blink);
  2325. +    // HOTEND_LOOP() _draw_heater_status(5 + e * 25, e, blink);
  2326. +    for(int e = 0; e < 1; e++) _draw_heater_status(38 + e * 25, e, blink);
  2327.  
  2328.      // Heated bed
  2329.      #if HOTENDS < 4 && HAS_TEMP_BED
  2330. -      _draw_heater_status(81, -1, blink);
  2331. +      _draw_heater_status(72, -1, blink);
  2332.      #endif
  2333.  
  2334.      #if HAS_FAN0
  2335. -      if (PAGE_CONTAINS(20, 27)) {
  2336. +      if (PAGE_CONTAINS(20, 27))
  2337. +      {
  2338.          // Fan
  2339.          const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256;
  2340. -        if (per) {
  2341. +        if (per)
  2342. +        {
  2343.            u8g.setPrintPos(104, 27);
  2344.            lcd_print(itostr3(per));
  2345.            u8g.print('%');
  2346. @@ -535,7 +542,8 @@ static void lcd_implementation_status_screen() {
  2347.      // SD Card Symbol
  2348.      //
  2349.  
  2350. -    if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
  2351. +    if (PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION)))
  2352. +    {
  2353.        // Upper box
  2354.        u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7);     // 42-48 (or 41-47)
  2355.        // Right edge
  2356. @@ -556,7 +564,7 @@ static void lcd_implementation_status_screen() {
  2357.      if (PAGE_CONTAINS(49, 52 - (TALL_FONT_CORRECTION)))       // 49-52 (or 49-51)
  2358.        u8g.drawFrame(
  2359.          PROGRESS_BAR_X, 49,
  2360. -        PROGRESS_BAR_WIDTH, 4 - (TALL_FONT_CORRECTION)
  2361. +        PROGRESS_BAR_X - 1, 4 - (TALL_FONT_CORRECTION)
  2362.        );
  2363.  
  2364.      if (IS_SD_PRINTING) {
  2365. @@ -568,7 +576,7 @@ static void lcd_implementation_status_screen() {
  2366.        if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION)))     // 50-51 (or just 50)
  2367.          u8g.drawBox(
  2368.            PROGRESS_BAR_X + 1, 50,
  2369. -          (uint16_t)((PROGRESS_BAR_WIDTH - 2) * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION)
  2370. +          (uint16_t)((PROGRESS_BAR_X - 1) * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION)
  2371.          );
  2372.  
  2373.        //
  2374. @@ -595,14 +603,31 @@ static void lcd_implementation_status_screen() {
  2375.        #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * DOG_CHAR_WIDTH)
  2376.      #endif
  2377.  
  2378. -    if (PAGE_CONTAINS(41, 48)) {
  2379. +    if (PAGE_CONTAINS(41, 48))
  2380. +    {
  2381.  
  2382.        char buffer[10];
  2383.        duration_t elapsed = print_job_timer.duration();
  2384.        bool has_days = (elapsed.value > 60*60*24L);
  2385.        uint8_t len = elapsed.toDigital(buffer, has_days);
  2386. -      u8g.setPrintPos(SD_DURATION_X, 48);
  2387. +      u8g.setPrintPos(60, 48);
  2388.        lcd_print(buffer);
  2389. +
  2390. +      if(previous_cmd_ms != 0)
  2391. +      {
  2392. +        // Displays the percentage of printing.
  2393. +        uint16_t progresssum=card.percentDone();
  2394. +        u8g.setPrintPos(104,51);
  2395. +        u8g.print(itostr3(progresssum));
  2396. +        u8g.print('%');
  2397. +      }
  2398. +      else
  2399. +      {
  2400. +        // Shows the percentage of print progress.
  2401. +        u8g.setPrintPos(104,51);
  2402. +        u8g.print(itostr3(0));
  2403. +        u8g.print('%');
  2404. +      }
  2405.      }
  2406.  
  2407.    #endif
  2408. @@ -641,7 +666,8 @@ static void lcd_implementation_status_screen() {
  2409.    #endif
  2410.  
  2411.    // At the first page, regenerate the XYZ strings
  2412. -  if (page.page == 0) {
  2413. +  if (page.page == 0)
  2414. +  {
  2415.      strcpy(xstring, ftostr4sign(current_position[X_AXIS]));
  2416.      strcpy(ystring, ftostr4sign(current_position[Y_AXIS]));
  2417.      strcpy(zstring, ftostr52sp(FIXFLOAT(current_position[Z_AXIS])));
  2418. @@ -690,7 +716,8 @@ static void lcd_implementation_status_screen() {
  2419.    // Feedrate
  2420.    //
  2421.  
  2422. -  if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
  2423. +  if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49))
  2424. +  {
  2425.      lcd_setFont(FONT_MENU);
  2426.      u8g.setPrintPos(3, 50);
  2427.      lcd_print(LCD_STR_FEEDRATE[0]);
  2428. @@ -723,14 +750,18 @@ static void lcd_implementation_status_screen() {
  2429.  
  2430.    #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
  2431.  
  2432. -  if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) {
  2433. +  if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE))
  2434. +  {
  2435.      u8g.setPrintPos(0, STATUS_BASELINE);
  2436.  
  2437.      #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
  2438. -      if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) {  //Display both Status message line and Filament display on the last line
  2439. +      if (PENDING(millis(), previous_lcd_status_ms + 5000UL))
  2440. +      {
  2441. +        //Display both Status message line and Filament display on the last line
  2442.          lcd_implementation_status_message(blink);
  2443.        }
  2444. -      else {
  2445. +      else
  2446. +      {
  2447.          lcd_printPGM(PSTR(LCD_STR_FILAM_DIA));
  2448.          u8g.print(':');
  2449.          lcd_print(ftostr12ns(filament_width_meas));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement