Skip to content

Commit

Permalink
define above use
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 18, 2022
1 parent 122bb48 commit bbf9a19
Showing 1 changed file with 30 additions and 35 deletions.
65 changes: 30 additions & 35 deletions Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,37 @@ void menu_backlash();
#if SHOW_MENU_ADVANCED_TEMPERATURE

#if ENABLED(MPC_EDIT_MENU)

#define MPC_EDIT_DEFS(N) \
MPC_t &c = thermalManager.temp_hotend[N].constants; \
TERN_(MPC_INCLUDE_FAN, editable.decimal = c.ambient_xfer_coeff_fan0 + c.fan255_adjustment)

#define _MPC_EDIT_ITEMS(N) \
EDIT_ITEM_FAST_N(float31sign, N, MSG_MPC_POWER_E, &c.heater_power, 1, 200); \
EDIT_ITEM_FAST_N(float31sign, N, MSG_MPC_BLOCK_HEAT_CAPACITY_E, &c.block_heat_capacity, 0, 40); \
EDIT_ITEM_FAST_N(float43, N, MSG_SENSOR_RESPONSIVENESS_E, &c.sensor_responsiveness, 0, 1); \
EDIT_ITEM_FAST_N(float43, N, MSG_MPC_AMBIENT_XFER_COEFF_E, &c.ambient_xfer_coeff_fan0, 0, 1)

#if ENABLED(MPC_INCLUDE_FAN)
#define MPC_EDIT_ITEMS(N)
_MPC_EDIT_ITEMS(N); \
EDIT_ITEM_FAST_N(float43, N, MSG_MPC_AMBIENT_XFER_COEFF_FAN255_E, &editable.decimal, 0, 1, []{ \
thermalManager.temp_hotend[N].constants.fan255_adjustment = editable.decimal - thermalManager.temp_hotend[N].constants.ambient_xfer_coeff_fan0; \
})
#else
#define MPC_EDIT_ITEMS _MPC_EDIT_ITEMS
#endif

#if HAS_MULTI_HOTEND
static uint8_t current_mpc_hotend = 0;
void mpc_edit_hotend(const uint8_t e);
void mpc_edit_hotend(const uint8_t e) {
static uint8_t current_mpc_hotend = 0;
current_mpc_hotend = e;
MPC_EDIT_DEFS(e);
START_MENU();
BACK_ITEM(MSG_TEMPERATURE);
MPC_EDIT_ITEMS(current_mpc_hotend);
END_MENU();
}
#endif
#endif

Expand Down Expand Up @@ -345,32 +370,13 @@ void menu_backlash();
#endif

#if ENABLED(MPC_EDIT_MENU)

#define _MPC_EDIT_ITEMS(N) \
EDIT_ITEM_FAST_N(float31sign, N, MSG_MPC_POWER_E, &c.heater_power, 1, 200); \
EDIT_ITEM_FAST_N(float31sign, N, MSG_MPC_BLOCK_HEAT_CAPACITY_E, &c.block_heat_capacity, 0, 40); \
EDIT_ITEM_FAST_N(float43, N, MSG_SENSOR_RESPONSIVENESS_E, &c.sensor_responsiveness, 0, 1); \
EDIT_ITEM_FAST_N(float43, N, MSG_MPC_AMBIENT_XFER_COEFF_E, &c.ambient_xfer_coeff_fan0, 0, 1)

#if ENABLED(MPC_INCLUDE_FAN)
#define MPC_EDIT_ITEMS(N) \
_MPC_EDIT_ITEMS(N); \
EDIT_ITEM_FAST_N(float43, N, MSG_MPC_AMBIENT_XFER_COEFF_FAN255_E, &editable.decimal, 0, 1, []{ \
thermalManager.temp_hotend[N].constants.fan255_adjustment = editable.decimal - thermalManager.temp_hotend[N].constants.ambient_xfer_coeff_fan0; \
});
#else
#define MPC_EDIT_ITEMS _MPC_EDIT_ITEMS
#endif

#if HAS_MULTI_HOTEND
#define MPC_ENTRY(N) SUBMENU_N(N, MSG_MPC_EDIT, []{ mpc_edit_hotend(MenuItemBase::itemIndex); });
REPEAT(HOTENDS, MPC_ENTRY);
#else
#define MPC_ENTRY MPC_EDIT_ITEMS
MPC_EDIT_ITEMS;
#endif

REPEAT(HOTENDS, MPC_ENTRY);

#endif // MPC_EDIT_MENU
#endif

#if ENABLED(MPC_AUTOTUNE_MENU)
ACTION_ITEM(MSG_MPC_AUTOTUNE, []{ queue.inject(F("M306 T")); ui.return_to_status(); });
Expand All @@ -397,17 +403,6 @@ void menu_backlash();
END_MENU();
}

#if ENABLED(MPC_EDIT_MENU) && HAS_MULTI_HOTEND
void mpc_edit_hotend(const uint8_t e) {
current_mpc_hotend = e;
MPC_EDIT_DEFS(e);
START_MENU();
BACK_ITEM(MSG_TEMPERATURE);
MPC_EDIT_ITEMS(current_mpc_hotend);
END_MENU();
}
#endif

#endif // SHOW_MENU_ADVANCED_TEMPERATURE

#if DISABLED(SLIM_LCD_MENUS)
Expand Down

0 comments on commit bbf9a19

Please sign in to comment.