mirror of https://github.com/joan2937/pigpio
v7303 Fix waveform length when merging pulses (#223)
This commit is contained in:
parent
fc6e3df438
commit
47f3bf7ec9
16
pigpio.c
16
pigpio.c
|
@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|||
For more information, please refer to <http://unlicense.org/>
|
||||
*/
|
||||
|
||||
/* pigpio version 73 */
|
||||
/* pigpio version 7303 */
|
||||
|
||||
/* include ------------------------------------------------------- */
|
||||
|
||||
|
@ -3242,7 +3242,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
|
|||
|
||||
unsigned numIn2, numOut;
|
||||
|
||||
uint32_t tNow, tNext1, tNext2, tDelay;
|
||||
uint32_t tNow, tNext1, tNext2, tDelay, tMax;
|
||||
|
||||
rawWave_t *in2, *out;
|
||||
|
||||
|
@ -3253,6 +3253,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
|
|||
out = wf[1-wfcur];
|
||||
|
||||
tNow = 0;
|
||||
tMax = 0;
|
||||
|
||||
if (!numIn1) tNext1 = -1; else tNext1 = 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;
|
||||
|
||||
tNext1 = tNow + in1[inPos1].usDelay; ++inPos1;
|
||||
if (tMax < tNext1) tMax = tNext1;
|
||||
}
|
||||
else if (tNext2 < tNext1)
|
||||
{
|
||||
|
@ -3292,6 +3294,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
|
|||
out[outPos].flags = in2[inPos2].flags;
|
||||
|
||||
tNext2 = tNow + in2[inPos2].usDelay; ++inPos2;
|
||||
if (tMax < tNext2) tMax = tNext2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3310,6 +3313,8 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
|
|||
|
||||
tNext1 = tNow + in1[inPos1].usDelay; ++inPos1;
|
||||
tNext2 = tNow + in2[inPos2].usDelay; ++inPos2;
|
||||
if (tMax < tNext1) tMax = tNext1;
|
||||
if (tMax < tNext2) tMax = tNext2;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
wfStats.micros = tNow;
|
||||
|
|
Loading…
Reference in New Issue