View unanswered posts | View active topics It is currently Thu Jul 31, 2014 7:31 am






Reply to topic  [ 3 posts ] 
is there a way to avoid program abortion if EXIT-KEY pressed 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post is there a way to avoid program abortion if EXIT-KEY pressed
hello,
is there a way to avoid program abortion if Exit Key is pressed?

I want the program to continue although the Exit Key is pressed,
but if I wrote
Code:
nNxtButtonTask=1;

this command line is completely ignored...


Code:
#define println nxtDisplayTextLine

char getch(){

  TButtons nBtn;
  nBtn = nNxtButtonPressed; // check for button press

  switch (nBtn)     {
      case kLeftButton: {
               return 1;   break;  }

      case kRightButton: {
               return 2;   break;  }

      case kEnterButton: {
               return 3;   break;  }

      case kExitButton: {
               return 4;   break;  }

      default: {
               return 0;   break;  }
  }
}

int key=-1;

task main() {
  eraseDisplay();
  nNxtButtonTask=1;  // program exits anyhow!
  while (true) {
    key=getch();
    println(1,"Key= %d",key);
    wait1Msec(50);
  }
}


Thx in advance!

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Last edited by Ford Prefect on Sun Apr 27, 2008 4:37 am, edited 2 times in total.



Sat Apr 26, 2008 10:23 am
Profile
Rookie

Joined: Sun Aug 12, 2007 3:18 pm
Posts: 38
Post 
Hello

You can use nNxtExitClicks variable

"Holds the number of 'clicks' of the EXIT button required to abort a program. Default value is one for compatibility with standard firmware.

This variable allows end user programs to use the EXIT button. If you set the variable to 'N' (where 'N' is greater than 1) then the first 'N-1' consecutive clicks of the EXIT button can be handled by the application program. On the N-th consecutive click the firmware will automatically EXIT (i.e. end) your program.

Having the firmware perform the check ensures that, even if there is an error in your program, you can always EXIT your program. But it also easily allows your program to have access to the EXIT button."



http//Lrobotikas.net


Sat Apr 26, 2008 11:42 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
hi,
I added
nNxtExitClicks=500; :wink:
and it works just as you wrote!
thx a lot!

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Apr 26, 2008 6:48 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.