Simplify menu items, use enum, adjust settings
This commit is contained in:
committed by
InsanityAutomation
parent
74574449a9
commit
b7ddd541c9
@@ -39,7 +39,7 @@
|
||||
* P<index> : Mode 0 = NONE
|
||||
* 1 = Switch NO (HIGH = filament present)
|
||||
* 2 = Switch NC (LOW = filament present)
|
||||
* 7 = Encoder / Motion Sensor
|
||||
* 3 = Encoder / Motion Sensor
|
||||
*/
|
||||
void GcodeSuite::M591() {
|
||||
if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H"))) {
|
||||
@@ -48,19 +48,17 @@ void GcodeSuite::M591() {
|
||||
#endif
|
||||
const bool seenR = parser.seen_test('R'), seenS = parser.seen('S');
|
||||
if (seenR || seenS) runout.reset();
|
||||
#if NUM_RUNOUT_SENSORS > 1
|
||||
const uint8_t tool = parser.ushortval('E', active_extruder);
|
||||
#else
|
||||
constexpr uint8_t tool = 0;
|
||||
#endif
|
||||
const uint8_t tool = TERN0(MULTI_FILAMENT_SENSOR, parser.ushortval('E', active_extruder));
|
||||
if (seenS) runout.enabled[tool] = parser.value_bool();
|
||||
if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool);
|
||||
if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool);
|
||||
if (parser.seen('D') || parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool);
|
||||
if (parser.seen('P')) {
|
||||
const uint8_t tmp_mode = parser.value_int();
|
||||
if (tmp_mode < 3 || tmp_mode == 7) {
|
||||
runout.mode[tool] = tmp_mode;
|
||||
runout.reset();
|
||||
const RunoutMode tmp_mode = (RunoutMode)parser.value_int();
|
||||
switch (tmp_mode) {
|
||||
case RM_NONE ... RM_OUT_ON_HIGH:
|
||||
case RM_MOTION_SENSOR:
|
||||
runout.mode[tool] = tmp_mode;
|
||||
runout.reset();
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +81,7 @@ void GcodeSuite::M591_report(const bool forReplay/*=true*/) {
|
||||
LOOP_S_L_N(e, 1, NUM_RUNOUT_SENSORS)
|
||||
SERIAL_ECHOLNPGM(
|
||||
" M591"
|
||||
#if NUM_RUNOUT_SENSORS > 1
|
||||
#if MULTI_FILAMENT_SENSOR
|
||||
" E", e,
|
||||
#endif
|
||||
" S", runout.enabled[e]
|
||||
|
||||
@@ -688,13 +688,13 @@ void __O2 Endstops::report_states() {
|
||||
if (i > 1) SERIAL_CHAR(' ', '0' + i);
|
||||
SERIAL_ECHOPGM(": ");
|
||||
if (rm == RM_NONE)
|
||||
SERIAL_ECHOLNPGM("DISABLED");
|
||||
SERIAL_ECHOLNPGM(STR_OFF);
|
||||
else if (rm == RM_MOTION_SENSOR) {
|
||||
SERIAL_ECHOPGM("MOTION : ");
|
||||
print_es_state(extDigitalRead(pin) == state);
|
||||
print_es_state(extDigitalRead(pin) == outval);
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == state ? PSTR("MISSING") : PSTR("PRESENT"));
|
||||
SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == outval ? PSTR("OUT") : PSTR("PRESENT"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -113,9 +113,6 @@
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
#include "../feature/runout.h"
|
||||
#define NRS NUM_RUNOUT_SENSORS
|
||||
#else
|
||||
#define NRS 1
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCE_K_EXTRA)
|
||||
@@ -237,9 +234,11 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
// FILAMENT_RUNOUT_SENSOR
|
||||
//
|
||||
bool runout_enabled[NRS]; // M591 S
|
||||
float runout_distance_mm[NRS]; // M591 D
|
||||
uint8_t runout_mode[NRS]; // M591 P
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
bool runout_enabled[NUM_RUNOUT_SENSORS]; // M591 S
|
||||
float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D
|
||||
uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P
|
||||
#endif
|
||||
|
||||
//
|
||||
// ENABLE_LEVELING_FADE_HEIGHT
|
||||
@@ -808,29 +807,23 @@ void MarlinSettings::postprocess() {
|
||||
//
|
||||
// Hotend Offsets, if any
|
||||
//
|
||||
{
|
||||
#if HAS_HOTEND_OFFSET
|
||||
// Skip hotend 0 which must be 0
|
||||
LOOP_S_L_N(e, 1, HOTENDS)
|
||||
EEPROM_WRITE(hotend_offset[e]);
|
||||
#endif
|
||||
}
|
||||
#if HAS_HOTEND_OFFSET
|
||||
// Skip hotend 0 which must be 0
|
||||
LOOP_S_L_N(e, 1, HOTENDS)
|
||||
EEPROM_WRITE(hotend_offset[e]);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Filament Runout Sensor
|
||||
//
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
{
|
||||
_FIELD_TEST(runout_enabled);
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
LOOP_L_N(e, NRS) EEPROM_WRITE(runout.enabled[e]);
|
||||
LOOP_L_N(e, NRS) EEPROM_WRITE(runout.runout_distance(e));
|
||||
LOOP_L_N(e, NRS) EEPROM_WRITE(runout.mode[e]);
|
||||
#else
|
||||
EEPROM_WRITE((int8_t)-1);
|
||||
EEPROM_WRITE((float)-0.0f);
|
||||
EEPROM_WRITE((uint8_t)0);
|
||||
#endif
|
||||
LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.enabled[e]);
|
||||
LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.runout_distance(e));
|
||||
LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.mode[e]);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Global Leveling
|
||||
@@ -1760,30 +1753,28 @@ void MarlinSettings::postprocess() {
|
||||
//
|
||||
// Filament Runout Sensor
|
||||
//
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
{
|
||||
_FIELD_TEST(runout_enabled);
|
||||
|
||||
int8_t runout_enabled[NRS];
|
||||
float runout_distance_mm[NRS];
|
||||
uint8_t runout_mode[NRS];
|
||||
bool runout_enabled[NUM_RUNOUT_SENSORS];
|
||||
float runout_distance_mm[NUM_RUNOUT_SENSORS];
|
||||
RunoutMode runout_mode[NUM_RUNOUT_SENSORS];
|
||||
|
||||
LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_enabled[e]);
|
||||
LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_distance_mm[e]);
|
||||
LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_mode[e]);
|
||||
EEPROM_READ(runout_enabled);
|
||||
EEPROM_READ(runout_distance_mm);
|
||||
EEPROM_READ(runout_mode);
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
if (!validating) {
|
||||
LOOP_S_L_N(e, 0, NRS) {
|
||||
if (runout_enabled[e] >= 0) {
|
||||
runout.enabled[e] = (runout_enabled[e] > 0);
|
||||
runout.set_runout_distance(runout_distance_mm[e], e);
|
||||
runout.mode[e] = runout_mode[e];
|
||||
}
|
||||
}
|
||||
runout.reset();
|
||||
if (!validating) {
|
||||
LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) {
|
||||
runout.enabled[e] = runout_enabled[e];
|
||||
runout.set_runout_distance(runout_distance_mm[e], e);
|
||||
runout.mode[e] = runout_mode[e];
|
||||
}
|
||||
#endif
|
||||
runout.reset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Global Leveling
|
||||
@@ -2889,12 +2880,12 @@ void MarlinSettings::reset() {
|
||||
constexpr bool fred[] = FIL_RUNOUT_ENABLED;
|
||||
constexpr uint8_t frm[] = FIL_RUNOUT_MODE;
|
||||
constexpr float frd[] = FIL_RUNOUT_DISTANCE_MM;
|
||||
static_assert(COUNT(fred) == NRS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values.");
|
||||
static_assert(COUNT(frm) == NRS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values.");
|
||||
static_assert(COUNT(frd) == NRS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values.");
|
||||
static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values.");
|
||||
static_assert(COUNT(frm) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values.");
|
||||
static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values.");
|
||||
COPY(runout.enabled, fred);
|
||||
COPY(runout.mode, frm);
|
||||
LOOP_L_N(e, NRS) runout.set_runout_distance(frd[e], e);
|
||||
LOOP_L_N(e, NUM_RUNOUT_SENSORS) runout.set_runout_distance(frd[e], e);
|
||||
runout.reset();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user