[Grbl_Esp32 PR#635] Cleaned up AMASS code

未分类 bolang 5个月前 (10-14) 47次浏览

Issue #635 | 状态: 已关闭 | 作者: MitchBradley | 创建时间: 2020-10-09


More #defines gone
74 lines shorter

Tested by comparing the result of original AMASS computation code to
the new code with values surrounding all of the cutoff frequencies.


评论 (3)

#1 – odaki 于 2020-10-10

I2SOut.cpp also uses FSTEPPERTIMER to calculate the pulse interval.
Please change this too.
https://github.com/bdring/GrblEsp32/blob/AmassOfChanges/GrblEsp32/src/I2SOut.cpp#L663
C++
int IRAMATTR i2soutsetpulseperiod(uint64t period) {

ifdef USEI2SOUTSTREAMIMPL

// Use 64-bit values to avoid overflowing during the calculation.
i2soutpulseperiod = period * 1000000 / FSTEPPER_TIMER;

endif

return 0;
}
`
We may want to modify the API to receive the calculated value to reduce our dependence on Stepper.h

For example:

Stepper.cpp
`C++
void IRAMATTR StepperTimerWritePeriod(uint64t alarm_val) {
if (currentstepper == STI2S_STREAM) {
#ifdef USEI2SSTEPS
// 1 tick = fTimers / fStepperTimer
// Pulse ISR is called for each tick of alarm_val.
i2soutsetpulseperiod(alarm_val * 1000000 / fStepperTimer);
#endif
} else {
timersetalarmvalue(STEPTIMERGROUP, STEPTIMERINDEX, alarmval);
}
}
`
I2SOut.cpp
`C++
int IRAMATTR i2soutsetpulseperiod(uint64t period) {

ifdef USEI2SOUTSTREAMIMPL

i2soutpulse_period = period;

endif

return 0;
}
`
I2SOut.h
`C++
/*
Set the pulse callback period in microseconds.
(Note that this is different from the value for the ISR timer period)
*/
int i2soutsetpulseperiod(uint64_t period);


#2 – odaki 于 2020-10-10

ticksPerMicrosecond is undefined at the time of compilation of I2SOut.cpp.
Do we include Stepper.h separately in I2SOut.cpp to minimize header dependencies?


#3 – odaki 于 2020-10-11

It’s very clear and makes it easier to communicate intentions without confusion.


原始Issue: https://github.com/bdring/Grbl_Esp32/pull/635

喜欢 (0)