Monday, 15 March 2010

user interface - Event driven (GUI) programming in C for embedded system -



user interface - Event driven (GUI) programming in C for embedded system -

i in process of making event driven gui in embedded system. finished implementing widget graphics , touchscreen functionality.

my question how / tips on implementing in c , on embedded system.

this how thinking in general "pseudo" code:

mainloop() { <all initializations etc.> eventloop(); } eventloop() { eventhandler(); sleep_low_power_uc_mode(); } touchscreen_interrupt_service_routine() { int * x, *y; eventtype event = touchscreen_click; get_xy_coordinate(x, y); post_event(*x, *y, event); } eventhandler() { int * x, *y; eventtype * event; static int current_state; get_event(x, y, event); if(event != no_event) { handle_events(*x, *y, *event, current_state); } } handle_events(int x, int y, eventtype event, int * current_state) { int buttonid, i=0; buttonid = check_if_button_pressed(x, y, current_state); while(buttons[i].enabled != false) { if(buttonid == buttons[i].id) { call_buttons_respective_handler(); } } }

here assume have touchscreen wake micro controller controlled device hardware interrupt. eventloop() never ending event loop handle events go sleep until next touchscreen interrupt. touchscreen interrupt service routine x , y coordinate touchscreen , post event post_event() function. event_handler() function, function within eventloop() function, events (if any) , phone call handle_events() function. handle_events() function check if button (for example) has been pressed given event, x , y coordinates , homecoming non-zero buttonid if button has been pressed. next loop through array of buttons , check of identical buttonid , phone call buttons handler.

does have tried describe create sense in event driven programming manner? thoughts welcome (and please bear me new this).

the reply depend on platform developing for. embedded rtos microchip controller going have 1 set of constraints, whereas rtos arm solution different. should clarify hardware, or @ minimum, micro controller, designing for.

c user-interface embedded event-driven

No comments:

Post a Comment