MarlinUI support for up to 5 Material Presets (#18488)
- Add `I` preset parameter to `G26`, `M106`, `M140`, and `M190`. - Extend menu items to permit a string interpolation. - Keep material names in a list and interpolate in menu items. - Extend material presets to support up to 5 predefined materials. Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,10 @@
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/temperature.h"
|
||||
|
||||
#if PREHEAT_COUNT
|
||||
#include "../../lcd/ultralcd.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
#define _ALT_P active_extruder
|
||||
#define _CNT_P EXTRUDERS
|
||||
@@ -39,6 +43,7 @@
|
||||
/**
|
||||
* M106: Set Fan Speed
|
||||
*
|
||||
* I<index> Material Preset index (if material presets are defined)
|
||||
* S<int> Speed between 0-255
|
||||
* P<index> Fan index, if more than one fan
|
||||
*
|
||||
@@ -50,19 +55,32 @@
|
||||
* 3-255 = Set the speed for use with T2
|
||||
*/
|
||||
void GcodeSuite::M106() {
|
||||
const uint8_t p = parser.byteval('P', _ALT_P);
|
||||
const uint8_t pfan = parser.byteval('P', _ALT_P);
|
||||
|
||||
if (p < _CNT_P) {
|
||||
if (pfan < _CNT_P) {
|
||||
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
const uint16_t t = parser.intval('T');
|
||||
if (t > 0) return thermalManager.set_temp_fan_speed(p, t);
|
||||
if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t);
|
||||
#endif
|
||||
uint16_t d = parser.seen('A') ? thermalManager.fan_speed[active_extruder] : 255;
|
||||
uint16_t s = parser.ushortval('S', d);
|
||||
NOMORE(s, 255U);
|
||||
|
||||
thermalManager.set_fan_speed(p, s);
|
||||
const uint16_t dspeed = parser.seen('A') ? thermalManager.fan_speed[active_extruder] : 255;
|
||||
|
||||
uint16_t speed = dspeed;
|
||||
|
||||
// Accept 'I' if temperature presets are defined
|
||||
#if PREHEAT_COUNT
|
||||
const bool got_preset = parser.seenval('I');
|
||||
if (got_preset) speed = ui.material_preset[_MIN(parser.value_byte(), PREHEAT_COUNT - 1)].fan_speed;
|
||||
#else
|
||||
constexpr bool got_preset = false;
|
||||
#endif
|
||||
|
||||
if (!got_preset && parser.seenval('S'))
|
||||
speed = parser.value_ushort();
|
||||
|
||||
// Set speed, with constraint
|
||||
thermalManager.set_fan_speed(pfan, speed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user