Peter Bindels gmail.com> writes: > int main() { > EventHdl handler; > Channel serial_out(handler, uart_info); > Button left(handler, serial_out, ...), right(handler, serial_out, > ...), confirm(handler, serial_out, ...); > > handler.process(); > } #include #include #include #include volatile int errors = 0; volatile int keycode = 0; void Rs232txd { CRITA if((rs232->status & RS232_TXEMPTY) && keycode) { rs232->txd = keycode; keycode = 0; } CRITZ } void ButtonsToSerial(void) { CRITA if(keycode) { // overrun errors |= TXD_OVERRUN; // NOT throw(), oops CRITZ // !!! return; } keycode = kbd->keycode; kbd->status & ~KEY_DOWN; CRITZ Rs232txd; } int main() { timer_init(); rs232_init(); kbd_init(); timer_setup(0, TICKS); // needed by kbd for debouncing rs232->speed = RS232_SPEED; rs232->txcallback = Rs232txd; rs232_poll(); kbd->debounce = DEBOUNCE_CONSTANT; kbd->callback = ButtonsToSerial; kbd_poll(); idle: goto idle; } Yes, I know that you described an event driven model and I a timer driven aided one, but this illustrates just a little bit of what you need to implement to make your 'beautiful' main() work (20-50 more lines of code missing, to do the timer interrupts, the keyboard, and the serial and baud generator init). You or someone who implements it (the libraries) for you. And isn't it dercandy ? Anyway the main() is about as terse as yours. Peter P. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist