Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/05/06 14:36
Read: times


 
#113663 - better code version
Responding to: ???'s previous message

place the code shown below inside a timer interrupt handler configured to fire at 500 microseconds.
if the key(s)is kept pressed for consecutive five increments then the program flow will take another path
resulting in rapid value increment of any desired variable.and as soon as the program see any keyup it will
resume to old slow value increment mode.HOPE THIS WILL HELP.....


/*---------here starts the code for incrementing value of variable X --------------------------------------*/

if(button_PLUS == 0) {
COUNT_PLUS++; }else {
COUNT_PLUS = 0;
RAPID_SCAN_COUNT_PLUS = 0;
RAPID_SCAN_FLAG_PLUS = 0;
KEY_SCAN_RATE_PLUS = 80;
}
if(COUNT_PLUS > key_scan_rate_PLUS) {
//update lcd value here or can be X++
COUNT_PLUS = 0;
if(RAPID_SCAN_FLAG_PLUS == 0)
RAPID_SCAN_COUNT_PLUS++;
}
if(RAPID_SCAN_FLAG_PLUS == 0) {

if(RAPID_SCAN_COUNT_PLUS > 5) {
RAPID_SCAN_FLAG_PLUS = 1;
KEY_SCAN_RATE_PLUS = 10; }
}


/*---------here ends the code for incrementing value of variable X --------------------------------------*/


/*---------here starts the code for decrementing value of variable X --------------------------------------*/

if(button_MINUS == 0) {
COUNT_MINUS++; }else {
COUNT_MINUS = 0;
RAPID_SCAN_COUNT_MINUS = 0;
RAPID_SCAN_FLAG_MINUS = 0;
KEY_SCAN_RATE_MINUS = 80;
}
if(COUNT_MINUS > key_scan_rate_MINUS) {
//update lcd value here or can be X--
COUNT_MINUS = 0;
if(RAPID_SCAN_FLAG_MINUS == 0)
RAPID_SCAN_COUNT_MINUS++;
}
if(RAPID_SCAN_FLAG_MINUS == 0) {

if(RAPID_SCAN_COUNT_MINUS > 5) {
RAPID_SCAN_FLAG_MINUS = 1;
KEY_SCAN_RATE_MINUS = 10; }
}


/*---------here ends the code for decrementing value of variable X --------------------------------------*/

Regards
SAIF ULLAH KHALID.


List of 17 messages in thread
TopicAuthorDate
LCD repeat function in C            01/01/70 00:00      
   First thought            01/01/70 00:00      
      if its roundrobin            01/01/70 00:00      
         last post            01/01/70 00:00      
      Sounds fine            01/01/70 00:00      
   the one issue            01/01/70 00:00      
      stuck key            01/01/70 00:00      
      Yes            01/01/70 00:00      
         Code Review            01/01/70 00:00      
            this must be excellent switches            01/01/70 00:00      
               excellent debounce for bad switches            01/01/70 00:00      
   better code version            01/01/70 00:00      
      no comments, captals, no indenting            01/01/70 00:00      
         It could do with some improvement!            01/01/70 00:00      
            I did not comment on that, it may very w            01/01/70 00:00      
            true....            01/01/70 00:00      
               led to so much misinformation in this fo            01/01/70 00:00      

Back to Subject List