Fix DAC setDrvPct (#20205)
This commit is contained in:
parent
19d0c985be
commit
fe88fb7ed9
|
@ -123,8 +123,8 @@ uint8_t MCP4728::getDrvPct(const uint8_t channel) { return uint8_t(100.0 * dac_v
|
|||
* Receives all Drive strengths as 0-100 percent values, updates
|
||||
* DAC Values array and calls fastwrite to update the DAC.
|
||||
*/
|
||||
void MCP4728::setDrvPct(xyze_uint8_t &pct) {
|
||||
dac_values *= pct.asFloat() * 0.01f * (DAC_STEPPER_MAX);
|
||||
void MCP4728::setDrvPct(xyze_uint_t &pct) {
|
||||
dac_values = pct * (DAC_STEPPER_MAX) * 0.01f;
|
||||
fastWrite();
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
static uint8_t fastWrite();
|
||||
static uint8_t simpleCommand(const byte simpleCommand);
|
||||
static uint8_t getDrvPct(const uint8_t channel);
|
||||
static void setDrvPct(xyze_uint8_t &pct);
|
||||
static void setDrvPct(xyze_uint_t &pct);
|
||||
};
|
||||
|
||||
extern MCP4728 mcp4728;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
bool dac_present = false;
|
||||
constexpr xyze_uint8_t dac_order = DAC_STEPPER_ORDER;
|
||||
xyze_uint8_t dac_channel_pct = DAC_MOTOR_CURRENT_DEFAULT;
|
||||
xyze_uint_t dac_channel_pct = DAC_MOTOR_CURRENT_DEFAULT;
|
||||
|
||||
StepperDAC stepper_dac;
|
||||
|
||||
|
@ -72,8 +72,8 @@ void StepperDAC::set_current_percent(const uint8_t channel, float val) {
|
|||
set_current_value(channel, _MIN(val, 100.0f) * (DAC_STEPPER_MAX) / 100.0f);
|
||||
}
|
||||
|
||||
static float dac_perc(int8_t n) { return 100.0 * mcp4728.getValue(dac_order[n]) * RECIPROCAL(DAC_STEPPER_MAX); }
|
||||
static float dac_amps(int8_t n) { return mcp4728.getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE); }
|
||||
static float dac_perc(int8_t n) { return mcp4728.getDrvPct(dac_order[n]); }
|
||||
static float dac_amps(int8_t n) { return mcp4728.getValue(dac_order[n]) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE * 1000); }
|
||||
|
||||
uint8_t StepperDAC::get_current_percent(const AxisEnum axis) { return mcp4728.getDrvPct(dac_order[axis]); }
|
||||
void StepperDAC::set_current_percents(xyze_uint8_t &pct) {
|
||||
|
|
Loading…
Reference in a new issue