Browse Source

Move inline laser state to fix EEPROM error

vanilla_fb_2.0.x
Scott Lahteine 5 years ago
parent
commit
181739d0d1
  1. 10
      Marlin/src/feature/spindle_laser.h
  2. 8
      Marlin/src/module/planner.cpp
  3. 9
      Marlin/src/module/planner.h
  4. 4
      Marlin/src/module/stepper.cpp

10
Marlin/src/feature/spindle_laser.h

@ -137,7 +137,7 @@ public:
#if ENABLED(LASER_POWER_INLINE) #if ENABLED(LASER_POWER_INLINE)
// Force disengage planner power control // Force disengage planner power control
static inline void inline_disable() { planner.settings.laser.status = 0; planner.settings.laser.power = 0; isOn = false;} static inline void inline_disable() { planner.laser.status = 0; planner.laser.power = 0; isOn = false;}
// Inline modes of all other functions; all enable planner inline power control // Inline modes of all other functions; all enable planner inline power control
static inline void inline_enabled(const bool enable) { enable ? inline_power(SPEED_POWER_STARTUP) : inline_ocr_power(0); } static inline void inline_enabled(const bool enable) { enable ? inline_power(SPEED_POWER_STARTUP) : inline_ocr_power(0); }
@ -146,8 +146,8 @@ public:
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
inline_ocr_power(translate_power(pwr)); inline_ocr_power(translate_power(pwr));
#else #else
planner.settings.laser.status = enabled(pwr) ? 0x03 : 0x01; planner.laser.status = enabled(pwr) ? 0x03 : 0x01;
planner.settings.laser.power = pwr; planner.laser.power = pwr;
#endif #endif
} }
@ -155,8 +155,8 @@ public:
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
static inline void inline_ocr_power(const uint8_t pwr) { static inline void inline_ocr_power(const uint8_t pwr) {
planner.settings.laser.status = pwr ? 0x03 : 0x01; planner.laser.status = pwr ? 0x03 : 0x01;
planner.settings.laser.power = pwr; planner.laser.power = pwr;
} }
#endif #endif
#endif #endif

8
Marlin/src/module/planner.cpp

@ -128,6 +128,10 @@ uint8_t Planner::delay_before_delivering; // This counter delays delivery
planner_settings_t Planner::settings; // Initialized by settings.load() planner_settings_t Planner::settings; // Initialized by settings.load()
#if ENABLED(LASER_POWER_INLINE)
laser_state_t Planner::laser; // Current state for blocks
#endif
uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
@ -1799,8 +1803,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
// Update block laser power // Update block laser power
#if ENABLED(LASER_POWER_INLINE) #if ENABLED(LASER_POWER_INLINE)
block->laser.status = settings.laser.status; block->laser.status = laser.status;
block->laser.power = settings.laser.power; block->laser.power = laser.power;
#endif #endif
// Number of steps for each axis // Number of steps for each axis

9
Marlin/src/module/planner.h

@ -248,7 +248,7 @@ typedef struct block_t {
* as it avoids floating points during move loop * as it avoids floating points during move loop
*/ */
uint8_t power; uint8_t power;
} settings_laser_t; } laser_state_t;
#endif #endif
typedef struct { typedef struct {
@ -261,9 +261,6 @@ typedef struct {
travel_acceleration; // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves. travel_acceleration; // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
feedRate_t min_feedrate_mm_s, // (mm/s) M205 S - Minimum linear feedrate feedRate_t min_feedrate_mm_s, // (mm/s) M205 S - Minimum linear feedrate
min_travel_feedrate_mm_s; // (mm/s) M205 T - Minimum travel feedrate min_travel_feedrate_mm_s; // (mm/s) M205 T - Minimum travel feedrate
#if ENABLED(LASER_POWER_INLINE)
settings_laser_t laser;
#endif
} planner_settings_t; } planner_settings_t;
#if DISABLED(SKEW_CORRECTION) #if DISABLED(SKEW_CORRECTION)
@ -334,6 +331,10 @@ class Planner {
static planner_settings_t settings; static planner_settings_t settings;
#if ENABLED(LASER_POWER_INLINE)
static laser_state_t laser;
#endif
static uint32_t max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2 static uint32_t max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
static float steps_to_mm[XYZE_N]; // Millimeters per step static float steps_to_mm[XYZE_N]; // Millimeters per step

4
Marlin/src/module/stepper.cpp

@ -2239,11 +2239,11 @@ uint32_t Stepper::block_phase_isr() {
#if ENABLED(LASER_POWER_INLINE_CONTINUOUS) #if ENABLED(LASER_POWER_INLINE_CONTINUOUS)
else { // No new block found; so apply inline laser parameters else { // No new block found; so apply inline laser parameters
// This should mean ending file with 'M5 I' will stop the laser; thus the inline flag isn't needed // This should mean ending file with 'M5 I' will stop the laser; thus the inline flag isn't needed
const uint8_t stat = planner.settings.laser.status; const uint8_t stat = planner.laser.status;
if (TEST(stat, 0)) { // Planner controls the laser if (TEST(stat, 0)) { // Planner controls the laser
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
if (TEST(stat, 1)) // Laser is on if (TEST(stat, 1)) // Laser is on
cutter.set_ocr_power(planner.settings.laser.power); cutter.set_ocr_power(planner.laser.power);
else else
cutter.set_power(0); cutter.set_power(0);
#else #else

Loading…
Cancel
Save