upiwin/src/ep_upiwin.c

49 lines
1.6 KiB
C
Raw Normal View History

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "scode.h"
#include "ep_init.h"
#include "gpio.h"
#include "ep_upiwin.h"
static PyMethodDef UPIWINMethods[] = {
/* Backlight control functions */
{"get_backlight", Epython_get_backlight, METH_VARARGS,
"Returns the current status of the backlight (True=on, False=off)."},
{"set_backlight", Epython_set_backlight, METH_VARARGS,
"Sets the current status of the backlight (True=on, False=off). Returns a SCODE."},
{"get_backlight_level", Epython_get_backlight_level, METH_VARARGS,
"Returns the current intensity level of the backlight."},
{"set_backlight_level", Epython_set_backlight_level, METH_VARARGS,
"Sets the current intensity level of the backlight. Returns a SCODE."},
{NULL, NULL, 0, NULL}
};
static PyModuleDef DefUPIWIN = {
PyModuleDef_HEAD_INIT, /* standard garbage */
Mod_UPIWIN, /* module name */
NULL, /* no doc string */
sizeof(UPIWIN_STATE), /* per-module memory */
UPIWINMethods, /* method defs */
NULL, /* no slots for multi-phase init */
NULL, /* no traversal proc */
NULL, /* no clear function */
NULL /* no free function */
};
PyObject *Epython_init_upiwin_module(void)
{
PyObject *module;
PUPIWIN_STATE pstate;
module = PyModule_Create(&DefUPIWIN);
if (!module)
return NULL;
/* set up the module state */
pstate = (PUPIWIN_STATE)PyModule_GetState(module);
pstate->backlight_on = TRUE;
pstate->backlight_level = GSB_BACKLIGHT_DEFAULT;
return module;
}