My code is HUGE!! .. i mean huge.. well at least i think it is:D just an overall question for all u guys out there programming this year.. my code is nearly 800 lines of code... including comments.. My question to u guys is.. 'How many lines of code does ur program have just for user_routines.c (including side files)?'
Just cuz im working on my camera code.. and went from 400 to 700...:eek:.... ima bad programmer... well not really... i just write long code! but then i end up breaking it down... if yu could let me noe:) that would be great!
Yeah, depending on your style of coding and how many comments you actually add, the lines can vary tremendously. What’s more important is the actual amount of data space you use. If you’re using MPLAB (and I’m assuming you are), go to View->Memory Usage Gauge, and this will tell you both the amount of code and variable space you’re using.
We overflowed the 2005 processor trying to get the camera and a driver perspective drive system with a gyro working. Last year we ended up using about 1/5 of the available space.
In an ideal world, yes, the compiler should do about the same thing. However, we’re talking about MPLAB’s compiler here, and it’s far from “ideal”. Something tells me even GCC would have difficulty optimizing it. My best bet goes to Intel’s super-optimizing compiler. It’s too bad we can’t have something like that for our PICs.
As for code length in user_routines.c? It’s only about 400-500. That’s because I split my code up into multiple files. In all, I think I’ve written about 2000 in the pre-season this year. I’ve also taken the time to write my own camera code as opposed to Kevin’s (it’s good, just a little drawn out, IMHO).
The current code I have for user_routines.c is 111 lines long.
I gutted it (all those Limit_ functions are gone; I never used them) and I haven’t put the drive code back in since the rewrite. That’s why it’s so short. Plus I have the code spread into other files I created, too.
Don’t worry about it being long. Worry about it being readable. Being up late in the shop night before ship date you may be tempted to just keep writing, but when you have to decipher it to figure out why autonomous mode did nothing, you will smack yourself if it isn’t readable.
Code length in C varies drastically based on style. If you use alot of functions your user_routine.c will be much shorter but you may have a huge header file some where.