#define PY_SSIZE_T_CLEAN #include #include "scode.h" #include "msg.h" #include "gpio.h" #include "ep_init.h" #include "ep_upiwin.h" #include "ep_util.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."}, /* Message functions */ {"get_message", Epython_get_message, METH_VARARGS, "Retrieves a message from the message queue, blocking if necessary."}, {"post_quit_message", Epython_post_quit_message, METH_VARARGS, "Posts a WM_QUIT message to the message queue, with an exit code."}, {NULL, NULL, 0, NULL} }; static PyModuleDef DefUPIWIN = { PyModuleDef_HEAD_INIT, /* standard garbage */ MOD_NAME_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 */ }; BEGIN_CONSTANT_TABLE(UPIWINConstants) /* Message constants */ CONSTANT_INT_MACRO(WM_NULL) CONSTANT_INT_MACRO(WM_QUIT) CONSTANT_INT_MACRO(WM_HWBUTTONDOWN) CONSTANT_INT_MACRO(WM_HWBUTTONUP) CONSTANT_INT_MACRO(WM_TOUCHDOWN) CONSTANT_INT_MACRO(WM_TOUCHMOVE) CONSTANT_INT_MACRO(WM_TOUCHUP) END_CONSTANT_TABLE PyObject *Epython_init_upiwin_module(void) { PyObject *module; PUPIWIN_STATE pstate; module = PyModule_Create(&DefUPIWIN); if (!module) return NULL; if (FAILED(Epython_register_constants(module, UPIWINConstants))) { Py_DECREF(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; }