浏览代码

Replace some functions with lambdas

Scott Lahteine 6 年前
父节点
当前提交
cc862a8213
共有 2 个文件被更改,包括 17 次插入19 次删除
  1. 9
    12
      Marlin/src/lcd/menu/menu_advanced.cpp
  2. 8
    7
      Marlin/src/lcd/menu/menu_configuration.cpp

+ 9
- 12
Marlin/src/lcd/menu/menu_advanced.cpp 查看文件

@@ -107,18 +107,7 @@ void menu_backlash();
107 107
 #endif
108 108
 
109 109
 #if ENABLED(SD_FIRMWARE_UPDATE)
110
-
111 110
   #include "../../module/configuration_store.h"
112
-
113
-  //
114
-  // Toggle the SD Firmware Update state in EEPROM
115
-  //
116
-  static void _lcd_toggle_sd_update() {
117
-    const bool new_state = !settings.sd_update_status();
118
-    ui.completion_feedback(settings.set_sd_update_status(new_state));
119
-    ui.return_to_status();
120
-    if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
121
-  }
122 111
 #endif
123 112
 
124 113
 #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
@@ -705,7 +694,15 @@ void menu_advanced_settings() {
705 694
 
706 695
   #if ENABLED(SD_FIRMWARE_UPDATE)
707 696
     bool sd_update_state = settings.sd_update_status();
708
-    MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, _lcd_toggle_sd_update);
697
+    MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, []{
698
+      //
699
+      // Toggle the SD Firmware Update state in EEPROM
700
+      //
701
+      const bool new_state = !settings.sd_update_status();
702
+      ui.completion_feedback(settings.set_sd_update_status(new_state));
703
+      ui.return_to_status();
704
+      if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
705
+    });
709 706
   #endif
710 707
 
711 708
   #if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)

+ 8
- 7
Marlin/src/lcd/menu/menu_configuration.cpp 查看文件

@@ -123,14 +123,15 @@ static void lcd_factory_settings() {
123 123
   #include "../../module/motion.h"
124 124
   #include "../../gcode/queue.h"
125 125
 
126
-  void _recalc_offsets() {
127
-    if (active_extruder && all_axes_known()) {  // For the 2nd extruder re-home so the next tool-change gets the new offsets.
128
-      enqueue_and_echo_commands_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
129
-      active_extruder = 0;
130
-    }
131
-  }
132
-
133 126
   void menu_tool_offsets() {
127
+
128
+    auto _recalc_offsets = []{
129
+      if (active_extruder && all_axes_known()) {  // For the 2nd extruder re-home so the next tool-change gets the new offsets.
130
+        enqueue_and_echo_commands_P(PSTR("G28")); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
131
+        active_extruder = 0;
132
+      }
133
+    };
134
+
134 135
     START_MENU();
135 136
     MENU_BACK(MSG_MAIN);
136 137
     #if ENABLED(DUAL_X_CARRIAGE)

正在加载...
取消
保存