diff options
author | Aki <please@ignore.pl> | 2021-10-16 17:11:44 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-10-16 17:11:44 +0200 |
commit | 3a183df872409594e74d3c55e3c1eedf9ee8abec (patch) | |
tree | dd1968198f4107c835a34bd01cdbda45d701f1f6 | |
parent | 5368f164a1c68c094c6649424f052c5180ce5269 (diff) | |
download | hwd-python-3a183df872409594e74d3c55e3c1eedf9ee8abec.zip hwd-python-3a183df872409594e74d3c55e3c1eedf9ee8abec.tar.gz hwd-python-3a183df872409594e74d3c55e3c1eedf9ee8abec.tar.bz2 |
Added signatures to the docstrings of functions
-rw-r--r-- | src/hwdmodule.cpp | 34 |
1 files 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 <hwd.h> -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} }; |