WPILib and FRC default code

My team used Easy C last year to learn how to program and i guess it worked for what we wanted it to do.
However we wanted more of a challenge so we decided that we were going to write all of my code in MPLab this year.
So far i haven’t had a problem with that.

EasyC made programming very fast and… well, easy (hence the name).
And if i’m ever in a pinch and i don’t know how to write something in C i’d like to be able to look at how it’s written in EasyC so that i can get it done quicker in MPLab. I tried to include the WPI library file in my MPLAB workspace but i keep getting errors saying that there are things being defined more than once.
I just want to add onto the FRC default code from IFI and use easyC to write a piece of code if i don’t know how or if i get to lazy to type it.

Basically what i want to do… i guess… is have the robot look to the WPLib secondary to the FRC default library. If something isn’t defined in FRC default then it should look in WPI. Is that possible?

I don’t believe C supports overloading of functions like that… You’re probably going to be stuck manually fixing those errors. Don’t worry, that shouldn’t be too much time.

Unless someone can come up with a more creative solution?

Just follow the instructions for using WPILib with MPLab that are posted on the WPILib web page.
Link: http://users.wpi.edu/~bamiller/WPILib/UsingMPLab.pdf

AFAIK, I don’t see how WPIlib can be combined with the default IFI code. Rather, it replaces the IFI code.

It would be better to ask this question in the WPILib forum.

If you’re linking in the WPILib, for example, then it provides the interrupt framework and startup routines.

It would also help to know exactly what errors you are getting.

Is it just me or do the errors in MPLab come up one at a time? It seems every time i fix one error i get another one. Is there a way to change that?

The errors i get include things like “_entry_scn” is defined more than once.
Pretty much the same message over and over again just with different variables. The way that i figured i would fix the problem is that i can #ifdef “variable” … #endif the section of code that has the problem. If the variable is defined skip this code, if it’s not defined use this code to define it.

I would like to do this on a large scale but i don’t know how.
I’d like to #ifdef for all variables in the code. And if they are not defined elsewhere in the code check in WPILib, if they are defined elsewhere skip WPILib.

Edit 1-22-08: By saying variables i mean functions in the libraries.

Including ifi_aliases.h and ifi_default.h should let you do some things, like assign pwms and digital IOs directly. As for interrupts and the like, our team hasn’t figured out how to do those with WPILib yet. We have a project made by taking the default code, adding WPILib, and commenting out everything that gave an error. This should theoretically let you use some of the WPILib functions with default code, but I really doubt ours works and I’m not sure how to get to work in general. It’s probably best to stick with either WPILib or the IFI default code.

To get it to show you all the errors at once:
Go to Configure–>Settings, then click on the Projects tab and uncheck “Halt build on first failure”.

You can catch interrupts with WPILib by calling RegisterInterruptHandler(). There are some examples in the documentation at the web site. This function lets you specify a port, rising or falling edge, and a function to call when the interrupt occurs. Remember: when you do this, your function runs as an Interrupt Service Routine (ISR). This means that all other interrupts are disabled while it is running. If you spend much time in your ISR, you run the risk of missing other interrupts and having other sensors and timing break.

Another (safer) way of catching fast events in WPILib is by registering an interrupt watcher. These series of functions (also in the documentation) will set up an internal ISR for you and set a variable when the interrupt occurs. Then in your non-interrupt code, you can poll that variable to see if the fast event has occured. This is useful in many cases, for example, knowing if a reed switch on a pneumatics piston closed, or watching one of the IR board ports.

As for using WPILib, I’d suggest starting with a clean program - you only need a single file and none of the IFI default code. Use the template on the web site or in the docs in that file. There you fill in your Initialization, Autonomous and OperaterControl code and your running. If you want to use some of the IFI/Microchip header files for direct access to digital ports, that’s not a problem.

The original reason that i made this thread was to find out if there was a way to define a library as secondary.

In MPLAB i can add the WPILib files to the directory and it will compile just fine. But if i call one thing from WPI i get error messages.
For example i put in my regular code the command “SetPWM (1, 255);” And all of a sudden i get the problem of multiple definitions for variables, commands and functions that i’ve never seen or played with before.
Like i said i want one library to be secondary. I only want to check in the library for functions that aren’t defined anywhere else. Is this possible? I’m fairly new to programming so i’m not really sure if it is or not.