|
Re: Programming tricks (and former trade secrets)
Pro-Tip: Don't use 255 as a full forward value.
With stop at 127, there are 127 effective negative numbers (0-126) and 128 effective positive numbers (128-255). Enforcing 254 as the maximum forward value allows you to easily change the sign of the number (254-n) by using the 8 bit number circle.
Pro-Tip: Use object oriented design. (And implement it that way)
Objects allow you to divide up your code based on things in real life instead of what the processor can do. It also is the easiest way to do abstraction, encapsulation and modularity in C. Even though the language (C) does not natively support objects, there are many ways to implement objects. My preferred way is to define a typedef structure with all of the members/attributes in the class and then implement functions that are prefixed with the class name that take in a pointer to the class structure. To get encapsulation put public function definitions in the header file and private function definitions in the c file.
__________________
"That mecanum guy"
- Woodie Flowers Finalist Award Winner: 2010 Minnesota North Star Regional
- Mentor and Founder of 7 FRC Teams since 2003.
- FRC Regional Competition Score Keeper/Field Power Controller, Robot Inspector, Control System Adviser, Judge
- Co-Founder, Alumni: Milwaukee FIRST Support Organization
- Board Member, Game Design Committee, Judge, MVP-FTA: Midwest Vex Programs
- Computer Engineering Alumni '06: MSOE
- Embedded Firmware Engineer: Rockwell Automation
|