*/
/*
-This version is for pigpio version 39+
+This version is for pigpio version 46+
*/
#include <stdio.h>
{PI_CMD_WVSM, "WVSM", 112, 2}, // gpioWaveGet*Micros
{PI_CMD_WVSP, "WVSP", 112, 2}, // gpioWaveGet*Pulses
{PI_CMD_WVTX, "WVTX", 112, 2}, // gpioWaveTxSend
+ {PI_CMD_WVTXM, "WVTXM", 121, 2}, // gpioWaveTxSend
{PI_CMD_WVTXR, "WVTXR", 112, 2}, // gpioWaveTxSend
{PI_CMD_ADD , "ADD" , 111, 0},
WVSM 0,1,2 Wave get micros stats\n\
WVSP 0,1,2 Wave get pulses stats\n\
WVTX wid Transmit wave as one-shot\n\
+WVTXM wid wmde Transmit wave using mode\n\
WVTXR wid Transmit wave repeatedly\n\
\n\
\n\
break;
case 121: /* HC I2CRD I2CRR I2CRW I2CWB I2CWQ P PFS PRS
- PWM S SERVO SLR SLRI W WDOG WRITE
+ PWM S SERVO SLR SLRI W WDOG WRITE WVTXM
Two positive parameters.
*/
.IP "" 4
This function transmits the waveform with id wave_id. The mode
determines whether the waveform is sent once or cycles endlessly.
+The SYNC variants wait for the current waveform to reach the
+end of a cycle or finish before starting the new waveform.
+
+.br
+
+.br
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
.br
.EX
wave_id: >=0, as returned by \fBgpioWaveCreate\fP
.br
-wave_mode: 0 (PI_WAVE_MODE_ONE_SHOT), 1 (PI_WAVE_MODE_REPEAT)
+wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
+.br
+ PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
.br
.EE
.br
.br
-The mode of waveform transmission, whether it is sent once or cycles
-repeatedly.
+The mode determines if the waveform is sent once or cycles
+repeatedly. The SYNC variants wait for the current waveform
+to reach the end of a cycle or finish before starting the new
+waveform.
.br
.br
.EX
-PI_WAVE_MODE_ONE_SHOT 0
+PI_WAVE_MODE_ONE_SHOT 0
.br
-PI_WAVE_MODE_REPEAT 1
+PI_WAVE_MODE_REPEAT 1
+.br
+PI_WAVE_MODE_ONE_SHOT_SYNC 2
+.br
+PI_WAVE_MODE_REPEAT_SYNC 3
.br
.EE
#define PI_CMD_NOIB 99
.br
+.br
+#define PI_CMD_WVTXM 100
+.br
+
.br
.EE
.br
#define PI_INITIALISED -32 // function called after gpioInitialise
.br
-#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-1
+#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
.br
#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
.br
For more information, please refer to <http://unlicense.org/>
*/
-/* pigpio version 45 */
+/* pigpio version 46 */
/* include ------------------------------------------------------- */
/* initialise every gpioInitialise */
static struct timespec libStarted;
+
+static uint32_t reportedLevel = 0;
+
static int waveClockInited = 0;
static volatile gpioStats_t gpioStats;
static int waveOutTopOOL = NUM_WAVE_OOL;
static int waveOutCount = 0;
+static uint32_t *waveEndPtr = NULL;
+
static volatile uint32_t alertBits = 0;
static volatile uint32_t monitorBits = 0;
static volatile uint32_t notifyBits = 0;
case PI_CMD_WVTX:
res = gpioWaveTxSend(p[1], PI_WAVE_MODE_ONE_SHOT); break;
+ case PI_CMD_WVTXM:
+ res = gpioWaveTxSend(p[1], p[2]); break;
+
case PI_CMD_WVTXR:
res = gpioWaveTxSend(p[1], PI_WAVE_MODE_REPEAT); break;
}
}
-uint32_t _reportedLevel, _changedBits;
-
-static void alertEmit(gpioSample_t *sample, int numSamples, uint32_t eTick)
+static void alertEmit(
+ gpioSample_t *sample, int numSamples, uint32_t changedBits, uint32_t eTick)
{
uint32_t oldLevel, newLevel;
int32_t diff;
char fifo[32];
gpioReport_t report[MAX_REPORT];
- if (_changedBits)
+ if (changedBits)
{
if (gpioGetSamples.func)
{
/* call alert callbacks for each bit transition */
- if (_changedBits & alertBits)
+ if (changedBits & alertBits)
{
- oldLevel = (_reportedLevel & alertBits);
+ oldLevel = (reportedLevel & alertBits);
for (d=0; d<numSamples; d++)
{
timeoutBits = 0;
- for (b=0; b<=PI_MAX_USER_GPIO; b++)
+ if (wdogBits)
{
- if (gpioAlert[b].wdSteadyUs)
+ for (b=0; b<=PI_MAX_USER_GPIO; b++)
{
- diff = eTick - gpioAlert[b].wdTick;
-
- if (diff >= gpioAlert[b].wdSteadyUs)
+ if (gpioAlert[b].wdSteadyUs)
{
- timeoutBits |= (1<<b);
+ diff = eTick - gpioAlert[b].wdTick;
- gpioAlert[b].wdTick = eTick;
-
- if (gpioAlert[b].func)
+ if (diff >= gpioAlert[b].wdSteadyUs)
{
- if (gpioAlert[b].ex)
- {
- (gpioAlert[b].func)
- (b, PI_TIMEOUT, eTick, gpioAlert[b].userdata);
- }
- else
+ timeoutBits |= (1<<b);
+
+ gpioAlert[b].wdTick = eTick;
+
+ if (gpioAlert[b].func)
{
- (gpioAlert[b].func)(b, PI_TIMEOUT, eTick);
+ if (gpioAlert[b].ex)
+ {
+ (gpioAlert[b].func)(b, PI_TIMEOUT, eTick,
+ gpioAlert[b].userdata);
+ }
+ else
+ {
+ (gpioAlert[b].func)(b, PI_TIMEOUT, eTick);
+ }
}
}
}
{
if (gpioNotify[n].state == PI_NOTIFY_CLOSING)
{
-
if (gpioNotify[n].pipe)
{
DBG(DBG_INTERNAL, "close notify pipe %d", gpioNotify[n].fd);
}
gpioNotify[n].state = PI_NOTIFY_CLOSED;
-
}
else if (gpioNotify[n].state == PI_NOTIFY_RUNNING)
{
notification.
bits is the set of notification bits
- _changedBits is the set of changed bits
+ changedBits is the set of changed bits
*/
- if (_changedBits & bits)
+ if (changedBits & bits)
{
- oldLevel = _reportedLevel & bits;
+ oldLevel = reportedLevel & bits;
for (d=0; d<numSamples; d++)
{
if (numSamples)
newLevel = sample[numSamples-1].level;
else
- newLevel = _reportedLevel;
+ newLevel = reportedLevel;
report[emit].seqno = seqno;
report[emit].flags = PI_NTFY_FLAGS_WDOG |
if (numSamples)
newLevel = sample[numSamples-1].level;
else
- newLevel = _reportedLevel;
+ newLevel = reportedLevel;
report[emit].seqno = seqno;
report[emit].flags = PI_NTFY_FLAGS_ALIVE;
err/sizeof(gpioReport_t), max_emits);
}
}
- else gpioStats.goodPipeWrite++;
+ else
+ {
+ gpioStats.goodPipeWrite++;
+ }
emitted += max_emits;
emit -= max_emits;
err/sizeof(gpioReport_t), emit);
}
}
- else gpioStats.goodPipeWrite++;
+ else
+ {
+ gpioStats.goodPipeWrite++;
+ }
emitted += emit;
emit = 0;
}
}
- if (_changedBits & scriptBits)
+ if (changedBits & scriptBits)
{
for (n=0; n<PI_MAX_SCRIPTS; n++)
{
if ((gpioScript[n].state == PI_SCRIPT_IN_USE) &&
(gpioScript[n].run_state == PI_SCRIPT_WAITING) &&
- (gpioScript[n].waitBits & _changedBits))
+ (gpioScript[n].waitBits & changedBits))
{
pthread_mutex_lock(&gpioScript[n].pthMutex);
if (gpioScript[n].run_state == PI_SCRIPT_WAITING)
{
gpioScript[n].changedBits =
- gpioScript[n].waitBits & _changedBits;
+ gpioScript[n].waitBits & changedBits;
pthread_cond_signal(&gpioScript[n].pthCond);
}
}
}
- if (numSamples) _reportedLevel = sample[numSamples-1].level;
+ if (numSamples) reportedLevel = sample[numSamples-1].level;
}
static void alertWdogCheck(gpioSample_t *sample, int numSamples)
uint32_t oldLevel, newLevel, level;
uint32_t oldSlot, newSlot;
uint32_t expected, ft, sTick;
+ uint32_t changedBits;
int32_t diff, minDiff, stickInited;
int cycle, pulse;
int numSamples, ticks, i;
- int rp, compactedSamples, totalSamples;
+ int rp, reports, totalSamples;
int stopped;
int moreToDo;
gpioSample_t sample[MAX_SAMPLE];
spinWhileStarting();
- _reportedLevel = gpioReg[GPLEV0];
+ reportedLevel = gpioReg[GPLEV0];
+
+ oldLevel = reportedLevel;
oldSlot = dmaCurrentSlot(dmaNowAtICB());
/* Compact samples */
- _changedBits = 0;
- oldLevel = _reportedLevel & monitorBits;
-
- compactedSamples = 0;
+ changedBits = 0;
+ oldLevel &= monitorBits;
+ reports = 0;
totalSamples = 0;
for (rp=0; rp<numSamples; rp++)
{
- level = sample[rp].level;
-
- newLevel = (level & monitorBits);
+ newLevel = (sample[rp].level & monitorBits);
if (newLevel != oldLevel)
{
- sample[compactedSamples].tick = sample[rp].tick;
- sample[compactedSamples].level = level;
- _changedBits |= (newLevel ^ oldLevel);
+ sample[reports].tick = sample[rp].tick;
+ sample[reports].level = sample[rp].level;
+ changedBits |= (newLevel ^ oldLevel);
oldLevel = newLevel;
- compactedSamples++;
- if (compactedSamples >= MAX_REPORT)
+ reports++;
+
+ if (reports >= MAX_REPORT)
{
- totalSamples += compactedSamples;
+ totalSamples += reports;
/* Rebase watchdog timeouts */
- if (wdogBits) alertWdogCheck(sample, compactedSamples);
+ if (wdogBits) alertWdogCheck(sample, reports);
- gpioStats.numSamples += compactedSamples;
+ gpioStats.numSamples += reports;
- alertEmit(sample, compactedSamples, sample[rp].tick);
+ alertEmit(sample, reports, changedBits, sample[rp].tick);
- compactedSamples = 0;
+ changedBits = 0;
+ reports = 0;
}
}
}
- if (compactedSamples)
+ if (reports)
{
- totalSamples += compactedSamples;
+ totalSamples += reports;
/* Rebase watchdog timeouts */
- if (wdogBits) alertWdogCheck(sample, compactedSamples);
+ if (wdogBits) alertWdogCheck(sample, reports);
- gpioStats.numSamples += compactedSamples;
+ gpioStats.numSamples += reports;
}
- alertEmit(sample, compactedSamples, sTick);
+ alertEmit(sample, reports, changedBits, sTick);
if (totalSamples > gpioStats.maxSamples)
gpioStats.maxSamples = numSamples;
waveOutCount = 0;
+ waveEndPtr = NULL;
+
return 0;
}
if ((wave_id >= waveOutCount) || waveInfo[wave_id].deleted)
SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id);
- if (wave_mode > PI_WAVE_MODE_REPEAT)
+ if (wave_mode > PI_WAVE_MODE_REPEAT_SYNC)
SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", wave_mode);
if (!waveClockInited)
waveClockInited = 1;
}
- dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
+ p = rawWaveCBAdr(waveInfo[wave_id].topCB);
- dmaOut[DMA_CONBLK_AD] = 0;
+ if ((wave_mode & 1) == PI_WAVE_MODE_ONE_SHOT)
+ p->next = 0;
+ else
+ p->next = waveCbPOadr(waveInfo[wave_id].botCB+1);
- p = rawWaveCBAdr(waveInfo[wave_id].topCB);
+ if (waveEndPtr && (wave_mode > PI_WAVE_MODE_REPEAT))
+ {
+ *waveEndPtr = waveCbPOadr(waveInfo[wave_id].botCB+1);
- if (wave_mode == PI_WAVE_MODE_ONE_SHOT) p->next = 0;
- else p->next = waveCbPOadr(waveInfo[wave_id].botCB+1);
+ if (!dmaOut[DMA_CONBLK_AD])
+ {
+ initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB));
+ }
+ }
+ else
+ {
+ initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB));
+ }
- initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB));
+ waveEndPtr = &p->next;
/* for compatability with the deprecated gpioWaveTxStart return the
number of cbs
rawCbs_t *p;
int i, wid, cmd, loop, counters;
unsigned cycles;
- uint32_t repeat, next;
+ uint32_t repeat, next, *endPtr;
int stk_pos[10], stk_lev=0;
cb = 0;
}
dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
-
dmaOut[DMA_CONBLK_AD] = 0;
+ waveEndPtr = NULL;
+ endPtr = NULL;
/* add delay cb at start of DMA */
p->dst = (uint32_t) (&dmaOBus[0]->periphData);
p->length = 4;
p->next = waveCbPOadr(chainGetCB(loop));
+ endPtr = &p->next;
}
else
SOFT_ERROR(PI_BAD_CHAIN_CMD,
p->length = 4;
p->next = 0;
+ if (!endPtr) endPtr = &p->next;
+
initDMAgo((uint32_t *)dmaOut, waveCbPOadr(chainGetCB(0)));
+ waveEndPtr = endPtr;
+
return 0;
}
CHECK_INITED;
dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
-
dmaOut[DMA_CONBLK_AD] = 0;
+ waveEndPtr = NULL;
+
return 0;
}
#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 45
+#define PIGPIO_VERSION 46
/*TEXT
/* wave tx mode */
-#define PI_WAVE_MODE_ONE_SHOT 0
-#define PI_WAVE_MODE_REPEAT 1
+#define PI_WAVE_MODE_ONE_SHOT 0
+#define PI_WAVE_MODE_REPEAT 1
+#define PI_WAVE_MODE_ONE_SHOT_SYNC 2
+#define PI_WAVE_MODE_REPEAT_SYNC 3
/* I2C, SPI, SER */
/*D
This function transmits the waveform with id wave_id. The mode
determines whether the waveform is sent once or cycles endlessly.
+The SYNC variants wait for the current waveform to reach the
+end of a cycle or finish before starting the new waveform.
+
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
NOTE: Any hardware PWM started by [*gpioHardwarePWM*] will be cancelled.
. .
wave_id: >=0, as returned by [*gpioWaveCreate*]
-wave_mode: 0 (PI_WAVE_MODE_ONE_SHOT), 1 (PI_WAVE_MODE_REPEAT)
+wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
+ PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
. .
Returns the number of DMA control blocks in the waveform if OK,
wave_mode::
-The mode of waveform transmission, whether it is sent once or cycles
-repeatedly.
+The mode determines if the waveform is sent once or cycles
+repeatedly. The SYNC variants wait for the current waveform
+to reach the end of a cycle or finish before starting the new
+waveform.
. .
-PI_WAVE_MODE_ONE_SHOT 0
-PI_WAVE_MODE_REPEAT 1
+PI_WAVE_MODE_ONE_SHOT 0
+PI_WAVE_MODE_REPEAT 1
+PI_WAVE_MODE_ONE_SHOT_SYNC 2
+PI_WAVE_MODE_REPEAT_SYNC 3
. .
wVal::0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)
#define PI_CMD_NOIB 99
+#define PI_CMD_WVTXM 100
+
/*DEF_E*/
/*
#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
#define PI_INITIALISED -32 // function called after gpioInitialise
-#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-1
+#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
wave_send_once Transmits a waveform once
wave_send_repeat Transmits a waveform repeatedly
+wave_send_using_mode Transmits a waveform in the chosen mode
wave_chain Transmits a chain of waveforms
import os
import atexit
-VERSION = "1.26"
+VERSION = "1.27"
exceptions = True
NTFY_FLAGS_WDOG = (1 << 5)
NTFY_FLAGS_GPIO = 31
+# wave modes
+
+WAVE_MODE_ONE_SHOT =0
+WAVE_MODE_REPEAT =1
+WAVE_MODE_ONE_SHOT_SYNC=2
+WAVE_MODE_REPEAT_SYNC =3
+
# pigpio command numbers
_PI_CMD_MODES= 0
_PI_CMD_FG =97
_PI_CMD_FN =98
+_PI_CMD_WVTXM=100
+
# pigpio error numbers
_PI_INIT_FAILED =-1
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXR, wave_id, 0))
+ def wave_send_using_mode(self, wave_id, mode):
+ """
+ Transmits the waveform with id wave_id using mode mode.
+
+ wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
+ mode:= WAVE_MODE_ONE_SHOT, WAVE_MODE_REPEAT,
+ WAVE_MODE_ONE_SHOT_SYNC, or WAVE_MODE_REPEAT_SYNC.
+
+ WAVE_MODE_ONE_SHOT: same as [*wave_send_once*].
+
+ WAVE_MODE_REPEAT same as [*wave_send_repeat*].
+
+ WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries
+ to sync with the previous waveform.
+
+ WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries
+ to sync with the previous waveform.
+
+ WARNING: bad things may happen if you delete the previous
+ waveform before it has been synced to the new waveform.
+
+ NOTE: Any hardware PWM started by [*hardware_PWM*] will
+ be cancelled.
+
+ wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
+
+ Returns the number of DMA control blocks used in the waveform.
+
+ ...
+ cbs = pi.wave_send_using_mode(wid, WAVE_MODE_REPEAT_SYNC)
+ ...
+ """
+ return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXM, wave_id, mode))
+
def wave_tx_busy(self):
"""
Returns 1 if a waveform is currently being transmitted,
SET = 1
TIMEOUT = 2 # only returned for a watchdog timeout
- mode: 0-7
+ mode:
+
+ 1.The operational mode of a gpio, normally INPUT or OUTPUT.
+
ALT0 = 4
ALT1 = 5
ALT2 = 6
INPUT = 0
OUTPUT = 1
+ 2. The mode of waveform transmission.
+
+ WAVE_MODE_ONE_SHOT = 0
+ WAVE_MODE_REPEAT = 1
+ WAVE_MODE_ONE_SHOT_SYNC = 2
+ WAVE_MODE_REPEAT_SYNC = 3
+
offset: 0-
The offset wave data starts from the beginning of the waveform
being currently defined.
.br
Level changes on the gpio are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
-level is then reported. Level changes of less than \fBsteady\fP
-microseconds are ignored.
+level is then reported. Level changes of less than
+\fBsteady\fP microseconds are ignored.
.br
.br
.br
-NOTE: Any waveform started by \fBwave_send_once\fP, \fBwave_send_repeat\fP,
-or \fBwave_chain\fP will be cancelled.
+NOTE: Any waveform started by \fBwave_send_*\fP or \fBwave_chain\fP
+will be cancelled.
.br
Returns the number of DMA control blocks in the waveform if OK,
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
+.IP "\fBint wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)\fP"
+.IP "" 4
+Transmits the waveform with id wave_id using mode mode.
+
+.br
+
+.br
+
+.EX
+ pi: 0- (as returned by \fBpigpio_start\fP).
+.br
+wave_id: >=0, as returned by \fBwave_create\fP.
+.br
+ mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
+.br
+ PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
+.br
+
+.EE
+
+.br
+
+.br
+PI_WAVE_MODE_ONE_SHOT: same as \fBwave_send_once\fP.
+
+.br
+
+.br
+PI_WAVE_MODE_REPEAT same as \fBwave_send_repeat\fP.
+
+.br
+
+.br
+PI_WAVE_MODE_ONE_SHOT_SYNC same as \fBwave_send_once\fP but tries
+to sync with the previous waveform.
+
+.br
+
+.br
+PI_WAVE_MODE_REPEAT_SYNC same as \fBwave_send_repeat\fP but tries
+to sync with the previous waveform.
+
+.br
+
+.br
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
+
+.br
+
+.br
+NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
+
+.br
+
+.br
+Returns the number of DMA control blocks in the waveform if OK,
+otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
+
.IP "\fBint wave_chain(int pi, char *buf, unsigned bufSize)\fP"
.IP "" 4
This function transmits a chain of waveforms.
.br
-.IP "\fBmode\fP: 0-7" 0
-The operational mode of a gpio, normally INPUT or OUTPUT.
+.IP "\fBmode\fP" 0
+1. The operational mode of a gpio, normally INPUT or OUTPUT.
.br
.br
+.br
+2. The mode of waveform transmission.
+
+.br
+
+.br
+
+.EX
+PI_WAVE_MODE_ONE_SHOT 0
+.br
+PI_WAVE_MODE_REPEAT 1
+.br
+PI_WAVE_MODE_ONE_SHOT_SYNC 2
+.br
+PI_WAVE_MODE_REPEAT_SYNC 3
+.br
+
+.EE
+
+.br
+
.br
.IP "\fBnumBytes\fP" 0
For more information, please refer to <http://unlicense.org/>
*/
-/* PIGPIOD_IF2_VERSION 2 */
+/* PIGPIOD_IF2_VERSION 3 */
#include <stdio.h>
#include <stdlib.h>
int wave_send_repeat(int pi, unsigned wave_id)
{return pigpio_command(pi, PI_CMD_WVTXR, wave_id, 0, 1);}
+int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)
+ {return pigpio_command(pi, PI_CMD_WVTXM, wave_id, mode, 1);}
+
int wave_chain(int pi, char *buf, unsigned bufSize)
{
gpioExtent_t ext[1];
#include "pigpio.h"
-#define PIGPIOD_IF2_VERSION 2
+#define PIGPIOD_IF2_VERSION 3
/*TEXT
wave_send_once Transmits a waveform once
wave_send_repeat Transmits a waveform repeatedly
+wave_send_using_mode Transmits a waveform in the chosen mode
wave_chain Transmits a chain of waveforms
Level changes on the gpio are not reported unless the level
has been stable for at least [*steady*] microseconds. The
-level is then reported. Level changes of less than [*steady*]
-microseconds are ignored.
+level is then reported. Level changes of less than
+[*steady*] microseconds are ignored.
. .
pi: 0- (as returned by [*pigpio_start*]).
Starts hardware PWM on a gpio at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
-NOTE: Any waveform started by [*wave_send_once*], [*wave_send_repeat*],
-or [*wave_chain*] will be cancelled.
+NOTE: Any waveform started by [*wave_send_**] or [*wave_chain*]
+will be cancelled.
This function is only valid if the pigpio main clock is PCM. The
main clock defaults to PCM but may be overridden when the pigpio
Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
D*/
+
/*F*/
int wave_send_once(int pi, unsigned wave_id);
/*D
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
D*/
+
/*F*/
int wave_send_repeat(int pi, unsigned wave_id);
/*D
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
D*/
+
+/*F*/
+int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode);
+/*D
+Transmits the waveform with id wave_id using mode mode.
+
+. .
+ pi: 0- (as returned by [*pigpio_start*]).
+wave_id: >=0, as returned by [*wave_create*].
+ mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
+ PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
+. .
+
+PI_WAVE_MODE_ONE_SHOT: same as [*wave_send_once*].
+
+PI_WAVE_MODE_REPEAT same as [*wave_send_repeat*].
+
+PI_WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries
+to sync with the previous waveform.
+
+PI_WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries
+to sync with the previous waveform.
+
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
+
+NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
+
+Returns the number of DMA control blocks in the waveform if OK,
+otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
+D*/
+
/*F*/
int wave_chain(int pi, char *buf, unsigned bufSize);
/*D
PI_TIMEOUT 2
. .
-mode::0-7
-The operational mode of a gpio, normally INPUT or OUTPUT.
+mode::
+1. The operational mode of a gpio, normally INPUT or OUTPUT.
. .
PI_INPUT 0
PI_ALT5 2
. .
+2. The mode of waveform transmission.
+
+. .
+PI_WAVE_MODE_ONE_SHOT 0
+PI_WAVE_MODE_REPEAT 1
+PI_WAVE_MODE_ONE_SHOT_SYNC 2
+PI_WAVE_MODE_REPEAT_SYNC 3
+. .
+
numBytes::
The number of bytes used to store characters in a string. Depending
on the number of bits per character there may be 1, 2, or 4 bytes
spi_flags::
See [*spi_open*].
-steady :: 0-300000
+steady:: 0-300000
The number of microseconds level changes must be stable for
before reporting the level changed ([*set_glitch_filter*]) or triggering
.br
+.IP "\fBWVTXM wid wmde\fP - Transmits waveform using mode"
+.IP "" 4
+
+.br
+This command transmits the waveform with id \fBwid\fP using mode \fBwmde\fP.
+
+.br
+The mode may be send once (0), send repeatedly (1), send once but
+first sync with previous wave (2), or send repeatedly but first
+sync with previous wave (3).
+
+.br
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
+
+.br
+NOTE: Any hardware PWM started by \fBHP\fP will be cancelled.
+
+.br
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs wvtxm 1 3
+.br
+75
+.br
+
+.br
+$ pigs wvtxm 2 0
+.br
+-66
+.br
+ERROR: non existent wave id
+.br
+
+.EE
+
+.br
+
.IP "\fBWVTXR wid\fP - Transmits waveform repeatedly"
.IP "" 4
.br
+.IP "\fBwmde\fP - mode (0-3)" 0
+The command expects a wave transmission mode.
+
+.br
+0 = send once
+.br
+1 = send repeatedly
+.br
+2 = send once but first sync with previous wave
+.br
+3 = send repeatedly but first sync with previous wave
+.br
+
+.br
+
.IP "\fBws\fP - wave stats sucommand (0-2)" 0
The command expects a subcommand.
The SYS script receives two unsigned parameters: the accumulator A and
the current gpio levels.
+.br
+
.SH SEE ALSO
pigpiod(1), pig2vcd(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
from distutils.core import setup
setup(name='pigpio',
- version='1.26',
+ version='1.27',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',
if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
s=$(pigs h)
-if [[ ${#s} = 4502 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
+if [[ ${#s} = 4544 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
s=$(pigs hwver)
if [[ $s -ne 0 ]]; then echo "HWVER ok"; else echo "HWVER fail ($s)"; fi