2019-12-07 20:53:59 -07:00
|
|
|
#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 = {
|
2019-12-07 20:59:18 -07:00
|
|
|
PyModuleDef_HEAD_INIT, /* standard garbage */
|
2019-12-07 21:18:27 -07:00
|
|
|
MOD_NAME_UPIWIN, /* module name */
|
2019-12-07 20:59:18 -07:00
|
|
|
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 */
|
2019-12-07 20:53:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|