Browse Source

Fix DAC-related bugs (#19921)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Orel 4 years ago
parent
commit
e3f1f7cd85
No account linked to committer's email address

+ 1
- 1
Marlin/src/feature/dac/dac_mcp4728.cpp View File

@@ -124,7 +124,7 @@ uint8_t MCP4728::getDrvPct(const uint8_t channel) { return uint8_t(100.0 * dac_v
124 124
  * DAC Values array and calls fastwrite to update the DAC.
125 125
  */
126 126
 void MCP4728::setDrvPct(xyze_uint8_t &pct) {
127
-  dac_values *= 0.01 * pct * (DAC_STEPPER_MAX);
127
+  dac_values *= pct.asFloat() * 0.01f * (DAC_STEPPER_MAX);
128 128
   fastWrite();
129 129
 }
130 130
 

+ 2
- 2
Marlin/src/gcode/calibrate/G34.cpp View File

@@ -80,7 +80,7 @@ void GcodeSuite::G34() {
80 80
     const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT);
81 81
     const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS];
82 82
     stepper.set_digipot_current(1, target_current);
83
-  #elif HAS_MOTOR_CURRENT_DAC
83
+  #elif ENABLED(HAS_MOTOR_CURRENT_DAC)
84 84
     const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT);
85 85
     const float previous_current = dac_amps(Z_AXIS, target_current);
86 86
     stepper_dac.set_current_value(Z_AXIS, target_current);
@@ -126,7 +126,7 @@ void GcodeSuite::G34() {
126 126
     stepper.set_digipot_current(Z_AXIS, previous_current);
127 127
   #elif HAS_MOTOR_CURRENT_PWM
128 128
     stepper.set_digipot_current(1, previous_current);
129
-  #elif HAS_MOTOR_CURRENT_DAC
129
+  #elif ENABLED(HAS_MOTOR_CURRENT_DAC)
130 130
     stepper_dac.set_current_value(Z_AXIS, previous_current);
131 131
   #elif ENABLED(HAS_MOTOR_CURRENT_I2C)
132 132
     digipot_i2c.set_current(Z_AXIS, previous_current)

+ 1
- 1
Marlin/src/lcd/menu/menu_advanced.cpp View File

@@ -72,7 +72,7 @@ void menu_backlash();
72 72
     EDIT_DAC_PERCENT(Y);
73 73
     EDIT_DAC_PERCENT(Z);
74 74
     EDIT_DAC_PERCENT(E);
75
-    ACTION_ITEM(MSG_DAC_EEPROM_WRITE, dac_commit_eeprom);
75
+    ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom);
76 76
     END_MENU();
77 77
   }
78 78
 

+ 1
- 1
Marlin/src/module/settings.cpp View File

@@ -3821,7 +3821,7 @@ void MarlinSettings::reset() {
3821 3821
     #elif HAS_MOTOR_CURRENT_I2C                                // i2c-based has any number of values
3822 3822
       // Values sent over i2c are not stored.
3823 3823
       // Indexes map directly to drivers, not axes.
3824
-    #elif HAS_MOTOR_CURRENT_DAC                                // DAC-based has 4 values, for X Y Z E
3824
+    #elif ENABLED(HAS_MOTOR_CURRENT_DAC)                                // DAC-based has 4 values, for X Y Z E
3825 3825
       // Values sent over i2c are not stored. Uses indirect mapping.
3826 3826
     #endif
3827 3827
 

Loading…
Cancel
Save