update code base to Marlin 2.0.9.2
This commit is contained in:
130
Marlin/src/feature/powerloss.h
Executable file → Normal file
130
Marlin/src/feature/powerloss.h
Executable file → Normal file
@@ -16,18 +16,24 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* power_loss_recovery.h - Resume an SD print after power-loss
|
||||
* feature/powerloss.h - Resume an SD print after power-loss
|
||||
*/
|
||||
|
||||
#include "../sd/cardreader.h"
|
||||
#include "../gcode/gcode.h"
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(GCODE_REPEAT_MARKERS)
|
||||
#include "../feature/repeat.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
#include "../feature/mixing.h"
|
||||
#endif
|
||||
@@ -36,6 +42,10 @@
|
||||
#define POWER_LOSS_STATE HIGH
|
||||
#endif
|
||||
|
||||
#ifndef POWER_LOSS_ZRAISE
|
||||
#define POWER_LOSS_ZRAISE 2
|
||||
#endif
|
||||
|
||||
//#define DEBUG_POWER_LOSS_RECOVERY
|
||||
//#define SAVE_EACH_CMD_MODE
|
||||
//#define SAVE_INFO_INTERVAL_MS 0
|
||||
@@ -45,6 +55,14 @@ typedef struct {
|
||||
|
||||
// Machine state
|
||||
xyze_pos_t current_position;
|
||||
uint16_t feedrate;
|
||||
|
||||
float zraise;
|
||||
|
||||
// Repeat information
|
||||
#if ENABLED(GCODE_REPEAT_MARKERS)
|
||||
Repeat stored_repeat;
|
||||
#endif
|
||||
|
||||
#if HAS_HOME_OFFSET
|
||||
xyz_pos_t home_offset;
|
||||
@@ -52,36 +70,25 @@ typedef struct {
|
||||
#if HAS_POSITION_SHIFT
|
||||
xyz_pos_t position_shift;
|
||||
#endif
|
||||
|
||||
uint16_t feedrate;
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
uint8_t active_extruder;
|
||||
#endif
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
bool volumetric_enabled;
|
||||
#if EXTRUDERS > 1
|
||||
float filament_size[EXTRUDERS];
|
||||
#else
|
||||
float filament_size;
|
||||
#endif
|
||||
float filament_size[EXTRUDERS];
|
||||
#endif
|
||||
|
||||
#if HOTENDS
|
||||
int16_t target_temperature[HOTENDS];
|
||||
#if HAS_HOTEND
|
||||
celsius_t target_temperature[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
int16_t target_temperature_bed;
|
||||
celsius_t target_temperature_bed;
|
||||
#endif
|
||||
|
||||
#if FAN_COUNT
|
||||
#if HAS_FAN
|
||||
uint8_t fan_speed[FAN_COUNT];
|
||||
#endif
|
||||
|
||||
#if HAS_LEVELING
|
||||
bool leveling;
|
||||
float fade;
|
||||
#endif
|
||||
|
||||
@@ -98,9 +105,6 @@ typedef struct {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Relative axis modes
|
||||
uint8_t axis_relative;
|
||||
|
||||
// SD Filename and position
|
||||
char sd_filename[MAXPATHNAMELENGTH];
|
||||
volatile uint32_t sdpos;
|
||||
@@ -108,8 +112,26 @@ typedef struct {
|
||||
// Job elapsed time
|
||||
millis_t print_job_elapsed;
|
||||
|
||||
// Relative axis modes
|
||||
uint8_t axis_relative;
|
||||
|
||||
// Misc. Marlin flags
|
||||
struct {
|
||||
bool raised:1; // Raised before saved
|
||||
bool dryrun:1; // M111 S8
|
||||
bool allow_cold_extrusion:1; // M302 P1
|
||||
#if HAS_LEVELING
|
||||
bool leveling:1; // M420 S
|
||||
#endif
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
bool volumetric_enabled:1; // M200 S D
|
||||
#endif
|
||||
} flag;
|
||||
|
||||
uint8_t valid_foot;
|
||||
|
||||
bool valid() { return valid_head && valid_head == valid_foot; }
|
||||
|
||||
} job_recovery_info_t;
|
||||
|
||||
class PrintJobRecovery {
|
||||
@@ -123,17 +145,19 @@ class PrintJobRecovery {
|
||||
static uint32_t cmd_sdpos, //!< SD position of the next command
|
||||
sdpos[BUFSIZE]; //!< SD positions of queued commands
|
||||
|
||||
#if HAS_DWIN_E3V2_BASIC
|
||||
static bool dwin_flag;
|
||||
#endif
|
||||
|
||||
static void init();
|
||||
static void prepare();
|
||||
|
||||
static inline void setup() {
|
||||
#if PIN_EXISTS(POWER_LOSS)
|
||||
#if ENABLED(POWER_LOSS_PULL)
|
||||
#if POWER_LOSS_STATE == LOW
|
||||
SET_INPUT_PULLUP(POWER_LOSS_PIN);
|
||||
#else
|
||||
SET_INPUT_PULLDOWN(POWER_LOSS_PIN);
|
||||
#endif
|
||||
#if ENABLED(POWER_LOSS_PULLUP)
|
||||
SET_INPUT_PULLUP(POWER_LOSS_PIN);
|
||||
#elif ENABLED(POWER_LOSS_PULLDOWN)
|
||||
SET_INPUT_PULLDOWN(POWER_LOSS_PIN);
|
||||
#else
|
||||
SET_INPUT(POWER_LOSS_PIN);
|
||||
#endif
|
||||
@@ -156,36 +180,46 @@ class PrintJobRecovery {
|
||||
static void resume();
|
||||
static void purge();
|
||||
|
||||
static inline void cancel() { purge(); card.autostart_index = 0; }
|
||||
static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); }
|
||||
|
||||
static void load();
|
||||
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE));
|
||||
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);
|
||||
|
||||
#if PIN_EXISTS(POWER_LOSS)
|
||||
static inline void outage() {
|
||||
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE)
|
||||
_outage();
|
||||
}
|
||||
#endif
|
||||
#if PIN_EXISTS(POWER_LOSS)
|
||||
static inline void outage() {
|
||||
static constexpr uint8_t OUTAGE_THRESHOLD = 3;
|
||||
static uint8_t outage_counter = 0;
|
||||
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
|
||||
outage_counter++;
|
||||
if (outage_counter >= OUTAGE_THRESHOLD) _outage();
|
||||
}
|
||||
else
|
||||
outage_counter = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline bool valid() { return info.valid_head && info.valid_head == info.valid_foot; }
|
||||
// The referenced file exists
|
||||
static inline bool interrupted_file_exists() { return card.fileExists(info.sd_filename); }
|
||||
|
||||
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
||||
static void debug(PGM_P const prefix);
|
||||
#else
|
||||
static inline void debug(PGM_P const) {}
|
||||
#endif
|
||||
static inline bool valid() { return info.valid() && interrupted_file_exists(); }
|
||||
|
||||
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
|
||||
static void debug(PGM_P const prefix);
|
||||
#else
|
||||
static inline void debug(PGM_P const) {}
|
||||
#endif
|
||||
|
||||
private:
|
||||
static void write();
|
||||
|
||||
#if ENABLED(BACKUP_POWER_SUPPLY)
|
||||
static void raise_z();
|
||||
#endif
|
||||
#if ENABLED(BACKUP_POWER_SUPPLY)
|
||||
static void retract_and_lift(const_float_t zraise);
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(POWER_LOSS)
|
||||
static void _outage();
|
||||
#endif
|
||||
#if PIN_EXISTS(POWER_LOSS)
|
||||
friend class GcodeSuite;
|
||||
static void _outage();
|
||||
#endif
|
||||
};
|
||||
|
||||
extern PrintJobRecovery recovery;
|
||||
|
Reference in New Issue
Block a user