Use uint8_t for all fan speeds (#12032)

This commit is contained in:
Scott Lahteine
2018-10-07 15:34:41 -05:00
committed by GitHub
parent cb7844c8d4
commit d6b0fbd771
25 changed files with 88 additions and 91 deletions

View File

@ -52,13 +52,13 @@ void GcodeSuite::M42() {
#if FAN_COUNT > 0
switch (pin) {
#if HAS_FAN0
case FAN_PIN: fanSpeeds[0] = pin_status; break;
case FAN_PIN: fan_speed[0] = pin_status; break;
#endif
#if HAS_FAN1
case FAN1_PIN: fanSpeeds[1] = pin_status; break;
case FAN1_PIN: fan_speed[1] = pin_status; break;
#endif
#if HAS_FAN2
case FAN2_PIN: fanSpeeds[2] = pin_status; break;
case FAN2_PIN: fan_speed[2] = pin_status; break;
#endif
}
#endif

View File

@ -98,10 +98,10 @@ void GcodeSuite::M81() {
planner.finish_and_disable();
#if FAN_COUNT > 0
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
#if ENABLED(PROBING_FANS_OFF)
fans_paused = false;
ZERO(paused_fanSpeeds);
ZERO(paused_fan_speed);
#endif
#endif

View File

@ -49,7 +49,7 @@ void GcodeSuite::M145() {
}
if (parser.seenval('F')) {
v = parser.value_int();
lcd_preheat_fan_speed[material] = constrain(v, 0, 255);
lcd_preheat_fan_speed[material] = (uint8_t)constrain(v, 0, 255);
}
#if TEMP_SENSOR_BED != 0
if (parser.seenval('B')) {

View File

@ -325,8 +325,8 @@ public:
FORCE_INLINE static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; }
FORCE_INLINE static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; }
FORCE_INLINE static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; }
FORCE_INLINE static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
FORCE_INLINE static float celsiusval(const char c, const float dval=0){ return seenval(c) ? value_celsius() : dval; }
FORCE_INLINE static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
FORCE_INLINE static float celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; }
};

View File

@ -25,7 +25,7 @@
#if FAN_COUNT > 0
#include "../gcode.h"
#include "../../Marlin.h" // for fanSpeeds — should move those to Planner
#include "../../Marlin.h" // for fan_speed — should move those to Planner
/**
* M106: Set Fan Speed
@ -48,21 +48,22 @@ void GcodeSuite::M106() {
if (t > 0) {
switch (t) {
case 1:
fanSpeeds[p] = old_fanSpeeds[p];
fan_speed[p] = old_fan_speed[p];
break;
case 2:
old_fanSpeeds[p] = fanSpeeds[p];
fanSpeeds[p] = new_fanSpeeds[p];
old_fan_speed[p] = fan_speed[p];
fan_speed[p] = new_fan_speed[p];
break;
default:
new_fanSpeeds[p] = MIN(t, 255);
new_fan_speed[p] = MIN(t, 255);
break;
}
return;
}
#endif // EXTRA_FAN_SPEED
const uint16_t s = parser.ushortval('S', 255);
fanSpeeds[p] = MIN(s, 255U);
fan_speed[p] = MIN(s, 255U);
}
}
@ -71,7 +72,7 @@ void GcodeSuite::M106() {
*/
void GcodeSuite::M107() {
const uint16_t p = parser.ushortval('P');
if (p < FAN_COUNT) fanSpeeds[p] = 0;
if (p < FAN_COUNT) fan_speed[p] = 0;
}
#endif // FAN_COUNT > 0