What language is this written in? Why should it not be run thru the comp
pre-processor?
on-off is NOT a legal C variable name. (I don't know if it is acceptable to
"comp". I wouldn't think so -- or more precisely, I wouldn't think that comp
would convert it to something acceptable by a C compiler.)
if( on-off == true ) /* output is currently on */
on-off = false ; /* turn output off */
if( on-off == false ) /* output is currently off */
on-off = true ; /* turn output on */
If on-off is true, the 2nd line will make it false. Then the third line will
be true and and 4th line will make on-off true again. I'm sure that isn't
what you want.
After solving any naming problems (by e.g., using on_off), replace the above
four lines with:
on_off = !on_off;
I am a programmer, but don't play one on TV. :-)
Stuart -- Have you already asked if such a component exists? Or what the
best way to do this might be? I suspect that one of the HAL gurus would
spend less time knocking one of these out than he would spend reading a
series of posts about it.
Ken
[EMAIL PROTECTED]
Mark Kenny Products Company, LLC
55 Main Street Voice: (888)ISO-SEVO (888)476-7386
Newtown, CT 06470 Fax: (203)426-9138
http://www.MarkKenny.com
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Stuart
Stevenson
Sent: Wednesday, April 18, 2007 7:31 PM
To: [email protected]
Subject: [Emc-users] Fwd: latching push button
Gentlemen,
This is our thoughts on latch component. Please critique it and let
me know what changes should be made.
thanks
Stuart
---------- Forwarded message ----------
From: jphillip <[EMAIL PROTECTED]>
Date: Apr 18, 2007 3:28 PM
Subject: latching push button
To: [EMAIL PROTECTED]
/* do not use the comp pre-processor on this component */
/* pin-in must be de-bounced */
component latching-push-button "Software alternate action switch"
pin in pin-in bit ;
pin out pin-out bit ;
option latch bit ;
option on-off bit ;
if( pin-in == true ) { /* button is pressed */
if ( latch == false ) { /* button was previously released */
latch = true ;
if( on-off == true ) /* output is currently on */
on-off = false ; /* turn output off */
if( on-off == false ) /* output is currently off */
on-off = true ; /* turn output on */
}
} else {
latch = false ;
}
pin-out = on-off ;
You have to be BRAVE to grow OLD.
There are no old CARELESS pilots or electricians.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users