Skip to content

Commit f211646

Browse files
alx3devPragma8123
authored andcommitted
🩹 Fix M3 uninitialized warning (MarlinFirmware#26091)
1 parent f1d2e53 commit f211646

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Marlin/src/gcode/control/M3-M5.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,18 @@
3232
* Laser:
3333
* M3 - Laser ON/Power (Ramped power)
3434
* M4 - Laser ON/Power (Ramped power)
35-
* M5 - Set power output to 0 (leaving inline mode unchanged).
3635
*
3736
* M3I - Enable continuous inline power to be processed by the planner, with power
3837
* calculated and set in the planner blocks, processed inline during stepping.
39-
* Within inline mode M3 S-Values will set the power for the next moves e.g. G1 X10 Y10 powers on with the last S-Value.
38+
* In inline mode M3 S-Values will set the power for the next moves.
39+
* (e.g., G1 X10 Y10 powers on with the last S-Value.)
4040
* M3I must be set before using planner-synced M3 inline S-Values (LASER_POWER_SYNC).
4141
*
4242
* M4I - Set dynamic mode which calculates laser power OCR based on the current feedrate.
4343
*
44-
* M5I - Clear inline mode and set power to 0.
45-
*
4644
* Spindle:
4745
* M3 - Spindle ON (Clockwise)
4846
* M4 - Spindle ON (Counter-clockwise)
49-
* M5 - Spindle OFF
5047
*
5148
* Parameters:
5249
* S<power> - Set power. S0 will turn the spindle/laser off.
@@ -92,19 +89,15 @@ void GcodeSuite::M3_M4(const bool is_M4) {
9289
#endif
9390

9491
auto get_s_power = [] {
95-
float u;
9692
if (parser.seenval('S')) {
9793
const float v = parser.value_float();
98-
u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v));
94+
cutter.menuPower = cutter.unitPower = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v));
9995
}
10096
else if (cutter.cutter_mode == CUTTER_MODE_STANDARD)
101-
u = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
102-
103-
cutter.menuPower = cutter.unitPower = u;
97+
cutter.menuPower = cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
10498

10599
// PWM not implied, power converted to OCR from unit definition and on/off if not PWM.
106-
cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0);
107-
return u;
100+
cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(cutter.unitPower), cutter.unitPower > 0 ? 255 : 0);
108101
};
109102

110103
if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { // Laser power in inline mode
@@ -138,6 +131,13 @@ void GcodeSuite::M3_M4(const bool is_M4) {
138131

139132
/**
140133
* M5 - Cutter OFF (when moves are complete)
134+
*
135+
* Laser:
136+
* M5 - Set power output to 0 (leaving inline mode unchanged).
137+
* M5I - Clear inline mode and set power to 0.
138+
*
139+
* Spindle:
140+
* M5 - Spindle OFF
141141
*/
142142
void GcodeSuite::M5() {
143143
planner.synchronize();

0 commit comments

Comments
 (0)