Skip to content

Commit

Permalink
0.6.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pako2 authored Jul 7, 2021
1 parent 622c282 commit 594de76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void define_constants(PyObject *module)
bthree = Py_BuildValue("i", THREE);
PyModule_AddObject(module, "THREE", bthree);

version = Py_BuildValue("s", "0.6.3.1");
version = Py_BuildValue("s", "0.6.4.0");
PyModule_AddObject(module, "VERSION", version);

PyModule_AddObject(module, "PA", Py_BuildValue("i", 0));
Expand Down
19 changes: 18 additions & 1 deletion source/py_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ static PyObject *py_getmode(PyObject *self, PyObject *args)
return value;
}


static unsigned int chan_from_gpio(unsigned int gpio)
{
int chan;
int chans;

if (gpio_mode == BCM)
return gpio;
chans = 40;

for (chan=1; chan<=chans; chan++)
if (*(*pin_to_gpio+chan) == (int)gpio)
return chan;
return -1;
}


// python function setwarnings(state)
static PyObject *py_setwarnings(PyObject *self, PyObject *args)
{
Expand Down Expand Up @@ -419,7 +436,7 @@ static void run_py_callbacks(unsigned int gpio)
if (cb->gpio == gpio) {
// run callback
gstate = PyGILState_Ensure();
result = PyObject_CallFunction(cb->py_cb, "i", gpio);
result = PyObject_CallFunction(cb->py_cb, "i", chan_from_gpio(gpio));
if (result == NULL && PyErr_Occurred()){
PyErr_Print();
PyErr_Clear();
Expand Down

0 comments on commit 594de76

Please sign in to comment.