Scott Lahteine 5 лет назад
Родитель
Сommit
3d3d2a923b
3 измененных файлов: 19 добавлений и 58 удалений
  1. 4
    16
      Marlin/src/feature/bedlevel/bedlevel.cpp
  2. 14
    42
      Marlin/src/lcd/extui/ui_api.cpp
  3. 1
    0
      Marlin/src/sd/cardreader.h

+ 4
- 16
Marlin/src/feature/bedlevel/bedlevel.cpp Просмотреть файл

@@ -47,17 +47,9 @@
47 47
 #endif
48 48
 
49 49
 bool leveling_is_valid() {
50
-  return
51
-    #if ENABLED(MESH_BED_LEVELING)
52
-      mbl.has_mesh()
53
-    #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
54
-      !!bilinear_grid_spacing.x
55
-    #elif ENABLED(AUTO_BED_LEVELING_UBL)
56
-      ubl.mesh_is_valid()
57
-    #else // 3POINT, LINEAR
58
-      true
59
-    #endif
60
-  ;
50
+  return TERN1(MESH_BED_LEVELING,          mbl.has_mesh())
51
+      && TERN1(AUTO_BED_LEVELING_BILINEAR, !!bilinear_grid_spacing.x)
52
+      && TERN1(AUTO_BED_LEVELING_UBL,      ubl.mesh_is_valid());
61 53
 }
62 54
 
63 55
 /**
@@ -69,11 +61,7 @@ bool leveling_is_valid() {
69 61
  */
70 62
 void set_bed_leveling_enabled(const bool enable/*=true*/) {
71 63
 
72
-  #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
73
-    const bool can_change = (!enable || leveling_is_valid());
74
-  #else
75
-    constexpr bool can_change = true;
76
-  #endif
64
+  const bool can_change = TERN1(AUTO_BED_LEVELING_BILINEAR, !enable || leveling_is_valid());
77 65
 
78 66
   if (can_change && enable != planner.leveling_active) {
79 67
 

+ 14
- 42
Marlin/src/lcd/extui/ui_api.cpp Просмотреть файл

@@ -70,9 +70,6 @@
70 70
 
71 71
 #if ENABLED(SDSUPPORT)
72 72
   #include "../../sd/cardreader.h"
73
-  #define IFSD(A,B) (A)
74
-#else
75
-  #define IFSD(A,B) (B)
76 73
 #endif
77 74
 
78 75
 #if HAS_TRINAMIC_CONFIG
@@ -164,8 +161,7 @@ namespace ExtUI {
164 161
   }
165 162
 
166 163
   void yield() {
167
-    if (!flags.printer_killed)
168
-      thermalManager.manage_heater();
164
+    if (!flags.printer_killed) thermalManager.manage_heater();
169 165
   }
170 166
 
171 167
   void enableHeater(const extruder_t extruder) {
@@ -180,13 +176,9 @@ namespace ExtUI {
180 176
     #if HEATER_IDLE_HANDLER
181 177
       switch (heater) {
182 178
         #if HAS_HEATED_BED
183
-          case BED:
184
-            thermalManager.reset_bed_idle_timer();
185
-            return;
186
-        #endif
187
-        #if HAS_HEATED_CHAMBER
188
-          case CHAMBER: return; // Chamber has no idle timer
179
+          case BED: thermalManager.reset_bed_idle_timer(); return;
189 180
         #endif
181
+        TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer
190 182
         default:
191 183
           TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0));
192 184
           break;
@@ -233,28 +225,21 @@ namespace ExtUI {
233 225
   #endif
234 226
 
235 227
   bool isHeaterIdle(const extruder_t extruder) {
236
-    return false
237
-      #if HAS_HOTEND && HEATER_IDLE_HANDLER
238
-        || thermalManager.hotend_idle[extruder - E0].timed_out
239
-      #else
240
-        ; UNUSED(extruder)
241
-      #endif
242
-    ;
228
+    #if HAS_HOTEND && HEATER_IDLE_HANDLER
229
+      return thermalManager.hotend_idle[extruder - E0].timed_out
230
+    #else
231
+      UNUSED(extruder);
232
+      return false;
233
+    #endif
243 234
   }
244 235
 
245 236
   bool isHeaterIdle(const heater_t heater) {
246 237
     #if HEATER_IDLE_HANDLER
247 238
       switch (heater) {
248 239
         TERN_(HAS_HEATED_BED, case BED: return thermalManager.bed_idle.timed_out);
249
-        #if HAS_HEATED_CHAMBER
250
-          case CHAMBER: return false; // Chamber has no idle timer
251
-        #endif
240
+        TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return false); // Chamber has no idle timer
252 241
         default:
253
-          #if HAS_HOTEND
254
-            return thermalManager.hotend_idle[heater - H0].timed_out;
255
-          #else
256
-            return false;
257
-          #endif
242
+          return TERN0(HAS_HOTEND, thermalManager.hotend_idle[heater - H0].timed_out);
258 243
       }
259 244
     #else
260 245
       UNUSED(heater);
@@ -311,22 +296,13 @@ namespace ExtUI {
311 296
   }
312 297
 
313 298
   float getAxisPosition_mm(const axis_t axis) {
314
-    return
315
-      #if ENABLED(JOYSTICK)
316
-        flags.jogging ? destination[axis] :
317
-      #endif
318
-      current_position[axis];
299
+    return TERN_(JOYSTICK, flags.jogging ? destination[axis] :) current_position[axis];
319 300
   }
320 301
 
321 302
   float getAxisPosition_mm(const extruder_t extruder) {
322 303
     const extruder_t old_tool = getActiveTool();
323 304
     setActiveTool(extruder, true);
324
-    const float epos = (
325
-      #if ENABLED(JOYSTICK)
326
-        flags.jogging ? destination.e :
327
-      #endif
328
-      current_position.e
329
-    );
305
+    const float epos = TERN_(JOYSTICK, flags.jogging ? destination.e :) current_position.e;
330 306
     setActiveTool(old_tool, true);
331 307
     return epos;
332 308
   }
@@ -1037,11 +1013,7 @@ namespace ExtUI {
1037 1013
   }
1038 1014
 
1039 1015
   bool FileList::isAtRootDir() {
1040
-    return (true
1041
-      #if ENABLED(SDSUPPORT)
1042
-        && card.flag.workDirIsRoot
1043
-      #endif
1044
-    );
1016
+    return IFSD(card.flag.workDirIsRoot, true);
1045 1017
   }
1046 1018
 
1047 1019
   void FileList::upDir() {

+ 1
- 0
Marlin/src/sd/cardreader.h Просмотреть файл

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

Загрузка…
Отмена
Сохранить