From: Michael R. <re...@eu...> - 2005-06-08 15:20:48
|
Hi Luis, > Ok, but we need to 'spinlock' around key polling because writing to > the LCD and reading the buttons uses the same 8 bit bus... No problem: thread.[ch] already provides mutex functions. But I see another problem, which I didn't think of: If your separate thread rises an event/signal, I have to pass this to the main thread :-( >>A handler will be a Evaluator expression. > Ok, something like a plugin then? The 'handler' is not a plugin, but an expression (which can call functions from plugins, of course). > We will need to have the output to the LCD and the input from the keys > in the same driver because of that 'spinlock' issue. Right. There will be a helper file "event.c", which will provide functions to raise an event. There will be "event classes", one of them being a keyboard event. A code fragment from your key polling thread could look like this: while (1) { mutex_lock(my_mutex); key = poll_keypad(); mutex_unlock(my_mutex); if (key >0) { now=time(); if (now-last > KEYPAD_DEBOUNCE_TIME) { event_raise (EVENT_KEY, key) } last=now; } usleep (keypad_delay); } I'm not shure if debouncing is that easy :-) Probably there should be a difference between key press and key release. > I was afraid of that... unfortunately i have NO idea how to do it > properly... see above :-) bye, Michael -- Michael Reinelt <re...@eu...> http://home.pages.at/reinelt GPG-Key 0xDF13BA50 ICQ #288386781 |