Update 'src/opst.cpp'
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-08-03 14:13:37 +02:00
parent 26719942e3
commit ecfbb6af04

View File

@@ -84,15 +84,12 @@ void pwmInFallingEdgeISR()
{
mOpstFiFo.mData[mOpstFiFo.mIn].mFalling = micros();
mOpstFiFo.mIn++;
mOpstFiFo.mIn %= OPST_FIFO_SIZE;
if(mOpstFiFo.mOut == mOpstFiFo.mIn)
{
mOpstFiFo.mOverrun = true;
}
if(OPST_FIFO_SIZE <= mOpstFiFo.mIn)
{
mOpstFiFo.mIn = 0;
}
attachInterrupt(digitalPinToInterrupt(mOpstPin), pwmInRisingEdgeISR, RISING);
}
@@ -131,14 +128,8 @@ void opstUpdate()
uint32_t pulseInterval = 0; // time between rising edge of current pulse and rising edge of following pulse
uint32_t pulseLen = 0; // time between rising edge of current pulse and falling edge of current pulse
if(OPST_FIFO_SIZE > (mOpstFiFo.mOut + 1))
{
nextOut = mOpstFiFo.mOut + 1;
}
else
{
nextOut = 0;
}
nextOut %= OPST_FIFO_SIZE;
pulseInterval = mOpstFiFo.mData[nextOut].mRising - mOpstFiFo.mData[mOpstFiFo.mOut].mRising;
pulseLen = mOpstFiFo.mData[mOpstFiFo.mOut].mFalling - mOpstFiFo.mData[mOpstFiFo.mOut].mRising;