From e3f1f7cd857f9fbfdbf6d0872324cb37d069b3f6 Mon Sep 17 00:00:00 2001 From: Orel <37673727+0r31@users.noreply.github.com> Date: Wed, 28 Oct 2020 03:37:10 +0100 Subject: [PATCH] Fix DAC-related bugs (#19921) Co-authored-by: Scott Lahteine --- Marlin/src/feature/dac/dac_mcp4728.cpp | 2 +- Marlin/src/gcode/calibrate/G34.cpp | 4 ++-- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/module/settings.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/feature/dac/dac_mcp4728.cpp b/Marlin/src/feature/dac/dac_mcp4728.cpp index 81c465cf29..c7a6370e17 100644 --- a/Marlin/src/feature/dac/dac_mcp4728.cpp +++ b/Marlin/src/feature/dac/dac_mcp4728.cpp @@ -124,7 +124,7 @@ uint8_t MCP4728::getDrvPct(const uint8_t channel) { return uint8_t(100.0 * dac_v * DAC Values array and calls fastwrite to update the DAC. */ void MCP4728::setDrvPct(xyze_uint8_t &pct) { - dac_values *= 0.01 * pct * (DAC_STEPPER_MAX); + dac_values *= pct.asFloat() * 0.01f * (DAC_STEPPER_MAX); fastWrite(); } diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 0ca4490eb6..315b2d7333 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -80,7 +80,7 @@ void GcodeSuite::G34() { const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; stepper.set_digipot_current(1, target_current); - #elif HAS_MOTOR_CURRENT_DAC + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT); const float previous_current = dac_amps(Z_AXIS, target_current); stepper_dac.set_current_value(Z_AXIS, target_current); @@ -126,7 +126,7 @@ void GcodeSuite::G34() { stepper.set_digipot_current(Z_AXIS, previous_current); #elif HAS_MOTOR_CURRENT_PWM stepper.set_digipot_current(1, previous_current); - #elif HAS_MOTOR_CURRENT_DAC + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) stepper_dac.set_current_value(Z_AXIS, previous_current); #elif ENABLED(HAS_MOTOR_CURRENT_I2C) digipot_i2c.set_current(Z_AXIS, previous_current) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 642d9d84d9..0e207ffc55 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -72,7 +72,7 @@ void menu_backlash(); EDIT_DAC_PERCENT(Y); EDIT_DAC_PERCENT(Z); EDIT_DAC_PERCENT(E); - ACTION_ITEM(MSG_DAC_EEPROM_WRITE, dac_commit_eeprom); + ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom); END_MENU(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 5c646c85dd..2ae4be5f49 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3821,7 +3821,7 @@ void MarlinSettings::reset() { #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values // Values sent over i2c are not stored. // Indexes map directly to drivers, not axes. - #elif HAS_MOTOR_CURRENT_DAC // DAC-based has 4 values, for X Y Z E + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) // DAC-based has 4 values, for X Y Z E // Values sent over i2c are not stored. Uses indirect mapping. #endif