tracing backlight problem and fixing a typo in a function definition
This commit is contained in:
		
							parent
							
								
									bb8b27fb24
								
							
						
					
					
						commit
						68be55a8f5
					
				@ -3,7 +3,7 @@ import upiwin
 | 
				
			|||||||
import upiwin_tmp
 | 
					import upiwin_tmp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def log_touch(event, x, y):
 | 
					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(10, 10, 50, 50, upiwin_tmp.FBPRIMCLR_RED, False)
 | 
				
			||||||
upiwin_tmp.filled_rectangle(60, 10, 100, 50, upiwin_tmp.FBPRIMCLR_GREEN, 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 = {}
 | 
					msg = {}
 | 
				
			||||||
while upiwin.get_message(msg):
 | 
					while upiwin.get_message(msg):
 | 
				
			||||||
	if msg['message'] == upiwin.WM_HWBUTTONDOWN:
 | 
						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:
 | 
						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]
 | 
							bn = msg['attrs'][0]
 | 
				
			||||||
		if bn == 1:
 | 
							if bn == 1:
 | 
				
			||||||
			print("Backlight ON.\n")
 | 
								print("Backlight ON.")
 | 
				
			||||||
			upiwin.set_backlight(True)
 | 
								upiwin.set_backlight(True)
 | 
				
			||||||
		elif bn == 2:
 | 
							elif bn == 2:
 | 
				
			||||||
			print("Backlight OFF.\n")
 | 
								print("Backlight OFF.")
 | 
				
			||||||
			upiwin.set_backlight(True)
 | 
								upiwin.set_backlight(False)
 | 
				
			||||||
		elif bn == 4:
 | 
							elif bn == 4:
 | 
				
			||||||
			print("Quitting the application.\n")
 | 
								print("Quitting the application.")
 | 
				
			||||||
			upiwin.post_quit_message(0)
 | 
								upiwin.post_quit_message(0)
 | 
				
			||||||
	elif msg['message'] == upiwin.WM_TOUCHDOWN:
 | 
						elif msg['message'] == upiwin.WM_TOUCHDOWN:
 | 
				
			||||||
		log_touch('DOWN', msg['attrs'][0], msg['attrs'][1])
 | 
							log_touch('DOWN', msg['attrs'][0], msg['attrs'][1])
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
#define PY_SSIZE_T_CLEAN
 | 
					#define PY_SSIZE_T_CLEAN
 | 
				
			||||||
#include <Python.h>
 | 
					#include <Python.h>
 | 
				
			||||||
#include "scode.h"
 | 
					#include "scode.h"
 | 
				
			||||||
 | 
					#include "log.h"
 | 
				
			||||||
#include "gpio.h"
 | 
					#include "gpio.h"
 | 
				
			||||||
#include "ep_upiwin.h"
 | 
					#include "ep_upiwin.h"
 | 
				
			||||||
#include "ep_init.h"
 | 
					#include "ep_init.h"
 | 
				
			||||||
@ -23,6 +24,7 @@ PyObject *Epython_set_backlight(PyObject *self, PyObject *args)
 | 
				
			|||||||
  if (!PyArg_ParseTuple(args, "p", &new_state))
 | 
					  if (!PyArg_ParseTuple(args, "p", &new_state))
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
  pstate = (PUPIWIN_STATE)PyModule_GetState(UPIWIN_module);
 | 
					  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))
 | 
					  if (new_state && !(pstate->backlight_on))
 | 
				
			||||||
    Gpio_set_backlight(pstate->backlight_level);
 | 
					    Gpio_set_backlight(pstate->backlight_level);
 | 
				
			||||||
  else if (!new_state && pstate->backlight_on)
 | 
					  else if (!new_state && pstate->backlight_on)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user