Cleanup with updated macros

This commit is contained in:
Scott Lahteine 2020-04-28 19:14:43 -05:00
parent f03f76ecfb
commit 3d3d2a923b
3 changed files with 19 additions and 58 deletions

View File

@ -47,17 +47,9 @@
#endif
bool leveling_is_valid() {
return
#if ENABLED(MESH_BED_LEVELING)
mbl.has_mesh()
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
!!bilinear_grid_spacing.x
#elif ENABLED(AUTO_BED_LEVELING_UBL)
ubl.mesh_is_valid()
#else // 3POINT, LINEAR
true
#endif
;
return TERN1(MESH_BED_LEVELING, mbl.has_mesh())
&& TERN1(AUTO_BED_LEVELING_BILINEAR, !!bilinear_grid_spacing.x)
&& TERN1(AUTO_BED_LEVELING_UBL, ubl.mesh_is_valid());
}
/**
@ -69,11 +61,7 @@ bool leveling_is_valid() {
*/
void set_bed_leveling_enabled(const bool enable/*=true*/) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
const bool can_change = (!enable || leveling_is_valid());
#else
constexpr bool can_change = true;
#endif
const bool can_change = TERN1(AUTO_BED_LEVELING_BILINEAR, !enable || leveling_is_valid());
if (can_change && enable != planner.leveling_active) {

View File

@ -70,9 +70,6 @@
#if ENABLED(SDSUPPORT)
#include "../../sd/cardreader.h"
#define IFSD(A,B) (A)
#else
#define IFSD(A,B) (B)
#endif
#if HAS_TRINAMIC_CONFIG
@ -164,8 +161,7 @@ namespace ExtUI {
}
void yield() {
if (!flags.printer_killed)
thermalManager.manage_heater();
if (!flags.printer_killed) thermalManager.manage_heater();
}
void enableHeater(const extruder_t extruder) {
@ -180,13 +176,9 @@ namespace ExtUI {
#if HEATER_IDLE_HANDLER
switch (heater) {
#if HAS_HEATED_BED
case BED:
thermalManager.reset_bed_idle_timer();
return;
#endif
#if HAS_HEATED_CHAMBER
case CHAMBER: return; // Chamber has no idle timer
case BED: thermalManager.reset_bed_idle_timer(); return;
#endif
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer
default:
TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0));
break;
@ -233,28 +225,21 @@ namespace ExtUI {
#endif
bool isHeaterIdle(const extruder_t extruder) {
return false
#if HAS_HOTEND && HEATER_IDLE_HANDLER
|| thermalManager.hotend_idle[extruder - E0].timed_out
return thermalManager.hotend_idle[extruder - E0].timed_out
#else
; UNUSED(extruder)
UNUSED(extruder);
return false;
#endif
;
}
bool isHeaterIdle(const heater_t heater) {
#if HEATER_IDLE_HANDLER
switch (heater) {
TERN_(HAS_HEATED_BED, case BED: return thermalManager.bed_idle.timed_out);
#if HAS_HEATED_CHAMBER
case CHAMBER: return false; // Chamber has no idle timer
#endif
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return false); // Chamber has no idle timer
default:
#if HAS_HOTEND
return thermalManager.hotend_idle[heater - H0].timed_out;
#else
return false;
#endif
return TERN0(HAS_HOTEND, thermalManager.hotend_idle[heater - H0].timed_out);
}
#else
UNUSED(heater);
@ -311,22 +296,13 @@ namespace ExtUI {
}
float getAxisPosition_mm(const axis_t axis) {
return
#if ENABLED(JOYSTICK)
flags.jogging ? destination[axis] :
#endif
current_position[axis];
return TERN_(JOYSTICK, flags.jogging ? destination[axis] :) current_position[axis];
}
float getAxisPosition_mm(const extruder_t extruder) {
const extruder_t old_tool = getActiveTool();
setActiveTool(extruder, true);
const float epos = (
#if ENABLED(JOYSTICK)
flags.jogging ? destination.e :
#endif
current_position.e
);
const float epos = TERN_(JOYSTICK, flags.jogging ? destination.e :) current_position.e;
setActiveTool(old_tool, true);
return epos;
}
@ -1037,11 +1013,7 @@ namespace ExtUI {
}
bool FileList::isAtRootDir() {
return (true
#if ENABLED(SDSUPPORT)
&& card.flag.workDirIsRoot
#endif
);
return IFSD(card.flag.workDirIsRoot, true);
}
void FileList::upDir() {

View File

@ -30,6 +30,7 @@
#endif
#define SD_ORDER(N,C) (TERN(SDCARD_RATHERRECENTFIRST, C - 1 - (N), N))
#define IFSD(A,B) TERN(SDSUPPORT,A,B)
#define MAX_DIR_DEPTH 10 // Maximum folder depth
#define MAXDIRNAMELENGTH 8 // DOS folder name size