Fix DAC-related bugs (#19921)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Orel 2020-10-28 03:37:10 +01:00 committed by Scott Lahteine
parent d7d1ef8228
commit f5f6170858
4 changed files with 5 additions and 5 deletions

View File

@ -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. * DAC Values array and calls fastwrite to update the DAC.
*/ */
void MCP4728::setDrvPct(xyze_uint8_t &pct) { 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(); fastWrite();
} }

View File

@ -80,7 +80,7 @@ void GcodeSuite::G34() {
const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT);
const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS];
stepper.set_digipot_current(1, target_current); 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 target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT);
const float previous_current = dac_amps(Z_AXIS, target_current); const float previous_current = dac_amps(Z_AXIS, target_current);
stepper_dac.set_current_value(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); stepper.set_digipot_current(Z_AXIS, previous_current);
#elif HAS_MOTOR_CURRENT_PWM #elif HAS_MOTOR_CURRENT_PWM
stepper.set_digipot_current(1, previous_current); 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); stepper_dac.set_current_value(Z_AXIS, previous_current);
#elif ENABLED(HAS_MOTOR_CURRENT_I2C) #elif ENABLED(HAS_MOTOR_CURRENT_I2C)
digipot_i2c.set_current(Z_AXIS, previous_current) digipot_i2c.set_current(Z_AXIS, previous_current)

View File

@ -72,7 +72,7 @@ void menu_backlash();
EDIT_DAC_PERCENT(Y); EDIT_DAC_PERCENT(Y);
EDIT_DAC_PERCENT(Z); EDIT_DAC_PERCENT(Z);
EDIT_DAC_PERCENT(E); 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(); END_MENU();
} }

View File

@ -3821,7 +3821,7 @@ void MarlinSettings::reset() {
#elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values
// Values sent over i2c are not stored. // Values sent over i2c are not stored.
// Indexes map directly to drivers, not axes. // 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. // Values sent over i2c are not stored. Uses indirect mapping.
#endif #endif