Silly question time
Archiver
Posts: 46,084
I have a silly little problem that is making me pull out my hair. Consider the
following command:
BUTTON 12,0,255,250,BtnWrk,0,not_pressed
do something here
then fall through to the exit
not_pressed:
exit
If my understanding of the button command is correct then "do something here"
will only get executed when the button is PUSHED. Am I correct?
What I want is to have the button command blow through the button command if
the button is not pressed. WHat I think is happening is the button command is
waiting for a press rather than taking a look at the button to see if it is
pressed and if not keep waiting until it is, not what I want to happen.. If the
button isn't pressed then go about your business.
Have I missed the bigger picture somewhere along the line?? Perhaps a "in12"
and branch construct would be a better choice??
Thanks Mike B.
[noparse][[/noparse]Non-text portions of this message have been removed]
following command:
BUTTON 12,0,255,250,BtnWrk,0,not_pressed
do something here
then fall through to the exit
not_pressed:
exit
If my understanding of the button command is correct then "do something here"
will only get executed when the button is PUSHED. Am I correct?
What I want is to have the button command blow through the button command if
the button is not pressed. WHat I think is happening is the button command is
waiting for a press rather than taking a look at the button to see if it is
pressed and if not keep waiting until it is, not what I want to happen.. If the
button isn't pressed then go about your business.
Have I missed the bigger picture somewhere along the line?? Perhaps a "in12"
and branch construct would be a better choice??
Thanks Mike B.
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
12 high when its not pushed? Also, there's no loop here - is it just
falling through before you can manage to push the button?
--- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> I have a silly little problem that is making me pull out my hair.
Consider the following command:
>
>
> BUTTON 12,0,255,250,BtnWrk,0,not_pressed
>
> do something here
>
> then fall through to the exit
>
> not_pressed:
>
> exit
>
>
>
> If my understanding of the button command is correct then "do
something here" will only get executed when the button is PUSHED.
Am I correct?
>
>
>
> What I want is to have the button command blow through the
button command if the button is not pressed. WHat I think is
happening is the button command is waiting for a press rather than
taking a look at the button to see if it is pressed and if not keep
waiting until it is, not what I want to happen.. If the button
isn't pressed then go about your business.
>
>
>
> Have I missed the bigger picture somewhere along the line??
Perhaps a "in12" and branch construct would be a better choice??
>
>
>
> Thanks Mike B.
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
low when the button is pressed.
MIke B.
Original Message
From: "ghidera2000" <ghidera2000@y...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, October 06, 2002 5:10 PM
Subject: [noparse][[/noparse]basicstamps] Re: Silly question time
> Just a n00b here but, what kind of circuit is your button using? is
> 12 high when its not pushed? Also, there's no loop here - is it just
> falling through before you can manage to push the button?
>
> --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > I have a silly little problem that is making me pull out my hair.
> Consider the following command:
> >
> >
> > BUTTON 12,0,255,250,BtnWrk,0,not_pressed
> >
> > do something here
> >
> > then fall through to the exit
> >
> > not_pressed:
> >
> > exit
> >
> >
> >
> > If my understanding of the button command is correct then "do
> something here" will only get executed when the button is PUSHED.
> Am I correct?
> >
> >
> >
> > What I want is to have the button command blow through the
> button command if the button is not pressed. WHat I think is
> happening is the button command is waiting for a press rather than
> taking a look at the button to see if it is pressed and if not keep
> waiting until it is, not what I want to happen.. If the button
> isn't pressed then go about your business.
> >
> >
> >
> > Have I missed the bigger picture somewhere along the line??
> Perhaps a "in12" and branch construct would be a better choice??
> >
> >
> >
> > Thanks Mike B.
> >
> >
> >
> > [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>Consider the following command:
>
>
>BUTTON 12,0,255,250,BtnWrk,0,not_pressed
>
> do something here
>
> then fall through to the exit
>
>not_pressed:
>
> exit
>
>
>
>If my understanding of the button command is correct then "do
>something here" will only get executed when the button is PUSHED.
>Am I correct?
>Sorry, guess I should have stated. The pin (P12) is pulled high and goes
>low when the button is pressed.
Hi Mike,
I think so. Here are the functional names of the parameters:
BUTTON inPin,downState,delay,rate,workVariable,targetState,targetAction
BUTTON 12, 0, 255, 250, BtnWrk, 0, not_pressed
In your statement, low is the downstate, and your not_pressed will be
executed when your button _is not_ in the downstate, because the
targetState parameter is zero.
> What I want is to have the button command blow through the button
>command if the button is not pressed.
In which case you might want targetState=1, not 0. That makes the
targetAction occur when the button _is_ in its downState. Still
pulling out your hair?
>WHat I think is happening is the button command is waiting for a
>press rather than taking a look at the button to see if it is
>pressed and if not keep waiting until it is, not what I want to
>happen.. If the button isn't pressed then go about your business.
I'm not sure what you mean, or what behavior you want. The BUTTON
command never waits for a press. It tests the state of the input pin
every time it is executed, and either blows by, or else jumps to the
targetAction. You have both the downState and the targetState
parameters to play with.
> Have I missed the bigger picture somewhere along the line??
>Perhaps a "in12" and branch construct would be a better choice??
I never use the BUTTON command myself, although I think it would be
good when a program needs delay/autorepeat. It is overkill for
simple branching. Depending on what you want to do, the program can
branch directly on the state of in12, or it can branch when there is
a change in state on in12.
Check out this URL for more info:
http://www.emesystems.com/BS2fsm.htm#BUTTON
>
>Thanks Mike B.
-- regards,
Tracy Allen
electronically monitored ecosystems
mailto:tracy@e...
http://www.emesystems.com
fine for me. Here's what I used
btnWrk var byte ' Workspace for BUTTON instruction.
Loop:
BUTTON 9,0,254,250,btnWrk,0,NoPress ' Go to NoPress unless P9 = 0.
DEBUG "*"
NoPress:
GOTO Loop ' Repeat endlessly.
Debug screen shows nothing until I press the button - then it shows
an asterisk. Repeats slowly if I hold it down.
--- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
> >I have a silly little problem that is making me pull out my hair.
> >Consider the following command:
button once instead of sitting there polling correct?
If so, I think the button command is a waste. It handles a lot more
than just seeing if the input is low. Perhaps you should just use an
if statement instead of button - save eeprom space.
--- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
> >I have a silly little problem that is making me pull out my hair.
> >Consider the following command:
good when a program needs delay/autorepeat. It is overkill for
simple branching. Depending on what you want to do, the program can
branch directly on the state of in12, or it can branch when there is
a change in state on in12."
Well you pretty much confirmed what I thought. I tried the in12/branch
thingy and it "feels" much better than the button command.
I'm using the bank program feature of the BS2P40 and just wanted to check
the state of a button and then and only then do something with it. The
"in12"/branch wins.
Thanks for bouncing off me ....
Mike B.\
Original Message
From: "Tracy Allen" <tracy@e...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, October 06, 2002 9:58 PM
Subject: Re: [noparse][[/noparse]basicstamps] Silly question time
> >I have a silly little problem that is making me pull out my hair.
> >Consider the following command:
> >
> >
> >BUTTON 12,0,255,250,BtnWrk,0,not_pressed
> >
> > do something here
> >
> > then fall through to the exit
> >
> >not_pressed:
> >
> > exit
> >
> >
> >
> >If my understanding of the button command is correct then "do
> >something here" will only get executed when the button is PUSHED.
> >Am I correct?
>
> >Sorry, guess I should have stated. The pin (P12) is pulled high and goes
> >low when the button is pressed.
>
> Hi Mike,
>
> I think so. Here are the functional names of the parameters:
> BUTTON inPin,downState,delay,rate,workVariable,targetState,targetAction
> BUTTON 12, 0, 255, 250, BtnWrk, 0, not_pressed
>
> In your statement, low is the downstate, and your not_pressed will be
> executed when your button _is not_ in the downstate, because the
> targetState parameter is zero.
>
> > What I want is to have the button command blow through the button
> >command if the button is not pressed.
>
> In which case you might want targetState=1, not 0. That makes the
> targetAction occur when the button _is_ in its downState. Still
> pulling out your hair?
>
> >WHat I think is happening is the button command is waiting for a
> >press rather than taking a look at the button to see if it is
> >pressed and if not keep waiting until it is, not what I want to
> >happen.. If the button isn't pressed then go about your business.
>
> I'm not sure what you mean, or what behavior you want. The BUTTON
> command never waits for a press. It tests the state of the input pin
> every time it is executed, and either blows by, or else jumps to the
> targetAction. You have both the downState and the targetState
> parameters to play with.
>
> > Have I missed the bigger picture somewhere along the line??
> >Perhaps a "in12" and branch construct would be a better choice??
>
> I never use the BUTTON command myself, although I think it would be
> good when a program needs delay/autorepeat. It is overkill for
> simple branching. Depending on what you want to do, the program can
> branch directly on the state of in12, or it can branch when there is
> a change in state on in12.
>
> Check out this URL for more info:
> http://www.emesystems.com/BS2fsm.htm#BUTTON
>
> >
> >Thanks Mike B.
>
> -- regards,
> Tracy Allen
> electronically monitored ecosystems
> mailto:tracy@e...
> http://www.emesystems.com
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
the slot programming feature of the "P" chip and you only get to run through
the button command ONCE and then run another program. I tried the
"IN12"/branch approach and that seems to work better..
Thanks, Mike B.
Original Message
From: "ghidera2000" <ghidera2000@y...>
To: <basicstamps@yahoogroups.com>
Sent: Monday, October 07, 2002 6:58 AM
Subject: [noparse][[/noparse]basicstamps] Re: Silly question time
> Now that I'm awake, I tried out the button command. Seems to work
> fine for me. Here's what I used
>
> btnWrk var byte ' Workspace for BUTTON instruction.
>
> Loop:
> BUTTON 9,0,254,250,btnWrk,0,NoPress ' Go to NoPress unless P9 = 0.
> DEBUG "*"
>
> NoPress:
> GOTO Loop ' Repeat endlessly.
>
> Debug screen shows nothing until I press the button - then it shows
> an asterisk. Repeats slowly if I hold it down.
>
> --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
> > >I have a silly little problem that is making me pull out my hair.
> > >Consider the following command:
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
that would be a problem. I thought I had some similar problems until I
realized that if I use slot 0 for some of my initialization, and then do a
run 1 at the end of that program in slot 0, with slot 1 being my main
program, I avoided some of the problems of having the program in slot 0
always start at the beginning.
Anyway, using slots does not preclude use of loops.
Original Message
From: Mike Blier [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Gft4Xux2631oQcQ7VEx1-twKpI9D68DlZ0b_l0Zt1egIDCMma-qlw1kMBPi3dP-GoPZGfhKvs-8]w6ffc@p...[/url
Sent: Monday, October 07, 2002 10:40 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Re: Silly question time
Well here in lies the problem, I'm not able to run in a loop. I am using
the slot programming feature of the "P" chip and you only get to run through
the button command ONCE and then run another program. I tried the
"IN12"/branch approach and that seems to work better..
Thanks, Mike B.
Original Message
From: "ghidera2000" <ghidera2000@y...>
To: <basicstamps@yahoogroups.com>
Sent: Monday, October 07, 2002 6:58 AM
Subject: [noparse][[/noparse]basicstamps] Re: Silly question time
> Now that I'm awake, I tried out the button command. Seems to work
> fine for me. Here's what I used
>
> btnWrk var byte ' Workspace for BUTTON instruction.
>
> Loop:
> BUTTON 9,0,254,250,btnWrk,0,NoPress ' Go to NoPress unless P9 = 0.
> DEBUG "*"
>
> NoPress:
> GOTO Loop ' Repeat endlessly.
>
> Debug screen shows nothing until I press the button - then it shows
> an asterisk. Repeats slowly if I hold it down.
>
> --- In basicstamps@y..., Tracy Allen <tracy@e...> wrote:
> > >I have a silly little problem that is making me pull out my hair.
> > >Consider the following command:
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
This e-mail message may contain legally privileged and/or confidential
information. If you are not the intended recipient(s), or the employee
or agent responsible for delivery of this message to the intended
recipient(s), you are hereby notified that any dissemination,
distribution or copying of this e-mail message is strictly prohibited.
If you have received this message in error, please immediately notify
the sender and delete this e-mail message from your computer.
[noparse][[/noparse]Non-text portions of this message have been removed]