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)
#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.
#1 – odaki 于 2020-10-10
I2SOut.cpp also uses
FSTEPPERTIMERto 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);