v7303 Fix waveform length when merging pulses (#223)

This commit is contained in:
Phil Wright 2018-07-13 00:04:09 +00:00 committed by Guy McSwain
parent fc6e3df438
commit 47f3bf7ec9
2 changed files with 15 additions and 3 deletions

View File

@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/> For more information, please refer to <http://unlicense.org/>
*/ */
/* pigpio version 73 */ /* pigpio version 7303 */
/* include ------------------------------------------------------- */ /* include ------------------------------------------------------- */
@ -3242,7 +3242,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
unsigned numIn2, numOut; unsigned numIn2, numOut;
uint32_t tNow, tNext1, tNext2, tDelay; uint32_t tNow, tNext1, tNext2, tDelay, tMax;
rawWave_t *in2, *out; rawWave_t *in2, *out;
@ -3253,6 +3253,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out = wf[1-wfcur]; out = wf[1-wfcur];
tNow = 0; tNow = 0;
tMax = 0;
if (!numIn1) tNext1 = -1; else tNext1 = 0; if (!numIn1) tNext1 = -1; else tNext1 = 0;
if (!numIn2) tNext2 = -1; else tNext2 = 0; if (!numIn2) tNext2 = -1; else tNext2 = 0;
@ -3275,6 +3276,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out[outPos].flags = in1[inPos1].flags; out[outPos].flags = in1[inPos1].flags;
tNext1 = tNow + in1[inPos1].usDelay; ++inPos1; tNext1 = tNow + in1[inPos1].usDelay; ++inPos1;
if (tMax < tNext1) tMax = tNext1;
} }
else if (tNext2 < tNext1) else if (tNext2 < tNext1)
{ {
@ -3292,6 +3294,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out[outPos].flags = in2[inPos2].flags; out[outPos].flags = in2[inPos2].flags;
tNext2 = tNow + in2[inPos2].usDelay; ++inPos2; tNext2 = tNow + in2[inPos2].usDelay; ++inPos2;
if (tMax < tNext2) tMax = tNext2;
} }
else else
{ {
@ -3310,6 +3313,8 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
tNext1 = tNow + in1[inPos1].usDelay; ++inPos1; tNext1 = tNow + in1[inPos1].usDelay; ++inPos1;
tNext2 = tNow + in2[inPos2].usDelay; ++inPos2; tNext2 = tNow + in2[inPos2].usDelay; ++inPos2;
if (tMax < tNext1) tMax = tNext1;
if (tMax < tNext2) tMax = tNext2;
} }
if (tNext1 <= tNext2) { tDelay = tNext1 - tNow; tNow = tNext1; } if (tNext1 <= tNext2) { tDelay = tNext1 - tNow; tNow = tNext1; }
@ -3342,6 +3347,13 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
} }
if (tNow < tMax)
{
/* extend previous delay */
out[outPos-1].usDelay += (tMax - tNow);
tNow = tMax;
}
if ((outPos < numOut) && (outPos < level)) if ((outPos < numOut) && (outPos < level))
{ {
wfStats.micros = tNow; wfStats.micros = tNow;

View File

@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#define PIGPIO_VERSION 7302 #define PIGPIO_VERSION 7303
/*TEXT /*TEXT