From 3a183df872409594e74d3c55e3c1eedf9ee8abec Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 16 Oct 2021 17:11:44 +0200 Subject: Added signatures to the docstrings of functions --- src/hwdmodule.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/hwdmodule.cpp b/src/hwdmodule.cpp index 3d21e08..6d3a574 100644 --- a/src/hwdmodule.cpp +++ b/src/hwdmodule.cpp @@ -4,34 +4,42 @@ #include -static PyObject * hwd_stop_server(PyObject * self, PyObject * args) +static PyObject * gpio_set_mode(PyObject * self, PyObject * args) { - hwd::stop_server(); + unsigned port; + short mode; + if (!PyArg_ParseTuple(args, "Ih", &port, &mode)) + return NULL; + hwd::gpio::set_mode(port, mode); Py_RETURN_NONE; } -static PyObject * hwd_get_value(PyObject * self, PyObject * args) +static PyObject * gpio_write(PyObject * self, PyObject * args) { - const int value = hwd::get_value(); - return PyLong_FromLong(value); + unsigned port; + short value; + if (!PyArg_ParseTuple(args, "Ih", &port, &value)) + return NULL; + hwd::gpio::write(port, value); + Py_RETURN_NONE; } -static PyObject * hwd_set_value(PyObject * self, PyObject * args) +static PyObject * gpio_read(PyObject * self, PyObject * args) { - int value = 0; - if (!PyArg_ParseTuple(args, "i", &value)) + unsigned port; + if (!PyArg_ParseTuple(args, "I", &port)) return NULL; - hwd::set_value(value); - Py_RETURN_NONE; + const short value = hwd::gpio::read(port); + return PyLong_FromLong(value); } static PyMethodDef HwdMethods[] = { - {"stop_server", hwd_stop_server, METH_VARARGS, "Shutdown daemon instance"}, - {"get_value", hwd_get_value, METH_VARARGS, "Gets value from the daemon instance"}, - {"set_value", hwd_set_value, METH_VARARGS, "Sets integer value in the daemon instance"}, + {"set_mode", gpio_set_mode, METH_VARARGS, "set_mode(port, mode)\n--\n\nSets *mode* of a *port*."}, + {"write", gpio_write, METH_VARARGS, "write(port, value)\n--\n\nWrites *value* to a *port*."}, + {"read", gpio_read, METH_VARARGS, "read(port)\n--\n\nReads a value from a *port*."}, {NULL, NULL, 0, NULL} }; -- cgit v1.1