Skip to content
Snippets Groups Projects
Commit 34365647 authored by o2-omisanya's avatar o2-omisanya
Browse files

Upload New File

parent 1a4e5015
No related branches found
No related tags found
No related merge requests found
Python 3.11.1 (v3.11.1:a7a450f84a, Dec 6 2022, 15:24:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> // OLED Initialization - Initialize OLED Display
... static PyObject* oled_init(PyObject* self, PyObject* args) {
... int channel, address, type, flip, invert;
...
... if (!PyArg_ParseTuple(args, "iiiii", &channel, &address, &type, &flip, &invert)) {
... return NULL;
... }
...
... int ret = oledInit(channel, address, type, flip, invert);
... return PyBool_FromLong(!ret);
... }
...
... // OLED Shutdown - Shutdown the OLED Display
... static PyObject* oled_shutdown(PyObject* self) {
... oledShutdown();
... Py_RETURN_NONE;
... }
...
... // OLED Fill - Fill the display with a byte pattern
... static PyObject* oled_fill(PyObject* self, PyObject* args) {
... unsigned char pattern;
... if (!PyArg_ParseTuple(args, "b", &pattern)) {
... return NULL;
... }
... return PyBool_FromLong(!oledFill(pattern));
... }
...
... // OLED Write String - Writes a string at the specified row and column with a specific size to the display
... static PyObject* oled_write_string(PyObject* self, PyObject* args) {
... int row, column;
... char* msg;
... int size;
... if (!PyArg_ParseTuple(args, "iisi", &row, &column, &msg, &size)) {
... printf("Failed to parse arguments");
... return NULL;
}
return PyBool_FromLong(!oledWriteString(row, column, msg, size));
}
// OLED Draw Line - Draw a line using the DDA algorithm from (x0, y0) to (x1, y1)
static PyObject* oled_draw_line(PyObject* self, PyObject* args) {
int x0, y0;
int x1, y1;
unsigned char pixel;
if (!PyArg_ParseTuple(args, "iiiib", &x0, &y0, &x1, &y1, &pixel)) {
return NULL;
}
return PyBool_FromLong(!oledDrawLine(x0, y0, x1, y1, pixel));
}
/* Define all the functions available in the module */
static struct PyMethodDef dd_oled_methods[] = {
{"init", oled_init, METH_VARARGS, "Initialize OLED display"},
{"shutdown", oled_shutdown, METH_NOARGS, "Shutdown OLED display"},
{"fill", oled_fill, METH_VARARGS, "Fill the OLED frame with a byte pattern"},
{"write_string", oled_write_string, METH_VARARGS, "Write the given string to the display"},
{"draw_line", oled_draw_line, METH_VARARGS, "Draw a line at the given position"},
{NULL, NULL, 0, NULL}
};
/* Define module information */
static struct PyModuleDef dd_oled_module = {
PyModuleDef_HEAD_INIT,
"dd_oled",
"Python interface for the oled module",
-1,
dd_oled_methods
};
PyMODINIT_FUNC PyInit_dd_oled(void) {
return PyModule_Create(&dd_oled_module);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment