This commit is contained in:
joan 2016-12-22 18:07:09 +00:00
parent 4c039aa250
commit a939b8b0e6
6 changed files with 81 additions and 47 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 58 */ /* pigpio version 59 */
/* include ------------------------------------------------------- */ /* include ------------------------------------------------------- */
@ -897,6 +897,8 @@ typedef struct
uint16_t width; uint16_t width;
uint16_t range; /* dutycycles specified by 0 .. range */ uint16_t range; /* dutycycles specified by 0 .. range */
uint16_t freqIdx; uint16_t freqIdx;
uint16_t deferOff;
uint16_t deferRng;
} gpioInfo_t; } gpioInfo_t;
typedef struct typedef struct
@ -2507,6 +2509,7 @@ static void myGpioSetPwm(unsigned gpio, int oldVal, int newVal)
{ {
int switchGpioOff; int switchGpioOff;
int newOff, oldOff, realRange, cycles, i; int newOff, oldOff, realRange, cycles, i;
int deferOff, deferRng;
DBG(DBG_INTERNAL, DBG(DBG_INTERNAL,
"myGpioSetPwm %d from %d to %d", gpio, oldVal, newVal); "myGpioSetPwm %d from %d to %d", gpio, oldVal, newVal);
@ -2520,6 +2523,18 @@ static void myGpioSetPwm(unsigned gpio, int oldVal, int newVal)
newOff = (newVal * realRange)/gpioInfo[gpio].range; newOff = (newVal * realRange)/gpioInfo[gpio].range;
oldOff = (oldVal * realRange)/gpioInfo[gpio].range; oldOff = (oldVal * realRange)/gpioInfo[gpio].range;
deferOff = gpioInfo[gpio].deferOff;
deferRng = gpioInfo[gpio].deferRng;
if (gpioInfo[gpio].deferOff)
{
for (i=0; i<SUPERLEVEL; i+=deferRng)
{
myClearGpioOff(gpio, i+deferOff);
}
gpioInfo[gpio].deferOff = 0;
}
if (newOff != oldOff) if (newOff != oldOff)
{ {
if (newOff && oldOff) /* PWM CHANGE */ if (newOff && oldOff) /* PWM CHANGE */
@ -2527,9 +2542,17 @@ static void myGpioSetPwm(unsigned gpio, int oldVal, int newVal)
for (i=0; i<SUPERLEVEL; i+=realRange) for (i=0; i<SUPERLEVEL; i+=realRange)
mySetGpioOff(gpio, i+newOff); mySetGpioOff(gpio, i+newOff);
if (newOff > oldOff)
{
for (i=0; i<SUPERLEVEL; i+=realRange) for (i=0; i<SUPERLEVEL; i+=realRange)
myClearGpioOff(gpio, i+oldOff); myClearGpioOff(gpio, i+oldOff);
} }
else
{
gpioInfo[gpio].deferOff = oldOff;
gpioInfo[gpio].deferRng = realRange;
}
}
else if (newOff) /* PWM START */ else if (newOff) /* PWM START */
{ {
for (i=0; i<SUPERLEVEL; i+=realRange) for (i=0; i<SUPERLEVEL; i+=realRange)
@ -2565,6 +2588,7 @@ static void myGpioSetPwm(unsigned gpio, int oldVal, int newVal)
static void myGpioSetServo(unsigned gpio, int oldVal, int newVal) static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
{ {
int newOff, oldOff, realRange, cycles, i; int newOff, oldOff, realRange, cycles, i;
int deferOff, deferRng;
DBG(DBG_INTERNAL, DBG(DBG_INTERNAL,
"myGpioSetServo %d from %d to %d", gpio, oldVal, newVal); "myGpioSetServo %d from %d to %d", gpio, oldVal, newVal);
@ -2575,6 +2599,18 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
newOff = (newVal * realRange)/20000; newOff = (newVal * realRange)/20000;
oldOff = (oldVal * realRange)/20000; oldOff = (oldVal * realRange)/20000;
deferOff = gpioInfo[gpio].deferOff;
deferRng = gpioInfo[gpio].deferRng;
if (gpioInfo[gpio].deferOff)
{
for (i=0; i<SUPERLEVEL; i+=deferRng)
{
myClearGpioOff(gpio, i+deferOff);
}
gpioInfo[gpio].deferOff = 0;
}
if (newOff != oldOff) if (newOff != oldOff)
{ {
if (newOff && oldOff) /* SERVO CHANGE */ if (newOff && oldOff) /* SERVO CHANGE */
@ -2582,9 +2618,17 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
for (i=0; i<SUPERLEVEL; i+=realRange) for (i=0; i<SUPERLEVEL; i+=realRange)
mySetGpioOff(gpio, i+newOff); mySetGpioOff(gpio, i+newOff);
if (newOff > oldOff)
{
for (i=0; i<SUPERLEVEL; i+=realRange) for (i=0; i<SUPERLEVEL; i+=realRange)
myClearGpioOff(gpio, i+oldOff); myClearGpioOff(gpio, i+oldOff);
} }
else
{
gpioInfo[gpio].deferOff = oldOff;
gpioInfo[gpio].deferRng = realRange;
}
}
else if (newOff) /* SERVO START */ else if (newOff) /* SERVO START */
{ {
for (i=0; i<SUPERLEVEL; i+=realRange) for (i=0; i<SUPERLEVEL; i+=realRange)
@ -2592,8 +2636,7 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
/* schedule new gpio on */ /* schedule new gpio on */
for (i=0; i<SUPERCYCLE; i+=cycles) for (i=0; i<SUPERCYCLE; i+=cycles) mySetGpioOn(gpio, i);
mySetGpioOn(gpio, i);
} }
else /* SERVO STOP */ else /* SERVO STOP */
{ {
@ -8537,11 +8580,11 @@ int gpioSetPullUpDown(unsigned gpio, unsigned pud)
*(gpioReg + GPPUD) = pud; *(gpioReg + GPPUD) = pud;
myGpioDelay(20); myGpioDelay(1);
*(gpioReg + GPPUDCLK0 + BANK) = BIT; *(gpioReg + GPPUDCLK0 + BANK) = BIT;
myGpioDelay(20); myGpioDelay(1);
*(gpioReg + GPPUD) = 0; *(gpioReg + GPPUD) = 0;
@ -10091,7 +10134,7 @@ static void I2C_delay(wfRx_t *w)
static void I2C_clock_stretch(wfRx_t *w) static void I2C_clock_stretch(wfRx_t *w)
{ {
uint32_t now, max_stretch=10000; uint32_t now, max_stretch=100000;
myGpioSetMode(w->I.SCL, PI_INPUT); myGpioSetMode(w->I.SCL, PI_INPUT);
now = gpioTick(); now = gpioTick();
@ -10348,7 +10391,7 @@ int bbI2CZip(
{ {
if (!ack) if (!ack)
{ {
if ((bytes + outPos) < outLen) if ((bytes + outPos) <= outLen)
{ {
for (i=0; i<(bytes-1); i++) for (i=0; i<(bytes-1); i++)
{ {
@ -10373,7 +10416,7 @@ int bbI2CZip(
{ {
if (!ack) if (!ack)
{ {
if ((bytes + inPos) < inLen) if ((bytes + inPos) <= inLen)
{ {
for (i=0; i<(bytes-1); i++) for (i=0; i<(bytes-1); i++)
{ {
@ -10382,7 +10425,7 @@ int bbI2CZip(
} }
ack = I2CPutByte(w, inBuf[inPos++]); ack = I2CPutByte(w, inBuf[inPos++]);
} }
else status = PI_BAD_I2C_RLEN; else status = PI_BAD_I2C_WLEN;
} else status = PI_I2C_WRITE_FAILED; } else status = PI_I2C_WRITE_FAILED;
} }
else status = PI_BAD_I2C_CMD; else status = PI_BAD_I2C_CMD;
@ -11224,6 +11267,7 @@ static void *pthISRThread(void *x)
{ {
lseek(fd, 0, SEEK_SET); /* consume interrupt */ lseek(fd, 0, SEEK_SET); /* consume interrupt */
read(fd, buf, sizeof buf); read(fd, buf, sizeof buf);
if (retval) if (retval)
{ {
if (levels & (1<<isr->gpio)) level = PI_ON; else level = PI_OFF; if (levels & (1<<isr->gpio)) level = PI_ON; else level = PI_OFF;

View File

@ -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 58 #define PIGPIO_VERSION 59
/*TEXT /*TEXT

View File

@ -299,7 +299,7 @@ import threading
import os import os
import atexit import atexit
VERSION = "1.34" VERSION = "1.35"
exceptions = True exceptions = True
@ -1744,12 +1744,11 @@ class pi():
The watchdog may be cancelled by setting timeout to 0. The watchdog may be cancelled by setting timeout to 0.
If no level change has been detected for the GPIO for timeout Once a watchdog has been started callbacks for the GPIO
milliseconds any notification for the GPIO has a report written will be triggered whenever there has been no GPIO activity
to the fifo with the flags set to indicate a watchdog timeout. for the timeout interval.
The callback class interprets the flags and will The callback will receive the special level TIMEOUT.
call registered callbacks for the GPIO with level TIMEOUT.
... ...
pi.set_watchdog(23, 1000) # 1000 ms watchdog on GPIO 23 pi.set_watchdog(23, 1000) # 1000 ms watchdog on GPIO 23

View File

@ -6065,7 +6065,7 @@ to cancel the callback.
.EX .EX
typedef void (*CBFunc_t) typedef void (*CBFunc_t)
.br .br
(unsigned user_gpio, unsigned level, uint32_t tick); (int pi, unsigned user_gpio, unsigned level, uint32_t tick);
.br .br
.EE .EE
@ -6079,7 +6079,7 @@ typedef void (*CBFunc_t)
.EX .EX
typedef void (*CBFuncEx_t) typedef void (*CBFuncEx_t)
.br .br
(unsigned user_gpio, unsigned level, uint32_t tick, void * userdata); (int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * userdata);
.br .br
.EE .EE

View File

@ -3641,13 +3641,13 @@ to cancel the callback.
CBFunc_t:: CBFunc_t::
. . . .
typedef void (*CBFunc_t) typedef void (*CBFunc_t)
(unsigned user_gpio, unsigned level, uint32_t tick); (int pi, unsigned user_gpio, unsigned level, uint32_t tick);
. . . .
CBFuncEx_t:: CBFuncEx_t::
. . . .
typedef void (*CBFuncEx_t) typedef void (*CBFuncEx_t)
(unsigned user_gpio, unsigned level, uint32_t tick, void * userdata); (int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * userdata);
. . . .
char:: char::

View File

@ -1,26 +1,17 @@
#!/usr/bin/env python #!/usr/bin/env python
from setuptools import setup, find_packages from distutils.core import setup
setup( setup(name='pigpio',
name='pigpio', version='1.35',
version='1.34',
author='joan', author='joan',
author_email='joan@abyz.co.uk', author_email='joan@abyz.co.uk',
maintainer='joan', maintainer='joan',
maintainer_email='joan@abyz.co.uk', maintainer_email='joan@abyz.co.uk',
url='http://abyz.co.uk/rpi/pigpio/python.html', url='http://abyz.co.uk/rpi/pigpio/python.html/',
description='Raspberry Pi GPIO module', description='Raspberry gpio module',
long_description='Raspberry Python module to access the pigpio daemon', long_description='Raspberry Python module to access the pigpio daemon',
download_url='http://abyz.co.uk/rpi/pigpio/pigpio.zip', download_url='http://abyz.co.uk/rpi/pigpio/pigpio.zip',
license='unlicense.org', license='unlicense.org',
keywords=[ py_modules=['pigpio']
'raspberrypi', )
'gpio',
],
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
]
)