mirror of https://github.com/joan2937/pigpio
V25
This commit is contained in:
parent
1d3d07daff
commit
84b06fca73
10
command.c
10
command.c
|
@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This version is for pigpio version 24+
|
This version is for pigpio version 25+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -136,7 +136,7 @@ cmdInfo_t cmdInfo[]=
|
||||||
|
|
||||||
{PI_CMD_SLR, "SLR", 121, 6}, // gpioSerialRead
|
{PI_CMD_SLR, "SLR", 121, 6}, // gpioSerialRead
|
||||||
{PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose
|
{PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose
|
||||||
{PI_CMD_SLRO, "SLRO", 121, 0}, // gpioSerialReadOpen
|
{PI_CMD_SLRO, "SLRO", 131, 0}, // gpioSerialReadOpen
|
||||||
|
|
||||||
{PI_CMD_SPIC, "SPIC", 112, 0}, // spiClose
|
{PI_CMD_SPIC, "SPIC", 112, 0}, // spiClose
|
||||||
{PI_CMD_SPIO, "SPIO", 131, 2}, // spiOpen
|
{PI_CMD_SPIO, "SPIO", 131, 2}, // spiOpen
|
||||||
|
@ -303,7 +303,7 @@ SERWB h bv Write byte to serial handle.\n\
|
||||||
\n\
|
\n\
|
||||||
SLR u num Read bit bang serial data from gpio.\n\
|
SLR u num Read bit bang serial data from gpio.\n\
|
||||||
SLRC u Close gpio for bit bang serial data.\n\
|
SLRC u Close gpio for bit bang serial data.\n\
|
||||||
SLRO u b Open gpio for bit bang serial data.\n\
|
SLRO u b db Open gpio for bit bang serial data.\n\
|
||||||
\n\
|
\n\
|
||||||
SPIC h SPI close handle.\n\
|
SPIC h SPI close handle.\n\
|
||||||
SPIO sc sb sf SPI open channel at baud with flags.\n\
|
SPIO sc sb sf SPI open channel at baud with flags.\n\
|
||||||
|
@ -682,7 +682,7 @@ int cmdParse(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 121: /* HC I2CRD I2CRR I2CRW I2CWB I2CWQ P PFS PRS
|
case 121: /* HC I2CRD I2CRR I2CRW I2CWB I2CWQ P PFS PRS
|
||||||
PWM S SERVO SLR SLRO W WDOG WRITE
|
PWM S SERVO SLR W WDOG WRITE
|
||||||
|
|
||||||
Two positive parameters.
|
Two positive parameters.
|
||||||
*/
|
*/
|
||||||
|
@ -778,7 +778,7 @@ int cmdParse(
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 131: /* HP I2CO I2CPC I2CRI I2CWB I2CWW SPIO TRIG
|
case 131: /* HP I2CO I2CPC I2CRI I2CWB I2CWW SLRO SPIO TRIG
|
||||||
|
|
||||||
Three positive parameters.
|
Three positive parameters.
|
||||||
*/
|
*/
|
||||||
|
|
51
pigpio.3
51
pigpio.3
|
@ -530,7 +530,16 @@ PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Range defaults to 255.
|
For normal PWM the dutycycle will be out of the defined range
|
||||||
|
for the gpio (see \fBgpioGetPWMrange\fP). If a hardware clock is
|
||||||
|
active on the gpio the reported dutycycle will be 500 (out of 1000).
|
||||||
|
If hardware PWM is active on the gpio the reported dutycycle
|
||||||
|
will be out of a 1000.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
Normal PWM range defaults to 255.
|
||||||
|
|
||||||
.IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP"
|
.IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
|
@ -617,6 +626,12 @@ user_gpio: 0-31
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio
|
||||||
|
the reported range will be 1000.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
.br
|
.br
|
||||||
|
@ -644,6 +659,12 @@ user_gpio: 0-31
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio
|
||||||
|
the reported real range will be 1000.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
.br
|
.br
|
||||||
|
@ -784,6 +805,15 @@ user_gpio: 0-31
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
For normal PWM the frequency will be that defined for the gpio by
|
||||||
|
\fBgpioSetPWMfrequency\fP. If a hardware clock is active on the gpio
|
||||||
|
the reported frequency will be that set by \fBgpioHardwareClock\fP.
|
||||||
|
If hardware PWM is active on the gpio the reported frequency
|
||||||
|
will be that set by \fBgpioHardwarePWM\fP.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
.br
|
.br
|
||||||
|
@ -1884,7 +1914,7 @@ waveform created since \fBgpioInitialise\fP was called.
|
||||||
This function returns the maximum possible size of a waveform in DMA
|
This function returns the maximum possible size of a waveform in DMA
|
||||||
control blocks.
|
control blocks.
|
||||||
|
|
||||||
.IP "\fBint gpioSerialReadOpen(unsigned user_gpio, unsigned bbBaud)\fP"
|
.IP "\fBint gpioSerialReadOpen(unsigned user_gpio, unsigned bbBaud, unsigned bbBits)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
This function opens a gpio for bit bang reading of serial data.
|
This function opens a gpio for bit bang reading of serial data.
|
||||||
|
|
||||||
|
@ -1897,6 +1927,8 @@ user_gpio: 0-31
|
||||||
.br
|
.br
|
||||||
bbBaud: 100-250000
|
bbBaud: 100-250000
|
||||||
.br
|
.br
|
||||||
|
bbBits: 1-32
|
||||||
|
.br
|
||||||
|
|
||||||
.EE
|
.EE
|
||||||
|
|
||||||
|
@ -1904,7 +1936,7 @@ user_gpio: 0-31
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
||||||
or PI_GPIO_IN_USE.
|
PI_BAD_DATABITS, or PI_GPIO_IN_USE.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
@ -1943,6 +1975,19 @@ user_gpio: 0-31, previously opened with \fBgpioSerialReadOpen\fP
|
||||||
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
||||||
or PI_NOT_SERIAL_GPIO.
|
or PI_NOT_SERIAL_GPIO.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The bytes returned for each character depend upon the number of
|
||||||
|
data bits \fBbbBits\fP specified in the \fBgpioSerialReadOpen\fP command.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
For \fBbbBits\fP 1-8 there will be one byte per character.
|
||||||
|
For \fBbbBits\fP 9-16 there will be two bytes per character.
|
||||||
|
For \fBbbBits\fP 17-32 there will be four bytes per character.
|
||||||
|
|
||||||
.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
|
.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
This function closes a gpio for bit bang reading of serial data.
|
This function closes a gpio for bit bang reading of serial data.
|
||||||
|
|
186
pigpio.c
186
pigpio.c
|
@ -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 24 */
|
/* pigpio version 25 */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -928,16 +928,18 @@ typedef struct
|
||||||
uint32_t bufSize;
|
uint32_t bufSize;
|
||||||
int readPos;
|
int readPos;
|
||||||
int writePos;
|
int writePos;
|
||||||
uint32_t baud;
|
uint32_t baud; /* 50-250000 */
|
||||||
uint32_t fullBit;
|
uint32_t fullBit; /* nanoseconds */
|
||||||
uint32_t halfBit;
|
uint32_t halfBit; /* nanoseconds */
|
||||||
int timeout;
|
int timeout; /* millisconds */
|
||||||
uint32_t startBitTick;
|
uint32_t startBitTick; /* microseconds */
|
||||||
uint32_t nextBitDiff;
|
uint32_t nextBitDiff; /* nanoseconds */
|
||||||
int bit;
|
int bit;
|
||||||
int byte;
|
uint32_t data;
|
||||||
|
int bytes; /* 1, 2, 4 */
|
||||||
int level;
|
int level;
|
||||||
int mode;
|
int mode;
|
||||||
|
int dataBits; /* 1-32 */
|
||||||
} wfRx_t;
|
} wfRx_t;
|
||||||
|
|
||||||
union my_smbus_data
|
union my_smbus_data
|
||||||
|
@ -1007,7 +1009,7 @@ static wfStats_t wfStats=
|
||||||
|
|
||||||
static rawWaveInfo_t waveInfo[PI_MAX_WAVES];
|
static rawWaveInfo_t waveInfo[PI_MAX_WAVES];
|
||||||
|
|
||||||
static volatile wfRx_t wfRx[PI_MAX_USER_GPIO+1];
|
static wfRx_t wfRx[PI_MAX_USER_GPIO+1];
|
||||||
|
|
||||||
static int waveOutBotCB = 0;
|
static int waveOutBotCB = 0;
|
||||||
static int waveOutTopCB = NUM_WAVE_CBS;
|
static int waveOutTopCB = NUM_WAVE_CBS;
|
||||||
|
@ -1116,6 +1118,8 @@ CC: 00 CLK0, 01 CLK1, 10 CLK2
|
||||||
gpio44 GPCLK1 ALT0 Compute module only (reserved for system use)
|
gpio44 GPCLK1 ALT0 Compute module only (reserved for system use)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
uint32_t hw_clk_freq[3];
|
||||||
|
|
||||||
uint8_t clkDef[PI_MAX_GPIO + 1] =
|
uint8_t clkDef[PI_MAX_GPIO + 1] =
|
||||||
{
|
{
|
||||||
/* 0 1 2 3 4 5 6 7 8 9 */
|
/* 0 1 2 3 4 5 6 7 8 9 */
|
||||||
|
@ -1146,6 +1150,9 @@ uint8_t clkDef[PI_MAX_GPIO + 1] =
|
||||||
gpio53 pwm1 ALT1
|
gpio53 pwm1 ALT1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
uint32_t hw_pwm_freq[2];
|
||||||
|
uint32_t hw_pwm_duty[2];
|
||||||
|
|
||||||
uint8_t PWMDef[PI_MAX_GPIO + 1] =
|
uint8_t PWMDef[PI_MAX_GPIO + 1] =
|
||||||
{
|
{
|
||||||
/* 0 1 2 3 4 5 6 7 8 9 */
|
/* 0 1 2 3 4 5 6 7 8 9 */
|
||||||
|
@ -1666,7 +1673,9 @@ static int myDoCommand(uint32_t *p, unsigned bufSize, char *buf)
|
||||||
|
|
||||||
case PI_CMD_SLRC: res = gpioSerialReadClose(p[1]); break;
|
case PI_CMD_SLRC: res = gpioSerialReadClose(p[1]); break;
|
||||||
|
|
||||||
case PI_CMD_SLRO: res = gpioSerialReadOpen(p[1], p[2]); break;
|
case PI_CMD_SLRO:
|
||||||
|
memcpy(&p[4], buf, 4);
|
||||||
|
res = gpioSerialReadOpen(p[1], p[2], p[4]); break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2262,44 +2271,48 @@ static int wave2Cbs(unsigned wave_mode)
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void waveRxSerial(volatile wfRx_t *s, int level, uint32_t tick)
|
static void waveRxSerial(wfRx_t *s, int level, uint32_t tick)
|
||||||
{
|
{
|
||||||
int diffTicks;
|
int diffTicks, lastLevel;
|
||||||
int newWritePos;
|
int newWritePos;
|
||||||
|
|
||||||
if (s->bit >= 0)
|
if (s->bit >= 0)
|
||||||
{
|
{
|
||||||
diffTicks = tick - s->startBitTick;
|
diffTicks = tick - s->startBitTick;
|
||||||
|
|
||||||
if (level != PI_TIMEOUT) s->level = level;
|
if (level != PI_TIMEOUT)
|
||||||
|
{
|
||||||
|
s->level = level;
|
||||||
|
lastLevel = !level;
|
||||||
|
}
|
||||||
|
else lastLevel = s->level;
|
||||||
|
|
||||||
while ((s->bit < 9) && (diffTicks > s->nextBitDiff))
|
while ((s->bit <= s->dataBits) && (diffTicks > (s->nextBitDiff/1000)))
|
||||||
{
|
{
|
||||||
if (s->bit)
|
if (s->bit)
|
||||||
{
|
{
|
||||||
if (!(s->level)) s->byte |= (1<<(s->bit-1));
|
if (lastLevel) s->data |= (1<<(s->bit-1));
|
||||||
}
|
}
|
||||||
else s->byte = 0;
|
else s->data = 0;
|
||||||
|
|
||||||
++(s->bit);
|
++(s->bit);
|
||||||
|
|
||||||
s->nextBitDiff += s->fullBit;
|
s->nextBitDiff += s->fullBit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->bit == 9)
|
if (s->bit > s->dataBits)
|
||||||
{
|
{
|
||||||
s->buf[s->writePos] = s->byte;
|
memcpy(s->buf + s->writePos, &s->data, s->bytes);
|
||||||
|
|
||||||
/* don't let writePos catch readPos */
|
/* don't let writePos catch readPos */
|
||||||
|
|
||||||
newWritePos = s->writePos;
|
newWritePos = (s->writePos + s->bytes) % (s->bufSize);
|
||||||
|
|
||||||
if (++newWritePos >= s->bufSize) newWritePos = 0;
|
|
||||||
|
|
||||||
if (newWritePos != s->readPos) s->writePos = newWritePos;
|
if (newWritePos != s->readPos) s->writePos = newWritePos;
|
||||||
|
|
||||||
if (level == 0) /* true transition high->low, not a timeout */
|
if (level == 0)
|
||||||
{
|
{
|
||||||
|
gpioSetWatchdog(s->gpio, s->timeout);
|
||||||
s->bit = 0;
|
s->bit = 0;
|
||||||
s->startBitTick = tick;
|
s->startBitTick = tick;
|
||||||
s->nextBitDiff = s->halfBit;
|
s->nextBitDiff = s->halfBit;
|
||||||
|
@ -5741,6 +5754,7 @@ static void initClock(int mainClock)
|
||||||
|
|
||||||
clkSrc = CLK_CTL_SRC_PLLD;
|
clkSrc = CLK_CTL_SRC_PLLD;
|
||||||
clkDivI = 50 * micros; /* 10 MHz - 1 MHz */
|
clkDivI = 50 * micros; /* 10 MHz - 1 MHz */
|
||||||
|
//if (!mainClock) clkDivI = 40 * micros;
|
||||||
clkBits = BITS; /* 10/BITS MHz - 1/BITS MHz */
|
clkBits = BITS; /* 10/BITS MHz - 1/BITS MHz */
|
||||||
clkDivF = 0;
|
clkDivF = 0;
|
||||||
clkMash = 0;
|
clkMash = 0;
|
||||||
|
@ -6387,8 +6401,6 @@ static void switchFunctionOff(unsigned gpio)
|
||||||
unsigned clock, pwm;
|
unsigned clock, pwm;
|
||||||
int cctl[] = {CLK_GP0_CTL, CLK_GP1_CTL, CLK_GP2_CTL};
|
int cctl[] = {CLK_GP0_CTL, CLK_GP1_CTL, CLK_GP2_CTL};
|
||||||
|
|
||||||
if (gpio <= PI_MAX_GPIO)
|
|
||||||
{
|
|
||||||
switch (gpioInfo[gpio].is)
|
switch (gpioInfo[gpio].is)
|
||||||
{
|
{
|
||||||
case GPIO_SERVO:
|
case GPIO_SERVO:
|
||||||
|
@ -6407,6 +6419,7 @@ static void switchFunctionOff(unsigned gpio)
|
||||||
/* switch hardware clock off */
|
/* switch hardware clock off */
|
||||||
clock = (clkDef[gpio] >> 4) & 3;
|
clock = (clkDef[gpio] >> 4) & 3;
|
||||||
clkReg[cctl[clock]] = CLK_PASSWD | CLK_CTL_KILL;
|
clkReg[cctl[clock]] = CLK_PASSWD | CLK_CTL_KILL;
|
||||||
|
gpioInfo[gpio].width = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GPIO_HW_PWM:
|
case GPIO_HW_PWM:
|
||||||
|
@ -6414,10 +6427,10 @@ static void switchFunctionOff(unsigned gpio)
|
||||||
pwm = (PWMDef[gpio] >> 4) & 3;
|
pwm = (PWMDef[gpio] >> 4) & 3;
|
||||||
if (pwm == 0) pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN1);
|
if (pwm == 0) pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN1);
|
||||||
else pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN2);
|
else pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN2);
|
||||||
|
gpioInfo[gpio].width = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void stopHardwarePWM(void)
|
static void stopHardwarePWM(void)
|
||||||
{
|
{
|
||||||
|
@ -6428,6 +6441,7 @@ static void stopHardwarePWM(void)
|
||||||
if (gpioInfo[i].is == GPIO_HW_PWM)
|
if (gpioInfo[i].is == GPIO_HW_PWM)
|
||||||
{
|
{
|
||||||
switchFunctionOff(i);
|
switchFunctionOff(i);
|
||||||
|
|
||||||
gpioInfo[i].is = GPIO_UNDEFINED;
|
gpioInfo[i].is = GPIO_UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6455,12 +6469,11 @@ int gpioSetMode(unsigned gpio, unsigned mode)
|
||||||
old_mode = (gpioReg[reg] >> shift) & 7;
|
old_mode = (gpioReg[reg] >> shift) & 7;
|
||||||
|
|
||||||
if (mode != old_mode)
|
if (mode != old_mode)
|
||||||
{
|
|
||||||
if (gpio <= PI_MAX_USER_GPIO)
|
|
||||||
{
|
{
|
||||||
switchFunctionOff(gpio);
|
switchFunctionOff(gpio);
|
||||||
|
|
||||||
gpioInfo[gpio].is = GPIO_UNDEFINED;
|
gpioInfo[gpio].is = GPIO_UNDEFINED;
|
||||||
}
|
|
||||||
gpioReg[reg] = (gpioReg[reg] & ~(7<<shift)) | (mode<<shift);
|
gpioReg[reg] = (gpioReg[reg] & ~(7<<shift)) | (mode<<shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6551,18 +6564,15 @@ int gpioWrite(unsigned gpio, unsigned level)
|
||||||
if (gpio <= PI_MAX_GPIO)
|
if (gpio <= PI_MAX_GPIO)
|
||||||
{
|
{
|
||||||
if (gpioInfo[gpio].is != GPIO_WRITE)
|
if (gpioInfo[gpio].is != GPIO_WRITE)
|
||||||
{
|
|
||||||
if (gpioInfo[gpio].is == GPIO_UNDEFINED)
|
|
||||||
{
|
{
|
||||||
/* stop a glitch between setting mode then level */
|
/* stop a glitch between setting mode then level */
|
||||||
if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT;
|
if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT;
|
||||||
else *(gpioReg + GPSET0 + BANK) = BIT;
|
else *(gpioReg + GPSET0 + BANK) = BIT;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switchFunctionOff(gpio);
|
switchFunctionOff(gpio);
|
||||||
}
|
|
||||||
gpioSetMode(gpio, PI_OUTPUT);
|
gpioSetMode(gpio, PI_OUTPUT);
|
||||||
|
|
||||||
gpioInfo[gpio].is = GPIO_WRITE;
|
gpioInfo[gpio].is = GPIO_WRITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6589,15 +6599,11 @@ int gpioPWM(unsigned gpio, unsigned val)
|
||||||
SOFT_ERROR(PI_BAD_DUTYCYCLE, "gpio %d, bad dutycycle (%d)", gpio, val);
|
SOFT_ERROR(PI_BAD_DUTYCYCLE, "gpio %d, bad dutycycle (%d)", gpio, val);
|
||||||
|
|
||||||
if (gpioInfo[gpio].is != GPIO_PWM)
|
if (gpioInfo[gpio].is != GPIO_PWM)
|
||||||
{
|
|
||||||
if (gpioInfo[gpio].is == GPIO_UNDEFINED)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
switchFunctionOff(gpio);
|
switchFunctionOff(gpio);
|
||||||
}
|
|
||||||
gpioSetMode(gpio, PI_OUTPUT);
|
gpioSetMode(gpio, PI_OUTPUT);
|
||||||
|
|
||||||
gpioInfo[gpio].is = GPIO_PWM;
|
gpioInfo[gpio].is = GPIO_PWM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6612,6 +6618,8 @@ int gpioPWM(unsigned gpio, unsigned val)
|
||||||
|
|
||||||
int gpioGetPWMdutycycle(unsigned gpio)
|
int gpioGetPWMdutycycle(unsigned gpio)
|
||||||
{
|
{
|
||||||
|
unsigned pwm;
|
||||||
|
|
||||||
DBG(DBG_USER, "gpio=%d", gpio);
|
DBG(DBG_USER, "gpio=%d", gpio);
|
||||||
|
|
||||||
CHECK_INITED;
|
CHECK_INITED;
|
||||||
|
@ -6619,10 +6627,21 @@ int gpioGetPWMdutycycle(unsigned gpio)
|
||||||
if (gpio > PI_MAX_USER_GPIO)
|
if (gpio > PI_MAX_USER_GPIO)
|
||||||
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
||||||
|
|
||||||
if (gpioInfo[gpio].is != GPIO_PWM)
|
switch (gpioInfo[gpio].is)
|
||||||
SOFT_ERROR(PI_NOT_PWM_GPIO, "not a PWM gpio (%d)", gpio);
|
{
|
||||||
|
case GPIO_PWM:
|
||||||
return gpioInfo[gpio].width;
|
return gpioInfo[gpio].width;
|
||||||
|
|
||||||
|
case GPIO_HW_PWM:
|
||||||
|
pwm = (PWMDef[gpio] >> 4) & 3;
|
||||||
|
return hw_pwm_duty[pwm];
|
||||||
|
|
||||||
|
case GPIO_HW_CLK:
|
||||||
|
return PI_HW_PWM_RANGE/2;
|
||||||
|
|
||||||
|
default:
|
||||||
|
SOFT_ERROR(PI_NOT_PWM_GPIO, "not a PWM gpio (%d)", gpio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6676,8 +6695,16 @@ int gpioGetPWMrange(unsigned gpio)
|
||||||
if (gpio > PI_MAX_USER_GPIO)
|
if (gpio > PI_MAX_USER_GPIO)
|
||||||
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
||||||
|
|
||||||
|
switch (gpioInfo[gpio].is)
|
||||||
|
{
|
||||||
|
case GPIO_HW_PWM:
|
||||||
|
case GPIO_HW_CLK:
|
||||||
|
return PI_HW_PWM_RANGE;
|
||||||
|
|
||||||
|
default:
|
||||||
return gpioInfo[gpio].range;
|
return gpioInfo[gpio].range;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -6691,8 +6718,16 @@ int gpioGetPWMrealRange(unsigned gpio)
|
||||||
if (gpio > PI_MAX_USER_GPIO)
|
if (gpio > PI_MAX_USER_GPIO)
|
||||||
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
||||||
|
|
||||||
|
switch (gpioInfo[gpio].is)
|
||||||
|
{
|
||||||
|
case GPIO_HW_PWM:
|
||||||
|
case GPIO_HW_CLK:
|
||||||
|
return PI_HW_PWM_RANGE;
|
||||||
|
|
||||||
|
default:
|
||||||
return pwmRealRange[gpioInfo[gpio].freqIdx];
|
return pwmRealRange[gpioInfo[gpio].freqIdx];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -6751,6 +6786,8 @@ int gpioSetPWMfrequency(unsigned gpio, unsigned frequency)
|
||||||
|
|
||||||
int gpioGetPWMfrequency(unsigned gpio)
|
int gpioGetPWMfrequency(unsigned gpio)
|
||||||
{
|
{
|
||||||
|
unsigned pwm, clock;
|
||||||
|
|
||||||
DBG(DBG_USER, "gpio=%d", gpio);
|
DBG(DBG_USER, "gpio=%d", gpio);
|
||||||
|
|
||||||
CHECK_INITED;
|
CHECK_INITED;
|
||||||
|
@ -6758,8 +6795,20 @@ int gpioGetPWMfrequency(unsigned gpio)
|
||||||
if (gpio > PI_MAX_USER_GPIO)
|
if (gpio > PI_MAX_USER_GPIO)
|
||||||
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
|
||||||
|
|
||||||
|
switch (gpioInfo[gpio].is)
|
||||||
|
{
|
||||||
|
case GPIO_HW_PWM:
|
||||||
|
pwm = (PWMDef[gpio] >> 4) & 3;
|
||||||
|
return hw_pwm_freq[pwm];
|
||||||
|
|
||||||
|
case GPIO_HW_CLK:
|
||||||
|
clock = (clkDef[gpio] >> 4) & 3;
|
||||||
|
return hw_clk_freq[clock];
|
||||||
|
|
||||||
|
default:
|
||||||
return pwmFreq[gpioInfo[gpio].freqIdx];
|
return pwmFreq[gpioInfo[gpio].freqIdx];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -6782,15 +6831,11 @@ int gpioServo(unsigned gpio, unsigned val)
|
||||||
"gpio %d, bad pulsewidth (%d)", gpio, val);
|
"gpio %d, bad pulsewidth (%d)", gpio, val);
|
||||||
|
|
||||||
if (gpioInfo[gpio].is != GPIO_SERVO)
|
if (gpioInfo[gpio].is != GPIO_SERVO)
|
||||||
{
|
|
||||||
if (gpioInfo[gpio].is == GPIO_UNDEFINED)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
switchFunctionOff(gpio);
|
switchFunctionOff(gpio);
|
||||||
}
|
|
||||||
gpioSetMode(gpio, PI_OUTPUT);
|
gpioSetMode(gpio, PI_OUTPUT);
|
||||||
|
|
||||||
gpioInfo[gpio].is = GPIO_SERVO;
|
gpioInfo[gpio].is = GPIO_SERVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7435,11 +7480,11 @@ int gpioWaveGetMaxCbs(void)
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int gpioSerialReadOpen(unsigned gpio, unsigned bbBaud)
|
int gpioSerialReadOpen(unsigned gpio, unsigned bbBaud, unsigned bbBits)
|
||||||
{
|
{
|
||||||
int bitTime, timeout;
|
int bitTime, timeout;
|
||||||
|
|
||||||
DBG(DBG_USER, "gpio=%d bbBaud=%d", gpio, bbBaud);
|
DBG(DBG_USER, "gpio=%d bbBaud=%d bbBits=%d", gpio, bbBaud, bbBits);
|
||||||
|
|
||||||
CHECK_INITED;
|
CHECK_INITED;
|
||||||
|
|
||||||
|
@ -7450,12 +7495,17 @@ int gpioSerialReadOpen(unsigned gpio, unsigned bbBaud)
|
||||||
SOFT_ERROR(PI_BAD_WAVE_BAUD,
|
SOFT_ERROR(PI_BAD_WAVE_BAUD,
|
||||||
"gpio %d, bad baud rate (%d)", gpio, bbBaud);
|
"gpio %d, bad baud rate (%d)", gpio, bbBaud);
|
||||||
|
|
||||||
|
if ((bbBits < PI_MIN_WAVE_DATABITS) || (bbBits > PI_MAX_WAVE_DATABITS))
|
||||||
|
SOFT_ERROR(PI_BAD_DATABITS,
|
||||||
|
"gpio %d, bad data bits (%d)", gpio, bbBits);
|
||||||
|
|
||||||
if (wfRx[gpio].mode != PI_WFRX_NONE)
|
if (wfRx[gpio].mode != PI_WFRX_NONE)
|
||||||
SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", gpio);
|
SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", gpio);
|
||||||
|
|
||||||
bitTime = MILLION / bbBaud;
|
bitTime = (1000 * MILLION) / bbBaud; /* nanoseconds */
|
||||||
|
|
||||||
|
timeout = ((bbBits+2) * bitTime)/MILLION; /* milliseconds */
|
||||||
|
|
||||||
timeout = (10 * bitTime)/1000;
|
|
||||||
if (timeout < 1) timeout = 1;
|
if (timeout < 1) timeout = 1;
|
||||||
|
|
||||||
wfRx[gpio].gpio = gpio;
|
wfRx[gpio].gpio = gpio;
|
||||||
|
@ -7464,11 +7514,16 @@ int gpioSerialReadOpen(unsigned gpio, unsigned bbBaud)
|
||||||
wfRx[gpio].mode = PI_WFRX_SERIAL;
|
wfRx[gpio].mode = PI_WFRX_SERIAL;
|
||||||
wfRx[gpio].baud = bbBaud;
|
wfRx[gpio].baud = bbBaud;
|
||||||
wfRx[gpio].timeout = timeout;
|
wfRx[gpio].timeout = timeout;
|
||||||
wfRx[gpio].fullBit = bitTime;
|
wfRx[gpio].fullBit = bitTime; /* nanoseconds */
|
||||||
wfRx[gpio].halfBit = bitTime/2;
|
wfRx[gpio].halfBit = (bitTime/2)+500; /* nanoseconds (500 for rounding) */
|
||||||
wfRx[gpio].readPos = 0;
|
wfRx[gpio].readPos = 0;
|
||||||
wfRx[gpio].writePos = 0;
|
wfRx[gpio].writePos = 0;
|
||||||
wfRx[gpio].bit = -1;
|
wfRx[gpio].bit = -1;
|
||||||
|
wfRx[gpio].dataBits = bbBits;
|
||||||
|
|
||||||
|
if (bbBits < 9) wfRx[gpio].bytes = 1;
|
||||||
|
else if (bbBits < 17) wfRx[gpio].bytes = 2;
|
||||||
|
else wfRx[gpio].bytes = 4;
|
||||||
|
|
||||||
gpioSetAlertFunc(gpio, waveRxBit);
|
gpioSetAlertFunc(gpio, waveRxBit);
|
||||||
|
|
||||||
|
@ -7506,6 +7561,10 @@ int gpioSerialRead(unsigned gpio, void *buf, size_t bufSize)
|
||||||
|
|
||||||
if (bytes > bufSize) bytes = bufSize;
|
if (bytes > bufSize) bytes = bufSize;
|
||||||
|
|
||||||
|
/* copy in multiples of the data size in bytes */
|
||||||
|
|
||||||
|
bytes = (bytes / p->bytes) * p->bytes;
|
||||||
|
|
||||||
if (buf) memcpy(buf, p->buf+p->readPos, bytes);
|
if (buf) memcpy(buf, p->buf+p->readPos, bytes);
|
||||||
|
|
||||||
p->readPos += bytes;
|
p->readPos += bytes;
|
||||||
|
@ -8426,6 +8485,10 @@ int gpioHardwareClock(unsigned gpio, unsigned frequency)
|
||||||
{
|
{
|
||||||
if (chooseBestClock(&clkInf, frequency, CLK_SRCS, cfreq))
|
if (chooseBestClock(&clkInf, frequency, CLK_SRCS, cfreq))
|
||||||
{
|
{
|
||||||
|
/* record the clock frequency */
|
||||||
|
|
||||||
|
hw_clk_freq[clock] = frequency;
|
||||||
|
|
||||||
initHWClk(cctl[clock], cdiv[clock],
|
initHWClk(cctl[clock], cdiv[clock],
|
||||||
csrc[clkInf.clock], clkInf.div, clkInf.frac, mash);
|
csrc[clkInf.clock], clkInf.div, clkInf.frac, mash);
|
||||||
|
|
||||||
|
@ -8496,6 +8559,11 @@ int gpioHardwarePWM(
|
||||||
{
|
{
|
||||||
if (chooseBestClock(&clkInf, frequency, CLK_SRCS, cfreq))
|
if (chooseBestClock(&clkInf, frequency, CLK_SRCS, cfreq))
|
||||||
{
|
{
|
||||||
|
/* record the PWM frequency and dutycycle */
|
||||||
|
|
||||||
|
hw_pwm_freq[pwm] = frequency / PI_HW_PWM_RANGE;
|
||||||
|
hw_pwm_duty[pwm] = dutycycle;
|
||||||
|
|
||||||
/* Abort any waveform transmission in progress */
|
/* Abort any waveform transmission in progress */
|
||||||
|
|
||||||
if (gpioWaveTxBusy()) gpioWaveTxStop();
|
if (gpioWaveTxBusy()) gpioWaveTxStop();
|
||||||
|
@ -8534,15 +8602,11 @@ int gpioHardwarePWM(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpioInfo[gpio].is != GPIO_HW_PWM)
|
if (gpioInfo[gpio].is != GPIO_HW_PWM)
|
||||||
{
|
|
||||||
if (gpioInfo[gpio].is == GPIO_UNDEFINED)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
switchFunctionOff(gpio);
|
switchFunctionOff(gpio);
|
||||||
}
|
|
||||||
gpioSetMode(gpio, mode);
|
gpioSetMode(gpio, mode);
|
||||||
|
|
||||||
gpioInfo[gpio].is = GPIO_HW_PWM;
|
gpioInfo[gpio].is = GPIO_HW_PWM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
34
pigpio.h
34
pigpio.h
|
@ -31,7 +31,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 24
|
#define PIGPIO_VERSION 25
|
||||||
|
|
||||||
/*TEXT
|
/*TEXT
|
||||||
|
|
||||||
|
@ -812,7 +812,13 @@ user_gpio: 0-31
|
||||||
Returns between 0 (off) and range (fully on) if OK, otherwise
|
Returns between 0 (off) and range (fully on) if OK, otherwise
|
||||||
PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
||||||
|
|
||||||
Range defaults to 255.
|
For normal PWM the dutycycle will be out of the defined range
|
||||||
|
for the gpio (see [*gpioGetPWMrange*]). If a hardware clock is
|
||||||
|
active on the gpio the reported dutycycle will be 500 (out of 1000).
|
||||||
|
If hardware PWM is active on the gpio the reported dutycycle
|
||||||
|
will be out of a 1000.
|
||||||
|
|
||||||
|
Normal PWM range defaults to 255.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -861,6 +867,9 @@ PI_BAD_USER_GPIO.
|
||||||
user_gpio: 0-31
|
user_gpio: 0-31
|
||||||
. .
|
. .
|
||||||
|
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio
|
||||||
|
the reported range will be 1000.
|
||||||
|
|
||||||
...
|
...
|
||||||
r = gpioGetPWMrange(23);
|
r = gpioGetPWMrange(23);
|
||||||
...
|
...
|
||||||
|
@ -877,6 +886,9 @@ PI_BAD_USER_GPIO.
|
||||||
user_gpio: 0-31
|
user_gpio: 0-31
|
||||||
. .
|
. .
|
||||||
|
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio
|
||||||
|
the reported real range will be 1000.
|
||||||
|
|
||||||
...
|
...
|
||||||
rr = gpioGetPWMrealRange(17);
|
rr = gpioGetPWMrealRange(17);
|
||||||
...
|
...
|
||||||
|
@ -950,6 +962,12 @@ PI_BAD_USER_GPIO.
|
||||||
user_gpio: 0-31
|
user_gpio: 0-31
|
||||||
. .
|
. .
|
||||||
|
|
||||||
|
For normal PWM the frequency will be that defined for the gpio by
|
||||||
|
[*gpioSetPWMfrequency*]. If a hardware clock is active on the gpio
|
||||||
|
the reported frequency will be that set by [*gpioHardwareClock*].
|
||||||
|
If hardware PWM is active on the gpio the reported frequency
|
||||||
|
will be that set by [*gpioHardwarePWM*].
|
||||||
|
|
||||||
...
|
...
|
||||||
f = gpioGetPWMfrequency(23); // Get frequency used for gpio23.
|
f = gpioGetPWMfrequency(23); // Get frequency used for gpio23.
|
||||||
...
|
...
|
||||||
|
@ -1603,17 +1621,18 @@ D*/
|
||||||
|
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
int gpioSerialReadOpen(unsigned user_gpio, unsigned bbBaud);
|
int gpioSerialReadOpen(unsigned user_gpio, unsigned bbBaud, unsigned bbBits);
|
||||||
/*D
|
/*D
|
||||||
This function opens a gpio for bit bang reading of serial data.
|
This function opens a gpio for bit bang reading of serial data.
|
||||||
|
|
||||||
. .
|
. .
|
||||||
user_gpio: 0-31
|
user_gpio: 0-31
|
||||||
bbBaud: 100-250000
|
bbBaud: 100-250000
|
||||||
|
bbBits: 1-32
|
||||||
. .
|
. .
|
||||||
|
|
||||||
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
||||||
or PI_GPIO_IN_USE.
|
PI_BAD_DATABITS, or PI_GPIO_IN_USE.
|
||||||
|
|
||||||
The serial data is returned in a cyclic buffer and is read using
|
The serial data is returned in a cyclic buffer and is read using
|
||||||
[*gpioSerialRead*].
|
[*gpioSerialRead*].
|
||||||
|
@ -1637,6 +1656,13 @@ user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*]
|
||||||
|
|
||||||
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
||||||
or PI_NOT_SERIAL_GPIO.
|
or PI_NOT_SERIAL_GPIO.
|
||||||
|
|
||||||
|
The bytes returned for each character depend upon the number of
|
||||||
|
data bits [*bbBits*] specified in the [*gpioSerialReadOpen*] command.
|
||||||
|
|
||||||
|
For [*bbBits*] 1-8 there will be one byte per character.
|
||||||
|
For [*bbBits*] 9-16 there will be two bytes per character.
|
||||||
|
For [*bbBits*] 17-32 there will be four bytes per character.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
|
|
||||||
|
|
46
pigpio.py
46
pigpio.py
|
@ -252,7 +252,7 @@ import threading
|
||||||
import os
|
import os
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
VERSION = "1.14"
|
VERSION = "1.15"
|
||||||
|
|
||||||
exceptions = True
|
exceptions = True
|
||||||
|
|
||||||
|
@ -1049,6 +1049,13 @@ class pi():
|
||||||
|
|
||||||
Returns the PWM dutycycle.
|
Returns the PWM dutycycle.
|
||||||
|
|
||||||
|
|
||||||
|
For normal PWM the dutycycle will be out of the defined range
|
||||||
|
for the gpio (see [*get_PWM_range*]). If a hardware clock is
|
||||||
|
active on the gpio the reported dutycycle will be 500
|
||||||
|
(out of 1000). If hardware PWM is active on the gpio the
|
||||||
|
reported dutycycle will be out of a 1000.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.set_PWM_dutycycle(4, 25)
|
pi.set_PWM_dutycycle(4, 25)
|
||||||
print(pi.get_PWM_dutycycle(4))
|
print(pi.get_PWM_dutycycle(4))
|
||||||
|
@ -1082,6 +1089,9 @@ class pi():
|
||||||
|
|
||||||
user_gpio:= 0-31.
|
user_gpio:= 0-31.
|
||||||
|
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio
|
||||||
|
the reported range will be 1000.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.set_PWM_range(9, 500)
|
pi.set_PWM_range(9, 500)
|
||||||
print(pi.get_PWM_range(9))
|
print(pi.get_PWM_range(9))
|
||||||
|
@ -1097,6 +1107,9 @@ class pi():
|
||||||
|
|
||||||
user_gpio:= 0-31.
|
user_gpio:= 0-31.
|
||||||
|
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio
|
||||||
|
the reported real range will be 1000.
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.set_PWM_frequency(4, 800)
|
pi.set_PWM_frequency(4, 800)
|
||||||
print(pi.get_PWM_real_range(4))
|
print(pi.get_PWM_real_range(4))
|
||||||
|
@ -1135,6 +1148,12 @@ class pi():
|
||||||
|
|
||||||
Returns the frequency (in Hz) used for the gpio.
|
Returns the frequency (in Hz) used for the gpio.
|
||||||
|
|
||||||
|
For normal PWM the frequency will be that defined for the gpio
|
||||||
|
by [*set_PWM_frequency*]. If a hardware clock is active on the
|
||||||
|
gpio the reported frequency will be that set by [*hardware_clock*].
|
||||||
|
If hardware PWM is active on the gpio the reported frequency
|
||||||
|
will be that set by [*hardware_PWM*].
|
||||||
|
|
||||||
...
|
...
|
||||||
pi.set_PWM_frequency(4,0)
|
pi.set_PWM_frequency(4,0)
|
||||||
print(pi.get_PWM_frequency(4))
|
print(pi.get_PWM_frequency(4))
|
||||||
|
@ -1684,7 +1703,7 @@ class pi():
|
||||||
to output.
|
to output.
|
||||||
bb_baud:= baud rate to use.
|
bb_baud:= baud rate to use.
|
||||||
data:= the bytes to write.
|
data:= the bytes to write.
|
||||||
offset:= number of microseconds from the starts of the
|
offset:= number of microseconds from the start of the
|
||||||
waveform, default 0.
|
waveform, default 0.
|
||||||
bb_bits:= number of data bits, default 8.
|
bb_bits:= number of data bits, default 8.
|
||||||
bb_stop:= number of stop half bits, default 2.
|
bb_stop:= number of stop half bits, default 2.
|
||||||
|
@ -2858,12 +2877,13 @@ class pi():
|
||||||
"""
|
"""
|
||||||
return _u2i(_pigpio_command(self.sl, _PI_CMD_PROCD, script_id, 0))
|
return _u2i(_pigpio_command(self.sl, _PI_CMD_PROCD, script_id, 0))
|
||||||
|
|
||||||
def bb_serial_read_open(self, user_gpio, bb_baud):
|
def bb_serial_read_open(self, user_gpio, bb_baud, bb_bits=8):
|
||||||
"""
|
"""
|
||||||
Opens a gpio for bit bang reading of serial data.
|
Opens a gpio for bit bang reading of serial data.
|
||||||
|
|
||||||
user_gpio:= 0-31, the gpio to use.
|
user_gpio:= 0-31, the gpio to use.
|
||||||
bb_baud:= 300-250000, the baud rate.
|
bb_baud:= 300-250000, the baud rate.
|
||||||
|
bb_bits:= 1-32, the number of bits per word, default 8.
|
||||||
|
|
||||||
The serial data is held in a cyclic buffer and is read using
|
The serial data is held in a cyclic buffer and is read using
|
||||||
[*bb_serial_read*].
|
[*bb_serial_read*].
|
||||||
|
@ -2876,8 +2896,16 @@ class pi():
|
||||||
status = pi.bb_serial_read_open(17, 9600)
|
status = pi.bb_serial_read_open(17, 9600)
|
||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
return _u2i(_pigpio_command(
|
# pigpio message format
|
||||||
self.sl, _PI_CMD_SLRO, user_gpio, bb_baud))
|
|
||||||
|
# I p1 user_gpio
|
||||||
|
# I p2 bb_baud
|
||||||
|
# I p3 4
|
||||||
|
## extension ##
|
||||||
|
# I bb_bits
|
||||||
|
extents = [struct.pack("I", bb_bits)]
|
||||||
|
return _u2i(_pigpio_command_ext(
|
||||||
|
self.sl, _PI_CMD_SLRO, user_gpio, bb_baud, 4, extents))
|
||||||
|
|
||||||
def bb_serial_read(self, user_gpio):
|
def bb_serial_read(self, user_gpio):
|
||||||
"""
|
"""
|
||||||
|
@ -2890,6 +2918,14 @@ class pi():
|
||||||
number of bytes read will be less than zero (and will contain
|
number of bytes read will be less than zero (and will contain
|
||||||
the error code).
|
the error code).
|
||||||
|
|
||||||
|
The bytes returned for each character depend upon the number of
|
||||||
|
data bits [*bb_bits*] specified in the [*bb_serial_read_open*]
|
||||||
|
command.
|
||||||
|
|
||||||
|
For [*bb_bits*] 1-8 there will be one byte per character.
|
||||||
|
For [*bb_bits*] 9-16 there will be two bytes per character.
|
||||||
|
For [*bb_bits*] 17-32 there will be four bytes per character.
|
||||||
|
|
||||||
...
|
...
|
||||||
(count, data) = pi.bb_serial_read(4)
|
(count, data) = pi.bb_serial_read(4)
|
||||||
...
|
...
|
||||||
|
|
47
pigpiod_if.3
47
pigpiod_if.3
|
@ -457,6 +457,15 @@ user_gpio: 0-31.
|
||||||
.br
|
.br
|
||||||
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
For normal PWM the dutycycle will be out of the defined range
|
||||||
|
for the gpio (see \fBget_PWM_range\fP). If a hardware clock is
|
||||||
|
active on the gpio the reported dutycycle will be 500 (out of 1000).
|
||||||
|
If hardware PWM is active on the gpio the reported dutycycle
|
||||||
|
will be out of a 1000.
|
||||||
|
|
||||||
.IP "\fBint set_PWM_range(unsigned user_gpio, unsigned range)\fP"
|
.IP "\fBint set_PWM_range(unsigned user_gpio, unsigned range)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
Set the range of PWM values to be used on the gpio.
|
Set the range of PWM values to be used on the gpio.
|
||||||
|
@ -535,6 +544,12 @@ user_gpio: 0-31.
|
||||||
Returns the dutycycle range used for the gpio if OK,
|
Returns the dutycycle range used for the gpio if OK,
|
||||||
otherwise PI_BAD_USER_GPIO.
|
otherwise PI_BAD_USER_GPIO.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio the
|
||||||
|
reported range will be 1000.
|
||||||
|
|
||||||
.IP "\fBint get_PWM_real_range(unsigned user_gpio)\fP"
|
.IP "\fBint get_PWM_real_range(unsigned user_gpio)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
Get the real underlying range of PWM values being used on the gpio.
|
Get the real underlying range of PWM values being used on the gpio.
|
||||||
|
@ -555,6 +570,12 @@ user_gpio: 0-31.
|
||||||
Returns the real range used for the gpio if OK,
|
Returns the real range used for the gpio if OK,
|
||||||
otherwise PI_BAD_USER_GPIO.
|
otherwise PI_BAD_USER_GPIO.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio the
|
||||||
|
reported real range will be 1000.
|
||||||
|
|
||||||
.IP "\fBint set_PWM_frequency(unsigned user_gpio, unsigned frequency)\fP"
|
.IP "\fBint set_PWM_frequency(unsigned user_gpio, unsigned frequency)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
Set the frequency (in Hz) of the PWM to be used on the gpio.
|
Set the frequency (in Hz) of the PWM to be used on the gpio.
|
||||||
|
@ -654,6 +675,15 @@ user_gpio: 0-31.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
For normal PWM the frequency will be that defined for the gpio by
|
||||||
|
\fBset_PWM_frequency\fP. If a hardware clock is active on the gpio the
|
||||||
|
reported frequency will be that set by \fBhardware_clock\fP. If hardware
|
||||||
|
PWM is active on the gpio the reported frequency will be that set by
|
||||||
|
\fBhardware_PWM\fP.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Returns the frequency (in hertz) used for the gpio if OK,
|
Returns the frequency (in hertz) used for the gpio if OK,
|
||||||
otherwise PI_BAD_USER_GPIO.
|
otherwise PI_BAD_USER_GPIO.
|
||||||
|
@ -1892,7 +1922,7 @@ script_id: >=0, as returned by \fBstore_script\fP.
|
||||||
.br
|
.br
|
||||||
The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
|
The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
|
||||||
|
|
||||||
.IP "\fBint bb_serial_read_open(unsigned user_gpio, unsigned bbBaud)\fP"
|
.IP "\fBint bb_serial_read_open(unsigned user_gpio, unsigned bbBaud, unsigned bbBits)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
This function opens a gpio for bit bang reading of serial data.
|
This function opens a gpio for bit bang reading of serial data.
|
||||||
|
|
||||||
|
@ -1905,6 +1935,8 @@ user_gpio: 0-31.
|
||||||
.br
|
.br
|
||||||
bbBaud: 100-250000
|
bbBaud: 100-250000
|
||||||
.br
|
.br
|
||||||
|
bbBits: 1-32
|
||||||
|
.br
|
||||||
|
|
||||||
.EE
|
.EE
|
||||||
|
|
||||||
|
@ -1951,6 +1983,19 @@ user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
|
||||||
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
||||||
or PI_NOT_SERIAL_GPIO.
|
or PI_NOT_SERIAL_GPIO.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
The bytes returned for each character depend upon the number of
|
||||||
|
data bits \fBbbBits\fP specified in the \fBbb_serial_read_open\fP command.
|
||||||
|
|
||||||
|
.br
|
||||||
|
|
||||||
|
.br
|
||||||
|
For \fBbbBits\fP 1-8 there will be one byte per character.
|
||||||
|
For \fBbbBits\fP 9-16 there will be two bytes per character.
|
||||||
|
For \fBbbBits\fP 17-32 there will be four bytes per character.
|
||||||
|
|
||||||
.IP "\fBint bb_serial_read_close(unsigned user_gpio)\fP"
|
.IP "\fBint bb_serial_read_close(unsigned user_gpio)\fP"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
This function closes a gpio for bit bang reading of serial data.
|
This function closes a gpio for bit bang reading of serial data.
|
||||||
|
|
20
pigpiod_if.c
20
pigpiod_if.c
|
@ -864,8 +864,24 @@ int stop_script(unsigned script_id)
|
||||||
int delete_script(unsigned script_id)
|
int delete_script(unsigned script_id)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_PROCD, script_id, 0, 1);}
|
{return pigpio_command(gPigCommand, PI_CMD_PROCD, script_id, 0, 1);}
|
||||||
|
|
||||||
int bb_serial_read_open(unsigned user_gpio, unsigned baud)
|
int bb_serial_read_open(unsigned user_gpio, unsigned baud, uint32_t bbBits)
|
||||||
{return pigpio_command(gPigCommand, PI_CMD_SLRO, user_gpio, baud, 1);}
|
{
|
||||||
|
gpioExtent_t ext[1];
|
||||||
|
|
||||||
|
/*
|
||||||
|
p1=user_gpio
|
||||||
|
p2=baud
|
||||||
|
p3=4
|
||||||
|
## extension ##
|
||||||
|
unsigned bbBits
|
||||||
|
*/
|
||||||
|
|
||||||
|
ext[0].size = sizeof(uint32_t);
|
||||||
|
ext[0].ptr = &bbBits;
|
||||||
|
|
||||||
|
return pigpio_command_ext(
|
||||||
|
gPigCommand, PI_CMD_SLRO, user_gpio, baud, 4, 1, ext, 1);
|
||||||
|
}
|
||||||
|
|
||||||
int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)
|
int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
|
|
30
pigpiod_if.h
30
pigpiod_if.h
|
@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||||
|
|
||||||
#include "pigpio.h"
|
#include "pigpio.h"
|
||||||
|
|
||||||
#define PIGPIOD_IF_VERSION 12
|
#define PIGPIOD_IF_VERSION 13
|
||||||
|
|
||||||
/*TEXT
|
/*TEXT
|
||||||
|
|
||||||
|
@ -464,6 +464,12 @@ user_gpio: 0-31.
|
||||||
. .
|
. .
|
||||||
|
|
||||||
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
||||||
|
|
||||||
|
For normal PWM the dutycycle will be out of the defined range
|
||||||
|
for the gpio (see [*get_PWM_range*]). If a hardware clock is
|
||||||
|
active on the gpio the reported dutycycle will be 500 (out of 1000).
|
||||||
|
If hardware PWM is active on the gpio the reported dutycycle
|
||||||
|
will be out of a 1000.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
|
@ -507,6 +513,9 @@ user_gpio: 0-31.
|
||||||
|
|
||||||
Returns the dutycycle range used for the gpio if OK,
|
Returns the dutycycle range used for the gpio if OK,
|
||||||
otherwise PI_BAD_USER_GPIO.
|
otherwise PI_BAD_USER_GPIO.
|
||||||
|
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio the
|
||||||
|
reported range will be 1000.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
|
@ -520,6 +529,9 @@ user_gpio: 0-31.
|
||||||
|
|
||||||
Returns the real range used for the gpio if OK,
|
Returns the real range used for the gpio if OK,
|
||||||
otherwise PI_BAD_USER_GPIO.
|
otherwise PI_BAD_USER_GPIO.
|
||||||
|
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio the
|
||||||
|
reported real range will be 1000.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
|
@ -575,6 +587,12 @@ Get the frequency of PWM being used on the gpio.
|
||||||
user_gpio: 0-31.
|
user_gpio: 0-31.
|
||||||
. .
|
. .
|
||||||
|
|
||||||
|
For normal PWM the frequency will be that defined for the gpio by
|
||||||
|
[*set_PWM_frequency*]. If a hardware clock is active on the gpio the
|
||||||
|
reported frequency will be that set by [*hardware_clock*]. If hardware
|
||||||
|
PWM is active on the gpio the reported frequency will be that set by
|
||||||
|
[*hardware_PWM*].
|
||||||
|
|
||||||
Returns the frequency (in hertz) used for the gpio if OK,
|
Returns the frequency (in hertz) used for the gpio if OK,
|
||||||
otherwise PI_BAD_USER_GPIO.
|
otherwise PI_BAD_USER_GPIO.
|
||||||
D*/
|
D*/
|
||||||
|
@ -1343,13 +1361,14 @@ The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
int bb_serial_read_open(unsigned user_gpio, unsigned bbBaud);
|
int bb_serial_read_open(unsigned user_gpio, unsigned bbBaud, unsigned bbBits);
|
||||||
/*D
|
/*D
|
||||||
This function opens a gpio for bit bang reading of serial data.
|
This function opens a gpio for bit bang reading of serial data.
|
||||||
|
|
||||||
. .
|
. .
|
||||||
user_gpio: 0-31.
|
user_gpio: 0-31.
|
||||||
bbBaud: 100-250000
|
bbBaud: 100-250000
|
||||||
|
bbBits: 1-32
|
||||||
. .
|
. .
|
||||||
|
|
||||||
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
||||||
|
@ -1376,6 +1395,13 @@ user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
|
||||||
|
|
||||||
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
||||||
or PI_NOT_SERIAL_GPIO.
|
or PI_NOT_SERIAL_GPIO.
|
||||||
|
|
||||||
|
The bytes returned for each character depend upon the number of
|
||||||
|
data bits [*bbBits*] specified in the [*bb_serial_read_open*] command.
|
||||||
|
|
||||||
|
For [*bbBits*] 1-8 there will be one byte per character.
|
||||||
|
For [*bbBits*] 9-16 there will be two bytes per character.
|
||||||
|
For [*bbBits*] 17-32 there will be four bytes per character.
|
||||||
D*/
|
D*/
|
||||||
|
|
||||||
/*F*/
|
/*F*/
|
||||||
|
|
41
pigs.1
41
pigs.1
|
@ -361,6 +361,13 @@ This command returns the PWM dutycycle in use on gpio \fBu\fP.
|
||||||
Upon success the dutycycle is returned. On error a negative
|
Upon success the dutycycle is returned. On error a negative
|
||||||
status code will be returned.
|
status code will be returned.
|
||||||
|
|
||||||
|
.br
|
||||||
|
For normal PWM the dutycycle will be out of the defined range
|
||||||
|
for the gpio (see \fBPRG\fP). If a hardware clock is active on
|
||||||
|
the gpio the reported dutycycle will be 500 (out of 1000).
|
||||||
|
If hardware PWM is active on the gpio the reported dutycycle
|
||||||
|
will be out of a 1000.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
|
@ -1482,6 +1489,13 @@ This command returns the PWM frequency in Hz used for gpio \fBu\fP.
|
||||||
Upon success the PWM frequency is returned. On error a negative
|
Upon success the PWM frequency is returned. On error a negative
|
||||||
status code will be returned.
|
status code will be returned.
|
||||||
|
|
||||||
|
.br
|
||||||
|
For normal PWM the frequency will be that defined for the gpio
|
||||||
|
by \fBPFS\fP. If a hardware clock is active on the gpio
|
||||||
|
the reported frequency will be that set by \fBHC\fP.
|
||||||
|
If hardware PWM is active on the gpio the reported frequency
|
||||||
|
will be that set by \fBHP\fP.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
|
@ -1610,6 +1624,10 @@ This command returns the dutycycle range for gpio \fBu\fP.
|
||||||
Upon success the range is returned. On error a negative status code
|
Upon success the range is returned. On error a negative status code
|
||||||
will be returned.
|
will be returned.
|
||||||
|
|
||||||
|
.br
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio the reported
|
||||||
|
range will be 1000.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
|
@ -1838,6 +1856,10 @@ ERROR: unknown script id
|
||||||
.br
|
.br
|
||||||
This command returns the real underlying range used by gpio \fBu\fP.
|
This command returns the real underlying range used by gpio \fBu\fP.
|
||||||
|
|
||||||
|
.br
|
||||||
|
If a hardware clock or hardware PWM is active on the gpio the
|
||||||
|
reported range will be 1000.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Upon success the real range is returned. On error a negative status code
|
Upon success the real range is returned. On error a negative status code
|
||||||
will be returned.
|
will be returned.
|
||||||
|
@ -2269,6 +2291,17 @@ is returned. On error a negative status code will be returned.
|
||||||
.br
|
.br
|
||||||
The gpio \fBu\fP should have been initialised with the \fBSLRO\fP command.
|
The gpio \fBu\fP should have been initialised with the \fBSLRO\fP command.
|
||||||
|
|
||||||
|
.br
|
||||||
|
The bytes returned for each character depend upon the number of
|
||||||
|
data bits \fBdb\fP specified in the \fBSLRO\fP command.
|
||||||
|
|
||||||
|
.br
|
||||||
|
For \fBdb\fP 1-8 there will be one byte per character.
|
||||||
|
.br
|
||||||
|
For \fBdb\fP 9-16 there will be two bytes per character.
|
||||||
|
.br
|
||||||
|
For \fBdb\fP 17-32 there will be four bytes per character.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBExample\fP
|
\fBExample\fP
|
||||||
|
@ -2315,12 +2348,12 @@ ERROR: no serial read in progress on gpio
|
||||||
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.IP "\fBSLRO u b\fP - Open gpio for bit bang serial data"
|
.IP "\fBSLRO u b db\fP - Open gpio for bit bang serial data"
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
|
|
||||||
.br
|
.br
|
||||||
This command opens gpio \fBu\fP for reading bit bang serial data
|
This command opens gpio \fBu\fP for reading bit bang serial data
|
||||||
at \fBb\fP baud.
|
at \fBb\fP baud and \fBdb\fP data bits.
|
||||||
|
|
||||||
.br
|
.br
|
||||||
Upon success nothing is returned. On error a negative status code
|
Upon success nothing is returned. On error a negative status code
|
||||||
|
@ -2339,11 +2372,11 @@ in a timely fashion.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.EX
|
.EX
|
||||||
$ pigs slro 23 19200
|
$ pigs slro 23 19200 8
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.br
|
.br
|
||||||
$ pigs slro 23 19200
|
$ pigs slro 23 19200 8
|
||||||
.br
|
.br
|
||||||
-50
|
-50
|
||||||
.br
|
.br
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -3,7 +3,7 @@
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
setup(name='pigpio',
|
setup(name='pigpio',
|
||||||
version='1.14',
|
version='1.15',
|
||||||
author='joan',
|
author='joan',
|
||||||
author_email='joan@abyz.co.uk',
|
author_email='joan@abyz.co.uk',
|
||||||
maintainer='joan',
|
maintainer='joan',
|
||||||
|
|
|
@ -392,7 +392,7 @@ To the lascivious pleasing of a lute.\n\
|
||||||
|
|
||||||
/* gpioSerialReadOpen changes the alert function */
|
/* gpioSerialReadOpen changes the alert function */
|
||||||
|
|
||||||
e = gpioSerialReadOpen(GPIO, BAUD);
|
e = gpioSerialReadOpen(GPIO, BAUD, 8);
|
||||||
CHECK(5, 6, e, 0, 0, "serial read open");
|
CHECK(5, 6, e, 0, 0, "serial read open");
|
||||||
|
|
||||||
gpioWaveClear();
|
gpioWaveClear();
|
||||||
|
|
|
@ -366,7 +366,7 @@ To the lascivious pleasing of a lute.\n\
|
||||||
e = wave_tx_stop();
|
e = wave_tx_stop();
|
||||||
CHECK(5, 5, e, 0, 0, "wave tx stop");
|
CHECK(5, 5, e, 0, 0, "wave tx stop");
|
||||||
|
|
||||||
e = bb_serial_read_open(GPIO, BAUD);
|
e = bb_serial_read_open(GPIO, BAUD, 8);
|
||||||
CHECK(5, 6, e, 0, 0, "serial read open");
|
CHECK(5, 6, e, 0, 0, "serial read open");
|
||||||
|
|
||||||
wave_clear();
|
wave_clear();
|
||||||
|
|
4
x_pigs
4
x_pigs
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VERSION=24
|
VERSION=25
|
||||||
|
|
||||||
GPIO=4
|
GPIO=4
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ if [[ $s = "" ]]; then echo "SERVO-d ok"; else echo "SERVO-d fail ($s)"; fi
|
||||||
|
|
||||||
s=$(pigs wvclr)
|
s=$(pigs wvclr)
|
||||||
if [[ $s = "" ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
||||||
s=$(pigs slro $GPIO 1200)
|
s=$(pigs slro $GPIO 1200 8)
|
||||||
if [[ $s = "" ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
if [[ $s = "" ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
||||||
s=$(pigs wvas $GPIO 1200 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e)
|
s=$(pigs wvas $GPIO 1200 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e)
|
||||||
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
|
if [[ $s = 95 ]]; then echo "SLR-c ok"; else echo "SLR-c fail ($s)"; fi
|
||||||
|
|
4
x_pipe
4
x_pipe
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VERSION=24
|
VERSION=25
|
||||||
|
|
||||||
GPIO=4
|
GPIO=4
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ if [[ $s = 0 ]]; then echo "SERVO-d ok"; else echo "SERVO-d fail ($s)"; fi
|
||||||
echo "wvclr" >/dev/pigpio
|
echo "wvclr" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 0 ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
if [[ $s = 0 ]]; then echo "SLR-a ok"; else echo "SLR-a fail ($s)"; fi
|
||||||
echo "slro $GPIO 1200" >/dev/pigpio
|
echo "slro $GPIO 1200 8" >/dev/pigpio
|
||||||
read -t 1 s </dev/pigout
|
read -t 1 s </dev/pigout
|
||||||
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
if [[ $s = 0 ]]; then echo "SLR-b ok"; else echo "SLR-b fail ($s)"; fi
|
||||||
echo "wvas $GPIO 1200 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e" >/dev/pigpio
|
echo "wvas $GPIO 1200 8 2 0 0x6d 0x79 0x20 0x6e 0x61 0x6d 0x65 0x20 0x69 0x73 0x20 0x6a 0x6f 0x61 0x6e" >/dev/pigpio
|
||||||
|
|
Loading…
Reference in New Issue