From 68be55a8f560331a56044dde9b416ef300a6975f Mon Sep 17 00:00:00 2001 From: Amy Bowersox Date: Mon, 9 Dec 2019 13:42:55 -0700 Subject: [PATCH] tracing backlight problem and fixing a typo in a function definition --- scripts/tmp_main.py | 14 +++++++------- src/ep_backlight.c | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/tmp_main.py b/scripts/tmp_main.py index c799dd4..815aa44 100644 --- a/scripts/tmp_main.py +++ b/scripts/tmp_main.py @@ -3,7 +3,7 @@ import upiwin import upiwin_tmp def log_touch(event, x, y): - print("Touch {0} at ({1), {2})\n".format(event, x, y)) + print("Touch {0} at ({1}, {2})".format(event, x, y)) upiwin_tmp.filled_rectangle(10, 10, 50, 50, upiwin_tmp.FBPRIMCLR_RED, False) upiwin_tmp.filled_rectangle(60, 10, 100, 50, upiwin_tmp.FBPRIMCLR_GREEN, False) @@ -22,18 +22,18 @@ upiwin_tmp.textout(10, 180, 'Amy was here!!!') msg = {} while upiwin.get_message(msg): if msg['message'] == upiwin.WM_HWBUTTONDOWN: - print("Button {0} was pressed.\n".format(msg['attrs'][0])) + print("Button {0} was pressed.".format(msg['attrs'][0])) elif msg['message'] == upiwin.WM_HWBUTTONUP: - print("Button {0} was released.\n".format(msg['attrs'][0])) + print("Button {0} was released.".format(msg['attrs'][0])) bn = msg['attrs'][0] if bn == 1: - print("Backlight ON.\n") + print("Backlight ON.") upiwin.set_backlight(True) elif bn == 2: - print("Backlight OFF.\n") - upiwin.set_backlight(True) + print("Backlight OFF.") + upiwin.set_backlight(False) elif bn == 4: - print("Quitting the application.\n") + print("Quitting the application.") upiwin.post_quit_message(0) elif msg['message'] == upiwin.WM_TOUCHDOWN: log_touch('DOWN', msg['attrs'][0], msg['attrs'][1]) diff --git a/src/ep_backlight.c b/src/ep_backlight.c index af4327b..bb37f07 100644 --- a/src/ep_backlight.c +++ b/src/ep_backlight.c @@ -1,6 +1,7 @@ #define PY_SSIZE_T_CLEAN #include #include "scode.h" +#include "log.h" #include "gpio.h" #include "ep_upiwin.h" #include "ep_init.h" @@ -23,6 +24,7 @@ PyObject *Epython_set_backlight(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "p", &new_state)) return NULL; pstate = (PUPIWIN_STATE)PyModule_GetState(UPIWIN_module); + Log(LDEBUG, "set_backlight: old=%d, new=%d (level=%u)", pstate->backlight_on, new_state, pstate->backlight_level); if (new_state && !(pstate->backlight_on)) Gpio_set_backlight(pstate->backlight_level); else if (!new_state && pstate->backlight_on)