>-----Original Message----- >From: Omer YALHI [mailto:oyalhi@TEKSAN.COM.TR] > >Hi, I am sorry to barge in but, how would you handle the short >press and long press with this? I could not figure out the >inc_value's purpose. > >I am really asking, as I am also struggling with this idea. >Also, I am trying to figure out a way to handle two or three >button presses. > >Thanks, > >Omer The idea is that this routine is called regularly, and the inc_value variable automaticaly holds a value that can be used to increase whatever parameter you wish in your main code. You could increase the number of buttons serviced relatively easily: void timerInterrupt(void) { // get current button(s) pressed e.g. read a PORT buttons = GetButtons(); // is at least one button pressed and // is it the same button(s) pressed as last time? // may want to check for ony one button pressed here! if( buttons && (buttons == prev_buttons) ) { // same buttons pressed, increment button_time // unless maximum value already reached if(button_time < MAX_BUTTON_TIME) button_time++; } else { // no buttons or different buttons pressed button_time = 0; } // set inc_value depending on how long button has // been held down if(button_time < DEBOUNCE_TIME) inc_value = 0; else if(button_time < SLOW_INC_TIME) inc_value = SLOW_INC_VALUE; else inc_value = FAST_INC_VALUE; // save current buttons for next comparision prev_buttons = buttons; } Main { while(1) { if(buttons & BUTTON_1_MASK) Parameter1 += inc_value; if(buttons & BUTTON_2_MASK) Parameter2 += inc_value; if(buttons & BUTTON_3_MASK) Parameter3 += inc_value; etc... } } HTH Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body