Servo library questions

Status
Not open for further replies.

WShawn

Well-known member
I have a few questions regarding the organization of the Servo library and creating and saving a modified version of the library:

Working in the Arduino application on a Mac, when I go to "Sketch>Include Library" I see Servo listed twice, both under the Arduino libraries subhead in the pulldown. I assume one of those corresponds to the Servo element that lives in the Contents/Java/libraries/Servo directory and the other that lives in the Contents/Java/hardware/teensy/avr/libraries/Servo directory. The latter apparently includes code tailored for the Teensy. How do I know which one is being used, as they both show up as Servo.h in the sketch? Why are they both listed under Arduino libraries instead of one listed there and the other, teensy-specific one listed under "Contributed libraries?"

I bring this up because I'm attempting to get a project working that uses a Teensy 3.2 to drive a DAC to output audio AND drive two servos. Apparently both the DAC and Servos use the PDB timer, but you can tweak the Servo library code to make a Teensy 3.2 use the LPTMR timer the Teensy LC uses. I made an educated guess as to how to change that code in the Servo.cpp file (in theContents/Java/hardware/teensy/avr/libraries/Servo directory), and it appears to work. What would happen, though, if in a future project I wanted to drive the servos with the PDB timer, requiring the original Servo.cpp file? I tried duplicating that Servo directory, changing the .cpp file, and changing every instance of the word "Servo" to "Servo_LC" in the code and file names. I got a bunch of error messages when I tried to compile my sketch using this new Servo_LC.h library file. Do I have to swap out the various versions in that libraries directory each time I compile and upload a sketch?

Thanks.

Shawn Marshall
 
Status
Not open for further replies.
Back
Top