Modifying code found in a .cpp file

How do I modify the code in the PololuWheelEncoders.cpp and include it in my project? I would like to change the way the ISR(PCINT0_vect) code functions to count the pulses from a TTL level push button. I am new to all this so any help would be great.


You should be able to copy the entire .cpp and .h files into your project folder, rename the files, classes, and all C functions to your own names so that they do not conflict with the library, and add a line like

#include "MyPololuWheelEncoders.cpp"

to your main C file. Are you using AVR Studio? If so, in the left column of your screen, you should see options for “Source Files” and “Header Files”. Right click on either one and you will have the option to add or remove files from the list. When you build your project, AVR Studio will automatically compile all C files in the project together to produce a single hex file.


By the way, you have to be careful to not use ANY functions from the original version of that file in your code, or the interrupt will be automatically included and cause some strange conflicts.