Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Relay Commands (http://www.chiefdelphi.com/forums/showthread.php?t=44211)

Matt Krass 17-02-2006 20:49

Relay Commands
 
1 Attachment(s)
I had some free time tonight and I noticed some people are having problems with relays, usually remembering to set both the corresponding FWD and REV values, so I wrote up a quick header file with commands to set relays forward, reverse or off simply by typing RELAY#_FWD or _REV or _OFF

Examples, setting Relay 1 forward
Code:

RELAY1_FWD;
Relay 1 reverse
Code:

RELAY1_REV;
Relay 1 off
Code:

RELAY1_OFF;
The semicolon is important, I designed it that way to be syntax compatible with C, some IDEs don't like commands without semicolons :)

Hope this helps someone.

Simply drop in your project and add #include "relays.h" where ever you use it.

X-Istence 17-02-2006 22:08

Re: Relay Commands
 
I forgot to set the reverse to 0 when I first tried. Once you know how it works, getting it to work is not a problem.

Matt Krass 18-02-2006 01:01

Re: Relay Commands
 
Quote:

Originally Posted by X-Istence
I forgot to set the reverse to 0 when I first tried. Once you know how it works, getting it to work is not a problem.

I wrote it to make programming a little simpler, nobody is saying you have to use it or not use it, it's out there if you wish to.

lil_longo 18-02-2006 15:04

Re: Relay Commands
 
Quote:

Originally Posted by X-Istence
I forgot to set the reverse to 0 when I first tried. Once you know how it works, getting it to work is not a problem.

i no me too

Anime-niac_2.9 18-02-2006 18:00

Re: Relay Commands
 
the RELAY_OFF shouldn't be needed, but then again if you're a noob and the easy C key you were given doesn't work then this will work since it's in a header file.

Mike 18-02-2006 18:32

Re: Relay Commands
 
Good job. I wouldn't limit the usage of this to "C noobs" either. Everyone can benefit from the readability change from
Code:

relay1_fwd = 0;
relay1_rev = 1;

to
Code:

RELAY1_OFF;

DanDon 18-02-2006 23:03

Re: Relay Commands
 
Quote:

Originally Posted by Mike
Good job. I wouldn't limit the usage of this to "C noobs" either. Everyone can benefit from the readability change from
Code:

relay1_fwd = 0;
relay1_rev = 1;

to
Code:

RELAY1_OFF;

Hey Mike, wouldn't that be RELAY1_REV?
And of would be relay1_fwd=relay1_rev=0?


All times are GMT -5. The time now is 08:44.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi