Skip to content
Guy McSwain edited this page Jun 28, 2020 · 1 revision

v77

Version 77 is a patch release for bugs and documentation clarifications.

Bug fixes:

  • (5395bbe) Waveform creation with simultaneous switching gpios. Versions affected: v76.
  • (328e09a) Glitch filter initialization. Versions affected: all previous.

Documentation:

  • wave_tx_at (or variants: wvtat, gpioWaveTxAt) do not support chained waveforms.
  • Correct event_callback cancel method.
  • Remove deprecated gpioCfgInternals and inform non-daemon users how to disable pigpio's signal handler.

v76

New APIs

  • gpioWaveCreatePad (pigpio C I/F)
  • wave_create_and_pad (Python module and pigpiod C I/F)
  • wvcap (pigs)

pigpio C I/F

int gpioWaveCreatePad(int pctCB, int pctBOOL, int pctTOOL);

Similar to [gpioWaveCreate], this function creates a waveform but pads the consumed
resources. Padded waves of equal dimension can be re-cycled efficiently allowing
newly created waves to re-use the resources of deleted waves of the same dimension.

pctCB: 0-100, the percent of all DMA control blocks to consume.
pctBOOL: 0-100, percent On-Off-Level (OOL) buffer to consume for wave output.
pctTOOL: 0-100, the percent of OOL buffer to consume for wave input (flags).

Upon success a wave id greater than or equal to 0 is returned, otherwise
PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
Waveform data provided by [gpioWaveAdd*] and [rawWaveAdd*] functions are consumed by this function.

A usage would be the creation of two waves where one is filled while the other is being transmitted. Each wave is assigned 50% of the resources. This buffer structure allows the transmission of infinite wave sequences.

  // get firstWaveChunk, somehow
  gpioWaveAddGeneric(firstWaveChunk);
  wid = gpioWaveCreatePad(50, 50, 0);
  gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
  // get nextWaveChunk
  while (nextWaveChunk) {
     gpioWaveAddGeneric(nextWaveChunk);
     nextWid = gpioWaveCreatePad(50, 50, 0);
     gpioWaveTxSend(nextWid, PI_WAVE_MODE_ONE_SHOT_SYNC);
     while(gpioWaveTxAt() == wid) time_sleep(0.1);
     gpioWaveDelete(wid);
     wid = nextWid;
     // get nextWaveChunk
  }

Python

def wave_create_and_pad(self, percent):
"""
    This function creates a waveform like [*wave_create*] but pads the consumed
    resources. Where percent gives the percentage of the resources to use
    (in terms of the theoretical maximum, not the current amount free).
    This allows the reuse of deleted waves while a transmission is active.
    
    Upon success a wave id greater than or equal to 0 is returned, otherwise
    PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
    . .
    percent: 0-100, size of waveform as percentage of maximum available.
    . .
    The data provided by the [*wave_add_**] functions are consumed by this
    function.
    
    As many waveforms may be created as there is space available. The
    wave id is passed to [*wave_send_**] to specify the waveform to transmit.
    
    A usage would be the creation of two waves where one is filled while the
    other is being transmitted.  Each wave is assigned 50% of the resources.
    This buffer structure allows the transmission of infinite wave sequences.
    
    Normal usage:
    Step 1. [*wave_clear*] to clear all waveforms and added data.
    Step 2. [*wave_add_**] calls to supply the waveform data.
    Step 3. [*wave_create_and_pad*] to create a waveform of uniform size.
    Step 4. [*wave_send_**] with the id of the waveform to transmit.
    Repeat steps 2-4 as needed.
    Step 5. Any wave id can now be deleted and another wave of the same size
            can be created in its place.
"""
    wid = pi.wave_create_and_pad(50)

Pigs

WVCAP ::

Similar to [WVCRE], this command creates a waveform but pads the consumed resources to a fixed size, specified as a percent of total resource. Padded waves of equal size can be re-cycled efficiently allowing newly created waves to re-use the resources of deleted waves of the same dimension.

Upon success a wave id (>=0) is returned. On error a negative status code will be returned.

The data provided by the [WVAG] and [WVAS] commands are consumed by this command.

As many waveforms may be created as there is space available. The wave id is passed to [WVTX] or [WVTXR] to specify the waveform to transmit.

Normal usage would be

Step 1. [WVCLR] to clear all waveforms and added data.

Step 2. [WVAG]/[WVAS] calls to supply the waveform data.

Step 3. [WVCAP] to create a waveform of a uniform size.

Step 4. [WVTX] or [WVTXR] with the id of the waveform to transmit.

Repeat steps 2 - 4 as needed.

Step 5. Any wave id can now be deleted and another wave of the same size can be created in its place.

# Create a wave that consumes 50% of the total resource:

$ pigs wvag 16 0 5000000 0 16 5000000
2
$ pigs wvcap 50
0
$ pigs wvtx 0
11918
Clone this wiki locally