Skip to content

Commit

Permalink
Fix DAC-related bugs (MarlinFirmware#19921)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
2 people authored and vgadreau committed Dec 9, 2020
1 parent f2d9064 commit b095c07
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/feature/dac/dac_mcp4728.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/calibrate/G34.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b095c07

Please sign in to comment.