piątek, 17 sierpnia 2012

RTCU front-panel keypad

In this example I use the front keypad to control an integer variable. Using up and down keys (codes 120 and 121) the user can increment and decrement the variable. Pressing ESC key (code 125) resets the variable to 0.

 PROGRAM keypad;  
 // These are the local variables of the program block  
 k : INT; //Key pressed on the front-panel keypad  
 x : INT; //Some number  
 // The next code will only be executed once after the program starts  
   x := 0;  
 // Code from this point until END will be executed repeatedly  
   k := displayGetKey(timeout:=1);  
   if k = 120 then   
    x := x+1;   
    elsif k = 121 then   
      x := x-1;   
      elsif k = 125 then   
       x := 0;   
   displayXY(x:=1, y:=1);  
   displayNumber(number := x);  

The variable is displayed on the front-panel LCD using displayNumber() function, that is much easier to use when displaying only numbers, compared to displayString(message:=intToStr()) function combination. On the other hand when using the displayNumber one can not easily format the output with some markings, so I suggest sticking to the casting method (eg. casting the integer to string and adding some text markings). The output is similar, the displayNumber() example code takes 2658 bytes and  displayString(message:=intToStr()) takes 2712 bytes. Additional 54 bytes are occupied by the casting I guess, but this shouldn't be a big problem, when one realizes that the total memory for the configuration is up to 640 KB.

The next big thing - filesystem on the internal memory and on SD-card.

2 komentarze:

  1. hey .... you done a good work here i m working on that control too so if u can help me with coding the keypad plz add me in fb my name is omar kabakaa thnx for your help :)

  2. hey you have done a good job thnx for that and im waiting you too add more coding cuz i m working too on the RTCU dx40 pro and i need some help from u at that keypad coding