Reduce repetition in menu edit items

This commit is contained in:
Scott Lahteine
2018-10-28 15:24:13 -05:00
parent b063b1b722
commit 3a935fd72b
4 changed files with 100 additions and 83 deletions

View File

@@ -212,10 +212,11 @@ static void lcd_factory_settings() {
dac_driver_getValues();
START_MENU();
MENU_BACK(MSG_CONTROL);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
#define EDIT_DAC_PERCENT(N) MENU_ITEM_EDIT_CALLBACK(int8, MSG_##N " " MSG_DAC_PERCENT, &driverPercent[_AXIS(N)], 0, 100, dac_driver_commit)
EDIT_DAC_PERCENT(X);
EDIT_DAC_PERCENT(Y);
EDIT_DAC_PERCENT(Z);
EDIT_DAC_PERCENT(E);
MENU_ITEM(function, MSG_DAC_EEPROM_WRITE, dac_commit_eeprom);
END_MENU();
}
@@ -229,14 +230,15 @@ static void lcd_factory_settings() {
void menu_pwm() {
START_MENU();
MENU_BACK(MSG_CONTROL);
#define EDIT_CURRENT_PWM(LABEL,I) MENU_ITEM_EDIT_CALLBACK(long5, LABEL, &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power)
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
MENU_ITEM_EDIT_CALLBACK(long5, MSG_X MSG_Y, &stepper.motor_current_setting[0], 100, 2000, stepper.refresh_motor_power);
EDIT_CURRENT_PWM(MSG_X MSG_Y, 0);
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
MENU_ITEM_EDIT_CALLBACK(long5, MSG_Z, &stepper.motor_current_setting[1], 100, 2000, stepper.refresh_motor_power);
EDIT_CURRENT_PWM(MSG_Z, 1);
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
MENU_ITEM_EDIT_CALLBACK(long5, MSG_E, &stepper.motor_current_setting[2], 100, 2000, stepper.refresh_motor_power);
EDIT_CURRENT_PWM(MSG_E, 2);
#endif
END_MENU();
}