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/>
*/
/* pigpio version 58 */
/* pigpio version 59 */
/* include ------------------------------------------------------- */
@ -897,6 +897,8 @@ typedef struct
uint16_t width;
uint16_t range; /* dutycycles specified by 0 .. range */
uint16_t freqIdx;
uint16_t deferOff;
uint16_t deferRng;
} gpioInfo_t;
typedef struct
@ -2507,6 +2509,7 @@ static void myGpioSetPwm(unsigned gpio, int oldVal, int newVal)
{
int switchGpioOff;
int newOff, oldOff, realRange, cycles, i;
int deferOff, deferRng;
DBG(DBG_INTERNAL,
"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;
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) /* PWM CHANGE */
@ -2527,9 +2542,17 @@ static void myGpioSetPwm(unsigned gpio, int oldVal, int newVal)
for (i=0; i<SUPERLEVEL; i+=realRange)
mySetGpioOff(gpio, i+newOff);
if (newOff > oldOff)
{
for (i=0; i<SUPERLEVEL; i+=realRange)
myClearGpioOff(gpio, i+oldOff);
}
else
{
gpioInfo[gpio].deferOff = oldOff;
gpioInfo[gpio].deferRng = realRange;
}
}
else if (newOff) /* PWM START */
{
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)
{
int newOff, oldOff, realRange, cycles, i;
int deferOff, deferRng;
DBG(DBG_INTERNAL,
"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;
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) /* SERVO CHANGE */
@ -2582,9 +2618,17 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
for (i=0; i<SUPERLEVEL; i+=realRange)
mySetGpioOff(gpio, i+newOff);
if (newOff > oldOff)
{
for (i=0; i<SUPERLEVEL; i+=realRange)
myClearGpioOff(gpio, i+oldOff);
}
else
{
gpioInfo[gpio].deferOff = oldOff;
gpioInfo[gpio].deferRng = realRange;
}
}
else if (newOff) /* SERVO START */
{
for (i=0; i<SUPERLEVEL; i+=realRange)
@ -2592,8 +2636,7 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal)
/* schedule new gpio on */
for (i=0; i<SUPERCYCLE; i+=cycles)
mySetGpioOn(gpio, i);
for (i=0; i<SUPERCYCLE; i+=cycles) mySetGpioOn(gpio, i);
}
else /* SERVO STOP */
{
@ -8537,11 +8580,11 @@ int gpioSetPullUpDown(unsigned gpio, unsigned pud)
*(gpioReg + GPPUD) = pud;
myGpioDelay(20);
myGpioDelay(1);
*(gpioReg + GPPUDCLK0 + BANK) = BIT;
myGpioDelay(20);
myGpioDelay(1);
*(gpioReg + GPPUD) = 0;
@ -10091,7 +10134,7 @@ static void I2C_delay(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);
now = gpioTick();
@ -10348,7 +10391,7 @@ int bbI2CZip(
{
if (!ack)
{
if ((bytes + outPos) < outLen)
if ((bytes + outPos) <= outLen)
{
for (i=0; i<(bytes-1); i++)
{
@ -10373,7 +10416,7 @@ int bbI2CZip(
{
if (!ack)
{
if ((bytes + inPos) < inLen)
if ((bytes + inPos) <= inLen)
{
for (i=0; i<(bytes-1); i++)
{
@ -10382,7 +10425,7 @@ int bbI2CZip(
}
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_BAD_I2C_CMD;
@ -11224,6 +11267,7 @@ static void *pthISRThread(void *x)
{
lseek(fd, 0, SEEK_SET); /* consume interrupt */
read(fd, buf, sizeof buf);
if (retval)
{
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 <pthread.h>
#define PIGPIO_VERSION 58
#define PIGPIO_VERSION 59
/*TEXT

View File

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

View File

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

View File

@ -3641,13 +3641,13 @@ to cancel the callback.
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::
. .
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::

View File

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