To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.org.us.laflrcOpen lugnet.org.us.laflrc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Organizations / United States / LafLRC / 96
95  |  97
Subject: 
Re: #define-ing stuff for Chibots
Newsgroups: 
lugnet.org.us.laflrc
Date: 
Sat, 8 Oct 2005 18:51:26 GMT
Viewed: 
1331 times
  
In lugnet.org.us.laflrc, Steve Hassenplug wrote:
Talking about Chibots Maze event, Davis, Brian L. wrote:

   Oh, and of course the real kicker for event day - I'm developing on a black maze
on white background, flagging everything that should matter to make a "negative
copy" of the software for later. Ugh.

I'm not totally sure about this, but try playing around with #define

In one language I use, the compiler will totally take out the variable, and put in
the defined value, before compiling the program.  I assume that's how it should work
in C and NQC.

So, you can do this:


---
#define UseColor    >
// '>' is black line
// '<' is white line

...

if (s1 UseColor threshold1)
{
  // s1 is on line
}
else
{
  // s1 is off line
}

Or a different way

#define BLACKLINE 1

#if BLACKLINE
#define SEELINE(reading,threshold) reading < threshold
#else
#define SEELINE(reading,threshold) reading > threshold
#endif

  if (SEELINE(s1,threshold1)) {
    // s1 is on the line
  } else {
    // s1 is off the line
  }

This way is what I see done by my coworkers and myself at work.  By
encapselating the entire comparison in the macro, then the macro name helps make
the code more self documenting.

You simply change the #define of BLACKLINE to 0 instead of 1 for white lines on
black background.

Kev

----

   What is the maximum incline in the advanced maze? I've got the sensor head
pivoting now, and I think ground clearence will be OK, but we'll see.

For Chibots advanced line, they usually have a hump that's about 2 inches high, in
the middle, and 6 to 8 inches long.

Steve



Message is in Reply To:
  #define-ing stuff for Chibots
 
(...) I'm not totally sure about this, but try playing around with #define In one language I use, the compiler will totally take out the variable, and put in the defined value, before compiling the program. I assume that's how it should work in C (...) (19 years ago, 3-Oct-05, to lugnet.org.us.laflrc)

3 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR