Replace some functions with lambdas

This commit is contained in:
Scott Lahteine 2019-05-21 18:23:40 -05:00
parent fafd73a3af
commit cc862a8213
2 changed files with 17 additions and 19 deletions

View file

@ -107,18 +107,7 @@ void menu_backlash();
#endif #endif
#if ENABLED(SD_FIRMWARE_UPDATE) #if ENABLED(SD_FIRMWARE_UPDATE)
#include "../../module/configuration_store.h" #include "../../module/configuration_store.h"
//
// Toggle the SD Firmware Update state in EEPROM
//
static void _lcd_toggle_sd_update() {
const bool new_state = !settings.sd_update_status();
ui.completion_feedback(settings.set_sd_update_status(new_state));
ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
}
#endif #endif
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE) #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
@ -705,7 +694,15 @@ void menu_advanced_settings() {
#if ENABLED(SD_FIRMWARE_UPDATE) #if ENABLED(SD_FIRMWARE_UPDATE)
bool sd_update_state = settings.sd_update_status(); bool sd_update_state = settings.sd_update_status();
MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, _lcd_toggle_sd_update); MENU_ITEM_EDIT_CALLBACK(bool, MSG_SD_UPDATE, &sd_update_state, []{
//
// Toggle the SD Firmware Update state in EEPROM
//
const bool new_state = !settings.sd_update_status();
ui.completion_feedback(settings.set_sd_update_status(new_state));
ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
});
#endif #endif
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS) #if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)

View file

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