|
|
|
| You've downloaded my heart. |
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Re: Do you write functions for your code?
We have a few more... =)
This list I can recall atm: 254_arm, 254_auton, 254_drive, 254_encoders, 254_utilities, 254_interrupts, 254_timers, 254_recordable (recordable autonomous, work in progress)...hmmm, I think that's it, might be one more somewhere. We're also working on breaking our pump and gear shifting code to functions for ease of use in autonomous mode. |
|
#17
|
||||
|
||||
|
Re: Do you write functions for your code?
Quote:
|
|
#18
|
|||
|
|||
|
Re: Do you write functions for your code?
I would have suffered greatly if not for the ability to divide everything into functions this year. Even if some of them are only called once, they still make it much easier to keep code organized, readable, and easy to debug. Our (failed) autonomous code has about 8 separate functions, each of which contains 20-30 lines of code. Trying to keep all that organized within Process_Data_From_Local_IO() would have been a nightmare, but dividing all of it into separate functions made coding a breeze. Sure, it might take another CPU cycle or two to jump to the appropriate memory location, but that's not much of a problem when the thing's running at 40 MHz.
|
|
#19
|
|||||
|
|||||
|
I did a lot of the stuff your taliking about. I'll post some of my hardware-driver code. (don't have it on me) It includes #defines for every motor, victor, spike, pot, and whatnot. And to top it of, to move the shoulder to a certain position, you call Shoulder_Check(Target). It also includes macros to scale (and translate) the analogs.
![]() |
|
#20
|
||||
|
||||
|
Re: Do you write functions for your code?
I used many functions, many just like:
#define square(a) a*a And also a nice function to turn based on degrees you want to turn. Kickin'. |
|
#21
|
||||
|
||||
|
Re: Do you write functions for your code?
dont get me wrong- there is nothing wrong with using functions for your code on this project - I was only pointing out in a reply to a post on the 1st page that using functions is not more effecient from a performance perspective, and if the function is only called from one place in your code, its takes up more code space after being compiled than simply putting the same code inline.
there is a balance somewhere, between breaking up every 3 or 4 lines of code into a separate function, and writing one long monolithic block of SW with no functions. |
|
#22
|
||||
|
||||
|
Re: Do you write functions for your code?
Functions? We wrote a whole math library worth of functions! Actually, it was the other programmer who did, not me, because he actually can understand CORDIC.
Otherwise, we only used functions in such situations where they would be called in more than one different place, such as our joystick auto-calibration function. |
|
#23
|
|||||
|
|||||
|
Re: Do you write functions for your code?
Quote:
|
|
#24
|
|||||
|
|||||
|
Re: Do you write functions for your code?
Quote:
|
|
#25
|
||||
|
||||
|
Re: Do you write functions for your code?
We should be posting a white paper containing our math library in the next week EDIT: day or so, keep an eye out for it. It should be good enough for any team's use; I believe we managed to get our CORDIC trig functions accurate to within 6 decimal places.
Last edited by Pat Fairbank : 10-03-2004 at 19:39. |
|
#26
|
|||||
|
|||||
|
Re: Do you write functions for your code?
Here's SOME of my code.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is your most prefered programming language? | Hailfire | Programming | 156 | 19-01-2005 21:42 |
| Interrupt timer, executing code asap? | SeanCassidy | Programming | 10 | 07-03-2004 01:47 |
| Inserting Naviagation code into Default code? | actorindp | Programming | 3 | 28-01-2004 18:12 |
| RC bootup sequence | Venkatesh | Programming | 17 | 18-11-2003 20:56 |
| Does your team use the Default code. | Jeff McCune | General Forum | 2 | 09-01-2003 14:46 |