Browse Source

Fix SpindleLaser::cpwr_to_pct() maths (#19970)

Julien Lirochon 4 years ago
parent
commit
24c5259005
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      Marlin/src/feature/spindle_laser.h

+ 3
- 3
Marlin/src/feature/spindle_laser.h View File

@@ -46,14 +46,14 @@
46 46
 class SpindleLaser {
47 47
 public:
48 48
   static constexpr float
49
-    min_pct = round(TERN(CUTTER_POWER_RELATIVE, 0, (100 * float(SPEED_POWER_MIN) / TERN(SPINDLE_FEATURE, float(SPEED_POWER_MAX), 100)))),
50
-    max_pct = round(TERN(SPINDLE_FEATURE, 100, float(SPEED_POWER_MAX)));
49
+    min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN))),
50
+    max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX);
51 51
 
52 52
   static const inline uint8_t pct_to_ocr(const float pct) { return uint8_t(PCT_TO_PWM(pct)); }
53 53
 
54 54
   // cpower = configured values (ie SPEED_POWER_MAX)
55 55
   static const inline uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { // configured value to pct
56
-    return unitPower ? round(100 * (cpwr - SPEED_POWER_FLOOR) / (SPEED_POWER_MAX - SPEED_POWER_FLOOR)) : 0;
56
+    return unitPower ? round(100.0f * (cpwr - (SPEED_POWER_FLOOR)) / (SPEED_POWER_MAX - (SPEED_POWER_FLOOR))) : 0;
57 57
   }
58 58
 
59 59
   // Convert a configured value (cpower)(ie SPEED_POWER_STARTUP) to unit power (upwr, upower),

Loading…
Cancel
Save