Browse Source

Laser updates followup (#18237)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Luu Lac 5 years ago
parent
commit
0fa345f98f
No account linked to committer's email address
3 changed files with 23 additions and 16 deletions
  1. 20
    14
      Marlin/src/feature/spindle_laser.h
  2. 1
    0
      Marlin/src/module/planner.cpp
  3. 2
    2
      Marlin/src/module/stepper.h

+ 20
- 14
Marlin/src/feature/spindle_laser.h View File

91
     static cutter_frequency_t frequency;  // Set PWM frequency; range: 2K-50K
91
     static cutter_frequency_t frequency;  // Set PWM frequency; range: 2K-50K
92
   #endif
92
   #endif
93
 
93
 
94
-  static cutter_power_t menuPower;        // Power as set via LCD menu in PWM, Percentage or RPM
95
-  static cutter_power_t unitPower;        // Power as displayed status in PWM, Percentage or RPM
94
+  static cutter_power_t menuPower,        // Power as set via LCD menu in PWM, Percentage or RPM
95
+                        unitPower;        // Power as displayed status in PWM, Percentage or RPM
96
 
96
 
97
   static void init();
97
   static void init();
98
 
98
 
225
     static inline void inline_disable()	{
225
     static inline void inline_disable()	{
226
       isReady = false;
226
       isReady = false;
227
       unitPower = 0;
227
       unitPower = 0;
228
-      planner.laser_inline.status = 0;
228
+      planner.laser_inline.status.isPlanned = false;
229
+      planner.laser_inline.status.isEnabled = false;
229
       planner.laser_inline.power = 0;
230
       planner.laser_inline.power = 0;
230
     }
231
     }
231
 
232
 
232
     // Inline modes of all other functions; all enable planner inline power control
233
     // Inline modes of all other functions; all enable planner inline power control
233
     static inline void set_inline_enabled(const bool enable) {
234
     static inline void set_inline_enabled(const bool enable) {
234
-      if (enable) { inline_power(cpwr_to_upwr(SPEED_POWER_STARTUP)); }
235
-      else { unitPower = 0; isReady = false; menuPower = 0; TERN(SPINDLE_LASER_PWM, inline_ocr_power, inline_power)(0);}
235
+      if (enable)
236
+        inline_power(cpwr_to_upwr(SPEED_POWER_STARTUP)); 
237
+      else {
238
+        isReady = false;
239
+        unitPower = menuPower = 0;
240
+        planner.laser_inline.status.isPlanned = false;
241
+        TERN(SPINDLE_LASER_PWM, inline_ocr_power, inline_power)(0);
242
+      }
236
     }
243
     }
237
 
244
 
238
     // Set the power for subsequent movement blocks
245
     // Set the power for subsequent movement blocks
239
     static void inline_power(const cutter_power_t upwr) {
246
     static void inline_power(const cutter_power_t upwr) {
240
-      unitPower = upwr;
241
-      menuPower = unitPower;
247
+      unitPower = menuPower = upwr;
242
       #if ENABLED(SPINDLE_LASER_PWM)
248
       #if ENABLED(SPINDLE_LASER_PWM)
243
-          isReady = true;
244
         #if ENABLED(SPEED_POWER_RELATIVE) && !CUTTER_UNIT_IS(RPM) // relative mode does not turn laser off at 0, except for RPM
249
         #if ENABLED(SPEED_POWER_RELATIVE) && !CUTTER_UNIT_IS(RPM) // relative mode does not turn laser off at 0, except for RPM
245
-          planner.laser_inline.status = 0x03;
250
+          planner.laser_inline.status.isEnabled = true;
246
           planner.laser_inline.power = upower_to_ocr(upwr);
251
           planner.laser_inline.power = upower_to_ocr(upwr);
252
+          isReady = true;
247
         #else
253
         #else
248
-          if (upwr > 0)
249
-            inline_ocr_power(upower_to_ocr(upwr));
254
+          inline_ocr_power(upower_to_ocr(upwr));
250
         #endif
255
         #endif
251
       #else
256
       #else
252
-        planner.laser_inline.status = enabled(pwr) ? 0x03 : 0x01;
253
-        planner.laser_inline.power = pwr;
257
+        planner.laser_inline.status.isEnabled = enabled(upwr);
258
+        planner.laser_inline.power = upwr;
254
         isReady = enabled(upwr);
259
         isReady = enabled(upwr);
255
       #endif
260
       #endif
256
     }
261
     }
259
 
264
 
260
     #if ENABLED(SPINDLE_LASER_PWM)
265
     #if ENABLED(SPINDLE_LASER_PWM)
261
       static inline void inline_ocr_power(const uint8_t ocrpwr) {
266
       static inline void inline_ocr_power(const uint8_t ocrpwr) {
262
-        planner.laser_inline.status = ocrpwr ? 0x03 : 0x01;
267
+        isReady = ocrpwr > 0;
268
+        planner.laser_inline.status.isEnabled = ocrpwr > 0;
263
         planner.laser_inline.power = ocrpwr;
269
         planner.laser_inline.power = ocrpwr;
264
       }
270
       }
265
     #endif
271
     #endif

+ 1
- 0
Marlin/src/module/planner.cpp View File

1826
 
1826
 
1827
   // Update block laser power
1827
   // Update block laser power
1828
   #if ENABLED(LASER_POWER_INLINE)
1828
   #if ENABLED(LASER_POWER_INLINE)
1829
+    laser_inline.status.isPlanned = true;
1829
     block->laser.status = laser_inline.status;
1830
     block->laser.status = laser_inline.status;
1830
     block->laser.power = laser_inline.power;
1831
     block->laser.power = laser_inline.power;
1831
   #endif
1832
   #endif

+ 2
- 2
Marlin/src/module/stepper.h View File

355
     #if ENABLED(LASER_POWER_INLINE_TRAPEZOID)
355
     #if ENABLED(LASER_POWER_INLINE_TRAPEZOID)
356
 
356
 
357
       typedef struct {
357
       typedef struct {
358
-        bool trap_en;       // Trapezoid needed flag (i.e., laser on, planner in control)
358
+        bool enabled;       // Trapezoid needed flag (i.e., laser on, planner in control)
359
         uint8_t cur_power;  // Current laser power
359
         uint8_t cur_power;  // Current laser power
360
         bool cruise_set;    // Power set up for cruising?
360
         bool cruise_set;    // Power set up for cruising?
361
 
361
 
367
         #endif
367
         #endif
368
       } stepper_laser_t;
368
       } stepper_laser_t;
369
 
369
 
370
-      static stepper_laser_t laser;
370
+      static stepper_laser_t laser_trap;
371
 
371
 
372
     #endif
372
     #endif
373
 
373
 

Loading…
Cancel
Save